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) <noreply@anthropic.com>
This commit is contained in:
parent
9b0284fab5
commit
e56f27f997
1 changed files with 9 additions and 6 deletions
|
|
@ -324,8 +324,7 @@ static void test_tlog_format_shows_frozen_virtual_time_not_infotime(void)
|
||||||
char buff[256];
|
char buff[256];
|
||||||
int rc;
|
int rc;
|
||||||
const uint64_t FROZEN_NS = 2000000000ULL * TEST_NSEC_PER_SEC;
|
const uint64_t FROZEN_NS = 2000000000ULL * TEST_NSEC_PER_SEC;
|
||||||
/* 2033-05-18ish -- exact date not asserted; only that it is NOT the
|
/* 2033-05-18 03:33:20 UTC -- asserted exactly below. */
|
||||||
* info->time value below. */
|
|
||||||
|
|
||||||
memset(&core, 0, sizeof(core));
|
memset(&core, 0, sizeof(core));
|
||||||
set_clock_atoms(&core, FROZEN_NS, test_monotonic_ns(), 0, 1);
|
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);
|
rc = call_format(buff, sizeof(buff), &info, NULL, "hello %d", 7);
|
||||||
TEST_ASSERT_TRUE(rc > 0);
|
TEST_ASSERT_TRUE(rc > 0);
|
||||||
TEST_ASSERT_NOT_NULL(strstr(buff, "hello 7"));
|
TEST_ASSERT_NOT_NULL(strstr(buff, "hello 7"));
|
||||||
TEST_ASSERT_NULL_MESSAGE(
|
/* Only the timestamp field is checked: the rest of the line carries
|
||||||
strstr(buff, "1999"),
|
* getpid(), which itself contains "1999" for some PIDs (bug-1924).
|
||||||
"formatted log line must NOT show info->time's wall-clock year "
|
* FROZEN_NS is 2000000000 s after the epoch, formatted with gmtime_r
|
||||||
"while the virtual clock is frozen");
|
* (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);
|
xce_core_set_active_for_logging(NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue