aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2022-10-09 21:21:53 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2022-10-10 20:45:56 -0400
commitf6c874187a5a8b6f7108fff3b668395de45f9904 (patch)
treeeba0324cacebbab2f9f0c3f676a514f0bebba556 /gdb/testsuite/gdb.base
parent4a5d6345a0bb18f8688540025036647509f56f81 (diff)
downloadgdb-f6c874187a5a8b6f7108fff3b668395de45f9904.zip
gdb-f6c874187a5a8b6f7108fff3b668395de45f9904.tar.gz
gdb-f6c874187a5a8b6f7108fff3b668395de45f9904.tar.bz2
gdb/testsuite: fix race in gdb.base/async-shell.exp
I see some random failures in this test: FAIL: gdb.base/async-shell.exp: run & (timeout) It can be reliably reproduced on a recent enough GNU/Linux with this change: diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 44cc28b30051..2a3c8253ba5a 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1301,6 +1301,7 @@ proc gdb_test_multiple { command message args } { } set gdb_test_name "$message" + sleep 2 set result 0 set code [catch {gdb_expect $code} string] "recent enough" means a system where libpthread.so was merged with libc.so, so at least glibc 2.34. The problem is that the `run &` command prints some things after the prompt: (gdb) [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1". If expect is quick enough, it will consume only up to the prompt. But if it is slow enough, it will consume those messages at the same time as the prompt, in which case the gdb_test used for "run &" won't match. By default, the prompt used by gdb_test uses a `$` to anchor the match at the end of the buffer. If there's anything following the prompt, it won't match. The diff above adds a delay between sending the command and consuming the output, giving GDB more time to output the messages, giving a good chance that expect consumes them at the same time as the prompt. This is normally handled by using gdb_test_multiple and specifying a pattern that ends with "$gdb_prompt", but not a trailing $. I think this is common enough that it deserves its own gdb_test option. Therefore, add the -no-anchor-prompt option to gdb_test, and gdb_test_no_output for completeness. Use it in gdb.base/async-shell.exp. Change-Id: I9051d8800d1c10a2e95db1a575991f7723492f1b Approved-By: Tom de Vries <tdevries@suse.de>
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/async-shell.exp2
1 files changed, 1 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.base/async-shell.exp b/gdb/testsuite/gdb.base/async-shell.exp
index e2d7182..2c09863 100644
--- a/gdb/testsuite/gdb.base/async-shell.exp
+++ b/gdb/testsuite/gdb.base/async-shell.exp
@@ -34,7 +34,7 @@ save_vars { GDBFLAGS } {
set gdbindex_warning_re "warning: Skipping \[^\r\n\]+ \\.gdb_index section \[^\r\n\]*\r\nDo \"set use-deprecated-index-sections on\" before the file is read\r\nto use the section anyway\\."
-gdb_test "run &" "Starting program: \[^\r\n\]*(\r\n$gdbindex_warning_re)?"
+gdb_test -no-prompt-anchor "run &" "Starting program: \[^\r\n\]*(\r\n$gdbindex_warning_re)?"
# `sleep 5' here would workaround the bug, do not sleep here.
# "shell" could eat waitpid event from the asynchronous inferior process.