[PATCH 3/4] gdb/testsuite: Reduce test name duplication in gdb.base tests

Andrew Burgess andrew.burgess@embecosm.com
Mon Sep 16 02:25:00 GMT 2019


This commit removes some, but not all, of the test name duplication
within the gdb.base tests.  On my local machine this takes the number
of duplicate test names in this set of tests from 454 to 145.  It is
possible that different setups might encounter more duplicate tests.

gdb/testsuite/ChangeLog:

	* gdb.base/break-interp.exp: Reduce test name duplication.
	* gdb.base/call-sc.exp: Likewise.
	* gdb.base/callfuncs.exp: Likewise.
	* gdb.base/charset.exp: Likewise.
	* gdb.base/dump.exp: Likewise.
	* gdb.base/ena-dis-br.exp: Likewise.
	* gdb.base/relational.exp: Likewise.
	* gdb.base/step-over-syscall.exp: Likewise.
	* gdb.base/structs.exp: Likewise.
---
 gdb/testsuite/ChangeLog                      |  12 ++
 gdb/testsuite/gdb.base/break-interp.exp      |  76 ++++++-----
 gdb/testsuite/gdb.base/call-sc.exp           |  10 +-
 gdb/testsuite/gdb.base/callfuncs.exp         |  46 ++++---
 gdb/testsuite/gdb.base/charset.exp           |  10 +-
 gdb/testsuite/gdb.base/dump.exp              |  42 +++---
 gdb/testsuite/gdb.base/ena-dis-br.exp        |  12 +-
 gdb/testsuite/gdb.base/relational.exp        | 193 +++++++++++++++------------
 gdb/testsuite/gdb.base/step-over-syscall.exp |  11 +-
 gdb/testsuite/gdb.base/structs.exp           |  10 +-
 10 files changed, 248 insertions(+), 174 deletions(-)

diff --git a/gdb/testsuite/gdb.base/break-interp.exp b/gdb/testsuite/gdb.base/break-interp.exp
index d6da6535293..a03c9f43fda 100644
--- a/gdb/testsuite/gdb.base/break-interp.exp
+++ b/gdb/testsuite/gdb.base/break-interp.exp
@@ -191,8 +191,16 @@ proc reach_1 {func command displacement} {
 # DISPLACEMENT can be "NONE" for no message to be present, "ZERO" for
 # displacement of 0 bytes to be present, "NONZERO" for displacement of non-0
 # bytes to be present and "PRESENT" if both "ZERO" and "NONZERO" are valid.
-proc reach {func command displacement} {
-    with_test_prefix "reach-$func" {
+#
+# The optional ITERATION parameter is used in order to make unique
+# test prefixes, when calling this proc with the same FUNC name
+# provide a unique ITERATION value for each call.
+proc reach {func command displacement {iteration 1}} {
+    set prefix "reach-$func"
+    if { $iteration > 1 } {
+	set prefix "$prefix-$iteration"
+    }
+    with_test_prefix $prefix {
 	reach_1 $func $command $displacement
     }
 }
@@ -399,7 +407,7 @@ proc test_ld {file ifmain trynosym displacement} {
 	    "set args OBJDIR/${subdir}/$binfile_test"
     }
 
-    reach $solib_bp "run" $displacement
+    reach $solib_bp "run" $displacement 1
 
     gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?$solib_bp\\M.*" "dl bt"
 
@@ -413,7 +421,7 @@ proc test_ld {file ifmain trynosym displacement} {
 
     # Try re-run if the new PIE displacement takes effect.
     gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y"
-    reach $solib_bp "run" $displacement
+    reach $solib_bp "run" $displacement 2
 
     if $ifmain {
 	test_core $file $displacement
@@ -445,7 +453,7 @@ proc test_ld {file ifmain trynosym displacement} {
 	gdb_test "exec-file $file" "exec-file $escapedfile" "load"
 
 	if $ifmain {
-	    reach $solib_bp run $displacement
+	    reach $solib_bp run $displacement 3
 
 	    # Use two separate gdb_test_multiple statements to avoid timeouts due
 	    # to slow processing of wildcard capturing long output
@@ -594,9 +602,10 @@ foreach ldprelink {NO YES} {
 		file delete "${interp}.debug"
 	    }
 
-	    if ![prelink$ldprelink $interp] {
+	    if ![prelink$ldprelink $interp "$interp, second time"] {
 		continue
 	    }
+
 	    if {$ldprelink == "NO"} {
 		set displacement "NONZERO"
 	    } else {
@@ -662,34 +671,39 @@ foreach ldprelink {NO YES} {
 
 			    if {[prelink$binprelink $relink_args [file tail $exec]]
 				&& [file_copy $interp_saved $interp]} {
-				if {$binpie != "ATTACH"} {
-				    test_ld $exec 1 [expr {$binsepdebug == "NO"}] $displacement
-				} else {
-				    # If the file has been randomly prelinked it must be
-				    # "NONZERO".  We could see "ZERO" only if it was unprelinked
-				    # and it is now running at the same address - which is 0 but
-				    # executable can never run at address 0.
-
-				    set displacement "NONZERO"
-				    test_attach $exec $displacement $relink_args
-
-				    # ATTACH means that executables and libraries have been
-				    # modified after they have been run.  They cannot be reused
-				    # for problem reproducibility after the testcase ends in
-				    # the ATTACH case.  Therefore they are rather deleted not
-				    # to confuse after the run finishes.
-				    set exec_debug [system_debug_get $exec]
-				    if {$exec_debug != ""} {
-					# `file delete [glob "${exec_debug}*"]' does not work.
-					foreach f [glob "${exec_debug}*"] {
+				# In order to make test names unique wrap the core of this if block
+				# with a test prefix.  Some of the tests performed in the if
+				# condition are repeated within this body.
+				with_test_prefix "INNER" {
+				    if {$binpie != "ATTACH"} {
+					test_ld $exec 1 [expr {$binsepdebug == "NO"}] $displacement
+				    } else {
+					# If the file has been randomly prelinked it must be
+					# "NONZERO".  We could see "ZERO" only if it was unprelinked
+					# and it is now running at the same address - which is 0 but
+					# executable can never run at address 0.
+
+					set displacement "NONZERO"
+					test_attach $exec $displacement $relink_args
+
+					# ATTACH means that executables and libraries have been
+					# modified after they have been run.  They cannot be reused
+					# for problem reproducibility after the testcase ends in
+					# the ATTACH case.  Therefore they are rather deleted not
+					# to confuse after the run finishes.
+					set exec_debug [system_debug_get $exec]
+					if {$exec_debug != ""} {
+					    # `file delete [glob "${exec_debug}*"]' does not work.
+					    foreach f [glob "${exec_debug}*"] {
+						file delete $f
+					    }
+					}
+					file delete -force $dir
+					# `file delete [glob "${exec}*"]' does not work.
+					foreach f [glob "${exec}*"] {
 					    file delete $f
 					}
 				    }
-				    file delete -force $dir
-				    # `file delete [glob "${exec}*"]' does not work.
-				    foreach f [glob "${exec}*"] {
-					file delete $f
-				    }
 				}
 			    }
 			}
diff --git a/gdb/testsuite/gdb.base/call-sc.exp b/gdb/testsuite/gdb.base/call-sc.exp
index c68dfeb3688..6cb67f85ae3 100644
--- a/gdb/testsuite/gdb.base/call-sc.exp
+++ b/gdb/testsuite/gdb.base/call-sc.exp
@@ -71,9 +71,11 @@ proc start_scalars_test { type } {
     gdb_load ${binfile}
 
     # Make certain that the output is consistent
-    gdb_test_no_output "set print sevenbit-strings"
-    gdb_test_no_output "set print address off"
-    gdb_test_no_output "set width 0"
+    with_test_prefix "testfile=$testfile" {
+	gdb_test_no_output "set print sevenbit-strings"
+	gdb_test_no_output "set print address off"
+	gdb_test_no_output "set width 0"
+    }
 
     # Advance to main
     if { ![runto_main] } then {
@@ -243,7 +245,7 @@ proc test_scalar_returns { } {
     #
     # This happens on ppc64 GNU/Linux with gcc 3.4.1 and a buggy GDB
 
-    set test "return foo; synchronize pc to main()"
+    set test "return foo; synchronize pc to main() for '${testfile}'"
     for {set loop_count 0} {$loop_count < 2} {incr loop_count} {
       gdb_test_multiple "backtrace 1" $test {
         -re "#0.*main \\(\\).*${gdb_prompt} $" {
diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index f9e4c432c80..04bdac85e73 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -322,21 +322,30 @@ proc fetch_all_registers {test} {
     return $all_registers_lines
 }
 
+set rerun_count 0
+
 proc rerun_and_prepare {} {
-    if { ![runto_main] } {
-	gdb_suppress_tests
-    }
+    global rerun_count
+
+    incr rerun_count
+    with_test_prefix "rerun number ${rerun_count}" {
 
-    gdb_test_no_output "set language c"
+	if { ![runto_main] } {
+	    gdb_suppress_tests
+	}
+
+	gdb_test_no_output "set language c"
 
-    get_debug_format
+	get_debug_format
 
-    # Make sure that malloc gets called and that the floating point unit
-    # is initialized via a call to t_double_values.
-    gdb_test "next" "t_double_values\\(double_val1, double_val2\\);.*" \
-	"next to t_double_values"
-    gdb_test "next" "t_structs_c\\(struct_val1\\);.*" \
-	"next to t_structs_c"
+	# Make sure that malloc gets called and that the floating
+	# point unit is initialized via a call to t_double_values.
+	gdb_test "next" \
+	    "t_double_values\\(double_val1, double_val2\\);.*" \
+	    "next to t_double_values"
+	gdb_test "next" "t_structs_c\\(struct_val1\\);.*" \
+	    "next to t_structs_c"
+    }
 }
 
 proc perform_all_tests {prototypes} {
@@ -347,7 +356,8 @@ proc perform_all_tests {prototypes} {
     rerun_and_prepare
 
     # Save all register contents.
-    set old_reg_content [fetch_all_registers "retrieve original register contents"]
+    set old_reg_content \
+	[fetch_all_registers "retrieve original register contents 1"]
 
     # Perform function calls.
     do_function_calls $prototypes
@@ -364,7 +374,8 @@ proc perform_all_tests {prototypes} {
 
     rerun_and_prepare
     # Save all register contents.
-    set old_reg_content [fetch_all_registers "retrieve original register contents"]
+    set old_reg_content \
+	[fetch_all_registers "retrieve original register contents 2"]
 
     # Set breakpoint at a function we will call from gdb.
     gdb_breakpoint add
@@ -391,7 +402,8 @@ proc perform_all_tests {prototypes} {
     # Set breakpoint at a function we will call from gdb.
     gdb_breakpoint add
     # Save all register contents.
-    set old_reg_content [fetch_all_registers "retrieve original register contents"]
+    set old_reg_content \
+	[fetch_all_registers "retrieve original register contents 3"]
 
     # Call function (causing a breakpoint hit in the call dummy) and do a finish,
     # make sure we are back at main and still have the same register contents.
@@ -416,7 +428,8 @@ proc perform_all_tests {prototypes} {
     # Set breakpoint at a function we will call from gdb.
     gdb_breakpoint add
     # Save all register contents.
-    set old_reg_content [fetch_all_registers "retrieve original register contents"]
+    set old_reg_content \
+	[fetch_all_registers "retrieve original register contents 4"]
 
     # Call function (causing a breakpoint hit in the call dummy) and do a return
     # with a value, make sure we are back at main with the same register contents.
@@ -439,7 +452,8 @@ proc perform_all_tests {prototypes} {
     rerun_and_prepare
     # Set breakpoint at a function we will call from gdb.
     gdb_breakpoint add
-    set old_reg_content [fetch_all_registers "retrieve original register contents"]
+    set old_reg_content \
+	[fetch_all_registers "retrieve original register contents 5"]
 
     # Call function (causing a breakpoint hit in the call dummy), and
     # call another function from the call dummy frame (thereby setting up
diff --git a/gdb/testsuite/gdb.base/charset.exp b/gdb/testsuite/gdb.base/charset.exp
index 72c7439ebd5..16e986c5190 100644
--- a/gdb/testsuite/gdb.base/charset.exp
+++ b/gdb/testsuite/gdb.base/charset.exp
@@ -175,7 +175,7 @@ gdb_expect {
 # We don't want to test all the charset names here, since that would
 # be too many combinations.  We we pick a subset.
 set charset_subset {ASCII ISO-8859-1 EBCDIC-US IBM1047}
-foreach host_charset $charset_subset {
+foreach_with_prefix host_charset $charset_subset {
     if {[valid_host_charset $host_charset]} {
 
         set testname "try `set host-charset $host_charset'"
@@ -591,8 +591,12 @@ gdb_test "print 'a' == 'a' || 'b' == 'b'" \
 
 
 proc string_display { var_name set_prefix x_size x_type} {
-  gdb_test_no_output "set ${var_name} = ${set_prefix}\"Test String\\0with zeroes\"" "assign ${var_name} with prefix ${set_prefix}"
-  gdb_test "x /2${x_size}s ${var_name}" ".*\t${x_type}\"Test String\"\[\r\n\]+.*\t${x_type}\"with zeroes\"" "display String ${var_name} with x/${x_size}s"
+    with_test_prefix "set_prefix=$set_prefix" {
+	gdb_test_no_output "set ${var_name} = ${set_prefix}\"Test String\\0with zeroes\""\
+	    "assign ${var_name} with prefix ${set_prefix}"
+	gdb_test "x /2${x_size}s ${var_name}" ".*\t${x_type}\"Test String\"\[\r\n\]+.*\t${x_type}\"with zeroes\"" \
+	    "display String ${var_name} with x/${x_size}s"
+    }
 }
 
 if {$ucs2_ok} {
diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index 52ba5f8ebe3..e2310375fef 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -36,6 +36,15 @@ if {[istarget "spu*-*-*"]} then {
     set is64bitonly "yes"
 }
 
+set print_zero_all_count 0
+proc print_zero_all { } {
+    global print_zero_all_count
+
+    incr print_zero_all_count
+    gdb_test "print zero_all ()" " = void" \
+	"call ${print_zero_all_count} to zero_all function"
+}
+
 # Debian9/Ubuntu16.10 onwards default to PIE enabled. Ensure it is disabled as
 # this causes addresses to be out of range for IHEX.
 lappend options {nopie}
@@ -278,7 +287,6 @@ proc test_restore_saved_value { restore_args msg oldval newval } {
 
 if ![string compare $is64bitonly "no"] then {
 
-  gdb_test "print zero_all ()" ".*"
 
   test_restore_saved_value "[set intarr1.srec]" "array as value, srec" \
 	$array_val "intarray"
@@ -286,7 +294,7 @@ if ![string compare $is64bitonly "no"] then {
   test_restore_saved_value "[set intstr1.srec]" "struct as value, srec" \
 	$struct_val "intstruct"
 
-  gdb_test "print zero_all ()" "void" "zero all"
+  print_zero_all
 
   test_restore_saved_value "[set intarr2.srec]" "array as memory, srec" \
 	$array_val "intarray"
@@ -294,7 +302,7 @@ if ![string compare $is64bitonly "no"] then {
   test_restore_saved_value "[set intstr2.srec]" "struct as memory, srec" \
 	$struct_val "intstruct"
 
-  gdb_test "print zero_all ()" ".*"
+  print_zero_all
 
   test_restore_saved_value "[set intarr1.ihex]" "array as value, ihex" \
 	$array_val "intarray"
@@ -302,7 +310,7 @@ if ![string compare $is64bitonly "no"] then {
   test_restore_saved_value "[set intstr1.ihex]" "struct as value, ihex" \
 	$struct_val "intstruct"
 
-  gdb_test "print zero_all ()" ".*"
+  print_zero_all
 
   test_restore_saved_value "[set intarr2.ihex]" "array as memory, ihex" \
 	$array_val "intarray"
@@ -310,7 +318,7 @@ if ![string compare $is64bitonly "no"] then {
   test_restore_saved_value "[set intstr2.ihex]" "struct as memory, ihex" \
 	$struct_val "intstruct"
 
-  gdb_test "print zero_all ()" ".*"
+  print_zero_all
 
   test_restore_saved_value "[set intarr1.tekhex]" "array as value, tekhex" \
 	$array_val "intarray"
@@ -318,7 +326,7 @@ if ![string compare $is64bitonly "no"] then {
   test_restore_saved_value "[set intstr1.tekhex]" "struct as value, tekhex" \
 	$struct_val "intstruct"
 
-  gdb_test "print zero_all ()" ".*"
+  print_zero_all
 
   test_restore_saved_value "[set intarr2.tekhex]" "array as memory, tekhex" \
 	$array_val "intarray"
@@ -327,7 +335,7 @@ if ![string compare $is64bitonly "no"] then {
 	$struct_val "intstruct"
 }
 
-gdb_test "print zero_all ()" ".*"
+print_zero_all
 
 test_restore_saved_value "[set intarr1.bin] binary $array_start" \
 	"array as value, binary" \
@@ -337,7 +345,7 @@ test_restore_saved_value "[set intstr1.bin] binary $struct_start" \
 	"struct as value, binary" \
 	$struct_val "intstruct"
 
-gdb_test "print zero_all ()" ".*"
+print_zero_all
 
 test_restore_saved_value "[set intarr2.bin] binary $array_start" \
 	"array as memory, binary" \
@@ -356,7 +364,7 @@ set array2_offset  \
 set struct2_offset \
 	[capture_value "(char *) &intstruct2 - (char *) &intstruct"]
 
-gdb_test "print zero_all ()" ".*"
+print_zero_all
 
 
 if ![string compare $is64bitonly "no"] then {
@@ -368,7 +376,7 @@ if ![string compare $is64bitonly "no"] then {
 	"struct copy, srec" \
 	$struct_val "intstruct2"
 
-  gdb_test "print zero_all ()" ".*"
+  print_zero_all
 
   test_restore_saved_value "[set intarr1.ihex] $array2_offset" \
 	"array copy, ihex" \
@@ -378,7 +386,7 @@ if ![string compare $is64bitonly "no"] then {
 	"struct copy, ihex" \
 	$struct_val "intstruct2"
 
-  gdb_test "print zero_all ()" ".*"
+  print_zero_all
 
   test_restore_saved_value "[set intarr1.tekhex] $array2_offset" \
 	"array copy, tekhex" \
@@ -389,7 +397,7 @@ if ![string compare $is64bitonly "no"] then {
 	$struct_val "intstruct2"
 }
 
-gdb_test "print zero_all ()" ".*"
+print_zero_all
 
 test_restore_saved_value "[set intarr1.bin] binary $array2_start" \
 	"array copy, binary" \
@@ -416,7 +424,7 @@ set element4_offset \
 	[capture_value "/x (char *) &intarray\[4\] - (char *) &intarray\[0\]"]
 
 if ![string compare $is64bitonly "no"] then {
-  gdb_test "print zero_all ()" ".*"
+  print_zero_all
 
   test_restore_saved_value "[set intarr1.srec] 0 $element3_start $element4_start" \
 	"array partial, srec" 4 "intarray\[3\]"
@@ -424,7 +432,7 @@ if ![string compare $is64bitonly "no"] then {
   gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 1"
   gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 1"
 
-  gdb_test "print zero_all ()" ".*"
+  print_zero_all
 
   test_restore_saved_value "[set intarr1.ihex] 0 $element3_start $element4_start" \
 	"array partial, ihex" 4 "intarray\[3\]"
@@ -432,7 +440,7 @@ if ![string compare $is64bitonly "no"] then {
   gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 2"
   gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 2"
 
-  gdb_test "print zero_all ()" ".*"
+  print_zero_all
 
   test_restore_saved_value "[set intarr1.tekhex] 0 $element3_start $element4_start" \
 	"array partial, tekhex" 4 "intarray\[3\]"
@@ -441,7 +449,7 @@ if ![string compare $is64bitonly "no"] then {
   gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 3"
 }
 
-gdb_test "print zero_all ()" ".*"
+print_zero_all
 
 test_restore_saved_value \
     "[set intarr1.bin] binary $array_start $element3_offset $element4_offset" \
@@ -451,7 +459,7 @@ gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 4"
 gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 4"
 
 if ![string compare $is64bitonly "no"] then {
-  gdb_test "print zero_all ()" ".*" ""
+  print_zero_all
 
   # restore with expressions 
   test_restore_saved_value \
diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp
index aa5b35e3586..cd05052a0ee 100644
--- a/gdb/testsuite/gdb.base/ena-dis-br.exp
+++ b/gdb/testsuite/gdb.base/ena-dis-br.exp
@@ -60,7 +60,7 @@ gdb_test_no_output "enable $bp" "enable break marker1"
 
 gdb_test "info break $bp" \
     "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*" \
-    "info break marker1"
+    "info break marker1 before hitting breakpoint"
 
 # See the comments in condbreak.exp for "run until breakpoint at
 # marker1" for an explanation of the xfail below.
@@ -84,7 +84,7 @@ gdb_test_no_output "enable once $bp" "enable once break marker2"
 
 gdb_test "info break $bp" \
     "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+y.*" \
-    "info auto-disabled break marker2"
+    "info auto-disabled break marker2 before hitting breakpoint"
 
 # See the comments in condbreak.exp for "run until breakpoint at
 # marker1" for an explanation of the xfail below.
@@ -100,7 +100,7 @@ gdb_test_multiple "continue" "$test" {
 
 gdb_test "info break $bp" \
     "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+dis\[ \t\]+n.*" \
-    "info auto-disabled break marker2"
+    "info auto-disabled break marker2 after hitting breakpoint"
 
 # Verify that we don't stop at a disabled breakpoint.
 gdb_continue_to_end "no stop"
@@ -209,7 +209,7 @@ gdb_test "ignore $bp 0" \
 
 gdb_test "ignore $bp 1" \
     "Will ignore next crossing of breakpoint \[0-9\]*.*" \
-    "ignore break marker1"
+    "ignore break marker1 1"
 
 gdb_test "info break $bp" \
     "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+keep\[ \t\]+y.*ignore next 1 hits.*" \
@@ -246,7 +246,7 @@ gdb_test_no_output "enable del $bp" "enable del break marker1"
 
 gdb_test "info break $bp" \
     "\[0-9\]*\[ \t\]+breakpoint\[ \t\]+del\[ \t\]+y.*ignore next 1 hits.*" \
-    "info break marker1"
+    "info break marker1 after hitting breakpoint"
 
 gdb_continue_to_end "no stop at ignored & auto-deleted break marker1"
 rerun_to_main
@@ -266,7 +266,7 @@ set bp [break_at marker1 " line $bp_location15"]
 
 gdb_test "ignore $bp 10" \
     "Will ignore next 10 crossings of breakpoint \[0-9\]*.*" \
-    "ignore break marker1"
+    "ignore break marker1 10"
 
 gdb_test_no_output "disable $bp" "disable break marker1"
 
diff --git a/gdb/testsuite/gdb.base/relational.exp b/gdb/testsuite/gdb.base/relational.exp
index 054c6259d4d..eb8e0a717f8 100644
--- a/gdb/testsuite/gdb.base/relational.exp
+++ b/gdb/testsuite/gdb.base/relational.exp
@@ -46,147 +46,162 @@ if ![runto_main] then {
 # test expressions with "int" types
 #
 
-gdb_test_no_output "set variable x=14" "set variable x=14"
-gdb_test_no_output "set variable y=2" "set variable y=2"
-gdb_test_no_output "set variable z=2" "set variable z=2"
-gdb_test_no_output "set variable w=3" "set variable w=3"
+with_test_prefix "int types" {
 
-gdb_test "print x" " = 14" "print value of x"
+    gdb_test_no_output "set variable x=14" "set variable x=14"
+    gdb_test_no_output "set variable y=2" "set variable y=2"
+    gdb_test_no_output "set variable z=2" "set variable z=2"
+    gdb_test_no_output "set variable w=3" "set variable w=3"
 
-gdb_test "print y" " = 2" "print value of y"
+    gdb_test "print x" " = 14" "print value of x"
 
-gdb_test "print z" " = 2" "print value of z"
+    gdb_test "print y" " = 2" "print value of y"
 
-gdb_test "print w" " = 3" "print value of w"
+    gdb_test "print z" " = 2" "print value of z"
 
-gdb_test "print x < y" "$false" "print value of x<y"
+    gdb_test "print w" " = 3" "print value of w"
 
-gdb_test "print x <= y" "$false" "print value of x<=y"
+    gdb_test "print x < y" "$false" "print value of x<y"
 
-gdb_test "print x > y" "$true" "print value of x>y"
+    gdb_test "print x <= y" "$false" "print value of x<=y"
 
-gdb_test "print x >= y" "$true" "print value of x>=y"
+    gdb_test "print x > y" "$true" "print value of x>y"
 
-gdb_test "print x == y" "$false" "print value of x==y"
+    gdb_test "print x >= y" "$true" "print value of x>=y"
 
-gdb_test "print x != y" "$true" "print value of x!=y"
+    gdb_test "print x == y" "$false" "print value of x==y"
 
+    gdb_test "print x != y" "$true" "print value of x!=y"
+}
 
 # Test associativity of <, >, <=, >=, ==, !=
+with_test_prefix "basic associativity" {
 
-gdb_test_no_output "set variable x=3" "set variable x"
-gdb_test_no_output "set variable y=5" "set variable y"
-gdb_test_no_output "set variable z=2" "set variable z"
-
-gdb_test "print x < y < z" "$true" "print value of x<y<z"
-
-gdb_test "print x <= y <= z" "$true" "print value of x<=y<=z"
-
-gdb_test "print x > y > z" "$false" "print value of x>y>z"
-
-gdb_test "print x >= y >= z" "$false" "print value of x>=y>=z"
+    gdb_test_no_output "set variable x=3" "set variable x=3"
+    gdb_test_no_output "set variable y=5" "set variable y=5"
+    gdb_test_no_output "set variable z=2" "set variable z=2"
 
-gdb_test_no_output "set variable x=2" "set variable x"
-gdb_test_no_output "set variable y=2" "set variable y"
-gdb_test_no_output "set variable z=1" "set variable z"
+    gdb_test "print x < y < z" "$true" "print value of x<y<z"
 
-gdb_test "print x == y == z" "$true" "print value of x==y==z"
+    gdb_test "print x <= y <= z" "$true" "print value of x<=y<=z"
 
-gdb_test_no_output "set variable z=0" "set variable z"
+    gdb_test "print x > y > z" "$false" "print value of x>y>z"
 
-gdb_test "print x != y != z" "$false" "print value of x!=y!=z"
+    gdb_test "print x >= y >= z" "$false" "print value of x>=y>=z"
 
-# test precedence rules on pairs of relational operators
+    gdb_test_no_output "set variable x=2" "set variable x=2"
+    gdb_test_no_output "set variable y=2" "set variable y=2"
+    gdb_test_no_output "set variable z=1" "set variable z=1"
 
-gdb_test_no_output "set variable x=0" "set variable x"
-gdb_test_no_output "set variable y=2" "set variable y"
-gdb_test_no_output "set variable z=2" "set variable z"
+    gdb_test "print x == y == z" "$true" "print value of x==y==z"
 
-gdb_test "print x < y == z" "$false" "print value of x<y==z"
+    gdb_test_no_output "set variable z=0" "set variable z"
 
-# 0  2  2
-gdb_test "print x < y != z" "$true" "print value of x<y!=z"
+    gdb_test "print x != y != z" "$false" "print value of x!=y!=z"
+}
 
-gdb_test_no_output "set variable x=2" "set variable x"
-gdb_test_no_output "set variable y=3" "set variable y"
-gdb_test_no_output "set variable z=1" "set variable z"
+# Test precedence rules on pairs of relational operators.  The use of
+# with_test_prefix with keys 1, 2, 3, etc is only to ensure that the
+# test names are unique.  Each nested group of tests starts at a
+# location where we are setting a variable to a value it has had in
+# the past, which would result in a test name repeating.
+with_test_prefix "pair associativity" {
+    with_test_prefix "1" {
+	gdb_test_no_output "set variable x=0" "set variable x=0"
+	gdb_test_no_output "set variable y=2" "set variable y=2"
+	gdb_test_no_output "set variable z=2" "set variable z=2"
 
+	gdb_test "print x < y == z" "$false" "print value of x<y==z"
 
-# 2 3 1
-gdb_test "print x < y <= z" "$true" "print value of x<y<=z"
+	# 0  2  2
+	gdb_test "print x < y != z" "$true" "print value of x<y!=z"
 
-# 2 3 1
-gdb_test "print x < y >= z" "$true" "print value of x<y>=z"
+	gdb_test_no_output "set variable x=2" "set variable x=2"
+	gdb_test_no_output "set variable y=3" "set variable y=3"
+	gdb_test_no_output "set variable z=1" "set variable z=1"
 
-gdb_test_no_output "set variable z=0" " set variable z"
+	# 2 3 1
+	gdb_test "print x < y <= z" "$true" "print value of x<y<=z"
 
-# 2 3 0
-gdb_test "print x < y > z" "$true" "print value of x<y>z"
+	# 2 3 1
+	gdb_test "print x < y >= z" "$true" "print value of x<y>=z"
 
-gdb_test_no_output "set variable x=1" " set variable x"
+	gdb_test_no_output "set variable z=0" " set variable z=0"
 
-# 1 3 0
-gdb_test "print x > y >= z" "$true" "print value of x>y>=z"
+	# 2 3 0
+	gdb_test "print x < y > z" "$true" "print value of x<y>z"
 
-gdb_test_no_output "set variable z=2" " set variable z"
+	gdb_test_no_output "set variable x=1" " set variable x=1"
 
-# 1 3 2
-gdb_test "print x > y == z" "$false" "print value of x>y==z"
+	# 1 3 0
+	gdb_test "print x > y >= z" "$true" "print value of x>y>=z"
+    }
 
-gdb_test_no_output "set variable x=2" " set variable x"
-gdb_test_no_output "set variable z=0" " set variable z"
+    with_test_prefix "2" {
+	gdb_test_no_output "set variable z=2" " set variable z=2"
 
-# 2 3 0
-gdb_test "print x > y != z" "$false" "print value of x>y!=z"
+	# 1 3 2
+	gdb_test "print x > y == z" "$false" "print value of x>y==z"
 
-gdb_test_no_output "set variable x=4" "set x to 4"
+	gdb_test_no_output "set variable x=2" " set variable x=2"
+	gdb_test_no_output "set variable z=0" " set variable z=0"
 
-# 4 3 0
-gdb_test "print x > y <= z" "$false" "print value of x>y<=z"
+	# 2 3 0
+	gdb_test "print x > y != z" "$false" "print value of x>y!=z"
 
-# 4 3 0
-gdb_test "print x >= y == z" "$false" "print value of x>=y==z"
+	gdb_test_no_output "set variable x=4" "set variable x=4"
 
-gdb_test_no_output "set variable x=2" " set variable x"
+	# 4 3 0
+	gdb_test "print x > y <= z" "$false" "print value of x>y<=z"
 
-# 2 3 0
-gdb_test "print x >= y != z" "$false" "print value of x>=y!=z"
+	# 4 3 0
+	gdb_test "print x >= y == z" "$false" "print value of x>=y==z"
+    }
 
-gdb_test_no_output "set variable x=0" " set variable x"
-gdb_test_no_output "set variable z=4" " set variable z"
+    with_test_prefix "3" {
+	gdb_test_no_output "set variable x=2" " set variable x=2"
 
-# 0 3 4 
-gdb_test "print x >= y <= z" "$true" "print value of x>=y<=z"
+	# 2 3 0
+	gdb_test "print x >= y != z" "$false" "print value of x>=y!=z"
 
-# 0 3 4
-gdb_test "print x <= y == z" "$false" "print value of x<=y==z"
+	gdb_test_no_output "set variable x=0" " set variable x=0"
+	gdb_test_no_output "set variable z=4" " set variable z=4"
 
-gdb_test_no_output "set variable x=2" " set variable x"
+	# 0 3 4
+	gdb_test "print x >= y <= z" "$true" "print value of x>=y<=z"
 
-# 2 3 4
-gdb_test "print x <= y != z" "$true" "print value of x<=y!=z"
+	# 0 3 4
+	gdb_test "print x <= y == z" "$false" "print value of x<=y==z"
+    }
 
-# 2 3 4
-gdb_test "print x == y != z" "$true" "print value of x==y!=z"
+    with_test_prefix "4" {
+	gdb_test_no_output "set variable x=2" " set variable x=2"
 
+	# 2 3 4
+	gdb_test "print x <= y != z" "$true" "print value of x<=y!=z"
 
+	# 2 3 4
+	gdb_test "print x == y != z" "$true" "print value of x==y!=z"
+    }
+}
 
 # test use of parenthesis to enforce different order of evaluation
+with_test_prefix "with parenthesis" {
+    gdb_test_no_output "set variable z=0" " set variable z=0"
 
-gdb_test_no_output "set variable z=0" " set variable z"
+    # 2 3 0
+    gdb_test "print x >= (y < z)" "$true" "print value of x>=(y<z)"
 
-# 2 3 0
-gdb_test "print x >= (y < z)" "$true" "print value of x>=(y<z)"
+    # 2 3 0
+    gdb_test "print x >= (y != z)" "$true" "print value of x>=(y!=z)"
 
-# 2 3 0
-gdb_test "print x >= (y != z)" "$true" "print value of x>=(y!=z)"
+    # 2 3 0
+    gdb_test "print x == (y == z)" "$false" "print value of x==(y==z)"
 
-# 2 3 0
-gdb_test "print x == (y == z)" "$false" "print value of x==(y==z)" 
+    gdb_test_no_output "set variable x=1" " set variable x=1"
+    gdb_test_no_output "set variable z=4" " set variable z=4"
 
-gdb_test_no_output "set variable x=1" " set variable x"
-gdb_test_no_output "set variable z=4" " set variable z"
-
-# 1 3 4
-gdb_test "print (x == y) < z" "$true" "print value of (x==y)<z"
+    # 1 3 4
+    gdb_test "print (x == y) < z" "$true" "print value of (x==y)<z"
+}
 
diff --git a/gdb/testsuite/gdb.base/step-over-syscall.exp b/gdb/testsuite/gdb.base/step-over-syscall.exp
index 8daf65b2d0d..061d706c614 100644
--- a/gdb/testsuite/gdb.base/step-over-syscall.exp
+++ b/gdb/testsuite/gdb.base/step-over-syscall.exp
@@ -27,7 +27,7 @@ if { [istarget "i\[34567\]86-*-linux*"] || [istarget "x86_64-*-linux*"] } {
     return -1
 }
 
-proc check_pc_after_cross_syscall { syscall syscall_insn_next_addr } {
+proc_with_prefix check_pc_after_cross_syscall { syscall syscall_insn_next_addr } {
     set syscall_insn_next_addr_found [get_hexadecimal_valueof "\$pc" "0"]
 
     set test "single step over $syscall final pc"
@@ -59,7 +59,8 @@ proc setup { syscall } {
     # Delete the breakpoint on main.
     gdb_test_no_output "delete break 1"
 
-    gdb_test_no_output "set displaced-stepping off"
+    gdb_test_no_output "set displaced-stepping off" \
+	"set displaced-stepping off during test setup"
 
     gdb_test "break $syscall" "Breakpoint \[0-9\]* at .*"
 
@@ -100,11 +101,13 @@ proc setup { syscall } {
 	return { -1, -1 }
     }
 
-    set syscall_insn_addr [get_hexadecimal_valueof "\$pc" "0"]
+    set syscall_insn_addr [get_hexadecimal_valueof "\$pc" "0" \
+			       "pc before stepi"]
     if {[gdb_test "stepi" "x/i .*=>.*" "stepi $syscall insn"] != 0} {
 	return { -1, -1 }
     }
-    return [list $syscall_insn_addr [get_hexadecimal_valueof "\$pc" "0"]]
+    return [list $syscall_insn_addr [get_hexadecimal_valueof "\$pc" \
+					 "0" "pc after stepi"]]
 }
 
 proc step_over_syscall { syscall } {
diff --git a/gdb/testsuite/gdb.base/structs.exp b/gdb/testsuite/gdb.base/structs.exp
index 0e9b8d2e02c..3d4172e3648 100644
--- a/gdb/testsuite/gdb.base/structs.exp
+++ b/gdb/testsuite/gdb.base/structs.exp
@@ -82,10 +82,12 @@ proc start_structs_test { types } {
     gdb_load ${binfile}
 
     # Make certain that the output is consistent
-    gdb_test_no_output "set print sevenbit-strings"
-    gdb_test_no_output "set print address off"
-    gdb_test_no_output "set width 0"
-    gdb_test_no_output "set print elements 300"
+    with_test_prefix "types=$types" {
+	gdb_test_no_output "set print sevenbit-strings"
+	gdb_test_no_output "set print address off"
+	gdb_test_no_output "set width 0"
+	gdb_test_no_output "set print elements 300"
+    }
 
     # Advance to main
     if { ![runto_main] } then {
-- 
2.14.5



More information about the Gdb-patches mailing list