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.
This commit is contained in:
Manuel Pégourié-Gonnard 2015-08-04 20:34:39 +02:00
parent 2c99800155
commit 74681fa2e6

View file

@ -215,21 +215,33 @@ has_mem_err() {
# wait for server to start: two versions depending on lsof availability # wait for server to start: two versions depending on lsof availability
wait_server_start() { wait_server_start() {
if which lsof >/dev/null 2>&1; then if which lsof >/dev/null 2>&1; then
# make sure we don't loop forever START_TIME=$( date +%s )
( sleep "$DOG_DELAY"; echo "SERVERSTART TIMEOUT"; kill $MAIN_PID ) & DONE=0
DOG_PID=$!
# make a tight loop, server usually takes less than 1 sec to start # make a tight loop, server usually takes less than 1 sec to start
if [ "$DTLS" -eq 1 ]; then if [ "$DTLS" -eq 1 ]; then
until lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null; while [ $DONE -eq 0 ]; do
do :; done if lsof -nbi UDP:"$SRV_PORT" 2>/dev/null | grep UDP >/dev/null
else then
until lsof -nbi TCP:"$SRV_PORT" 2>/dev/null | grep LISTEN >/dev/null; DONE=1
do :; done elif [ $(( $( date +%s ) - $START_TIME )) -gt $DOG_DELAY ]; then
echo "SERVERSTART TIMEOUT"
echo "SERVERSTART TIMEOUT" >> $SRV_OUT
DONE=1
fi
done
else
while [ $DONE -eq 0 ]; do
if lsof -nbi TCP:"$SRV_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
fi fi
kill $DOG_PID >/dev/null 2>&1
wait $DOG_PID
else else
sleep "$START_DELAY" sleep "$START_DELAY"
fi fi