File chrony-ntp-era-split.patch of Package chrony.19955
commit 2d9eb5b6fa5225a7300c8eed95712969249900fb
Author: Miroslav Lichvar <mlichvar@redhat.com>
Date: Fri Jan 3 11:25:55 2020 +0100
test: fix util unit test for NTP era split
The current default NTP era split passed the Unix epoch (~50 years ago),
which means the epoch converted to an NTP timestamp and back ends up in
the next NTP era (year 2106).
Fix the test to take into account the era split.
--- test/unit/util.c.orig
+++ test/unit/util.c
@@ -43,11 +43,19 @@ void test_unit(void) {
ntp_ts.hi = htonl(JAN_1970);
ntp_ts.lo = 0xffffffff;
UTI_Ntp64ToTimespec(&ntp_ts, &ts);
+#if defined(HAVE_LONG_TIME_T) && NTP_ERA_SPLIT > 0
+ TEST_CHECK(ts.tv_sec == 0x100000000LL * (1 + (NTP_ERA_SPLIT - 1) / 0x100000000LL));
+#else
TEST_CHECK(ts.tv_sec == 0);
+#endif
TEST_CHECK(ts.tv_nsec == 999999999);
UTI_AddDoubleToTimespec(&ts, 1e-9, &ts);
+#if defined(HAVE_LONG_TIME_T) && NTP_ERA_SPLIT > 0
+ TEST_CHECK(ts.tv_sec == 1 + 0x100000000LL * (1 + (NTP_ERA_SPLIT - 1) / 0x100000000LL));
+#else
TEST_CHECK(ts.tv_sec == 1);
+#endif
TEST_CHECK(ts.tv_nsec == 0);
ntp_fuzz.hi = 0;