[gdb/testsuite] Don't abort testrun for invalid command in test-case Say we add a call to foobar at the end of a test-case, and run the test-suite. We'll run into a dejagnu error: ... ERROR: (DejaGnu) proc "foobar" does not exist. ... and the test-suite run is aborted. It's reasonable that the test-case is aborted, but it's not reasonable that the testsuite run is aborted. Problems in one test-case should not leak into other test-cases, and they generally don't. The exception is the "invalid command name" problem due to an override of ::unknown in dejagnu's framework.exp. Fix this by limiting the scope of dejagnu's ::unknown override. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-06-11 Tom de Vries PR testsuite/26110 * lib/gdb.exp (gdb_unknown): New proc. (::tcl_source): Rename from ::source. (source): New proc. --- gdb/testsuite/lib/gdb.exp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 51f8a05464..ae6d561a10 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -7243,5 +7243,35 @@ proc with_override { name override body } { return $result } +proc gdb_unknown { args } { + # Skip dejagnu_unknown to prevent it from exiting and aborting the entire + # test run. + return [uplevel 1 ::tcl_unknown $args] +} + +rename ::source ::tcl_source + +proc source { arg } { + set script $arg + + set script [file dirname $script] + set subdir3 [file tail $script] + + set script [file dirname $script] + set subdir2 [file tail $script] + + set script [file dirname $script] + set subdir1 [file tail $script] + + if { $subdir1 == "gdb" + && $subdir2 == "testsuite" + && [regexp {^gdb[.]} $subdir3] } { + return \ + [uplevel 1 with_override ::unknown gdb_unknown \"::tcl_source $arg\"] + } + + return [uplevel 1 ::tcl_source $arg] +} + # Always load compatibility stuff. load_lib future.exp