Fix more cases of improper test names
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / break-always.exp
index 68b02c999556c55127cd9f7d5f2a1bfef9a48c7e..068e3312035749d904f9aac4191b7f9a2f371f77 100644 (file)
@@ -1,4 +1,4 @@
-#   Copyright 2008-2012 Free Software Foundation, Inc.
+#   Copyright 2008-2016 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
@@ -17,7 +17,7 @@
 # Also verifies that breakpoint enabling/disabling works properly
 # with duplicated breakpoints.
 
-if { [prepare_for_testing break-always.exp break-always break-always.c] } {
+if { [prepare_for_testing "failed to prepare" break-always break-always.c] } {
     return -1
 }
 
@@ -69,22 +69,29 @@ gdb_test "p /x \$shadow = *(char *) $bp_address" \
 # and still leave the breakpoint insn planted.  Try twice with
 # different values, in case we happen to be writting exactly what was
 # there already.
-gdb_test "p /x *(char *) $bp_address = 0" \
-    " = 0x0" \
-    "write 0 to breakpoint's address"
-gdb_test "p /x *(char *) $bp_address" \
-    " = 0x0" \
-    "read back 0 from the breakpoint's address"
-
-gdb_test "p /x *(char *) $bp_address = 1" \
-    " = 0x1" \
-    "write 1 to breakpoint's address"
-gdb_test "p /x *(char *) $bp_address" \
-    " = 0x1" \
-    "read back 1 from the breakpoint's address"
+foreach test_value {0 1} {
+    set write_test "write $test_value to breakpoint's address"
+
+    gdb_test_multiple "p /x *(char *) $bp_address = $test_value" $write_test {
+       -re "Cannot access memory at address $hex.*$gdb_prompt $" {
+
+           # Some targets do not allow manually writing a breakpoint to a
+           # certain memory address, like QEMU.  In that case, just bail out.
+           unsupported "cannot write to address $bp_address"
+           return -1
+       }
+       -re " = .*$gdb_prompt $" {
+           pass $write_test
+       }
+    }
+
+    set read_test "read back $test_value from the breakpoint's address"
+    gdb_test "p /x *(char *) $bp_address" " = 0x$test_value" $read_test
+}
 
 # Restore the original contents.
-gdb_test "p /x *(char *) $bp_address = \$shadow" ""
+gdb_test "p /x *(char *) $bp_address = \$shadow" "" \
+    "restore the original contents"
 
 # Run to breakpoint.
 gdb_continue_to_breakpoint "bar" ".*break-always.c:$bar_location.*"
This page took 0.026301 seconds and 4 git commands to generate.