From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id E0774383C7FF for ; Tue, 13 Dec 2022 14:02:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E0774383C7FF Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 243381FDD2 for ; Tue, 13 Dec 2022 14:02:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1670940158; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=swaF2fuXKyf1YojrZhb1kwV+JBlJ5wkTsxw2xR/u2NU=; b=lJE3u/eQSkg4ZdgAWbVN0/7TKzU4QrLAEn4upcWQh5sKOLzFLDLjpTWQPzT5Tl40Yad1Cc Y7g5t7JsCCri4nV04zZ8zhSkvsfic1/V1Qcb9QDcLwPMtM0zcNJakmeVueci+H7EjPtfmp 7ppTbsLwdvtAuK1lyyzX4FphSqEy/Hk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1670940158; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=swaF2fuXKyf1YojrZhb1kwV+JBlJ5wkTsxw2xR/u2NU=; b=KosOqHJezWBGdA11d25xEWza2nFYlZs+opdingHP49Gr6nP4JRACdcSScvlDvfr7v3fdI0 a8OqAblgh+4Rb/Ag== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 11413138F9 for ; Tue, 13 Dec 2022 14:02:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ybonA/6FmGMtYgAAMHmgww (envelope-from ) for ; Tue, 13 Dec 2022 14:02:38 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/testsuite] Fix race in gdb.threads/detach-step-over.exp Date: Tue, 13 Dec 2022 15:02:37 +0100 Message-Id: <20221213140237.32325-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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. --- .../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..225d3ab5313 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 == 0 } { + 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.*" base-commit: fa59ab98685e4b5431d2be423f449df5069a454e -- 2.35.3