From patchwork Mon Apr 15 15:56:26 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: 88506 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 16EED3849AFC for ; Mon, 15 Apr 2024 15:58:47 +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 [195.135.223.130]) by sourceware.org (Postfix) with ESMTPS id 09C2A3858282 for ; Mon, 15 Apr 2024 15:56:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 09C2A3858282 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 09C2A3858282 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713196578; cv=none; b=B/Tf2mZZ+krD6RdnFxvz+YguzyZwIZl3dg9dXuGND8pqiOb1Ole0Bhcng3a2ygLHo8qWP83EMO1e472+TL2oqGVh31y3rI4WlcNS5HUBcTdp+sSSN8Xn0Zw/mKizN2ErWjD7Y9XV8xyB1pZgfL59cRx/c1SM9xgqrynFUY65G4Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713196578; c=relaxed/simple; bh=GU5HWyqS2LbFeu1txd8VArYWqZUGaLZq/k7fqK1X8KE=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:From: To:Subject:Date:Message-Id:MIME-Version; b=SC/9DVr7vq+EN0K4elCbo0NqMK+R+ZdR1ydRE8Z5zpLEub51gMBHYo12h7TJIXMC+//Yi/O6FxR5G/bGtLg5JOmVlrfEBl19bHTh9BXFXyeT7eKMYniTWfNhYR7IZWjrue2EwnxdcZm4tARQQ2Kt9xJxDHqaB7zeuC1Euq6gyis= 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 E8DFD372E8 for ; Mon, 15 Apr 2024 15:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713196575; 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=Y3wu2zwBD/fbralhFzY60lAcV97nvZNsbWt4JTxnUDU=; b=YQOSUChMcXJNXd7H5n7k2PrU/Q/emP8QBeNxl7o1LnYFlnFpua4pRyZpea99ulzhSMlJgZ T6BxIKz/6gzZ+OubxD1L5PbBYonRc2RHO+VYaP1G910K/LnM+5NfVhlQJbKcAXpNBuw8cM hkjbw3xrv5EpoZXulFifbjYLEHhnBrw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713196575; 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=Y3wu2zwBD/fbralhFzY60lAcV97nvZNsbWt4JTxnUDU=; b=Fh900LZO8wMo/n3gP4e74OERP9Qk06jEecfishu5k4GPZFFx7/Zt0HRJb50NV3rpkm+4ul D90w7KcMoOS5rjBA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=mpGoe7mz; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=lZ50e1Fx DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1713196574; 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=Y3wu2zwBD/fbralhFzY60lAcV97nvZNsbWt4JTxnUDU=; b=mpGoe7mzvOxqJy6Cuvgg5nGU9hSLftVfZpAYCyDhYShOyP+XDJHKKpA/Evw4RQ0nU8WDYE Um36QabIgANropZEejj370Uh9wfDNA1hq0rV4It0/usB3gBueO79q0ZjewO6nkI5MBVUDX CkaHEfjPF70MWjt/bTvu3Kw2Z1OCuQo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1713196574; 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=Y3wu2zwBD/fbralhFzY60lAcV97nvZNsbWt4JTxnUDU=; b=lZ50e1Fxuo9Jg4iwChNv1UDAflxv00bbuojQ1e+4u3KaCU6fcm2OEvYi8nGQi+S09VaYNK WBNsgt1PclB7tsCg== 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 D232C1386E for ; Mon, 15 Apr 2024 15:56:14 +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 yAsTMh5OHWaVRgAAD6G6ig (envelope-from ) for ; Mon, 15 Apr 2024 15:56:14 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Subject: [PATCH 6/7] [gdb/testsuite] Use unique portnum in parallel testing Date: Mon, 15 Apr 2024 17:56:26 +0200 Message-Id: <20240415155627.22108-6-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240415155627.22108-1-tdevries@suse.de> References: <20240415155627.22108-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Level: X-Spamd-Result: default: False [-4.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; DWL_DNSWL_LOW(-1.00)[suse.de:dkim]; NEURAL_HAM_LONG(-1.00)[-1.000]; 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)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_NONE(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim, imap1.dmz-prg2.suse.org:helo, imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Action: no action X-Rspamd-Queue-Id: E8DFD372E8 X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: -4.01 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 When instrumenting get_portnum using: ... puts "PORTNUM: $res" ... and running: ... $ cd build/gdb $ make check-parallel -j2 TESTS=gdb.server/*.exp ... we run into: ... Running gdb.server/abspath.exp ... PORTNUM: 2345 ... and: ... Running gdb.server/bkpt-other-inferior.exp ... PORTNUM: 2345 ... This is because the test-cases are run in independent runtest invocations. Fix this by handling the parallel case in get_portnum using: - a file $objdir/cache/portnum to keep the portnum variable, and - a file $objdir/cache/portnum.lock to serialize access to it. Tested on aarch64-linux. --- gdb/testsuite/lib/gdbserver-support.exp | 47 ++++++++++++++++++++----- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/gdb/testsuite/lib/gdbserver-support.exp b/gdb/testsuite/lib/gdbserver-support.exp index 0f97ce9c0fd..41ad5e6cbfb 100644 --- a/gdb/testsuite/lib/gdbserver-support.exp +++ b/gdb/testsuite/lib/gdbserver-support.exp @@ -141,18 +141,47 @@ proc get_portnum {} { # starting at $initial_portnum, to avoid conflicts with hung ports. set initial_portnum 2345 - # Currently available port number. - gdb_persistent_global portnum + if { ![info exists ::GDB_PARALLEL] } { + # Sequential case. - # Initialize, if necessary. - if { ![info exists portnum] } { - set portnum $initial_portnum + # Currently available port number. + gdb_persistent_global portnum + + # Initialize, if necessary. + if { ![info exists portnum] } { + set portnum $initial_portnum + } + + # Return currently available port number, and update it. + set res $portnum + incr portnum + return $res + } + + # Parallel case. + with_lock portnum.lock { + # Keep portnum file alongside the lock that guards it. + set portnum_file [lock_dir]/portnum + + if { [file exists $portnum_file] } { + set fd [open $portnum_file r] + set portnum [read $fd] + close $fd + + set portnum [string trim $portnum] + } else { + # Initialize. + set portnum $initial_portnum + } + + set next_portnum [expr $portnum + 1] + + set fd [open $portnum_file w] + puts $fd $next_portnum + close $fd } - # Return currently available port number, and update it. - set res $portnum - incr portnum - return $res + return $portnum } # Locate the gdbserver binary. Returns "" if gdbserver could not be found.