gdb: fix duplicate test names in gdb.base/break.exp
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / break.exp
index ef0a5d2faca4687a345d010bc8f12c78ef2ebfe9..d2121c3d635ec326ae2593b4f181ba73ba51b32b 100644 (file)
@@ -1,4 +1,4 @@
-#   Copyright 1988-2016 Free Software Foundation, Inc.
+#   Copyright 1988-2020 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
 
 # This file was written by Rob Savoye. (rob@cygnus.com)
 
-if { [prepare_for_testing break.exp "break" {break.c break1.c} {debug nowarnings}] } {
+if { [prepare_for_testing "failed to prepare" "break" {break.c break1.c} {debug nowarnings}] } {
     return -1
 }
 set srcfile break.c
@@ -583,22 +583,25 @@ gdb_test "clear marker3" {Deleted breakpoints [0-9]+ [0-9]+.*}
 
 # Verify that a breakpoint can be set via a convenience variable.
 #
-gdb_test_no_output "set \$foo=$bp_location11" \
-    "set convenience variable \$foo to bp_location11"
 
-gdb_test "break \$foo" \
-    "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*" \
-    "set breakpoint via convenience variable"
+with_test_prefix "set line breakpoint via convenience variable" {
+    gdb_test_no_output "set \$foo=$bp_location11" \
+       "set convenience variable \$foo to bp_location11"
 
-# Verify that GDB responds gracefully to an attempt to set a
-# breakpoint via a convenience variable whose type is not integer.
-#
-gdb_test_no_output "set \$foo=81.5" \
-    "set convenience variable \$foo to 81.5"
+    gdb_test "break \$foo" \
+       "Breakpoint (\[0-9\]*) at .*, line $bp_location11.*"
+
+    # Verify that GDB responds gracefully to an attempt to set a
+    # breakpoint via a convenience variable whose type is not integer.
+    #
 
-gdb_test "break \$foo" \
-    "Convenience variables used in line specs must have integer values.*" \
-    "set breakpoint via non-integer convenience variable disallowed"
+    gdb_test_no_output "set \$foo=81.5" \
+       "set convenience variable \$foo to 81.5"
+
+    gdb_test "break \$foo" \
+       "Convenience variables used in line specs must have integer values.*" \
+       "non-integer convenience variable disallowed"
+}
 
 # Verify that we can set and trigger a breakpoint in a user-called function.
 #
@@ -747,7 +750,7 @@ test_next_with_recursion
 # build a new file with optimization enabled so that we can try breakpoints
 # on targets with optimized prologues
 
-if { [prepare_for_testing break.exp "breako2" {break.c break1.c} {debug nowarnings optimize=-O2}] } {
+if { [prepare_for_testing "failed to prepare" "breako2" {break.c break1.c} {debug nowarnings optimize=-O2}] } {
     return -1
 }
 
@@ -845,12 +848,39 @@ gdb_test_multiple "" $test {
 #
 # Test break via convenience variable with file name
 #
-set line [gdb_get_line_number "set breakpoint 1 here"]
-gdb_test_no_output "set \$l = $line"
-gdb_breakpoint ${srcfile}:\$l
 
-gdb_test_no_output "set \$foo=81.5" \
-    "set convenience variable \$foo to 81.5"
-gdb_test "break $srcfile:\$foo" \
-    "Convenience variables used in line specs must have integer values.*" \
-    "set breakpoint via non-integer convenience variable disallowed"
+with_test_prefix "set line:file breakpoint via convenience variable" {
+    set line [gdb_get_line_number "set breakpoint 1 here"]
+    gdb_test_no_output "set \$l = $line"
+
+    set line_actual "-1"
+    set test "break ${srcfile}:\$l"
+    gdb_test_multiple "$test" $test {
+       -re "Breakpoint $decimal at $hex: file .*break\\.c, line ($decimal)\\.\r\n$gdb_prompt $" {
+           # Save the actual line number on which the breakpoint was
+           # actually set. On some systems (Eg: Ubuntu 16.04 with GCC
+           # version 5.4.0), that line gets completely inlined, including
+           # the call to printf, and so we end up inserting the breakpoint
+           # on one of the following lines instead.
+           set line_actual $expect_out(1,string)
+           pass $test
+       }
+    }
+
+    gdb_test_no_output "set \$foo=81.5" \
+       "set convenience variable \$foo to 81.5"
+    gdb_test "break $srcfile:\$foo" \
+       "Convenience variables used in line specs must have integer values.*" \
+       "non-integer convenience variable disallowed"
+}
+
+#
+# Test that commands can be cleared without error.
+#
+
+gdb_test "commands\nprint 232323\nend" ">end" "set some breakpoint commands"
+gdb_test "commands\nend" ">end" "clear breakpoint commands"
+# We verify that the commands were cleared by ensuring that the last
+# breakpoint's location ends the output -- if there were commands,
+# they would have been printed after the location.
+gdb_test "info break" "$srcfile:$line_actual" "verify that they were cleared"
This page took 0.027147 seconds and 4 git commands to generate.