[sheepdog] [PATCH 5/7] test: fix 015

Liu Yuan namei.unix at gmail.com
Mon Aug 13 10:14:02 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

add a new helper to wait for collie command completion

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 tests/015       |    8 ++++----
 tests/common.rc |   11 +++++++++++
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/tests/015 b/tests/015
index 09a526c..5ef362a 100755
--- a/tests/015
+++ b/tests/015
@@ -25,7 +25,7 @@ $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
-$COLLIE vdi write test 512 512 < /dev/zero
+_wait_for_collie
 echo "there should be 3 setattr errors"
 
 $COLLIE vdi setattr test lock 1 -x &
@@ -36,7 +36,7 @@ $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
-$COLLIE vdi write test 512 512 < /dev/zero
+_wait_for_collie
 echo "there should be 8 setattr errors"
 
 $COLLIE vdi setattr test lock 1 -x &
@@ -45,7 +45,7 @@ $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
-$COLLIE vdi write test 512 512 < /dev/zero
+_wait_for_collie
 echo "there should be 6 setattr errors"
 
 $COLLIE vdi setattr test lock 1 -x &
@@ -53,5 +53,5 @@ $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
 $COLLIE vdi setattr test lock 1 -x &
-$COLLIE vdi write test 512 512 < /dev/zero
+_wait_for_collie
 echo "there should be 5 setattr errors"
diff --git a/tests/common.rc b/tests/common.rc
index b74fd0f..0b58fcb 100644
--- a/tests/common.rc
+++ b/tests/common.rc
@@ -131,5 +131,16 @@ _cleanup()
     done
 }
 
+_wait_for_collie()
+{
+    for ((;;)); do
+        if [ "$(pgrep collie)" ]; then
+            sleep 1
+        else
+            break
+        fi
+    done
+}
+
 # make sure this script returns success
 /bin/true
-- 
1.7.10.2




More information about the sheepdog mailing list