[sheepdog] [PATCH 6/6] tests: add support for running testcase file directly

MORITA Kazutaka morita.kazutaka at gmail.com
Wed Jun 5 10:35:34 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

Currently, out test framework assumes that all the testcases are
executed via check script.  To run a testcase script directly
(e.g. sudo ./001), this patch moves a variable MD to common.config,
assigns the default value to STORE, and makes 'iam' a global variable.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 tests/047           |    2 +-
 tests/055           |    3 ++-
 tests/056           |    3 ++-
 tests/057           |    3 ++-
 tests/check         |    6 ++----
 tests/common.config |    3 ++-
 tests/common.rc     |    6 +++---
 7 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/tests/047 b/tests/047
index f45cad6..59c62a9 100755
--- a/tests/047
+++ b/tests/047
@@ -29,7 +29,7 @@ echo "hello" | $COLLIE vdi write test 0 512
 echo "sheepdog" | $COLLIE vdi write test 4M 512
 # corrupt the vdi...
 _kill_sheep 0
-if $md; then
+if $MD; then
 	rm $STORE/0/d2/807c2b2500000000
 	rm $STORE/0/d2/007c2b25*
 else
diff --git a/tests/055 b/tests/055
index 3737b17..4a2a462 100755
--- a/tests/055
+++ b/tests/055
@@ -7,12 +7,13 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1        # failure is the default!
-md=true
 
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
 
+MD=true
+
 _cleanup
 
 for i in 0 1 2; do
diff --git a/tests/056 b/tests/056
index a76b1fe..f6ad00b 100755
--- a/tests/056
+++ b/tests/056
@@ -7,12 +7,13 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1        # failure is the default!
-md=true
 
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
 
+MD=true
+
 _cleanup
 
 for i in 0 1 2; do
diff --git a/tests/057 b/tests/057
index 643c27a..ee95589 100755
--- a/tests/057
+++ b/tests/057
@@ -7,12 +7,13 @@ echo "QA output created by $seq"
 here=`pwd`
 tmp=/tmp/$$
 status=1        # failure is the default!
-md=true
 
 # get standard environment, filters and checks
 . ./common.rc
 . ./common.filter
 
+MD=true
+
 if [ "$STORE" != "/tmp/sheepdog/057" ]; then
     _notrun "This test cannot be run when WD is manually set"
 fi
diff --git a/tests/check b/tests/check
index 5120d3f..5addc23 100755
--- a/tests/check
+++ b/tests/check
@@ -32,7 +32,7 @@ interrupt=true
 timestamp=${TIMESTAMP:=false}
 
 # generic initialization
-iam=check
+export iam=check
 
 cd $(readlink -f $(dirname $0))
 
@@ -67,8 +67,6 @@ have_test_arg=false
 randomize=false
 valgrind=false
 
-export md=false
-
 rm -f $tmp.list $tmp.tmp $tmp.sed
 
 for r
@@ -173,7 +171,7 @@ testlist options
 	    ;;
 
 	-md)
-	    md=true
+	    MD=true
 	    xpand=false
 	    ;;
 
diff --git a/tests/common.config b/tests/common.config
index 76166e6..d6eec20 100644
--- a/tests/common.config
+++ b/tests/common.config
@@ -74,12 +74,13 @@ export BC_PROG="`set_prog_path bc`"
 
 export DRIVER=${DRIVER:-local}
 export WD=${WD:-/tmp/sheepdog}
-export STORE
+export STORE=$WD
 export SHEEP_PROG=${SHEEP_PROG:-../sheep/sheep}
 export SHEEP=${SHEEP:-$SHEEP_PROG}
 export SHEEP_OPTIONS=${SHEEP_OPTIONS:-"-n -y 127.0.0.1 -d"}
 export COLLIE_PROG=${COLLIE_PROG:-../collie/collie}
 export COLLIE=${COLLIE:-$COLLIE_PROG}
+export MD=${MD:-false}
 
 # make sure this script returns success
 /bin/true
diff --git a/tests/common.rc b/tests/common.rc
index 85a02f9..7d79dff 100644
--- a/tests/common.rc
+++ b/tests/common.rc
@@ -275,11 +275,11 @@ _start_sheep()
         _die "sheep $1 is still running"
     fi
 
-    if $md; then
-	MD=",$STORE/$1/d0,$STORE/$1/d1,$STORE/$1/d2"
+    if $MD; then
+	MD_STORE=",$STORE/$1/d0,$STORE/$1/d1,$STORE/$1/d2"
     fi
 
-    $SHEEP $STORE/$1$MD -z $1 -p $((7000+$1)) -c $DRIVER $SHEEP_OPTIONS $2
+    $SHEEP $STORE/$1$MD_STORE -z $1 -p $((7000+$1)) -c $DRIVER $SHEEP_OPTIONS $2
 
     if [ $? != 0 ]; then
         _die "cannot start sheep $1"
-- 
1.7.9.5




More information about the sheepdog mailing list