aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
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
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')
-rw-r--r--gdb/testsuite/ChangeLog16
-rw-r--r--gdb/testsuite/gdb.base/commands.exp224
-rw-r--r--gdb/testsuite/lib/gdb.exp8
3 files changed, 131 insertions, 117 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index e0e4a6c..b9fabee 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,19 @@
+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.
+
2016-11-09 Andreas Arnez <arnez@linux.vnet.ibm.com>
* gdb.base/tui-layout.c: New file.
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index 11d6db7..fe2c23a 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -23,111 +23,108 @@ if { [prepare_for_testing commands.exp commands run.c {debug additional_flags=-D
return -1
}
-proc gdbvar_simple_if_test {} {
+proc_with_prefix gdbvar_simple_if_test {} {
global gdb_prompt
- gdb_test_no_output "set \$foo = 0" "set foo in gdbvar_simple_if_test"
+ gdb_test_no_output "set \$foo = 0" "set foo"
# All this test should do is print 0xdeadbeef once.
gdb_test "if \$foo == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
- "\\\$\[0-9\]* = 0xdeadbeef" "gdbvar_simple_if_test #1"
+ "\\\$\[0-9\]* = 0xdeadbeef" "#1"
# All this test should do is print 0xfeedface once.
gdb_test "if \$foo == 0\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
- "\\\$\[0-9\]* = 0xfeedface" "gdbvar_simple_if_test #2"
+ "\\\$\[0-9\]* = 0xfeedface" "#2"
}
-proc gdbvar_simple_while_test {} {
+proc_with_prefix gdbvar_simple_while_test {} {
global gdb_prompt
- gdb_test_no_output "set \$foo = 5" "set foo in gdbvar_simple_while_test"
+ gdb_test_no_output "set \$foo = 5" "set foo"
# This test should print 0xfeedface five times.
gdb_test "while \$foo > 0\np/x 0xfeedface\nset \$foo -= 1\nend" \
"\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
- "gdbvar_simple_while_test #1"
+ "#1"
}
-proc gdbvar_complex_if_while_test {} {
+proc_with_prefix gdbvar_complex_if_while_test {} {
global gdb_prompt
gdb_test_no_output "set \$foo = 4" \
- "set foo in gdbvar complex_if_while_test"
+ "set foo"
# This test should alternate between 0xdeadbeef and 0xfeedface two times.
gdb_test "while \$foo > 0\nset \$foo -= 1\nif \(\$foo % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend" \
"\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
- "gdbvar_complex_if_while_test #1"
+ "#1"
}
-proc progvar_simple_if_test {} {
+proc_with_prefix progvar_simple_if_test {} {
global gdb_prompt
if { ![runto factorial] } then { gdb_suppress_tests; }
# Don't depend upon argument passing, since most simulators don't
# currently support it. Bash value variable to be what we want.
- gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test #1"
+ gdb_test "p value=5" ".*" "set value to 5"
# All this test should do is print 0xdeadbeef once.
gdb_test "if value == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
"\\\$\[0-9\]* = 0xdeadbeef" \
- "progvar_simple_if_test #1"
+ "#1"
# All this test should do is print 0xfeedface once.
gdb_test "if value == 5\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
"\\\$\[0-9\]* = 0xfeedface" \
- "progvar_simple_if_test #2"
+ "#2"
gdb_stop_suppressing_tests
}
-proc progvar_simple_while_test {} {
+proc_with_prefix progvar_simple_while_test {} {
global gdb_prompt
if { ![runto factorial] } then { gdb_suppress_tests }
# Don't depend upon argument passing, since most simulators don't
# currently support it. Bash value variable to be what we want.
- gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test #2"
+ gdb_test "p value=5" ".*" "set value to 5"
# This test should print 0xfeedface five times.
gdb_test "while value > 0\np/x 0xfeedface\nset value -= 1\nend" \
"\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
- "progvar_simple_while_test #1"
+ "#1"
gdb_stop_suppressing_tests
}
-proc progvar_complex_if_while_test {} {
+proc_with_prefix progvar_complex_if_while_test {} {
global gdb_prompt
if { ![runto factorial] } then { gdb_suppress_tests }
# Don't depend upon argument passing, since most simulators don't
# currently support it. Bash value variable to be what we want.
- gdb_test "p value=4" ".*" "set value to 4 in progvar_simple_if_test"
+ gdb_test "p value=4" ".*" "set value to 4"
# This test should alternate between 0xdeadbeef and 0xfeedface two times.
gdb_test "while value > 0\nset value -= 1\nif \(value % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend" \
"\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
- "progvar_complex_if_while_test #1"
+ "#1"
gdb_stop_suppressing_tests
}
-proc if_while_breakpoint_command_test {} {
+proc_with_prefix if_while_breakpoint_command_test {} {
if { ![runto factorial] } then { gdb_suppress_tests }
# Don't depend upon argument passing, since most simulators don't
# currently support it. Bash value variable to be what we want.
- gdb_test "p value=5" ".*" "set value to 5 in progvar_simple_if_test"
+ gdb_test "p value=5" ".*" "set value to 5"
delete_breakpoints
- gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #1"
+ gdb_test "break factorial" "Breakpoint.*at.*" "break factorial"
- gdb_test_multiple "commands" \
- "commands in if_while_breakpoint_command_test" {
- -re "End with" {
- pass "commands in if_while_breakpoint_command_test"
- }
+ gdb_test_multiple "commands" "commands" {
+ -re "End with" {
+ pass "commands"
}
+ }
# This test should alternate between 0xdeadbeef and 0xfeedface two times.
gdb_test "while value > 0\nset value -= 1\nif \(value % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend\nend" \
"" \
- "commands part 2 in if_while_breakpoint_command_test"
+ "commands part 2"
gdb_test "continue" \
"\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
- "if_while_breakpoint_command_test #1"
- gdb_test "info break" \
- "while.*set.*if.*p/x.*else.*p/x.*end.*" \
- "info break in if_while_breakpoint_command_test"
+ "#1"
+ gdb_test "info break" "while.*set.*if.*p/x.*else.*p/x.*end.*"
gdb_stop_suppressing_tests
}
@@ -137,12 +134,12 @@ proc if_while_breakpoint_command_test {} {
# shall be ignored. See the gdb manual, "Break Commands",
# subsection "Breakpoint command lists".
-proc infrun_breakpoint_command_test {} {
+proc_with_prefix infrun_breakpoint_command_test {} {
if { ![runto factorial] } then { gdb_suppress_tests }
# Don't depend upon argument passing, since most simulators don't
# currently support it. Bash value variable to be what we want.
- gdb_test "p value=6" ".*" "set value to 6 in progvar_simple_if_test #1"
+ gdb_test "p value=6" ".*" "set value to 6"
delete_breakpoints
gdb_test "break factorial if value == 5" "Breakpoint.*at.*"
@@ -150,89 +147,85 @@ proc infrun_breakpoint_command_test {} {
# to get around a synchronization problem in expect.
# part1: issue the gdb command "commands"
# part2: send the list of commands
- gdb_test_multiple "commands" \
- "commands in infrun_breakpoint_command_test #1" {
- -re "End with" {
- pass "commands in infrun_breakpoint_command_test #1"
- }
+
+ set test "commands #1"
+ gdb_test_multiple "commands" $test {
+ -re "End with" {
+ pass $test
}
+ }
gdb_test "step\nstep\nstep\nstep\nend" "" \
- "commands in infrun_breakpoint_command_test #2"
+ "commands #2"
gdb_test "continue" \
- "Continuing.*.*.*Breakpoint \[0-9\]*, factorial \\(value=5\\).*at.*\[0-9\]*\[ \]*if \\(value > 1\\) \{.*\[0-9\]*\[ \]*value \\*= factorial \\(value - 1\\);.*" \
- "continue in infrun_breakpoint_command_test"
+ "Continuing.*.*.*Breakpoint \[0-9\]*, factorial \\(value=5\\).*at.*\[0-9\]*\[ \]*if \\(value > 1\\) \{.*\[0-9\]*\[ \]*value \\*= factorial \\(value - 1\\);.*"
gdb_stop_suppressing_tests
}
-proc breakpoint_command_test {} {
+proc_with_prefix breakpoint_command_test {} {
if { ![runto factorial] } then { gdb_suppress_tests; }
# Don't depend upon argument passing, since most simulators don't
# currently support it. Bash value variable to be what we want.
- gdb_test "p value=6" ".*" "set value to 6 in progvar_simple_if_test #2"
+ gdb_test "p value=6" ".*" "set value to 6"
delete_breakpoints
- gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #2"
+ gdb_test "break factorial" "Breakpoint.*at.*"
gdb_test "commands\nprintf \"Now the value is %d\\n\", value\nend" \
- "End with.*" "commands in breakpoint_command_test"
+ "End with.*" "commands"
gdb_test "continue" \
- "Breakpoint \[0-9\]*, factorial.*Now the value is 5" \
- "continue in breakpoint_command_test"
- gdb_test "print value" " = 5" "print value in breakpoint_command_test"
+ "Breakpoint \[0-9\]*, factorial.*Now the value is 5"
+ gdb_test "print value" " = 5"
gdb_stop_suppressing_tests
}
# Test a simple user defined command (with arguments)
-proc user_defined_command_test {} {
+proc_with_prefix user_defined_command_test {} {
global gdb_prompt
- gdb_test_no_output "set \$foo = 4" \
- "set foo in user_defined_command_test"
+ gdb_test_no_output "set \$foo = 4" "set foo"
- gdb_test_multiple "define mycommand" \
- "define mycommand in user_defined_command_test" {
- -re "End with" {
- pass "define mycommand in user_defined_command_test"
- }
+ gdb_test_multiple "define mycommand" "define mycommand" {
+ -re "End with" {
+ pass "define mycommand"
}
+ }
# This test should alternate between 0xdeadbeef and 0xfeedface two times.
gdb_test "while \$arg0 > 0\nset \$arg0 -= 1\nif \(\$arg0 % 2\) == 1\np/x 0xdeadbeef\nelse\np/x 0xfeedface\nend\nend\nend" \
"" \
- "enter commands in user_defined_command_test"
+ "enter commands"
gdb_test "mycommand \$foo" \
"\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface\[^\n\]*\n\\\$\[0-9\]* = 0xdeadbeef\[^\n\]*\n\\\$\[0-9\]* = 0xfeedface" \
- "execute user defined command in user_defined_command_test"
+ "execute user-defined command"
gdb_test "show user mycommand" \
" while \\\$arg0.*set.* if \\\(\\\$arg0.*p/x.* else\[^\n\].*p/x.* end\[^\n\].* end\[^\n\].*" \
- "display user command in user_defined_command_test"
+ "display user command"
# Create and test a user-defined command with an empty body.
- gdb_test_multiple "define myemptycommand" \
- "define myemptycommand in user_defined_command_test" {
- -re "End with" {
- pass "define myemptycommand in user_defined_command_test"
- }
+ gdb_test_multiple "define myemptycommand" "define myemptycommand" {
+ -re "End with" {
+ pass "define myemptycommand"
}
+ }
gdb_test "end" \
"" \
"end definition of user-defined command with empty body"
gdb_test_no_output "myemptycommand" \
- "execute user-defined empty command in user_defined_command_test"
+ "execute user-defined empty command"
gdb_test "show user" \
"User command \"myemptycommand.*" \
- "display empty command in command list in user_defined_command_test"
+ "display empty command in command list"
gdb_test "show user myemptycommand" \
"User command \"myemptycommand.*" \
- "display user-defined empty command in user_defined_command_test"
+ "display user-defined empty command"
}
-proc watchpoint_command_test {} {
+proc_with_prefix watchpoint_command_test {} {
global gdb_prompt
# Disable hardware watchpoints if necessary.
@@ -303,19 +296,19 @@ proc watchpoint_command_test {} {
}
}
-proc test_command_prompt_position {} {
+proc_with_prefix test_command_prompt_position {} {
global gdb_prompt
if { ![runto factorial] } then { gdb_suppress_tests; }
# Don't depend upon argument passing, since most simulators don't
# currently support it. Bash value variable to be what we want.
delete_breakpoints
- gdb_test "break factorial" "Breakpoint.*at.*" "break factorial #3"
- gdb_test "p value=5" ".*" "set value to 5 in test_command_prompt_position"
+ gdb_test "break factorial" "Breakpoint.*at.*"
+ gdb_test "p value=5" ".*" "set value to 5"
# All this test should do is print 0xdeadbeef once.
gdb_test "if value == 1\np/x 0xfeedface\nelse\np/x 0xdeadbeef\nend" \
"\\\$\[0-9\]* = 0xdeadbeef" \
- "if test in test_command_prompt_position"
+ "if test"
# Now let's test for the correct position of the '>' in gdb's
# prompt for commands. It should be at the beginning of the line,
@@ -330,32 +323,32 @@ proc test_command_prompt_position {} {
send_gdb "end\n"
gdb_expect {
-re "^end\r\n$gdb_prompt $" {
- pass "> OK in test_command_prompt_position"
+ pass "> OK"
}
-re ".*$gdb_prompt $" {
- fail "some other message in test_command_prompt_position"
+ fail "some other message"
}
timeout {
- fail "(timeout) 1 in test_command_prompt_position"
+ fail "(timeout) 1"
}
}
}
- -re "^ >$" { fail "> not OK in test_command_prompt_position" }
+ -re "^ >$" { fail "> not OK" }
-re ".*$gdb_prompt $" {
- fail "wrong message in test_command_prompt_position"
+ fail "wrong message"
}
timeout {
- fail "(timeout) 2 in test_command_prompt_position "
+ fail "(timeout) 2"
}
}
}
-re "Type commands.*End with.*\[\r\n\] >$" {
- fail "prompt not OK in test_command_prompt_position"
+ fail "prompt not OK"
}
-re ".*$gdb_prompt $" {
- fail "commands in test_command_prompt_position"
+ fail "commands"
}
- timeout { fail "(timeout) 3 commands in test_command_prompt_position" }
+ timeout { fail "(timeout) 3" }
}
gdb_stop_suppressing_tests
@@ -363,7 +356,7 @@ proc test_command_prompt_position {} {
-proc deprecated_command_test {} {
+proc_with_prefix deprecated_command_test {} {
gdb_test "maintenance deprecate blah" "Can't find command.*" \
"tried to deprecate non-existing command"
@@ -397,7 +390,7 @@ proc deprecated_command_test {} {
"deprecate with no arguments"
}
-proc bp_deleted_in_command_test {} {
+proc_with_prefix bp_deleted_in_command_test {} {
global gdb_prompt
delete_breakpoints
@@ -405,12 +398,11 @@ proc bp_deleted_in_command_test {} {
# Create a breakpoint, and associate a command-list to it, with
# one command that deletes this breakpoint.
gdb_test "break factorial" \
- "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." \
- "breakpoint in bp_deleted_in_command_test"
+ "Breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\."
- gdb_test_multiple "commands" "begin commands in bp_deleted_in_command_test" {
+ gdb_test_multiple "commands" "begin commands" {
-re "Type commands for breakpoint.*>$" {
- pass "begin commands in bp_deleted_in_command_test"
+ pass "begin commands"
}
}
gdb_test_multiple "silent" "add silent command" {
@@ -442,7 +434,7 @@ proc bp_deleted_in_command_test {} {
gdb_test "" "factorial command-list executed.*" "run factorial until breakpoint"
}
-proc temporary_breakpoint_commands {} {
+proc_with_prefix temporary_breakpoint_commands {} {
global gdb_prompt
delete_breakpoints
@@ -452,12 +444,12 @@ proc temporary_breakpoint_commands {} {
# breakpoint is hit.
gdb_test "tbreak factorial" \
"Temporary breakpoint \[0-9\]+ at .*: file .*run.c, line \[0-9\]+\." \
- "breakpoint in temporary_breakpoint_commands"
-
+ "breakpoint"
+
gdb_test_multiple "commands" \
"begin commands in bp_deleted_in_command_test" {
-re "Type commands for breakpoint.*>$" {
- pass "begin commands in bp_deleted_in_command_test"
+ pass "begin commands"
}
}
gdb_test_multiple "silent" "add silent tbreak command" {
@@ -487,26 +479,26 @@ proc temporary_breakpoint_commands {} {
# Test that GDB can handle $arg0 outside of user functions without
# crashing.
-proc stray_arg0_test { } {
+proc_with_prefix stray_arg0_test { } {
gdb_test "print \$arg0" \
"\\\$\[0-9\]* = void" \
- "stray_arg0_test #1"
+ "#1"
gdb_test "if 1 == 1\nprint \$arg0\nend" \
"\\\$\[0-9\]* = void" \
- "stray_arg0_test #2"
+ "#2"
gdb_test "print \$arg0 = 1" \
"\\\$\[0-9\]* = 1" \
- "stray_arg0_test #3"
+ "#3"
gdb_test "print \$arg0" \
"\\\$\[0-9\]* = 1" \
- "stray_arg0_test #4"
+ "#4"
}
# Test that GDB is able to source a file with an indented comment.
-proc source_file_with_indented_comment {} {
+proc_with_prefix source_file_with_indented_comment {} {
set file1 [standard_output_file file1]
set fd [open "$file1" w]
@@ -517,12 +509,12 @@ end
echo Done!\n}
close $fd
- gdb_test "source $file1" "Done!" "source file with indented comment"
+ gdb_test "source $file1" "Done!" "source file"
}
# Test that GDB can handle arguments when sourcing files recursively.
# If the arguments are overwritten with ####### then the test has failed.
-proc recursive_source_test {} {
+proc_with_prefix recursive_source_test {} {
set file1 [standard_output_file file1]
set file2 [standard_output_file file2]
set file3 [standard_output_file file3]
@@ -550,7 +542,7 @@ end"
gdb_test "source $file1" \
"1: <<<qwerty>>>\[\r\n]+in file3\[\r\n]+2: <<<qwerty>>>" \
- "recursive source test"
+ "source file"
file delete $file1
file delete $file2
@@ -575,10 +567,10 @@ proc gdb_test_no_prompt { command result msg } {
return 0
}
-proc if_commands_test {} {
+proc_with_prefix if_commands_test {} {
global gdb_prompt
- gdb_test_no_output "set \$tem = 1" "set \$tem in if_commands_test"
+ gdb_test_no_output "set \$tem = 1" "set \$tem"
set test "if_commands_test 1"
gdb_test_no_prompt "if \$tem == 2" { >} $test
@@ -633,7 +625,7 @@ proc if_commands_test {} {
# Verify an error during "commands" commands execution will prevent any other
# "commands" from other breakpoints at the same location to be executed.
-proc error_clears_commands_left {} {
+proc_with_prefix error_clears_commands_left {} {
set test "hook-stop 1"
gdb_test_multiple {define hook-stop} $test {
-re "End with a line saying just \"end\"\\.\r\n>$" {
@@ -698,7 +690,7 @@ proc error_clears_commands_left {} {
gdb_test {echo idle\n} "\r\nidle" "no cmd2"
}
-proc redefine_hook_test {} {
+proc_with_prefix redefine_hook_test {} {
global gdb_prompt
gdb_test "define one\nend" \
@@ -709,30 +701,28 @@ proc redefine_hook_test {} {
"" \
"define hook-one"
- gdb_test_multiple "define one" "redefine one" {
+ set test "redefine one"
+ gdb_test_multiple "define one" $test {
-re "Redefine command .one.. .y or n. $" {
send_gdb "y\n"
exp_continue
}
-re "End with" {
- pass "define one in redefine_hook_test"
- }
- default {
- fail "(timeout or eof) define one in redefine_hook_test"
+ pass $test
}
}
gdb_test "end" \
"" \
- "enter commands for one redefinition in redefine_hook_test"
+ "enter commands for one redefinition"
gdb_test "one" \
"hibob" \
- "execute one command in redefine_hook_test"
+ "execute one command"
}
-proc redefine_backtrace_test {} {
+proc_with_prefix redefine_backtrace_test {} {
global gdb_prompt
gdb_test_multiple "define backtrace" "define backtrace" {
@@ -749,14 +739,14 @@ proc redefine_backtrace_test {} {
gdb_test "echo hibob\\n\nend" \
"" \
- "enter commands in redefine_backtrace_test"
+ "enter commands"
gdb_test "backtrace" \
"hibob" \
- "execute backtrace command in redefine_backtrace_test"
+ "execute backtrace command"
gdb_test "bt" \
"hibob" \
- "execute bt command in redefine_backtrace_test"
+ "execute bt command"
}
gdbvar_simple_if_test
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.
#