From patchwork Fri May 24 14:56:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 90817 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C5093870882 for ; Fri, 24 May 2024 14:57:28 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2a07:de40:b251:101:10:150:64:1]) by sourceware.org (Postfix) with ESMTPS id 2F49B3858C48 for ; Fri, 24 May 2024 14:57:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F49B3858C48 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2F49B3858C48 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716562624; cv=none; b=oQYrTQsEN88zWhwC2YjGDt3uh0i/SFCIk2DLCmt1dvkdsWxYam5RLNQ4kC4bZWnzro5uSdKXj6S9t8jDqhbEpmKAUDcAbiQSK3GFScTIUzEgUTgcnZqHxsHy7IF1fBd0/EqwllCPLOUE4pXf9TVuYihMpeyn/zf9Rz6xIjpVK9w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716562624; c=relaxed/simple; bh=wakfVZGPzYJb5LP+ATA+hu//JOuPQDo5oCRI+E7t188=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=s1ajjHAaOv5WDWU22I4ZPKvnDJ6MbR+DF67prqn0ag2zIw9UAbOIcnSjOZhF0zKYhdB18lUDPxXqht//BbwtKGXGkIWvACMQF5r5UWtWbSfadeUVeG/XXNYt00srIRZXjxLhUEKdDLn++jx0bToSR3TyPX+HG3y3f7WK6aMrIpo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 0AEF733B9C for ; Fri, 24 May 2024 14:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716562620; 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=tShvJatfLA0S+sXgTsoJqNlfLZiBGkPZJD0yqGgNibE=; b=HS3qTaHaJORufznylsbauH0BDVgmv5frfE9ykI6URy0h3axE90rrVSakN83ZuTEK/aVUzo uZ4470gnL7tCwoidG79Fpk27giPyLgqN80V+6mQEtLCLSz2pDIfdGCEJwWQ3qrGfHQdXVx S9sO5+rILC0UAniKMdv6PD8OnUR/JK0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716562620; 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=tShvJatfLA0S+sXgTsoJqNlfLZiBGkPZJD0yqGgNibE=; b=+TtpfktevORryZRgxnQDCCSAPfCCDm6wa5BlhO7EN4TLeRiwyYMy5EHO0hOC+OKitk8QFR 6Ox34P2Aqs6ed9DA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=HS3qTaHa; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=+Ttpfkte DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1716562620; 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=tShvJatfLA0S+sXgTsoJqNlfLZiBGkPZJD0yqGgNibE=; b=HS3qTaHaJORufznylsbauH0BDVgmv5frfE9ykI6URy0h3axE90rrVSakN83ZuTEK/aVUzo uZ4470gnL7tCwoidG79Fpk27giPyLgqN80V+6mQEtLCLSz2pDIfdGCEJwWQ3qrGfHQdXVx S9sO5+rILC0UAniKMdv6PD8OnUR/JK0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1716562620; 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=tShvJatfLA0S+sXgTsoJqNlfLZiBGkPZJD0yqGgNibE=; b=+TtpfktevORryZRgxnQDCCSAPfCCDm6wa5BlhO7EN4TLeRiwyYMy5EHO0hOC+OKitk8QFR 6Ox34P2Aqs6ed9DA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id E546E13A6B for ; Fri, 24 May 2024 14:56:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id ESRaNruqUGa5CgAAD6G6ig (envelope-from ) for ; Fri, 24 May 2024 14:56:59 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH] [gdb/testsuite] Fix timeout in gdb.base/bg-execution-repeat.exp Date: Fri, 24 May 2024 16:56:49 +0200 Message-Id: <20240524145649.28355-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Score: -5.01 X-Rspamd-Action: no action X-Rspamd-Queue-Id: 0AEF733B9C X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; FROM_EQ_ENVFROM(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_DN_NONE(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,sourceware.org:url]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Status: No, score=-12.3 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org I ran into the following test failure with test-case gdb.base/bg-execution-repeat.exp: ... (gdb) PASS: gdb.base/bg-execution-repeat.exp: c&: repeat bg command ^M Breakpoint 2, foo () at bg-execution-repeat.c:23^M 23 return 0; /* set break here */^M print 1^M $1 = 1^M (gdb) PASS: gdb.base/bg-execution-repeat.exp: c&: input still accepted FAIL: gdb.base/bg-execution-repeat.exp: c&: breakpoint hit 2 (timeout) ... The failure can be easily reproduced by adding a sleep 5 here: ... + sleep 5 gdb_test "print 1" " = 1" "input still accepted" ... There's a race in the test-case, between: - the command handled in the foreground: the "print 1" command, and - the command handled in the background: the continue command. The current way of dealing with this is by putting the inferior to sleep for 5 seconds: ... foo (); sleep (5); foo (); ... with the aim that the "print 1" command will win the race. This method is both slow and unreliable. Fix this by making the inferior wait just long enough for the "print 1" command to win the race. This reduces running time from ~11s to ~1s. Tested on aarch64-linux. PR testsuite/31794 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31794 --- gdb/testsuite/gdb.base/bg-execution-repeat.c | 16 +++++++++++++++- gdb/testsuite/gdb.base/bg-execution-repeat.exp | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) base-commit: 2597ca3417d9adb0adda135c90ab86c4ea675139 diff --git a/gdb/testsuite/gdb.base/bg-execution-repeat.c b/gdb/testsuite/gdb.base/bg-execution-repeat.c index 2caa7d442f6..c92d34ed9f9 100644 --- a/gdb/testsuite/gdb.base/bg-execution-repeat.c +++ b/gdb/testsuite/gdb.base/bg-execution-repeat.c @@ -23,11 +23,25 @@ foo (void) return 0; /* set break here */ } +static volatile int do_wait; + +static void +wait (void) +{ + while (do_wait) + usleep (10 * 1000); +} + int main (void) { foo (); - sleep (5); + + do_wait = 1; + wait (); + /* do_wait set to 0 externally. */ + foo (); + return 0; } diff --git a/gdb/testsuite/gdb.base/bg-execution-repeat.exp b/gdb/testsuite/gdb.base/bg-execution-repeat.exp index a4cc7daa702..3497ef2d47d 100644 --- a/gdb/testsuite/gdb.base/bg-execution-repeat.exp +++ b/gdb/testsuite/gdb.base/bg-execution-repeat.exp @@ -68,6 +68,9 @@ proc test {continue_cmd} { # stopped. gdb_test "print 1" " = 1" "input still accepted" + # Allow the breakpoint to trigger. + gdb_test -no-prompt-anchor "set var do_wait=0" + # Make sure we see a stop after the print, and not before. Don't # expect a prompt, as we had resumed the inferior in the background. set test "breakpoint hit 2"