From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id iXHpHKqcu2p1EhcAWB0awg (envelope-from ) for ; Tue, 29 Sep 2026 07:10:34 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=vSPLDUaa; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=edpIb+53; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=DEF7pulu; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=imyUJuLy; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 731381E06B; Tue, 29 Sep 2026 07:10:34 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id A3CB41E033 for ; Tue, 29 Sep 2026 07:10:30 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8EE974BB3B9A for ; Tue, 29 Sep 2026 11:10:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EE974BB3B9A Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=vSPLDUaa; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=edpIb+53; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=DEF7pulu; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=imyUJuLy Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by sourceware.org (Postfix) with ESMTPS id C4ACA4BB1C3E for ; Tue, 29 Sep 2026 11:09:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C4ACA4BB1C3E 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 C4ACA4BB1C3E Authentication-Results: sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790680173; cv=none; b=kSwcdjUZOXouuv7xUrarMPMm2gFcb4UFVurWC+OvAV+B7Pz9x4qrb9YwQFBq6MnZVO6rH+kV9WNJNx8Ksmt3y5Pd5DGjuY7s15H9apmmn3Moffs5yMjb0OBVM0ieD9EFcAiXgkvMk6qacLk2UCr+fQ3MDuDvfPjWA1PDXcgcEIA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1790680173; c=relaxed/simple; bh=8p2xld+Ycbz89mEjSt194b4GeGeXO6Na6yoibFkV+7U=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-ID:MIME-Version; b=VmlZlPhT+lfLJV4cYAgZMWNoEtHKeYfjGmHljrfZAf90s3vR88M2lpTa8qO29+vUx+tEWp9IE8ngjQG/PxPrESkJtRa5dcmJrnhr8OPhzYnkUaZ1N2z4LaLrX3Vt9i8IUkoqoBxOZu1q0+yIe+W/ls7D2qeADq99QIkZJCQeBTo= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=vSPLDUaa; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=edpIb+53; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=DEF7pulu; dkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=imyUJuLy DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C4ACA4BB1C3E 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-out2.suse.de (Postfix) with ESMTPS id 81A8C1F399 for ; Tue, 29 Sep 2026 11:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790680168; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6af9FIhME/7JRxILS/MMeYonHJ1KdbkRVvJ3EkRozX8=; b=vSPLDUaadm03OyYumSn9wtQ3NwXSTEB/rFShwns5dx3dEq0gLJk8uhAUtm9PgAtNkWNRYr bIMMsR7LNgEmsy4IjXykPKmE2cexLA24QRntp6+jF4bAyAaMGaVeQYGAGdXQgG6W3S+MY3 hnsz1AVSTGOlSkhGCf1O2Rgvjqgwu/Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790680168; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6af9FIhME/7JRxILS/MMeYonHJ1KdbkRVvJ3EkRozX8=; b=edpIb+53NaiL8arUNJuVAElyWmJCqgDArDt6p6J8sknpccmXrQqx5dnWI0GFOGh0CGSBzu 6z0V+rqNyqxbk+BA== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=DEF7pulu; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=imyUJuLy DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1790680164; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6af9FIhME/7JRxILS/MMeYonHJ1KdbkRVvJ3EkRozX8=; b=DEF7puluRXWbWfQCxyVyCUPkXsCVHDn9raDld7f9ZSLcP2v0fdlaerBpKIm1neLBQ3LjEk a3YuNzR1lg+ih7A4BTk1L5D80/uT1wkoEBkq1svSTo/yLKpL+ZNWBpV7vVCTVFR1uhyMIN g97ebMzBpTGI6VZVH3ulXdPPIHPBxkU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1790680164; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6af9FIhME/7JRxILS/MMeYonHJ1KdbkRVvJ3EkRozX8=; b=imyUJuLygqd417WpnqLWObM6NfKHAMBQE93aZ+QF1mTOc9iKdpWoerKLQrQnovK9/6/rL6 SMnkzIGEj0+pjvAA== 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 7C52113777 for ; Tue, 29 Sep 2026 11:09:22 +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 jiAQNGGcu2oIAgAAD6G6ig:T5 (envelope-from ) for ; Tue, 29 Sep 2026 11:09:22 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH v2 5/6] [gdb/testsuite] Extend gdb.testsuite/lock.exp Date: Tue, 29 Sep 2026 13:09:20 +0200 Message-ID: <20260929110921.1910094-5-tdevries@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260929110921.1910094-1-tdevries@suse.de> References: <20260929110921.1910094-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 81A8C1F399 X-Rspamd-Action: no action X-Spamd-Result: default: False [-2.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; FROM_HAS_DN(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; TO_DN_NONE(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+] 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~public-inbox=simark.ca@sourceware.org The current test-case gdb.testsuite/lock.exp contains only a very basic test: acquiring a lock, followed by releasing it. I wanted to extend the test-case to trigger the case that the lock is taken. I tried out: ... set res [lock_file_acquire $lockfile] gdb_assert {[file exists $lockfile]} "Acquire lock" after 1000 {lock_file_release $res} set res2 [lock_file_acquire $lockfile] gdb_assert {[file exists $lockfile]} "Re-acquire lock" lock_file_release $res2 gdb_assert {![file exists $lockfile]} "Release lock" ... but found out that this hangs. This can be fixed by using the update command [1] to allow the code scheduled by after to execute: ... # Lock in use. Ignore and try again. Propagate all other errors. + update after 10 ... We could just add this, but the update is not necessary for the normal use case of lock_file_{acquire,release}: interprocess locking, so I'd rather not. So instead, I added an interface to lock_file_acquire by which we can handle this: an optional parameter on_retry. Note that the default behavior hasn't changed. If on_retry is non-empty, it's called as a proc, and if the call returns 0, no retry is done, and lock_file_acquire returns an empty list. Add a test in gdb.testsuite/lock.exp to cover this scenario. [1] https://www.tcl-lang.org/man/tcl9.0/TclCmd/update.html --- gdb/testsuite/gdb.testsuite/lock.exp | 40 ++++++++++++++++++++++++++++ gdb/testsuite/lib/gdb-utils.exp | 19 +++++++++---- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/gdb/testsuite/gdb.testsuite/lock.exp b/gdb/testsuite/gdb.testsuite/lock.exp index 67ea09390ac..51859cb80db 100644 --- a/gdb/testsuite/gdb.testsuite/lock.exp +++ b/gdb/testsuite/gdb.testsuite/lock.exp @@ -26,3 +26,43 @@ with_test_prefix "simple" { lock_file_release $res gdb_assert {![file exists $lockfile]} "Release lock" } + +# Scenario 2: +# - acquire 1 +# - acquire 2 fails, waits, and tries again in a loop. +# - release 1, acquire 2 succeeds. +# - release 2 +with_test_prefix "on retry wait" { + set res [lock_file_acquire $lockfile] + gdb_assert {[file exists $lockfile]} "Acquire lock" + + after 1000 {lock_file_release $res} + + proc on_retry {} { + update + after 100 + return 1 + } + set res2 [lock_file_acquire $lockfile on_retry] + gdb_assert {[file exists $lockfile]} "Re-acquire lock" + + lock_file_release $res2 + gdb_assert {![file exists $lockfile]} "Release lock" +} + +# Scenario 3: +# - acquire 1 +# - acquire 2 fails +with_test_prefix "on retry return" { + set res [lock_file_acquire $lockfile] + gdb_assert {[file exists $lockfile]} "Acquire lock" + + proc on_retry {} { + return 0 + } + set res2 [lock_file_acquire $lockfile on_retry] + gdb_assert {$res2 == {}} "Acquire lock again" + + lock_file_release $res + gdb_assert {![file exists $lockfile]} "Release lock" +} diff --git a/gdb/testsuite/lib/gdb-utils.exp b/gdb/testsuite/lib/gdb-utils.exp index 1277558170d..9ccde20634e 100644 --- a/gdb/testsuite/lib/gdb-utils.exp +++ b/gdb/testsuite/lib/gdb-utils.exp @@ -180,10 +180,15 @@ proc version_compare { l1 op l2 } { return 1 } -# Acquire lock file LOCKFILE. Tries forever until the lock file is -# successfully created. - -proc lock_file_acquire {lockfile} { +# Acquire lock file LOCKFILE. +# If the lock file: +# - doesn't exist, create it and return a file handle/file name pair. +# - does exist, and: +# - ON_RETRY is empty, wait a bit and try again. +# - ON_RETRY is non-empty, call it. If it returns 0, don't retry and +# return {} to indicate failure. + +proc lock_file_acquire {lockfile {on_retry ""}} { verbose -log "acquiring lock file: $::subdir/${::gdb_test_file_name}.exp" while {![info exists fh]} { @@ -191,7 +196,11 @@ proc lock_file_acquire {lockfile} { set fh [open $lockfile {WRONLY CREAT EXCL}] } trap "POSIX EEXIST" {} { # Lock in use. Ignore and try again. Propagate all other errors. - after 10 + if {$on_retry == ""} { + after 10 + } elseif {![$on_retry]} { + return {} + } } } -- 2.51.0