diff options
author | jc_gargma <jc_gargma@iserlohn-fortress.net> | 2020-08-30 10:21:54 -0700 |
---|---|---|
committer | jc_gargma <jc_gargma@iserlohn-fortress.net> | 2020-08-30 10:21:54 -0700 |
commit | c1a9dd9eeb80bd7009ef85216a6bb958cef0d287 (patch) | |
tree | aa2582a8f4b5d2f1ae98d0ed369b5c6a7b126af7 /fix-util-unit-test-for-NTP-era-split.patch | |
parent | Rebuild with -fPIE (diff) | |
download | chrony-c1a9dd9eeb80bd7009ef85216a6bb958cef0d287.tar.xz |
Updated to 3.5.1
Diffstat (limited to 'fix-util-unit-test-for-NTP-era-split.patch')
-rw-r--r-- | fix-util-unit-test-for-NTP-era-split.patch | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/fix-util-unit-test-for-NTP-era-split.patch b/fix-util-unit-test-for-NTP-era-split.patch new file mode 100644 index 0000000..28a6545 --- /dev/null +++ b/fix-util-unit-test-for-NTP-era-split.patch @@ -0,0 +1,38 @@ +From 2d9eb5b6fa5225a7300c8eed95712969249900fb Mon Sep 17 00:00:00 2001 +From: Miroslav Lichvar <mlichvar@redhat.com> +Date: Fri, 3 Jan 2020 11:25:55 +0100 +Subject: [PATCH] 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 | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/test/unit/util.c b/test/unit/util.c +index f4d9f33..af9e90c 100644 +--- a/test/unit/util.c ++++ b/test/unit/util.c +@@ -100,11 +100,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; |