From: Martin Schwenke Date: Tue, 10 Sep 2019 00:51:31 +0000 (+1000) Subject: ctdb-tests: Move test duration calculation to ctdb_test_run() X-Git-Tag: talloc-2.3.1~483 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=435d903ad84e72e8223ae53ca46bb47c1cfe1293;p=thirdparty%2Fsamba.git ctdb-tests: Move test duration calculation to ctdb_test_run() It makes sense to do this in one place in case other headers/footers are added. Reindent ctdb_test_begin() while touching this function. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tests/run_tests.sh b/ctdb/tests/run_tests.sh index a97ce63e3d5..6e4082e396a 100755 --- a/ctdb/tests/run_tests.sh +++ b/ctdb/tests/run_tests.sh @@ -87,14 +87,11 @@ fi ctdb_test_begin () { - local name="$1" + local name="$1" - teststarttime=$(date '+%s') - testduration=0 - - echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--" - echo "Running test $name ($(date '+%T'))" - echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--" + echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--" + echo "Running test $name ($(date '+%T'))" + echo "--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--" } ctdb_test_end () @@ -102,6 +99,7 @@ ctdb_test_end () local f="$1" local status="$2" local interp="$3" + local duration="$4" local statstr="" if [ "$status" -eq 0 ] ; then @@ -110,10 +108,8 @@ ctdb_test_end () statstr=" (status $status)" fi - testduration=$(($(date +%s) - teststarttime)) - echo "==========================================================================" - echo "TEST ${interp}: ${f}${statstr} (duration: ${testduration}s)" + echo "TEST ${interp}: ${f}${statstr} (duration: ${duration}s)" echo "==========================================================================" } @@ -124,6 +120,10 @@ ctdb_test_run () $no_header || ctdb_test_begin "$f" local status=0 + local start_time + + start_time=$(date '+%s') + if [ -x "$f" ] ; then timeout "$test_time_limit" "$f" | show_progress status=$? @@ -132,6 +132,8 @@ ctdb_test_run () status=99 fi + local duration=$(($(date +%s) - start_time)) + tests_total=$((tests_total + 1)) local interp @@ -158,7 +160,7 @@ ctdb_test_run () ;; esac - $no_header || ctdb_test_end "$f" "$status" "$interp" + $no_header || ctdb_test_end "$f" "$status" "$interp" "$duration" if $with_summary ; then local t