aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/lib
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2016-11-09 15:45:49 +0000
committerPedro Alves <palves@redhat.com>2016-11-09 15:12:11 +0000
commit64f367a201565d5c7d1e03da072db51123ac2174 (patch)
tree1c0a08b5a7aace232354deb7db99f11b668f8afd /gdb/testsuite/lib
parent2806dc7eec04db49fca03e04827e3dff7f6704e0 (diff)
downloadgdb-64f367a201565d5c7d1e03da072db51123ac2174.zip
gdb-64f367a201565d5c7d1e03da072db51123ac2174.tar.gz
gdb-64f367a201565d5c7d1e03da072db51123ac2174.tar.bz2
gdb/testsuite: Introduce "proc_with_prefix"
While adding new tests to gdb.base/commands.exp, I noticed that the file includes a bunch of individual testcases split into their own procedures, and that none have ever been adjusted to use with_test_prefix. Instead, each gdb_test/gdb_test_multiple/etc invocation takes care of including the procedure name in the test message, in order to make sure test messages are unique. Simon convinced me that using the procedure name as prefix is not that bad of an idea: https://sourceware.org/ml/gdb-patches/2016-10/msg00020.html This commit adds an IMO simpler alternative to with_test_prefix_procname added by that patch -- a new "proc_with_prefix" convenience proc that is meant to be used in place of "proc", and then uses it in commands.exp. Procedures defined with this automatically run their bodies under with_test_prefix $proc_name. Here's a sample of the resulting gdb.sum diff: [...] -PASS: gdb.base/commands.exp: break factorial #3 -PASS: gdb.base/commands.exp: set value to 5 in test_command_prompt_position -PASS: gdb.base/commands.exp: if test in test_command_prompt_position -PASS: gdb.base/commands.exp: > OK in test_command_prompt_position +PASS: gdb.base/commands.exp: test_command_prompt_position: break factorial +PASS: gdb.base/commands.exp: test_command_prompt_position: set value to 5 +PASS: gdb.base/commands.exp: test_command_prompt_position: if test +PASS: gdb.base/commands.exp: test_command_prompt_position: > OK [...] gdb/testsuite/ChangeLog: 2016-11-09 Pedro Alves <palves@redhat.com> * gdb.base/commands.exp (gdbvar_simple_if_test) (gdbvar_simple_while_test, gdbvar_complex_if_while_test) (progvar_simple_if_test, progvar_simple_while_test) (progvar_complex_if_while_test, if_while_breakpoint_command_test) (infrun_breakpoint_command_test, breakpoint_command_test) (user_defined_command_test, watchpoint_command_test) (test_command_prompt_position, deprecated_command_test) (bp_deleted_in_command, temporary_breakpoint_commands) (stray_arg0_test, source_file_with_indented_comment) (recursive_source_test, if_commands_test) (error_clears_commands_left, redefine_hook_test) (redefine_backtrace_test): Use proc_with_prefix. * lib/gdb.exp (proc_with_prefix): New proc.
Diffstat (limited to 'gdb/testsuite/lib')
-rw-r--r--gdb/testsuite/lib/gdb.exp8
1 files changed, 8 insertions, 0 deletions
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7d9b198..735ed11 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -1918,6 +1918,14 @@ proc foreach_with_prefix {var list body} {
}
}
+# Like TCL's native proc, but defines a procedure that wraps its body
+# within 'with_test_prefix "$proc_name" { ... }'.
+proc proc_with_prefix {name arguments body} {
+ # Define the advertised proc.
+ proc $name $arguments [list with_test_prefix $name $body]
+}
+
+
# Run BODY in the context of the caller. After BODY is run, the variables
# listed in VARS will be reset to the values they had before BODY was run.
#