From: Simon McVittie Date: Tue, 28 Aug 2018 15:26:38 +0000 (+0100) Subject: test-webserver: Fix race condition X-Git-Tag: archive/raspbian/1.0.2-1+rpi1^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=637b2c8acea6f13353ebe2cc2c339f11983a51a0;p=flatpak.git test-webserver: Fix race condition If we rely on the background subshell to create the httpd-output file, and we are unlucky, then the "cp" invocation in the loop might execute before the file has been created, and fail. This appears to have happened on Debian's arm64 autobuilder, which failed with: Running web server: PYTHONUNBUFFERED=1 setsid python3 /<>/tests/http-utils-test-server.py 0 Web server pid: 13319 Waiting for web server (1/300)... cp: cannot stat '/var/tmp/tap-test.p1cxRN/httpd-output': No such file or directory Signed-off-by: Simon McVittie Forwarded: https://github.com/flatpak/flatpak/pull/2098 Gbp-Pq: Name test-webserver-Fix-race-condition.patch --- diff --git a/tests/test-webserver.sh b/tests/test-webserver.sh index 4508537..6d10b01 100755 --- a/tests/test-webserver.sh +++ b/tests/test-webserver.sh @@ -8,6 +8,7 @@ test_tmpdir=$(pwd) [ "$dir" != "" ] && cd ${dir} echo "Running web server: PYTHONUNBUFFERED=1 setsid $cmd" >&2 +touch ${test_tmpdir}/httpd-output env PYTHONUNBUFFERED=1 setsid $cmd >${test_tmpdir}/httpd-output & child_pid=$! echo "Web server pid: $child_pid" >&2