summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2012-04-16 14:48:49 +1000
committerMartin Schwenke <martin@meltin.net>2012-04-16 14:57:45 +1000
commitfec6fe628736c2b20ceeb53a43faa1ebff0a7ff0 (patch)
treed09fd8288488caf355f8b7d6a62e60a350249c2a
parentf6178fcc9db4e05bddba1af16fd5ef6c56e9a515 (diff)
downloadsamba-fec6fe628736c2b20ceeb53a43faa1ebff0a7ff0.tar.gz
samba-fec6fe628736c2b20ceeb53a43faa1ebff0a7ff0.tar.xz
samba-fec6fe628736c2b20ceeb53a43faa1ebff0a7ff0.zip
tests - move functions only used by scripts/run_tests into that script
Along with minor logic tweaks and removal of test_exit(). Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit 00713eb46cce638339845799bba2da041b3d02fb)
-rw-r--r--ctdb/tests/scripts/ctdb_test_functions.bash61
-rwxr-xr-xctdb/tests/scripts/run_tests63
2 files changed, 62 insertions, 62 deletions
diff --git a/ctdb/tests/scripts/ctdb_test_functions.bash b/ctdb/tests/scripts/ctdb_test_functions.bash
index 95a9cd1f87..e729486f55 100644
--- a/ctdb/tests/scripts/ctdb_test_functions.bash
+++ b/ctdb/tests/scripts/ctdb_test_functions.bash
@@ -8,51 +8,6 @@ fail ()
######################################################################
-ctdb_test_begin ()
-{
- local name="$1"
-
- teststarttime=$(date '+%s')
- testduration=0
-
- echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--"
- echo "Running test $name ($(date '+%T'))"
- echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--"
-}
-
-ctdb_test_end ()
-{
- local name="$1" ; shift
- local status="$1" ; shift
- # "$@" is command-line
-
- local interp="SKIPPED"
- local statstr=" (reason $*)"
- if [ -n "$status" ] ; then
- if [ $status -eq 0 ] ; then
- interp="PASSED"
- statstr=""
- echo "ALL OK: $*"
- else
- interp="FAILED"
- statstr=" (status $status)"
- testfailures=$(($testfailures+1))
- fi
- fi
-
- testduration=$(($(date +%s)-$teststarttime))
-
- echo "=========================================================================="
- echo "TEST ${interp}: ${name}${statstr} (duration: ${testduration}s)"
- echo "=========================================================================="
-
-}
-
-test_exit ()
-{
- exit $(($testfailures+0))
-}
-
ctdb_check_time_logs ()
{
local threshold=20
@@ -144,22 +99,6 @@ ctdb_test_exit_hook_add ()
ctdb_test_exit_hook="${ctdb_test_exit_hook}${ctdb_test_exit_hook:+ ; }$*"
}
-ctdb_test_run ()
-{
- local name="$1" ; shift
-
- [ -n "$1" ] || set -- "$name"
-
- ctdb_test_begin "$name"
-
- local status=0
- "$@" || status=$?
-
- ctdb_test_end "$name" "$status" "$*"
-
- return $status
-}
-
ctdb_test_usage()
{
local status=${1:-2}
diff --git a/ctdb/tests/scripts/run_tests b/ctdb/tests/scripts/run_tests
index 1ce089d852..394b4150ac 100755
--- a/ctdb/tests/scripts/run_tests
+++ b/ctdb/tests/scripts/run_tests
@@ -46,8 +46,66 @@ fi
######################################################################
+ctdb_test_begin ()
+{
+ local name="$1"
+
+ teststarttime=$(date '+%s')
+ testduration=0
+
+ echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--"
+ echo "Running test $name ($(date '+%T'))"
+ echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--"
+}
+
+ctdb_test_end ()
+{
+ local name="$1" ; shift
+ local status="$1" ; shift
+ # "$@" is command-line
+
+ local interp="SKIPPED"
+ local statstr=" (reason $*)"
+ if [ -n "$status" ] ; then
+ if [ $status -eq 0 ] ; then
+ interp="PASSED"
+ statstr=""
+ echo "ALL OK: $*"
+ else
+ interp="FAILED"
+ statstr=" (status $status)"
+ fi
+ fi
+
+ testduration=$(($(date +%s)-$teststarttime))
+
+ echo "=========================================================================="
+ echo "TEST ${interp}: ${name}${statstr} (duration: ${testduration}s)"
+ echo "=========================================================================="
+
+}
+
+ctdb_test_run ()
+{
+ local name="$1" ; shift
+
+ [ -n "$1" ] || set -- "$name"
+
+ ctdb_test_begin "$name"
+
+ local status=0
+ "$@" || status=$?
+
+ ctdb_test_end "$name" "$status" "$*"
+
+ return $status
+}
+
+######################################################################
+
tests_total=0
tests_passed=0
+tests_failed=0
summary=""
rows=$(if tty -s ; then stty size ; else echo x 80 ; fi | sed -e 's@.* @@' -e 's@^0$@80@')
@@ -69,6 +127,7 @@ for f; do
t=" PASSED "
else
t="*FAILED*"
+ tests_failed=$(($tests_failed + 1))
fi
if $with_desc ; then
desc=$(tail -n +4 $tf | head -n 1)
@@ -89,4 +148,6 @@ fi
rm -f "$sf"
-test_exit
+if [ $tests_failed -gt 0 ] ; then
+ exit 1
+fi