]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Make gdb.base/long-inferior-output.exp fail fast
authorPedro Alves <pedro@palves.net>
Thu, 3 Jun 2021 18:39:18 +0000 (19:39 +0100)
committerPedro Alves <pedro@palves.net>
Mon, 14 Jun 2021 20:31:28 +0000 (21:31 +0100)
A local change I was working on had a bug that made GDB lose inferior
output, which was caught by the gdb.base/long-inferior-output.exp
testcase.  While debugging the problem, I found it useful to have the
testcase fail quickly when it noticed output was missing.

Also, tighten the regexes to make sure that we don't get
spurious/repeated/bogus output between each "this is line number ..."
line.

gdb/testsuite/ChangeLog:
yyyy-mm-dd  Pedro Alves  <pedro@palves.net>

* gdb.base/long-inferior-output.exp: Don't set "more" when we see
an unexpected "this is line number" number.

Change-Id: I53e8499bd8fdbf961431a7f2a94d263da6a9f573

gdb/testsuite/gdb.base/long-inferior-output.exp

index 294786ffff2e4dd27cfbd84629ce4c20f6c32f37..c0e18029600072ee3a635f4400c26eb889fe59bc 100644 (file)
@@ -47,21 +47,46 @@ if { ![runto_main] } then {
 set printing_done_line [gdb_get_line_number "printing done"]
 gdb_test "break $printing_done_line" ".*" "set breakpoint after printing"
 
-send_gdb "continue\n"
+gdb_test_multiple "continue" "" {
+    -re "Continuing\.\r\n" {
+       pass $gdb_test_name
+    }
+}
 
 set expected_lines 3000
 set more 1
 set i 0
 while {$more} {
     set more 0
+
+    # Make sure that we don't get spurious/repeated/bogus output
+    # between each "this is line number ..."  line, with an anchor.
+    # But consume any output that precedes the first line, because
+    # when testing against GDBserver, we'll get:
+    #
+    #   continue
+    #   Continuing.
+    #   PASS: gdb.base/long-inferior-output.exp: continue
+    #   Remote debugging from host ::1, port 40044
+    #   this is line number 0
+    #   ...
+    if {$i != 0} {
+       set anchor "^"
+    } else {
+       set anchor ""
+    }
+
     gdb_expect {
        -i $inferior_spawn_id
-       -ex "this is line number $i" {
+       -re "${anchor}this is line number $i\r\n" {
            incr i
-           if {$i != $expected_lines} {
+           if {$i != $expected_lines} {
                set more 1
            }
        }
+       -re "this is line number \[^\r\n\]*\r\n" {
+           # If we see this, we've lost output.
+       }
     }
 }