aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-04-05 11:56:42 +1000
committerStefano Brivio <sbrivio@redhat.com>2023-04-08 01:11:36 +0200
commit55bbe3dbcb043b62f2d8b7f204873c160d40e7b9 (patch)
treeef4323d7941cd0f52d4699f8c2f1a7a721ec7f22
parentca2749e1bd520c6a1dbca24f1561ee31dd833a54 (diff)
downloadpasst-55bbe3dbcb043b62f2d8b7f204873c160d40e7b9.tar
passt-55bbe3dbcb043b62f2d8b7f204873c160d40e7b9.tar.gz
passt-55bbe3dbcb043b62f2d8b7f204873c160d40e7b9.tar.bz2
passt-55bbe3dbcb043b62f2d8b7f204873c160d40e7b9.tar.lz
passt-55bbe3dbcb043b62f2d8b7f204873c160d40e7b9.tar.xz
passt-55bbe3dbcb043b62f2d8b7f204873c160d40e7b9.tar.zst
passt-55bbe3dbcb043b62f2d8b7f204873c160d40e7b9.zip
test: Remove race between commands run in the same context
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 <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--test/lib/context4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/lib/context b/test/lib/context
index e84fc18..624f86b 100644
--- a/test/lib/context
+++ b/test/lib/context
@@ -89,8 +89,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}"