Skip to content

Commit 78b95cc

Browse files
keszybzbluca
authored andcommitted
test-time-util: suppress timestamp conversion failures for Africa/Khartoum timezone
Our timestamp conversion roundtrip test was failing. But I think that this is not our bug: $ TZ='Africa/Khartoum' date --date='@1509482094' Tue Oct 31 23:34:54 EAT 2017 $ TZ='Africa/Khartoum' date --date='Tue Oct 31 23:34:54 EAT 2017' +%s 1509485694 $ TZ='Africa/Khartoum' date --date='@1509485694' Tue Oct 31 23:34:54 CAT 2017 $ echo $[1509485694 - 1509482094] 3600 This is essentially the same as what happens in our test. After a round-trip, we end up one hour ahead. > For 1509482094632752, from the change log of tzdata: > > Release 2017c - 2017-10-20 14:49:34 -0700 > > Changes to future timestamps > Sudan will switch from +03 to +02 on 2017-11-01. Fixes systemd#28472.
1 parent 04fc5b6 commit 78b95cc

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/test/test-time-util.c

+18-4
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ TEST(format_timestamp) {
391391
}
392392

393393
static void test_format_timestamp_impl(usec_t x) {
394-
bool success;
394+
bool success, override;
395395
const char *xx, *yy;
396396
usec_t y;
397397

@@ -402,9 +402,19 @@ 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-
log_full(success ? LOG_DEBUG : LOG_ERR, "@" USEC_FMT " → %s → @" USEC_FMT " → %s", x, xx, y, yy);
406-
assert_se(x / USEC_PER_SEC == y / USEC_PER_SEC);
407-
assert_se(streq(xx, yy));
405+
/* Workaround for https://github.com/systemd/systemd/issues/28472 */
406+
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 */
410+
log_full(success ? LOG_DEBUG : override ? LOG_WARNING : LOG_ERR,
411+
"@" USEC_FMT " → %s → @" USEC_FMT " → %s%s",
412+
x, xx, y, yy,
413+
override ? ", ignoring." : "");
414+
if (!override) {
415+
assert_se(x / USEC_PER_SEC == y / USEC_PER_SEC);
416+
assert_se(streq(xx, yy));
417+
}
408418
}
409419

410420
static void test_format_timestamp_loop(void) {
@@ -414,6 +424,10 @@ static void test_format_timestamp_loop(void) {
414424
test_format_timestamp_impl(USEC_TIMESTAMP_FORMATTABLE_MAX-1);
415425
test_format_timestamp_impl(USEC_TIMESTAMP_FORMATTABLE_MAX);
416426

427+
/* Two cases which trigger https://github.com/systemd/systemd/issues/28472 */
428+
test_format_timestamp_impl(1504938962980066);
429+
test_format_timestamp_impl(1509482094632752);
430+
417431
for (unsigned i = 0; i < TRIAL; i++) {
418432
usec_t x;
419433

0 commit comments

Comments
 (0)