Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PUSHED] gdb/testsuite: don't spin forever in gdb.tui/flush-after-run.exp
Date: Sun, 22 Nov 2026 11:08:50 +0000	[thread overview]
Message-ID: <7f8c8d38cc60fe15e1cc615aab7babd4a0ec7106.1795345716.git.aburgess@redhat.com> (raw)

Recently I noticed that this test would hang forever:

  make check-gdb \
    TESTS="gdb.tui/flush-after-run.exp" \
    RUNTESTFLAGS="--target_board=native-extended-gdbserver"

The test starts an inferior and waits for the inferior to create a file
in the file system to indicate that it is running.  However, if the
inferior never creates the file then the test will spin forever waiting
for the file to appear.

An unrelated recent change in GDB (the gdb::span work) means that GDB is
currently crashing when using remote targets.  A fix for this issue is
already on the mailing list:

  https://inbox.sourceware.org/gdb-patches/20261122054124.3738131-1-tom@tromey.com

But I think it is still worth fixing the test so that if something like
this happens in the future the test will not hang forever.

Do this by placing a limit on the number of times the test will spin
waiting for the inferior to create the file.  As the spin loop includes
a 'sleep 1', this limit creates a maximum time that the test can hang
for before giving up.

There should be no change in what is actually being tested after this
commit.
---
 gdb/testsuite/gdb.tui/flush-after-run.exp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.tui/flush-after-run.exp b/gdb/testsuite/gdb.tui/flush-after-run.exp
index db20b8cee80..df8161a4f3b 100644
--- a/gdb/testsuite/gdb.tui/flush-after-run.exp
+++ b/gdb/testsuite/gdb.tui/flush-after-run.exp
@@ -41,11 +41,20 @@ file delete $marker_file
 # Run the inferior, which will create MARKER_FILE.
 send_gdb "run \"$marker_file\"\n"
 
-# Spin until MARKER_FILE appears.
-while { ! [file exists $marker_file] } {
+# Spin until MARKER_FILE appears.  Wait up to ::TIMEOUT seconds.  If the
+# inferior fails to start (gdbserver crash, inferior startup issues) then we
+# don't want this test to spin forever.
+for { set i 0 } { ![file exists $marker_file] && $i < $::timeout } { incr i } {
     sleep 1
 }
 
+# In case the loop above bailed out due to timeout, spot that the marker file
+# hasn't appeared yet and abandon this test.
+if { ![file exists $marker_file] } {
+    unresolved "marker file failed to appear"
+    return
+}
+
 # We now know that the inferior has started, and that the 'Starting
 # program: ' string should have been printed to the terminal.  Don't
 # use Term::wait_for here as there will be no prompt after the

base-commit: ab4dbb9838795fe09a82d41d86b47de29fbf80f3
-- 
2.56.1



                 reply	other threads:[~2026-11-22 11:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7f8c8d38cc60fe15e1cc615aab7babd4a0ec7106.1795345716.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox