]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Don't abort testrun for invalid command in test-case
authorTom de Vries <tdevries@suse.de>
Fri, 12 Jun 2020 07:13:17 +0000 (09:13 +0200)
committerTom de Vries <tdevries@suse.de>
Fri, 12 Jun 2020 07:13:17 +0000 (09:13 +0200)
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 reverting dejagnu's ::unknown override for the duration of each
test-case, using the gdb_init/gdb_finish hooks.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2020-06-12  Tom de Vries  <tdevries@suse.de>

PR testsuite/26110
* lib/gdb.exp (gdb_init): Revert dejagnu's override of ::unknown.
(gdb_finish): Reinstall dejagnu's override of ::unknown.

gdb/testsuite/ChangeLog
gdb/testsuite/lib/gdb.exp

index 0523f7cb8813b47bca9d4b4483ec0fb416ed6b1e..ff834b7e3a0028cd4cb8c113c3b27f15dbdc8ad7 100644 (file)
@@ -1,3 +1,9 @@
+2020-06-12  Tom de Vries  <tdevries@suse.de>
+
+       PR testsuite/26110
+       * lib/gdb.exp (gdb_init): Revert dejagnu's override of ::unknown.
+       (gdb_finish): Reinstall dejagnu's override of ::unknown.
+
 2020-06-11  Tom Tromey  <tom@tromey.com>
 
        PR gdb/18318:
index 51f8a05464566387239f6fc64d772c7d957f968e..64e667c20e04846cdd94e921dd7e3bc60fe93ce2 100644 (file)
@@ -5193,7 +5193,19 @@ proc gdb_init { test_file_name } {
     global gdb_instances
     set gdb_instances 0
 
-    return [default_gdb_init $test_file_name]
+    set res [default_gdb_init $test_file_name]
+
+    # Dejagnu overrides proc unknown.  The dejagnu version may trigger in a
+    # test-case but abort the entire test run.  To fix this, we install a
+    # local version here, which reverts dejagnu's override, and restore
+    # dejagnu's version in gdb_finish.
+    rename ::unknown ::dejagnu_unknown
+    proc unknown { args } {
+       # Dejagnu saves the original version in ::tcl_unknown, use it.
+       return [uplevel 1 ::tcl_unknown $args]
+    }
+
+    return $res
 }
 
 proc gdb_finish { } {
@@ -5201,6 +5213,10 @@ proc gdb_finish { } {
     global gdb_prompt
     global cleanfiles
 
+    # Restore dejagnu's version of proc unknown.
+    rename ::unknown ""
+    rename ::dejagnu_unknown ::unknown
+
     # Exit first, so that the files are no longer in use.
     gdb_exit