aboutsummaryrefslogtreecommitdiff
path: root/sim/testsuite/lib
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-01-05 01:26:21 -0500
committerMike Frysinger <vapier@gentoo.org>2021-01-15 01:33:35 -0500
commit37a9c3a53e3705c5120506e457455642702845e6 (patch)
treebd55d53db865c08ba94edebf9e9b3a44538f97ae /sim/testsuite/lib
parent3624a6c15ce48e03d43983ec11d586d97ca08728 (diff)
downloadfsf-binutils-gdb-37a9c3a53e3705c5120506e457455642702845e6.zip
fsf-binutils-gdb-37a9c3a53e3705c5120506e457455642702845e6.tar.gz
fsf-binutils-gdb-37a9c3a53e3705c5120506e457455642702845e6.tar.bz2
sim: testsuite: allow tests to declare expected exit status
Some tests want to verify they can control the exit status, and allowing any non-zero value would allow tests to silently fail: if it crashed & exited 1, or forced all non-zero to 1, then we wouldn't be able to differentiate with a test exiting with a status like 47. Extend the test harness to allow tests to declare their expected exit status that would be defined as a "pass". This requires a small tweak to the sim_run API to return the status directly, but that shouldn't be a big deal as it's only used by sim code.
Diffstat (limited to 'sim/testsuite/lib')
-rw-r--r--sim/testsuite/lib/sim-defs.exp23
1 files changed, 12 insertions, 11 deletions
diff --git a/sim/testsuite/lib/sim-defs.exp b/sim/testsuite/lib/sim-defs.exp
index b8ce230..43a0705 100644
--- a/sim/testsuite/lib/sim-defs.exp
+++ b/sim/testsuite/lib/sim-defs.exp
@@ -62,7 +62,7 @@ proc sim_compile { source dest type options } {
# timeout=val - set the timeout to val for this run
#
# The result is a list of two elements.
-# The first is one of pass/fail/etc.
+# The first is the program's exit status (0/1/etc...).
# The second is the program's output.
#
# This is different than the sim_load routine provided by
@@ -156,15 +156,7 @@ proc sim_run { prog sim_opts prog_opts redir options } {
remote_file host delete $prog
}
- # ??? Not sure the test for pass/fail is right.
- # We just care that the simulator ran correctly, not whether the simulated
- # program return 0 or non-zero from `main'.
- set status fail
- if { $return_code == 0 } {
- set status pass
- }
-
- return [list $status $output]
+ return [list $return_code $output]
}
# Run testcase NAME.
@@ -183,6 +175,7 @@ proc sim_run { prog sim_opts prog_opts redir options } {
# cc[(mach-list)]: <compiler options>
# sim[(mach-list)]: <simulator options>
# progopts: <arguments to the program being simulated>
+# status: program exit status to treat as "pass"
# output: program output pattern to match with string-match
# xerror: program is expected to return with a "failure" exit code
# xfail: <PRMS-opt> <target-triplets-where-test-fails>
@@ -223,6 +216,7 @@ proc run_sim_test { name requested_machs } {
set opts(cc) ""
set opts(progopts) ""
set opts(sim) ""
+ set opts(status) "0"
set opts(output) ""
set opts(mach) ""
set opts(timeout) ""
@@ -385,15 +379,21 @@ proc run_sim_test { name requested_machs } {
}
set result [sim_run ${name}.x "$opts(sim,$mach) $global_sim_options" "$opts(progopts)" "" "$options"]
- set status [lindex $result 0]
+ set return_code [lindex $result 0]
set output [lindex $result 1]
+ set status fail
+ if { $return_code == $opts(status) } {
+ set status pass
+ }
+
if { "$status" == "pass" } {
if { "$opts(xerror)" == "no" } {
if [string match $opts(output) $output] {
pass "$mach $testname"
file delete ${name}.o ${name}.x
} else {
+ verbose -log "status: $return_code" 3
verbose -log "output: $output" 3
verbose -log "pattern: $opts(output)" 3
fail "$mach $testname (execution)"
@@ -410,6 +410,7 @@ proc run_sim_test { name requested_machs } {
pass "$mach $testname"
file delete ${name}.o ${name}.x
} else {
+ verbose -log "status: $return_code" 3
verbose -log "output: $output" 3
verbose -log "pattern: $opts(output)" 3
fail "$mach $testname (execution)"