Skip to content

Commit adb49b3

Browse files
committed
test(mcp): snapshot the query-branch DB state before suite teardown
CI's tsan and lsan-macos runs failed the mutation-guard suite on ASSERT(cbm_file_exists(db_path)) at the guard-balance test, while the behavior suite passed everywhere. The assertion ran after the test's own teardown: cleanup_project_db() unlinks the same db path before the assertion block, and the manage_adr branch above replants and quarantines that very path, so the late file check observed the test's cleanup, not the query-only resolve it was meant to pin. Whether it tripped depended on unlink/visibility timing, which is why it surfaced only under some schedulers and never in the single-suite local runs. Capture cbm_file_exists() into query_db_left_in_place right after the query branch completes, before anything replants or removes the file, and assert on that snapshot. Signed-off-by: 周文瑄 <zhouwx1997@126.com>
1 parent 240dc81 commit adb49b3

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎tests/test_mcp.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7595,6 +7595,11 @@ TEST(tool_corrupt_store_cleanup_guard_is_balanced_and_not_nested) {
75957595
mcp_find_corrupt_backups(cache, project, query_backup_path, sizeof(query_backup_path));
75967596
bool query_quarantined =
75977597
!cbm_file_exists(db_path) && query_backup_count == 1 && query_backup_path[0] != '\0';
7598+
/* Snapshot the on-disk state HERE: the manage_adr branch below replants
7599+
* and then quarantines this same path, and the suite's cleanup unlinks
7600+
* it before the assertions run — a later cbm_file_exists() would observe
7601+
* that teardown, not the query-only resolve this check pins. */
7602+
bool query_db_left_in_place = cbm_file_exists(db_path);
75987603

75997604
/* Replant the same deterministic corruption to exercise manage_adr's
76007605
* already-held lease independently from the query server above. */
@@ -7628,7 +7633,7 @@ TEST(tool_corrupt_store_cleanup_guard_is_balanced_and_not_nested) {
76287633
* and its sidecars stay in place, and the reply names the corruption
76297634
* instead of "project not found". */
76307635
ASSERT_FALSE(query_quarantined);
7631-
ASSERT_TRUE(cbm_file_exists(db_path));
7636+
ASSERT_TRUE(query_db_left_in_place);
76327637
ASSERT_TRUE(query_reports_corruption);
76337638
ASSERT_EQ(query_probe.begin_count, 0);
76347639
ASSERT_EQ(query_probe.end_count, 0);

0 commit comments

Comments
 (0)