From b48a0cea735d32abd1f6006adac8a602c38fd76d Mon Sep 17 00:00:00 2001 From: klzgrad Date: Sun, 23 May 2021 21:46:06 +0800 Subject: [PATCH] Add a timeout limit in tests --- tests/basic.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/basic.sh b/tests/basic.sh index ba354540df..f1b7c97655 100755 --- a/tests/basic.sh +++ b/tests/basic.sh @@ -47,7 +47,16 @@ test_naive() { name=naive$(echo "$arg" | tr -c 0-9a-z _) $naive $arg 2>$name.log & pid="$pid $!" tail -f $name.log & pid="$pid $!" - while ! grep -q 'Listening on' $name.log; do sleep 1; done + for i in $(seq 10); do + if grep -q 'Listening on' $name.log; then + break + fi + if [ $i -eq 10 ]; then + echo Timeout to start naive + exit 1 + fi + sleep 1 + done done test_proxy "$proxy" ); then