]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
testing: Log timestamps relative to the start of the test
authorTobias Brunner <tobias@strongswan.org>
Fri, 29 Nov 2024 19:04:45 +0000 (20:04 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Dec 2024 07:43:45 +0000 (08:43 +0100)
Makes it easier to compare multiple runs against each other.

testing/do-tests

index 570c2e437891b1cc942f9d7fa91ebc23846139d2..89670da294c01be9d16e6d74e1ccf2953cd1582c 100755 (executable)
@@ -71,7 +71,9 @@ shift $((OPTIND-1))
 
 function print_time()
 {
-       [ "$timestamps" == "YES" ] && echo "$(date +%T.%N) ~ "
+       [ "$timestamps" == "YES" ] && \
+               logtime=$(date +"%s.%N") && \
+               echo "$(date -d "0 +${logtime} sec -${teststart_ns} sec"  +%S.%N) [$(date -d @${logtime} +%T.%N)] ~ "
 }
 
 ##############################################################################
@@ -304,7 +306,8 @@ do
        testname=$SUBDIR/$name
        log_action " $testnumber $testname:"
 
-       teststart=$(date +%s)
+       teststart_ns=$(date +"%s.%N")
+       teststart=$(date -d "@$teststart_ns" +"%s")
 
        if [ ! -d $DEFAULTTESTSDIR/${testname} ]
        then