Skip to content

Commit 33b0102

Browse files
keszybzbluca
authored andcommitted
test-time-util: do more suppression of time zone checks
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 3cf362f) (cherry picked from commit 43a99d4) (cherry picked from commit 98cf43b)
1 parent 615ab02 commit 33b0102

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/test/test-time-util.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,12 @@ static void test_format_timestamp_impl(usec_t x) {
402402
assert_se(yy);
403403

404404
success = (x / USEC_PER_SEC == y / USEC_PER_SEC) && streq(xx, yy);
405-
/* Workaround for https://github.com/systemd/systemd/issues/28472 */
405+
/* Workaround for https://github.com/systemd/systemd/issues/28472
406+
* and https://github.com/systemd/systemd/pull/35471. */
406407
override = !success &&
407-
(STRPTR_IN_SET(tzname[0], "CAT", "EAT") ||
408-
STRPTR_IN_SET(tzname[1], "CAT", "EAT")) &&
409-
DIV_ROUND_UP(y - x, USEC_PER_SEC) == 3600; /* 1 hour, ignore fractional second */
408+
(STRPTR_IN_SET(tzname[0], "CAT", "EAT", "WET") ||
409+
STRPTR_IN_SET(tzname[1], "CAT", "EAT", "WET")) &&
410+
DIV_ROUND_UP(x > y ? x - y : y - x, USEC_PER_SEC) == 3600; /* 1 hour, ignore fractional second */
410411
log_full(success ? LOG_DEBUG : override ? LOG_WARNING : LOG_ERR,
411412
"@" USEC_FMT " → %s → @" USEC_FMT " → %s%s",
412413
x, xx, y, yy,
@@ -418,7 +419,7 @@ static void test_format_timestamp_impl(usec_t x) {
418419
}
419420

420421
static void test_format_timestamp_loop(void) {
421-
test_format_timestamp_impl(USEC_PER_SEC);
422+
test_format_timestamp_impl(USEC_PER_DAY + USEC_PER_SEC);
422423
test_format_timestamp_impl(USEC_TIMESTAMP_FORMATTABLE_MAX_32BIT-1);
423424
test_format_timestamp_impl(USEC_TIMESTAMP_FORMATTABLE_MAX_32BIT);
424425
test_format_timestamp_impl(USEC_TIMESTAMP_FORMATTABLE_MAX-1);

0 commit comments

Comments
 (0)