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 <houtao1@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
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