gdb/testsuite: Reduce test name duplication in gdb.base tests
authorAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 16 Sep 2019 01:50:17 +0000 (21:50 -0400)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 3 Oct 2019 16:48:03 +0000 (17:48 +0100)
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
gdb/testsuite/gdb.base/break-interp.exp
gdb/testsuite/gdb.base/call-sc.exp
gdb/testsuite/gdb.base/callfuncs.exp
gdb/testsuite/gdb.base/charset.exp
gdb/testsuite/gdb.base/dump.exp
gdb/testsuite/gdb.base/ena-dis-br.exp
gdb/testsuite/gdb.base/relational.exp
gdb/testsuite/gdb.base/step-over-syscall.exp
gdb/testsuite/gdb.base/structs.exp

index 4228c26b38b207b6f8886d69ed54aedd905c6c3b..2261b15542b30b4296393f6b9b1fefefbdc40a66 100644 (file)
@@ -1,3 +1,15 @@
+2019-10-03  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * 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.
+
 2019-10-03  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * gdb.linespec/explicit.exp: Make test names unique.
index d6da6535293bddff1a05756ef8a445382c9ab55c..a03c9f43fda254d92abe04e243bb37c849851197 100644 (file)
@@ -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
-                                   }
                                }
                            }
                        }
index c68dfeb368800d68f4d60cfc73dc4497ffb07897..6cb67f85ae3f2a9eb251354f19410f8210342019 100644 (file)
@@ -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} $" {
index f9e4c432c8001d95d06ad040b54048db02492a8b..3f33feba42b97972db7abc9e4450cd00b4eb1148 100644 (file)
@@ -322,21 +322,31 @@ proc fetch_all_registers {test} {
     return $all_registers_lines
 }
 
+# Global used by RERUN_AND_PREPARE to make test names unique.
+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 +357,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 +375,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 +403,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 +429,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 +453,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
index 72c7439ebd5092a62eae36b20f696393c3c767d9..16e986c51906d4261a703abaef7064c862acf57b 100644 (file)
@@ -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} {
index 77db17936eb1b238cbfc3696bcc9abd644120ea7..7635b6b272a8996179e627791954db2ee051c832 100644 (file)
@@ -30,6 +30,17 @@ if [istarget "alpha*-*-*"] then {
     lappend options "additional_flags=-Wl,-taso"
 }
 
+# Runs the command 'print zero_all ()'.  Uses the PRINT_ZERO_ALL_COUNT
+# global to ensure the test names are unique.
+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}
@@ -272,7 +283,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"
@@ -280,7 +290,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"
@@ -288,7 +298,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"
@@ -296,7 +306,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"
@@ -304,7 +314,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"
@@ -312,7 +322,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"
@@ -321,7 +331,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" \
@@ -331,7 +341,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" \
@@ -350,7 +360,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 {
@@ -362,7 +372,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" \
@@ -372,7 +382,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" \
@@ -383,7 +393,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" \
@@ -410,7 +420,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\]"
@@ -418,7 +428,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\]"
@@ -426,7 +436,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\]"
@@ -435,7 +445,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" \
@@ -445,7 +455,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 \
index aa5b35e3586d4b7a876ca6c35e6980811ca0e3b1..cd05052a0ee30820173d298a6de29f00601d7608 100644 (file)
@@ -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"
 
index 054c6259d4d6a6a18d4f782401f12d324e368f20..eb8e0a717f8a65f8ace08f661e43fe0eaeebd20f 100644 (file)
@@ -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"
+}
 
index 8daf65b2d0dbe7ef7722ed2dfd46b406a7e61394..061d706c614f144a5cd22e79be7d5b3fbe559bfe 100644 (file)
@@ -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 } {
index 0e9b8d2e02c81f8cbc491b4622400303c28120e7..3d4172e3648ac621d487de261d89ecc64d512a31 100644 (file)
@@ -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 {
This page took 0.044469 seconds and 4 git commands to generate.