Skip to content

Commit 675fdf3

Browse files
fix(store): address QA round 1 findings
- Wrap bulk_crash_recovery test and its POSIX includes with #ifndef _WIN32 guards to fix compilation failure on Windows (fork/waitpid unavailable) - Add negative assertion that the uncommitted "crashed" row is absent after crash recovery, completing the test's correctness verification Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8dd490b commit 675fdf3

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

tests/test_store_bulk.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
#include <stdio.h>
1919
#include <stdlib.h>
2020
#include <string.h>
21+
#ifndef _WIN32
2122
#include <unistd.h>
2223
#include <sys/wait.h>
24+
#endif
2325

2426
/* ── Helpers ──────────────────────────────────────────────────── */
2527

@@ -108,7 +110,10 @@ TEST(bulk_pragma_end_wal_invariant) {
108110
/* Simulate a crash mid-bulk-write: fork a child that calls begin_bulk, opens
109111
* an explicit transaction, and then calls _exit() without committing or calling
110112
* end_bulk. The parent verifies the database is still openable and that
111-
* committed baseline data is intact. */
113+
* committed baseline data is intact and uncommitted data is absent.
114+
*
115+
* This test uses fork()/waitpid() and is therefore POSIX-only. */
116+
#ifndef _WIN32
112117
TEST(bulk_crash_recovery) {
113118
char db_path[256];
114119
make_temp_path(db_path, sizeof(db_path));
@@ -148,15 +153,23 @@ TEST(bulk_crash_recovery) {
148153
ASSERT_STR_EQ(p.name, "baseline");
149154
cbm_project_free_fields(&p);
150155

156+
/* Uncommitted "crashed" write must NOT appear after recovery. */
157+
cbm_project_t p2 = {0};
158+
int rc2 = cbm_store_get_project(recovered, "crashed", &p2);
159+
ASSERT_NEQ(rc2, CBM_STORE_OK); /* row must be absent */
160+
151161
cbm_store_close(recovered);
152162
cleanup_db(db_path);
153163
PASS();
154164
}
165+
#endif /* _WIN32 */
155166

156167
/* ── Suite ──────────────────────────────────────────────────────── */
157168

158169
SUITE(store_bulk) {
159170
RUN_TEST(bulk_pragma_wal_invariant);
160171
RUN_TEST(bulk_pragma_end_wal_invariant);
172+
#ifndef _WIN32
161173
RUN_TEST(bulk_crash_recovery);
174+
#endif
162175
}

0 commit comments

Comments
 (0)