From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 61FF45A027B for ; Thu, 6 Apr 2023 04:50:15 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4PsQvz6g2rz4xFn; Thu, 6 Apr 2023 12:50:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1680749407; bh=DtNp+sor49UFb137dj+CW/OkuPtQh8miW4JfWffi+EI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VoL/GkvXfuwPJWA3i92f7klYCXOtbqaap2NV6OzSx+ihcSjxLZbAxp6objomUdIrm ThGQAchmwrl3J6bGQZFl0uj4QZduAEnqzd650+cpmeC3iiXMKKTrfXB8AbWWaHn3bT 6jl+vrqbxIgkBBeRx6ponEiePMt+EJkhnglItVO4= Date: Thu, 6 Apr 2023 11:15:31 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] test: Remove race between commands run in the same context Message-ID: References: <20230405015642.406952-1-david@gibson.dropbear.id.au> <20230405142324.75f0a416@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="STiaXdK3GZaER4V1" Content-Disposition: inline In-Reply-To: <20230405142324.75f0a416@elisabeth> Message-ID-Hash: VAT4GQDAM5WAEE7KP5ME5KBE4UXRPGAA X-Message-ID-Hash: VAT4GQDAM5WAEE7KP5ME5KBE4UXRPGAA 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: passt-dev@passt.top 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: --STiaXdK3GZaER4V1 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Apr 05, 2023 at 02:23:24PM +0200, Stefano Brivio wrote: > On Wed, 5 Apr 2023 11:56:42 +1000 > David Gibson wrote: >=20 > > context_run() has a race condition if two commands are run in close > > proximity (generally involving at least one in the background). Becaus= e we > > always use the same name for the temporary fifo files, if another comma= nd > > is issued while the fifos for the first still exist, mkfifo will fail, > > typically causing the entire test script to jam. > >=20 > > Create unique names for the temporary fifos to avoid this problem. > >=20 > > Signed-off-by: David Gibson > > --- > > test/lib/context | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > >=20 > > 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=3D"$1" > > __log=3D"${LOGDIR}/context_${__name}.log" > > __enter=3D"${STATESETUP}/context_${__name}.enter" > > - __stdout=3D"${STATESETUP}/context_${__name}.stdout" > > - __stderr=3D"${STATESETUP}/context_${__name}.stderr" > > + __stdout=3D"$(mktemp -u "${STATESETUP}/context_${__name}.stdout.XXXXX= XXX")" > > + __stderr=3D"$(mktemp -u "${STATESETUP}/context_${__name}.stderr.XXXXX= XXX")" >=20 > In practice, this is never going to be an issue, but strictly > speaking, -u doesn't guarantee the name is unique. Yeah, I know. > On the other hand we don't need a loop (or further directories) with > this, so the simplicity of it might be preferable over correctness... Right, that's the conclusion I came to as well. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --STiaXdK3GZaER4V1 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmQuHSsACgkQzQJF27ox 2Gfv2hAAg9CeRJoPpT5xr5sBFDwucuMiSM64xLLpTak4gXxBCIfs91tIfCttqipm eQKEyfzD0bv0e5bRAMPeThV23rxTXLVL17ar7jSZwXEsFyovFVKvhl8pm27fWJeg oFy+t2459YbyxPQpRHorhh1RRcgM9S86bwB4Pzj31AYKsba5Q0inLT6hO6zrJO3B VwW6iCQ65+/4A5GcK8Nq7S0EJXQ07WORWcNvL14tY1vtyGjDOi7SVm6q8zSiUlfH S7IPWKVjMy5eGecletArbbyk4UVNVavMteszrBvtK0cJ8y1+6w0Y2jI+N45iLrCu G9rN2eMPN7rop7GGhp/F0+5zHJG/GhPC7xoySfoMH0sNwjuWKztWmJSV8nLsIU6M lpcRJW48TKVJm1o30PC4BvIonIEt3R/DB5lEyGaSdphuqsuSWWJfA2AXswfVWXy0 p+iDw8IpiDM8KzV83QjFWlk4CBeFkQLctL6UApIdQ8H+YOD7vQ3Acw1AXFU4CBfy FvLW3fExukHUjBFnOAE0hry7zT6L5y7O4+AdVj0R/zanM4Drkj3FOv9UFy4ZdEAq SX6VUEFY3vUPif1vniJgLY4SIoUOrF2BxhaIIhkny7m0k+bslVUnuh+ZCjp/yxbj N2Q5wGt0K1n2pK4Puj7Oy9Xf/mEZhN8pSyz3peyV6zku8H3I4nk= =5Vkb -----END PGP SIGNATURE----- --STiaXdK3GZaER4V1--