public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 1/2] gdb/testsuite: Consume all debug output in gdb.base/osabi.exp
@ 2024-03-04 19:47 Thiago Jung Bauermann
  2024-03-04 19:47 ` [PATCH v3 2/2] gdb/testsuite: Clarify -lbl option in gdb_test_multiple Thiago Jung Bauermann
  0 siblings, 1 reply; 2+ messages in thread
From: Thiago Jung Bauermann @ 2024-03-04 19:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

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(-)

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

base-commit: 1485a3fb63619cced99dd7a4a043cf01a0f423d9

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH v3 2/2] gdb/testsuite: Clarify -lbl option in gdb_test_multiple
  2024-03-04 19:47 [PATCH v3 1/2] gdb/testsuite: Consume all debug output in gdb.base/osabi.exp Thiago Jung Bauermann
@ 2024-03-04 19:47 ` Thiago Jung Bauermann
  0 siblings, 0 replies; 2+ messages in thread
From: Thiago Jung Bauermann @ 2024-03-04 19:47 UTC (permalink / raw)
  To: gdb-patches

I was a bit confused about the -lbl option in gdb_test_multiple, and needed
to read its implementation to determine that it would be useful for my
needs.  Explicitly mention what the option does and why it's useful to
hopefully help other developers.
---
 gdb/testsuite/lib/gdb.exp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index fe4ac7d27190..9a2a64fa9ba1 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -921,7 +921,10 @@ proc fill_in_default_prompt {prompt_regexp with_anchor} {
 #   if one of them matches.  If MESSAGE is empty COMMAND will be used.
 # -prompt PROMPT_REGEXP specifies a regexp matching the expected prompt
 #   after the command output.  If empty, defaults to "$gdb_prompt $".
-# -lbl specifies that line-by-line matching will be used.
+# -lbl specifies that line-by-line matching will be used.  This means
+#   that lines from GDB not matched by any pattern will be consumed from
+#   the output buffer.  This helps avoid buffer overflows and timeouts
+#   when testing verbose commands.
 # EXPECT_ARGUMENTS will be fed to expect in addition to the standard
 #   patterns.  Pattern elements will be evaluated in the caller's
 #   context; action elements will be executed in the caller's context.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-04 19:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-04 19:47 [PATCH v3 1/2] gdb/testsuite: Consume all debug output in gdb.base/osabi.exp Thiago Jung Bauermann
2024-03-04 19:47 ` [PATCH v3 2/2] gdb/testsuite: Clarify -lbl option in gdb_test_multiple Thiago Jung Bauermann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).