]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-time-util: do more suppression of time zone checks
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 5 Dec 2024 12:32:19 +0000 (13:32 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 20 Dec 2024 19:43:57 +0000 (19:43 +0000)
The issue is directly triggered by tzdata-2024b, where the setting of timezone
started to fail and the tests stopped passing. But those timestamps in 1/1/1970
appear to have some problems already before:

  $ sudo date -s 'Thu 1970-01-01 13:00:01 WET'
  Thu Jan  1 03:00:01 PM EET 1970
  $ sudo date -s 'Thu 1970-01-01 12:00:01 WET'
  date: cannot set date: Invalid argument
  Thu Jan  1 02:00:01 PM EET 1970
  $ rpm -q tzdata
  tzdata-2024a-9.fc41.noarch

The same issue appears with other timezones. So move the first timestamp one
day forward to avoid the issue.

After the previous problem is solved, we also get the problem already seen
previously where the roundtrip returns a time that is off by one hour:

@86401000000 → Fri 1970-01-02 00:00:01 WET → @82801000000 → Thu 1970-01-01 23:00:01 WET
Assertion 'x / USEC_PER_SEC == y / USEC_PER_SEC' failed at src/test/test-time-util.c:415, function test_format_timestamp_impl(). Aborting.

Extend the override to suppress this.

(cherry picked from commit 3cf362f6f57b7d0b5f6b86a49316303b0dda7599)

src/test/test-time-util.c

index 8b2daf527aaf4381120db2e2f8104c831347e474..4b42366820250f22e910e9a1de33bc9e17d28393 100644 (file)
@@ -402,11 +402,12 @@ static void test_format_timestamp_impl(usec_t x) {
         assert_se(yy);
 
         success = (x / USEC_PER_SEC == y / USEC_PER_SEC) && streq(xx, yy);
-        /* Workaround for https://github.com/systemd/systemd/issues/28472 */
+        /* Workaround for https://github.com/systemd/systemd/issues/28472
+         * and https://github.com/systemd/systemd/pull/35471. */
         override = !success &&
-                   (STRPTR_IN_SET(tzname[0], "CAT", "EAT") ||
-                    STRPTR_IN_SET(tzname[1], "CAT", "EAT")) &&
-                   DIV_ROUND_UP(y - x, USEC_PER_SEC) == 3600; /* 1 hour, ignore fractional second */
+                   (STRPTR_IN_SET(tzname[0], "CAT", "EAT", "WET") ||
+                    STRPTR_IN_SET(tzname[1], "CAT", "EAT", "WET")) &&
+                   DIV_ROUND_UP(x > y ? x - y : y - x, USEC_PER_SEC) == 3600; /* 1 hour, ignore fractional second */
         log_full(success ? LOG_DEBUG : override ? LOG_WARNING : LOG_ERR,
                  "@" USEC_FMT " → %s → @" USEC_FMT " → %s%s",
                  x, xx, y, yy,
@@ -418,7 +419,7 @@ static void test_format_timestamp_impl(usec_t x) {
 }
 
 static void test_format_timestamp_loop(void) {
-        test_format_timestamp_impl(USEC_PER_SEC);
+        test_format_timestamp_impl(USEC_PER_DAY + USEC_PER_SEC);
         test_format_timestamp_impl(USEC_TIMESTAMP_FORMATTABLE_MAX_32BIT-1);
         test_format_timestamp_impl(USEC_TIMESTAMP_FORMATTABLE_MAX_32BIT);
         test_format_timestamp_impl(USEC_TIMESTAMP_FORMATTABLE_MAX-1);