From: Yu Watanabe Date: Sun, 27 Jul 2025 12:42:12 +0000 (+0900) Subject: test: skip verification for racy test cases X-Git-Tag: v258-rc2~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7292d676d0514150572fcc15ac68b26d900b12a7;p=thirdparty%2Fsystemd.git test: skip verification for racy test cases FORMAT_LIFETIME() internally calls now(), hence we cannot provide any reliable verifications for finite lifetime. --- diff --git a/src/network/test-networkd-address.c b/src/network/test-networkd-address.c index a40c571483a..c7757f98f57 100644 --- a/src/network/test-networkd-address.c +++ b/src/network/test-networkd-address.c @@ -7,8 +7,9 @@ static void test_FORMAT_LIFETIME_one(usec_t lifetime, const char *expected) { const char *t = FORMAT_LIFETIME(lifetime); - log_debug(USEC_FMT " → \"%s\" (expected \"%s\")", lifetime, t, expected); - assert_se(streq(t, expected)); + log_debug(USEC_FMT " → \"%s\" (expected \"%s\")", lifetime, t, strna(expected)); + if (expected) + ASSERT_STREQ(t, expected); } TEST(FORMAT_LIFETIME) { @@ -17,9 +18,11 @@ TEST(FORMAT_LIFETIME) { now_usec = now(CLOCK_BOOTTIME); test_FORMAT_LIFETIME_one(now_usec, "for 0"); - test_FORMAT_LIFETIME_one(usec_add(now_usec, 2 * USEC_PER_SEC - 1), "for 1s"); - test_FORMAT_LIFETIME_one(usec_add(now_usec, 3 * USEC_PER_WEEK + USEC_PER_SEC - 1), "for 3w"); test_FORMAT_LIFETIME_one(USEC_INFINITY, "forever"); + + /* These two are necessarily racy, especially for slow test environment. */ + test_FORMAT_LIFETIME_one(usec_add(now_usec, 2 * USEC_PER_SEC - 1), NULL); + test_FORMAT_LIFETIME_one(usec_add(now_usec, 3 * USEC_PER_WEEK + USEC_PER_SEC - 1), NULL); } DEFINE_TEST_MAIN(LOG_DEBUG);