From 57937d0e6321520de55747baf0fdc758b299ffe5 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 2 Oct 2017 13:03:31 -0400 Subject: [PATCH] libtest: Squash a race in temp webserver setup Saw this in one of the PR contexts. Closes: #1031 Approved by: jlebon --- tests/common/libtest.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/common/libtest.sh b/tests/common/libtest.sh index 5a6af8ef..8f800550 100644 --- a/tests/common/libtest.sh +++ b/tests/common/libtest.sh @@ -145,9 +145,11 @@ setup_test_repository () { run_temp_webserver() { env PYTHONUNBUFFERED=1 setsid python -m SimpleHTTPServer 0 >${test_tmpdir}/httpd-output & for x in $(seq 50); do - sed -e 's,Serving HTTP on 0.0.0.0 port \([0-9]*\) \.\.\.,\1,' < ${test_tmpdir}/httpd-output > ${test_tmpdir}/httpd-port - if ! cmp ${test_tmpdir}/httpd-output ${test_tmpdir}/httpd-port 1>/dev/null; then - break + if test -e ${test_tmpdir}/httpd-output; then + sed -e 's,Serving HTTP on 0.0.0.0 port \([0-9]*\) \.\.\.,\1,' < ${test_tmpdir}/httpd-output > ${test_tmpdir}/httpd-port + if ! cmp ${test_tmpdir}/httpd-output ${test_tmpdir}/httpd-port 1>/dev/null; then + break + fi fi sleep 0.1 done