]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: add helper to selection functions implementing tests
authorLoic Dachary <loic@dachary.org>
Sun, 16 Mar 2014 15:16:26 +0000 (16:16 +0100)
committerLoic Dachary <loic@dachary.org>
Mon, 17 Mar 2014 15:48:53 +0000 (16:48 +0100)
The call_TEST_functions will lookup SHARE_MON_TEST_* shell functions and
run them after creating a mon. Each is expected to clean up and avoid
interferences. It will also lookup TEST_* shell functions and include them
in setup/teardown to provide them with a clean environment.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/mon/mon-test-helpers.sh

index f3925af89e14aa1c231087f40f6b029aac82c9ca..3ed178438bd0274faa3194424bb01c89cb248e7f 100644 (file)
@@ -66,6 +66,31 @@ function kill_daemons() {
     done
 }
 
+function call_TEST_functions() {
+    local dir=$1
+    shift
+    local id=$2
+    shift
+
+    setup $dir || return 1
+    run_mon $dir $id "$@"
+    SHARE_MON_FUNCTIONS=${SHARE_MON_FUNCTIONS:-$(set | sed -n -e 's/^\(SHARE_MON_TEST_[0-9a-z_]*\) .*/\1/p')}
+    for TEST_function in $SHARE_MON_FUNCTIONS ; do
+        if ! $TEST_function $dir $id ; then
+            cat $dir/$id/log
+            return 1
+        fi
+    done
+    teardown $dir || return 1
+
+    FUNCTIONS=${FUNCTIONS:-$(set | sed -n -e 's/^\(TEST_[0-9a-z_]*\) .*/\1/p')}
+    for TEST_function in $FUNCTIONS ; do
+        setup $dir || return 1
+        $TEST_function $dir || return 1
+        teardown $dir || return 1
+    done
+}
+
 function main() {
     local dir=$1