From: Yu Watanabe Date: Wed, 12 Nov 2025 02:40:22 +0000 (+0900) Subject: musl: test-time-util: skip parsing back when currently unused timezone is set X-Git-Tag: v259-rc1~81^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F39688%2Fhead;p=thirdparty%2Fsystemd.git musl: test-time-util: skip parsing back when currently unused timezone is set --- diff --git a/src/test/test-time-util.c b/src/test/test-time-util.c index 8f5d8bd5a8d..f58be952ef3 100644 --- a/src/test/test-time-util.c +++ b/src/test/test-time-util.c @@ -400,6 +400,28 @@ static void test_format_timestamp_impl(usec_t x) { const char *xx = FORMAT_TIMESTAMP(x); ASSERT_NOT_NULL(xx); + /* Because of the timezone change, format_timestamp() may set timezone that is currently unused. + * E.g. Africa/Juba uses EAT since Sat Jan 15 10:00:00 2000 and until Sun Jan 31 20:59:59 2021, but + * now CAT/CAST is used there (see zdump for more details). In such cases, format_timestamp() may set + * the timezone used at the specified time (which happens when built with musl), but it may not match + * the timezone currently used, thus we may not parse back the timestamp. */ + + const char *space; + ASSERT_NOT_NULL(space = strrchr(xx, ' ')); + + const char *tz = space + 1; + if (!streq_ptr(tz, get_tzname(/* dst= */ false)) && + !streq_ptr(tz, get_tzname(/* dst= */ true)) && + parse_gmtoff(tz, NULL) < 0) { + + log_warning("@" USEC_FMT " → %s, timezone '%s' is currently unused, ignoring.", x, xx, tz); + + /* Verify the generated string except for the timezone part. Of course, in most cases, parsed + * time does not match with the input, hence only check if it is parsable. */ + ASSERT_OK(parse_timestamp(strndupa_safe(xx, space - xx), NULL)); + return; + } + usec_t y; ASSERT_OK(parse_timestamp(xx, &y)); const char *yy = FORMAT_TIMESTAMP(y);