From: Martin Schwenke Date: Mon, 9 Sep 2019 10:57:42 +0000 (+1000) Subject: ctdb-tests: Move test status interpretation to ctdb_test_run() X-Git-Tag: talloc-2.3.1~486 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55dd0f047f58f9be2d1a317dfcbebe18e22201a0;p=thirdparty%2Fsamba.git ctdb-tests: Move test status interpretation to ctdb_test_run() It makes sense to do this in one place in case other headers/footers are added. Simplify ctdb_test_end() accordingly, reindenting because nearly all lines are modified. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh index a5775ca0814..8994c6d801e 100755 --- a/ctdb/tests/run_tests.sh +++ b/ctdb/tests/run_tests.sh @@ -99,32 +99,22 @@ ctdb_test_begin () ctdb_test_end () { - local name="$1" ; shift - local status="$1" ; shift - # "$@" is command-line + local f="$1" + local status="$2" + local interp="$3" - local interp="SKIPPED" - local statstr=" (reason $*)" - if [ -n "$status" ] ; then + local statstr="" if [ "$status" -eq 0 ] ; then - interp="PASSED" - statstr="" - echo "ALL OK: $*" - elif [ "$status" -eq 124 ] ; then - interp="TIMEOUT" - statstr=" (status $status)" + statstr="" else - interp="FAILED" - statstr=" (status $status)" + statstr=" (status $status)" fi - fi - testduration=$(($(date +%s) - teststarttime)) - - echo "==========================================================================" - echo "TEST ${interp}: ${name}${statstr} (duration: ${testduration}s)" - echo "==========================================================================" + testduration=$(($(date +%s) - teststarttime)) + echo "==========================================================================" + echo "TEST ${interp}: ${f}${statstr} (duration: ${testduration}s)" + echo "==========================================================================" } ctdb_test_run () @@ -142,7 +132,35 @@ ctdb_test_run () status=1 fi - $no_header || ctdb_test_end "$f" "$status" + tests_total=$((tests_total + 1)) + + local interp + case "$status" in + 0) + interp="PASSED" + tests_passed=$((tests_passed + 1)) + ;; + 124) + interp="TIMEDOUT" + tests_failed=$((tests_failed + 1)) + ;; + *) + interp="FAILED" + tests_failed=$((tests_failed + 1)) + ;; + esac + + $no_header || ctdb_test_end "$f" "$status" "$interp" + + if $with_summary ; then + local t + if [ $status -eq 0 ] ; then + t=" ${interp}" + else + t="*${interp}*" + fi + printf '%-10s %s\n' "$t" "$f" >>"$summary_file" + fi return $status } @@ -201,24 +219,8 @@ run_one_test () rm -rf "$CTDB_TEST_TMP_DIR" mkdir -p "$CTDB_TEST_TMP_DIR" - tests_total=$((tests_total + 1)) - ctdb_test_run "$f" status=$? - if [ $status -eq 0 ] ; then - tests_passed=$((tests_passed + 1)) - else - tests_failed=$((tests_failed + 1)) - fi - if $with_summary ; then - local t - if [ $status -eq 0 ] ; then - t=" PASSED " - else - t="*FAILED*" - fi - echo "$t $f" >>"$summary_file" - fi } run_tests ()