From e56f27f997fc03a44101acf9abbfd8496ae9d152 Mon Sep 17 00:00:00 2001 From: Rongsong Shen Date: Thu, 8 Oct 2026 09:50:36 +0000 Subject: [PATCH] test(scheduler): check only the timestamp field in the frozen tlog format test (bug-1924) test_tlog_format_shows_frozen_virtual_time_not_infotime asserted that "1999" (info->time's year) appears nowhere in the formatted line, but the line also carries getpid(), so the test failed whenever its PID contained 1999. It now asserts the exact frozen timestamp field. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/scheduler/testsuite/test_clock.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/scheduler/testsuite/test_clock.c b/src/scheduler/testsuite/test_clock.c index 85d746b8..fbbd873f 100644 --- a/src/scheduler/testsuite/test_clock.c +++ b/src/scheduler/testsuite/test_clock.c @@ -324,8 +324,7 @@ static void test_tlog_format_shows_frozen_virtual_time_not_infotime(void) char buff[256]; int rc; const uint64_t FROZEN_NS = 2000000000ULL * TEST_NSEC_PER_SEC; - /* 2033-05-18ish -- exact date not asserted; only that it is NOT the - * info->time value below. */ + /* 2033-05-18 03:33:20 UTC -- asserted exactly below. */ memset(&core, 0, sizeof(core)); set_clock_atoms(&core, FROZEN_NS, test_monotonic_ns(), 0, 1); @@ -348,10 +347,14 @@ static void test_tlog_format_shows_frozen_virtual_time_not_infotime(void) rc = call_format(buff, sizeof(buff), &info, NULL, "hello %d", 7); TEST_ASSERT_TRUE(rc > 0); TEST_ASSERT_NOT_NULL(strstr(buff, "hello 7")); - TEST_ASSERT_NULL_MESSAGE( - strstr(buff, "1999"), - "formatted log line must NOT show info->time's wall-clock year " - "while the virtual clock is frozen"); + /* Only the timestamp field is checked: the rest of the line carries + * getpid(), which itself contains "1999" for some PIDs (bug-1924). + * FROZEN_NS is 2000000000 s after the epoch, formatted with gmtime_r + * (core_clock.c ns_to_tlog_time), so the field is exact. */ + TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE( + "[2033-05-18 03:33:20,000] ", buff, 26, + "formatted log line must show the frozen virtual time, not " + "info->time's wall-clock time"); xce_core_set_active_for_logging(NULL); }