diff options
author | Martin Schwenke <martin@meltin.net> | 2019-08-05 11:19:30 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2019-08-14 09:11:35 +0000 |
commit | 91e6fc209be07c13db1d85fb268d4ff56b257973 (patch) | |
tree | fca8ef84c4a8c13dc4c320ed6dbb90d7f83f3083 /ctdb/tests | |
parent | da33fb27ab4f858689d4e93760edadd2018b9068 (diff) | |
download | samba-91e6fc209be07c13db1d85fb268d4ff56b257973.tar.gz |
ctdb-tests: Factor out main test loop into run_tests()
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tests')
-rwxr-xr-x | ctdb/tests/run_tests.sh | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh index 27f9b1d1878..12e87b6c1b5 100755 --- a/ctdb/tests/run_tests.sh +++ b/ctdb/tests/run_tests.sh @@ -236,6 +236,37 @@ find_and_run_one_test () fi } +run_tests () +{ + local tests=("$@") + + for f in "${tests[@]}" ; do + find_and_run_one_test "$f" + + if [ $status -eq 127 ] ; then + # Find the the top-level tests directory + d=$(cd "$TEST_SCRIPTS_DIR" && echo "$PWD") + if [ -z "$d" ] ; then + local t="$TEST_SCRIPTS_DIR" + die "Unable to find TEST_SCRIPTS_DIR=\"${t}\"" + fi + tests_dir=$(dirname "$d") + # Strip off current directory from beginning, + # if there, just to make paths more friendly. + tests_dir="${tests_dir#${PWD}/}" + find_and_run_one_test "$f" "$tests_dir" + fi + + if [ $status -eq 127 ] ; then + die "test \"$f\" is not recognised" + fi + + if $exit_on_fail && [ $status -ne 0 ] ; then + return $status + fi + done +} + export CTDB_TEST_MODE="yes" # Following 2 lines may be modified by installation script @@ -299,30 +330,8 @@ for f ; do fi done -for f in "${tests[@]}" ; do - find_and_run_one_test "$f" - - if [ $status -eq 127 ] ; then - # Find the the top-level tests directory - d=$(cd "$TEST_SCRIPTS_DIR" && echo "$PWD") - if [ -z "$d" ] ; then - die "Unable to find TEST_SCRIPTS_DIR=\"${TEST_SCRIPTS_DIR}\"" - fi - tests_dir=$(dirname "$d") - # Strip off current directory from beginning, if there, just - # to make paths more friendly. - tests_dir=${tests_dir#$PWD/} - find_and_run_one_test "$f" "$tests_dir" - fi - - if [ $status -eq 127 ] ; then - die "test \"$f\" is not recognised" - fi - - if $exit_on_fail && [ $status -ne 0 ] ; then - break - fi -done +run_tests "${tests[@]}" +status=$? rm -f "$tf" |