From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTP id 35F8C5A026D for ; Wed, 5 Apr 2023 14:23:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680697417; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WRrCJxv1MdfUJZXonc5vcEsZXsNT/EHAQNYJJ1wDf7c=; b=Mhx0lhmtRoW/J6BfaVqt6y1AX63T/0jmkj79FZpENa32/+x9wW4p6O0sO1SvMlEwa2Cp8L d37WD+k6Jk1RYxywtmppR6OtXWSHPHLEH6hi3kNARdm4r8BFEWR4jWiF2zQkiDvTSJNDJY w8wGg+yiqgODZKkM8Fr5luB8hTYvA6U= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-205-vTI6SNZxN06IuFUy7uL6tQ-1; Wed, 05 Apr 2023 08:23:36 -0400 X-MC-Unique: vTI6SNZxN06IuFUy7uL6tQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A65493C218A2; Wed, 5 Apr 2023 12:23:35 +0000 (UTC) Received: from elisabeth (unknown [10.39.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE8B2E09100; Wed, 5 Apr 2023 12:23:34 +0000 (UTC) Date: Wed, 5 Apr 2023 14:23:24 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH] test: Remove race between commands run in the same context Message-ID: <20230405142324.75f0a416@elisabeth> In-Reply-To: <20230405015642.406952-1-david@gibson.dropbear.id.au> References: <20230405015642.406952-1-david@gibson.dropbear.id.au> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: GOLIBERVFJ5A3X2GVKNLAND2XFQLJKXR X-Message-ID-Hash: GOLIBERVFJ5A3X2GVKNLAND2XFQLJKXR X-MailFrom: sbrivio@redhat.com 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: On Wed, 5 Apr 2023 11:56:42 +1000 David Gibson wrote: > 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")" In practice, this is never going to be an issue, but strictly speaking, -u doesn't guarantee the name is unique. 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... -- Stefano