From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id D738E5A0262 for ; Wed, 5 Apr 2023 03:56:51 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Prnmv4krTz4xDr; Wed, 5 Apr 2023 11:56:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1680659807; bh=o9ZPlYCEiX4fiPfFzdASHZsjJT+/8FnO4iJXWqz0vks=; h=From:To:Cc:Subject:Date:From; b=RDpdWHIUeJcV/6qH4GHcmJEYfRNSXZ/JUYlwZ2T3H8NbNuIStrPUroY5K6l4U3dOo d07p3MoV8OfjfVxihsGmhD+T7SipfS1tRNUB9hM5EoXmPHa0/kyRAcE338EFsmIDBL toA7PumlehurNQh0hpmxJ9+zm6B5hL3mdpS72QZ8= From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH] test: Remove race between commands run in the same context Date: Wed, 5 Apr 2023 11:56:42 +1000 Message-Id: <20230405015642.406952-1-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: RMOKFCHQZMHF47EWML7MWNUPZXXSQFYI X-Message-ID-Hash: RMOKFCHQZMHF47EWML7MWNUPZXXSQFYI X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: context_run() has a race condition if two commands are run in close proximity (generally involving at least one in the background). Because we always use the same name for the temporary fifo files, if another command is issued while the fifos for the first still exist, mkfifo will fail, typically causing the entire test script to jam. Create unique names for the temporary fifos to avoid this problem. Signed-off-by: David Gibson --- test/lib/context | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lib/context b/test/lib/context index d9d8260..09cad89 100644 --- a/test/lib/context +++ b/test/lib/context @@ -93,8 +93,8 @@ context_run() { __name="$1" __log="${LOGDIR}/context_${__name}.log" __enter="${STATESETUP}/context_${__name}.enter" - __stdout="${STATESETUP}/context_${__name}.stdout" - __stderr="${STATESETUP}/context_${__name}.stderr" + __stdout="$(mktemp -u "${STATESETUP}/context_${__name}.stdout.XXXXXXXX")" + __stderr="$(mktemp -u "${STATESETUP}/context_${__name}.stderr.XXXXXXXX")" shift echo "$*" >> "${__log}" mkfifo "${__stdout}" "${__stderr}" -- 2.39.2