diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 16:09:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 16:09:41 +0000 |
commit | 3271d1ac389d2ec93db9c5b9ce0991ce478476cf (patch) | |
tree | 35ff7d180e1ccc061f28535d7435b5ba1789e734 /test/simulation/008-ntpera | |
parent | Initial commit. (diff) | |
download | chrony-upstream/4.3.tar.xz chrony-upstream/4.3.zip |
Adding upstream version 4.3.upstream/4.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | test/simulation/008-ntpera | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/simulation/008-ntpera b/test/simulation/008-ntpera new file mode 100755 index 0000000..2eea63b --- /dev/null +++ b/test/simulation/008-ntpera @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +. ./test.common +test_start "NTP eras" + +if check_config_h 'HAVE_LONG_TIME_T 1'; then + ntp_start=$(awk "BEGIN {print $(grep NTP_ERA_SPLIT ../../config.h | tr -dc '0-9*+-')}") +else + ntp_start="-2147483648" +fi + +# Set the starting test date to 500 seconds before the second NTP era. +# This should work with 32-bit time_t and also with 64-bit time_t if the +# configured NTP interval covers the test interval. +export CLKNETSIM_START_DATE=$(date -d 'Feb 7 06:19:56 UTC 2036' +'%s') + +if awk "BEGIN {exit !($ntp_start <= $CLKNETSIM_START_DATE && \ + $CLKNETSIM_START_DATE + $limit < $ntp_start + 2^32)}"; then + run_test || test_fail + check_chronyd_exit || test_fail + check_source_selection || test_fail + check_packet_interval || test_fail + check_sync || test_fail +fi + +# The following tests need 64-bit time_t and ntp_start not before 1970 +check_config_h 'HAVE_LONG_TIME_T 1' || test_skip +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 {printf \"%.0f\", $ntp_start + $start_offset}") + run_test || test_fail + check_chronyd_exit || test_fail + check_source_selection || test_fail + check_packet_interval || test_fail + check_sync || test_fail + done + + for start_offset in -$limit "2^32"; do + 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 + check_packet_interval || test_fail + check_sync && test_fail + done +done + +test_pass |