ctdb-tests: Refactor code using simple test harness functions
authorAmitay Isaacs <amitay@gmail.com>
Mon, 6 Jul 2015 08:15:31 +0000 (18:15 +1000)
committerMartin Schwenke <martins@samba.org>
Thu, 9 Jul 2015 04:23:21 +0000 (06:23 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/tests/eventscripts/scripts/local.sh
ctdb/tests/takeover/scripts/local.sh
ctdb/tests/tool/scripts/local.sh

index 3b16fb94b19508697083a459493e443ff50224db..ae313a75607acc19949f94a442c87258ee04cd89 100644 (file)
@@ -1119,15 +1119,7 @@ ip command is "$(which ip)"
 EOF
     }
 
-    _shell=""
-    if $TEST_COMMAND_TRACE ; then
-       _shell="sh -x"
-    else
-       _shell="sh"
-    fi
-    _out=$($_shell "${script_dir}/${script}" "$event" "$@" 2>&1)
-
-    result_check
+    script_test "${script_dir}/${script}" "$event" "$@"
 
     reset_test_header
     reset_extra_header
@@ -1146,15 +1138,7 @@ simple_test_event ()
 
 simple_test_command ()
 {
-    # If something has previously failed then don't continue.
-    : ${_passed:=true}
-    $_passed || return 1
-
-    echo "=================================================="
-    echo "Running command \"$*\""
-    _out=$("$@" 2>&1)
-
-    result_check
+    unit_test "$@"
 }
 
 # Run an eventscript iteratively.
index c5f3f4d5baf8651dfe493dc256a4e9aa877ee893..a84f58bcbf1cb33f0730a120f30dd0eaddfe60c9 100644 (file)
@@ -26,7 +26,5 @@ EOF
 
 simple_test ()
 {
-    _out=$($VALGRIND $test_prog "$@" 2>&1)
-
-    result_check
+    unit_test $test_prog "$@"
 }
index 6cdf4c5089ffe4e3bdfb4cef3f31d6ff13553a5b..737cb716278f8985c5186fcd1853f44ab8179626 100644 (file)
@@ -71,7 +71,5 @@ simple_test ()
     : ${CTDB_DEBUGLEVEL:=3}
     export CTDB_DEBUGLEVEL
 
-    _out=$($VALGRIND $test_prog "$@" 2>&1)
-
-    result_check
+    unit_test $test_prog "$@"
 }