From 84690c35ee96f1e4c96c67fed1e3b42db9f7c0db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 4 Aug 2015 20:34:39 +0200 Subject: [PATCH] Make ssl-opt.sh more tolerant to start timeouts Rather than flat-out die when we can't see the server started with lsof, just stop waiting and try to go ahead with the test. Maybe it'll work if there was a problem with lsof, most probably it will fail, but at least we'll have the log, and the results of the following tests. Note: date +%s isn't POSIX, but it works at least on Linux, Darwin/FreeBSD and OpenBSD, which should be good enough for a test script. --- tests/ssl-opt.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh index 4595b890a..e2efae91c 100755 --- a/tests/ssl-opt.sh +++ b/tests/ssl-opt.sh @@ -157,17 +157,21 @@ has_mem_err() { # wait for server to start: two versions depending on lsof availability wait_server_start() { - if which lsof >/dev/null; then - # make sure we don't loop forever - ( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) & - WATCHDOG_PID=$! + if which lsof >/dev/null 2>&1; then + START_TIME=$( date +%s ) + DONE=0 # make a tight loop, server usually takes less than 1 sec to start - until lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null; - do :; done - - kill $WATCHDOG_PID - wait $WATCHDOG_PID + while [ $DONE -eq 0 ]; do + if lsof -nbi TCP:"$PORT" 2>/dev/null | grep LISTEN >/dev/null + then + DONE=1 + elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then + echo "SERVERSTART TIMEOUT" + echo "SERVERSTART TIMEOUT" >> $SRV_OUT + DONE=1 + fi + done else sleep "$START_DELAY" fi