Fix "save breakpoints" for "catch" command
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / catch-signal.exp
index 22caf401b3e19150f940cfdcebb45dbba5f7e268..3045b8c09fd3929f3720da8023a93c71d2d183fd 100644 (file)
@@ -117,6 +117,7 @@ foreach {arg desc} {"" "standard signals" \
        "set catchpoint '$arg' for printing"
     gdb_test "info break" "$decimal.*catchpoint.*signal.*$desc.*" \
        "info break for '$arg'"
+    gdb_breakpoint "main"
     gdb_test "save breakpoints [standard_output_file bps.$i]" \
        "Saved to file .*bps.$i.*" \
        "save breakpoints for '$arg'"
@@ -124,7 +125,8 @@ foreach {arg desc} {"" "standard signals" \
     set filename [remote_upload host [standard_output_file bps.$i] \
                      [standard_output_file bps-local.$i]]
     set fd [open $filename]
-    set contents [read -nonewline $fd]
+    set file_data [read $fd]
+    set data [split $file_data "\n"]
     close $fd
 
     if {$arg == ""} {
@@ -132,11 +134,17 @@ foreach {arg desc} {"" "standard signals" \
     } else {
        set pattern "catch signal $arg"
     }
-    if {[string match $pattern $contents]} {
-       pass "results of save breakpoints for '$arg'"
-    } else {
-       fail "results of save breakpoints for '$arg'"
-    }
+    gdb_assert {[expr [llength $data] == 3]} \
+       "Number of lines of save breakpoints for '$arg'"
+    # Check the first line.
+    gdb_assert {[string match $pattern [lindex $data 0]]} \
+       "1st line of save breakpoints for '$arg'"
+    # Check the second line.
+    gdb_assert {[string match "break main" [lindex $data 1]]} \
+        "2nd line of save breakpoints for '$arg'"
+    # Check the trailing newline.
+    gdb_assert {[string match "" [lindex $data 2]]} \
+        "Trailing newline of save breakpoints for '$arg'"
 
     incr i
 }
This page took 0.024484 seconds and 4 git commands to generate.