Skip to content

Commit 300725e

Browse files
mrc0mmandbluca
authored andcommitted
test: wait for the swtpm socket to appear
On slower/overloaded systems it may take a bit for the swtpm socket to show up: I: Started swtpm as PID 189419 with state dir /tmp/tmp.pWqUutuGUj I: Configured emulated TPM2 device tpm-spapr + tee /var/tmp/systemd-test-TEST-70-TPM2_1/console.log + timeout --foreground 1200 /bin/qemu-system-ppc64le -smp 4 ... qemu-system-ppc64le: -chardev socket,id=chrtpm,path=/tmp/tmp.pWqUutuGUj/sock: Failed to connect to '/tmp/tmp.pWqUutuGUj/sock': No such file or directory E: qemu failed with exit code 1 Spotted regularly in the ppc64le cron job and in some Ubuntu CI/CentOS CI pr runs [0]. [0] systemd/systemd#29183 (comment) (cherry picked from commit 18c3ffb) (cherry picked from commit 2171f68) (cherry picked from commit bf449d7)
1 parent c08e879 commit 300725e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/test-functions

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,12 @@ qemu_setup_swtpm_socket() {
369369
swtpm socket --tpm2 --tpmstate dir="$state_dir" --ctrl type=unixio,path="$state_dir/sock" &
370370
pid=$!
371371
if ! kill -0 "$pid"; then
372-
echo >&2 "Failed to setup swtpm socket"
372+
derror "Failed to start swtpm"
373+
return 1
374+
fi
375+
376+
if ! timeout 5 bash -c "until [[ -S $state_dir/sock ]]; do sleep .5; done"; then
377+
derror "Failed to setup swtpm socket"
373378
return 1
374379
fi
375380

0 commit comments

Comments
 (0)