GNU bug report logs - #75440
dejagnu does not like java.io.Console of OpenJDK >= 22

Previous Next

Package: dejagnu;

Reported by: Chris Nospam <chris21k <at> gmx.de>

Date: Wed, 8 Jan 2025 17:25:01 UTC

Severity: normal

Full log


Message #17 received at 75440 <at> debbugs.gnu.org (full text, mbox):

From: Jacob Bachmeyer <jcb62281 <at> gmail.com>
To: Chris Nospam <chris21k <at> gmx.de>, 75440 <at> debbugs.gnu.org
Subject: Re: bug#75440: dejagnu does not like java.io.Console of OpenJDK >= 22
Date: Tue, 14 Jan 2025 22:00:04 -0600
[Message part 1 (text/plain, inline)]
[actually you had the new ZIP file on the first message; I can tell 
because the Java program has a loop now]

[also, traditional email discussions use inline responses with a summary 
or further commentary at the end after the response to the last quote; 
please refrain from top-posting if possible]

On 1/14/25 05:12, Chris Nospam wrote:
> Dear Jacob,
> sorry for my late reply and thanks for your rapid and detailed answer. 
> Also I am sorry for the faulty default.exp, it was a quick & dirty 
> version to trigger the bug and only a short snipped of my real project.

That is a new piece of information and I have found other issues that I 
would normally overlook in a small testsuite, but will make problems for 
you in a large testsuite.  More on this below.

> It should only show the problem with the first echo. However, I have 
> enhanced it somehow now, see the attachement.

I see that the new version of your sample program now contains a loop 
instead of exiting unconditionally after the first input. This produces 
a more useful error, complete with a backtrace explaining how you got 
there.  (The framework will call a "${tool}_exit" procedure during 
per-target cleanup if it exists.)

Unfortunately, coordinating the exit of an interactive program is 
tedious because Expect will close the channel upon reading EOF and 
expecting on a closed channel throws an error.  (This should be a hint 
towards one way to solve the problem.)

You should try using runtest's --debug option, which will cause Expect 
to write considerable information about its operation to the "dbg.log" 
file.  That log is particularly useful when seeking to understand why 
patterns do or do not match.

> > Tcl interpolates backslash escapes in double-quoted strings
> I changed now \r\n to \\r\\n in all regular expressions.

It is important to understand what Tcl will do with your code, although 
that particular item "happens to work" either way. (Literal carriage 
return and newline match themselves in Tcl regexps in normal syntax, but 
can make dbg.log harder to read.)

> Please forgive me, I am not an expert in expect script but I try to do 
> my best. I would be happy if you could give me some (direct) advices.

You still need to think about what your test results mean. DejaGnu has 
other status codes because simple PASS/FAIL does not really work in the 
real world.  You should be using "perror" and "unresolved" to report 
inabilities to run the test program.

More concretely, simple_start should clear the prompt_error flag upon 
receiving a prompt and should use "perror" instead of "send_user" to 
report failure to spawn the program.

Similarly, if the prompt_error flag is set, "simple_test" should emit an 
UNRESOLVED result (using the "unresolved" procedure) before returning, 
because the test was not performed due to a run-time condition.

The important rule here is that the total number of test results should 
not change.

Tcl allows optional arguments; you can replace the dispatch logic around 
"simple_test" by using {proc simple_test {expr result {comment ""}} 
...}  (The outer-most brace pair denotes a Tcl code fragment.)

Tcl procedure arguments are also ordinary local variables, so you can do 
{ if {$comment ne ""} {set comment "\[$comment\]"} } in a combined 
"simple_test" if you want.

Think carefully about what you are doing with the "answer" global 
variable.  It should probably be an argument, if not the "result" 
argument that you already have.

Lastly, your "if" conditionals should usually be in braces; this allows 
the Tcl compiler to produce more efficient bytecode.

> I will open a corresponding issue at https://bugreport.java.com and 
> report back a link. Hopefully, they will look into/fix it and not only 
> dismiss that using dejagnu is an edge case.

Hopefully they will at least recognize that a transparent console mode 
is important and ensure that one remains supported.


-- Jacob
[Message part 2 (text/html, inline)]

This bug report was last modified 146 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.