I'm putting in a test for the feature I submitted a patch for recently
allowing the return code of the simulated OR1K program to also be
passed back by or1ksim (useful when using or1ksim for regression
testing of the compiler without having a functioning GDB port, but
also in other cases, too.)
I'm having trouble doing it, though. I want to figure out how to get
the return code of or1ksim back into the TCL script so I can test it.
The file in question the changes must go into are
or1ksim/testsuite/lib/or1ksim.exp
I've tried the following at the end of the expect loop:
...
...
timeout {
perror "Timeout";
unresolved "$testname: timeout";
return
}
catch wait returncode
# Check return code if we got passed one
if { 0 != [string length $rc] } {
send_user "testing $returncode != $rc\n";
if { $returncode != $rc } {
send_user "return code not what we wanted: $returncode !=
$rc\n";
}
}
...
...
To explain a little bit I've added a new parameter to the run_or1ksim
function, "rc" which should be tested against if it's set. (We should
probably check the sim returns 0 in all other cases by default, but
let's get this thing working first.)
So I'm trying to get the returncode of the sim run in $returncode with
the "catch wait" statement..
I get this:
Running ../../or1ksim/testsuite/or1ksim.tests/returncode.exp ...
ERROR: tcl error sourcing ../../or1ksim/testsuite/or1ksim.tests/returncode.exp.
ERROR: wrong # args: no expression after "if" argument
while executing
"if"
invoked from within
"expect {
-ex $matchstr {
set matchlen [string length $matchstr]
set buflen [string length $expect_out(buffer)]
set lastch [expr {$buflen - ..."
(procedure "run_or1ksim" line 61)
invoked from within
"run_or1ksim "returncode" \
[list "!exit(42)"] \
"" "returncode/returncode --use-sim-return-code" "42""
(file "../../or1ksim/testsuite/or1ksim.tests/returncode.exp" line 26)
invoked from within
"source ../../or1ksim/testsuite/or1ksim.tests/returncode.exp"
("uplevel" body line 1)
invoked from within
"uplevel #0 source ../../or1ksim/testsuite/or1ksim.tests/returncode.exp"
invoked from within
"catch "uplevel #0 source $test_file_name""
It looks like a basic TCL error ("wrong # args") but what on earth am
I doing wrong? Also, i get the feeling this isn't even the right way
of going about it.
I've looked on many sites for a quick fix (I got this attempt's method
from
http://stackoverflow.com/questions/3299502/how-to-return-spawned-process-exit-code-in-expect-script)
but still haven't found something that works. All this should take is
a quick hack I would think, to test a simple thing like a return code.
Julius
_______________________________________________
OpenRISC mailing list
[email protected]
http://lists.openrisc.net/listinfo/openrisc