[v2,1/2] generic/131: wait until the server is ready or timeout
diff mbox series

Message ID 20190104081927.112622-2-houtao1@huawei.com
State New
Headers show
Series
  • tiny fixes for xfstests
Related show

Commit Message

Hou Tao Jan. 4, 2019, 8:19 a.m. UTC
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.

Signed-off-by: Hou Tao <houtao1@huawei.com>
---
v2:
    * add a timeout for the check of server readiness, else
      the test case may loop forever.
---
 tests/generic/131 | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Patch
diff mbox series

diff --git a/tests/generic/131 b/tests/generic/131
index d7c146ae..80929c23 100755
--- a/tests/generic/131
+++ b/tests/generic/131
@@ -37,10 +37,19 @@  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
+
+	let timeout=timeout-1
+done
+
+if [ -z "$PORT" ]; then
 	echo "Could not get server port"
 	exit 1
 fi