]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
test: ensure awk commands in 008-ntpera return an integer
authorVincent Blut <vincent.debian@free.fr>
Wed, 12 Jan 2022 17:08:34 +0000 (18:08 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 13 Jan 2022 08:40:12 +0000 (09:40 +0100)
Some awk interpreters (e.g. mawk) print long integers in exponential
notation skewing the test result.

test/simulation/008-ntpera

index 2a4f33252c8fa01e89b0b17b12fcdbd88b3aa196..2eea63b5be01744f7da76e8816058bcb51f35635 100755 (executable)
@@ -29,7 +29,7 @@ echo "$ntp_start" | grep -q '-' && test_skip
 
 for time_offset in -1e-1 1e-1; do
        for start_offset in 0 "2^32 - $limit"; do
-               export CLKNETSIM_START_DATE=$(awk "BEGIN {print $ntp_start + $start_offset}")
+               export CLKNETSIM_START_DATE=$(awk "BEGIN {printf \"%.0f\", $ntp_start + $start_offset}")
                run_test || test_fail
                check_chronyd_exit || test_fail
                check_source_selection || test_fail
@@ -38,7 +38,7 @@ for time_offset in -1e-1 1e-1; do
        done
 
        for start_offset in -$limit "2^32"; do
-               export CLKNETSIM_START_DATE=$(awk "BEGIN {print $ntp_start + $start_offset}")
+               export CLKNETSIM_START_DATE=$(awk "BEGIN {printf \"%.0f\", $ntp_start + $start_offset}")
                run_test || test_fail
                check_chronyd_exit || test_fail
                check_source_selection || test_fail