From: Hou Tao Date: Fri, 4 Jan 2019 08:19:26 +0000 (+0800) Subject: generic/131: wait until the server is ready or timeout X-Git-Tag: v2022.05.01~1295 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e18876187ce76fd69118728206b89c7007752ea7;p=users%2Fhch%2Fxfstests-dev.git generic/131: wait until the server is ready or timeout When running xfstests under KVM VM and the load of host is high, only delaying 1s and checking the readiness of server are not enough, and the test case will fail early. Fix it by repeatedly checking the readiness signal until it's found, or timeout is triggered. [Eryu: check if lock server died or not, like v1 patch did] Signed-off-by: Hou Tao Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/tests/generic/131 b/tests/generic/131 index d7c146aea..c7bac3bcf 100755 --- a/tests/generic/131 +++ b/tests/generic/131 @@ -37,10 +37,25 @@ TESTFILE=$TEST_DIR/lock_file src/locktest $TESTFILE 2>&1 > $TEST_DIR/server.out & locktest_pid1=$! -sleep 1 +timeout=30 +while [ $timeout -gt 0 ]; do + sleep 1 -PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}') -if [ -z $PORT ]; then + PORT=$(cat $TEST_DIR/server.out | grep "^server port: " | awk '{print $3}') + if [ -n "$PORT" ]; then + break + fi + + # check the existence of server process + if ! kill -s 0 $locktest_pid1 >/dev/null 2>&1; then + echo "Server died abnormally" + exit 1 + fi + + let timeout=timeout-1 +done + +if [ -z "$PORT" ]; then echo "Could not get server port" exit 1 fi