public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Tom de Vries <vries@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Fix race in gdb.threads/detach-step-over.exp Date: Fri, 16 Dec 2022 14:28:30 +0000 (GMT) [thread overview] Message-ID: <20221216142831.087AD3835891@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=832a980e1725a4a7fa527f2dcd92a64d7e68ab0f commit 832a980e1725a4a7fa527f2dcd92a64d7e68ab0f Author: Tom de Vries <tdevries@suse.de> Date: Fri Dec 16 15:28:27 2022 +0100 [gdb/testsuite] Fix race in gdb.threads/detach-step-over.exp Once in a while I run into: ... FAIL: gdb.threads/detach-step-over.exp: \ breakpoint-condition-evaluation=host: target-non-stop=off: non-stop=off: \ displaced=off: iter 1: all threads running ... In can easily reproduce this by doing: ... # Wait a bit, to give time for the threads to hit the # breakpoint. - sleep 1 return true ... Fix this by counting the running threads in a loop, effectively allowing 10 seconds (instead of 1) for the threads to start running, but only sleeping if needed. Reduces total execution time from 1m27s to 56s. Tested on x86_64-linux. Diff: --- gdb/testsuite/gdb.threads/detach-step-over.exp | 34 ++++++++++++++++++++------ 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp b/gdb/testsuite/gdb.threads/detach-step-over.exp index 38d796620cb..6c3a74fd16d 100644 --- a/gdb/testsuite/gdb.threads/detach-step-over.exp +++ b/gdb/testsuite/gdb.threads/detach-step-over.exp @@ -187,10 +187,6 @@ proc prepare_test_iter {testpid non_stop attempt attempts tid_re} { } } - # Wait a bit, to give time for the threads to hit the - # breakpoint. - sleep 1 - return true } @@ -233,7 +229,8 @@ proc_with_prefix test_detach_command {condition_eval target_non_stop non_stop di set running_count 0 set interrupted 0 - gdb_test_multiple "info threads" "all threads running" { + set running_expected [expr ($::n_threads + 1) * 2] + gdb_test_multiple "info threads" "threads running" { -re "\\(running\\)" { incr running_count exp_continue @@ -254,10 +251,31 @@ proc_with_prefix test_detach_command {condition_eval target_non_stop non_stop di } } } - -re "$::gdb_prompt $" { - gdb_assert {$running_count == ($::n_threads + 1) * 2} \ - $gdb_test_name + -re "$::gdb_prompt " { + } + } + + if { !$interrupted } { + set iterations 0 + set max_iterations 10 + while { $running_count < $running_expected } { + sleep 1 + set running_count 0 + gdb_test_multiple "info threads" "threads running" { + -re "\\(running\\)" { + incr running_count + exp_continue + } + -re "$::gdb_prompt " { + } + } + incr iterations + if { $iterations == $max_iterations } { + break + } } + gdb_assert {$running_count == $running_expected} \ + "all threads running" } gdb_test "detach" "Detaching from.*"
reply other threads:[~2022-12-16 14:28 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=20221216142831.087AD3835891@sourceware.org \ --to=vries@sourceware.org \ --cc=gdb-cvs@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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).