diff mbox series

[v3,1/2] gdb/testsuite: Consume all debug output in gdb.base/osabi.exp

Message ID 20240304194706.3384389-1-thiago.bauermann@linaro.org
State New
Headers show
Series [v3,1/2] gdb/testsuite: Consume all debug output in gdb.base/osabi.exp | expand

Commit Message

Thiago Jung Bauermann March 4, 2024, 7:47 p.m. UTC
The Linaro CI runs the GDB testsuite using the read1 tool, which
significantly increases the time it takes DejaGNU to read inferior output.
On top of that sometimes the test machine has higher than normal load,
which causes tests to run even slower.

Because the gdb.base/osabi.exp enables "debug arch" output, which is
somewhat verbose, it sometimes fails when running in the Linaro CI
environment.

Fix this problem by consuming each line of output from GDB, which causes
DejaGNU to reset the timeout after each match (IIUC).

Suggested-by: Simon Marchi <simark@simark.ca>
---

Hello,

This version uses the -lbl option to consume the non-interesting lines
from the output, instead of rolling my own regexp. The difference in
the regexp from -lbl is that it uses a lookahead pattern for the last
\r\n in the line so it doesn't consume it.

This version also fixes a problem pointed out by Simon:

> Ok, one interrogation I had while reading your patch was the fact that
> the two patterns above begin and end with \r\n.  I don't see how that
> can possibly work, since that would consume two \r\n between each line.
> I would expect to see only \r\n at the end of each pattern.

I noticed that the general pattern in the testsuite is to consume the
\r\n at the beginning of the line, so that is what this patch does. I
use a lookahead pattern for the \r\n at the end so that it isn't
consumed.

 gdb/testsuite/gdb.base/osabi.exp | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)


base-commit: 1485a3fb63619cced99dd7a4a043cf01a0f423d9
diff mbox series

Patch

diff --git a/gdb/testsuite/gdb.base/osabi.exp b/gdb/testsuite/gdb.base/osabi.exp
index 9bbfff52bae8..97060a33e06a 100644
--- a/gdb/testsuite/gdb.base/osabi.exp
+++ b/gdb/testsuite/gdb.base/osabi.exp
@@ -23,8 +23,24 @@  require !gdb_debug_enabled
 
 proc test_set_osabi_none { } {
     clean_restart
+    # Because the test enables debug output, which is somewhat verbose, if we
+    # look just for the specific line we want to see may timeout before GDB
+    # prints the next prompt when running in very slow or overloaded machines
+    # (especially when the read1 tool is used).  We need to consume all the
+    # debug output to avoid triggering the timeout, so use line-by-line
+    # matching.
     gdb_test_no_output "set debug arch 1"
-    gdb_test "set osabi none" ".*gdbarch_find_by_info: info.osabi 1 \\(none\\).*"
+    set saw_info_osabi 0
+    set test "set osabi none"
+    gdb_test_multiple $test $test -lbl {
+	-re "\r\ngdbarch_find_by_info: info.osabi 1 \\(none\\)(?=\r\n)" {
+	    set saw_info_osabi 1
+	    exp_continue
+	}
+	-re "$::gdb_prompt \$" {
+	    gdb_assert { $saw_info_osabi } $test
+	}
+    }
 }
 
 test_set_osabi_none