From 18c3ffbfcc2d4d6d1a4680092123e510945f7a78 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sat, 23 Sep 2023 09:13:56 +0200 Subject: [PATCH] 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] https://github.com/systemd/systemd/pull/29183#issuecomment-1721727927 --- test/test-functions | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/test-functions b/test/test-functions index e21247558e2..9eeabd860a9 100644 --- a/test/test-functions +++ b/test/test-functions @@ -379,7 +379,12 @@ qemu_setup_swtpm_socket() { swtpm socket --tpm2 --tpmstate dir="$state_dir" --ctrl type=unixio,path="$state_dir/sock" & pid=$! if ! kill -0 "$pid"; then - echo >&2 "Failed to setup swtpm socket" + derror "Failed to start swtpm" + return 1 + fi + + if ! timeout 5 bash -c "until [[ -S $state_dir/sock ]]; do sleep .5; done"; then + derror "Failed to setup swtpm socket" return 1 fi