3 # The ability of ctdb_test_env to take tests on the command-line is
4 # nice, but here we need to hack around it with that colon to reset
5 # the arguments that it sees.
6 . $(dirname $0)/ctdb_test_env :
8 . ctdb_test_functions.bash
12 Usage: run_tests [OPTIONS] [TESTS]
18 ######################################################################
24 export TEST_VERBOSE=false
26 temp=$(getopt -n "$prog" -o "xdhqsv" -l help -- "$@")
35 -d) with_desc=true ; shift ;; # 4th line of output is description
36 -q) quiet=true ; shift ;;
37 -s) with_summary=true ; shift ;;
38 -v) TEST_VERBOSE=true ; shift ;;
45 show_progress() { cat >/dev/null ; }
47 show_progress() { cat ; }
50 ######################################################################
56 teststarttime=$(date '+%s')
59 echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--"
60 echo "Running test $name ($(date '+%T'))"
61 echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--"
66 local name="$1" ; shift
67 local status="$1" ; shift
68 # "$@" is command-line
70 local interp="SKIPPED"
71 local statstr=" (reason $*)"
72 if [ -n "$status" ] ; then
73 if [ $status -eq 0 ] ; then
79 statstr=" (status $status)"
83 testduration=$(($(date +%s)-$teststarttime))
85 echo "=========================================================================="
86 echo "TEST ${interp}: ${name}${statstr} (duration: ${testduration}s)"
87 echo "=========================================================================="
93 local name="$1" ; shift
95 [ -n "$1" ] || set -- "$name"
97 ctdb_test_begin "$name"
102 ctdb_test_end "$name" "$status" "$*"
107 ######################################################################
114 rows=$(if tty -s ; then stty size ; else echo x 80 ; fi | sed -e 's@.* @@' -e 's@^0$@80@')
123 [ -x $f ] || fail "test \"$f\" is not executable"
124 tests_total=$(($tests_total + 1))
125 ctdb_test_run "$f" | tee "$tf" | show_progress
127 if $with_summary ; then
128 if [ $status -eq 0 ] ; then
129 tests_passed=$(($tests_passed + 1))
133 tests_failed=$(($tests_failed + 1))
136 desc=$(tail -n +4 $tf | head -n 1)
145 if $with_summary ; then
149 echo "${tests_passed}/${tests_total} tests passed"
154 if [ $tests_failed -gt 0 ] ; then