From 78577fcf1a60c2c78d72fa4a4956e8d2be515938 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Tue, 21 Sep 2021 16:13:03 +0200 Subject: [PATCH] tests: fix time measurement --- tools/integration-tests.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/integration-tests.sh b/tools/integration-tests.sh index a8eb3a91a..0172548ef 100755 --- a/tools/integration-tests.sh +++ b/tools/integration-tests.sh @@ -84,7 +84,7 @@ for TEST in ${TESTS}; do TESTNAME=$(basename -s .sh ${TEST}) # Start time measurement - SECONDS=0 + START=$(date +%s.%N) # Run test if (( ${VERBOSE} == 0 )); then @@ -95,7 +95,8 @@ for TEST in ${TESTS}; do RC=${PIPESTATUS[0]} fi - TOTAL_SECONDS=${SECONDS} + END=$(date +%s.%N) + DIFF=$(echo "$END - $START" | bc) # Show full log in case of an error if (( ${VERBOSE} == 0 )); then @@ -106,7 +107,7 @@ for TEST in ${TESTS}; do case $RC in 0) - echo -e "\e[32m[PASS] \e[39m ${TESTNAME} (ran for ${SECONDS}s)" + echo -e "\e[32m[PASS] \e[39m ${TESTNAME} (ran for ${DIFF}s)" PASSED=$((${PASSED} + 1)) ;; 99) @@ -119,7 +120,7 @@ for TEST in ${TESTS}; do FAILED=$((${FAILED} + 1)) ;; *) - echo -e "\e[31m[FAIL] \e[39m ${TESTNAME} (exited with code $RC, ran for ${SECONDS}s)" + echo -e "\e[31m[FAIL] \e[39m ${TESTNAME} (exited with code $RC, ran for ${DIFF}s)" FAILED=$((${FAILED} + 1)) ;; esac