Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

test: write Windows fixtures byte-exactly

Martin Vogelbe1e98fd99ad
diff --git a/tests/test_cli.c b/tests/test_cli.c
index 04412f3aa..2d4f31ca0 100644
--- a/tests/test_cli.c
+++ b/tests/test_cli.c
@@ -30,7 +30,7 @@
/* Helper: create a file with content */
static int write_test_file(const char *path, const char *content) {
- FILE *f = fopen(path, "w");
+ FILE *f = cbm_fopen(path, "wb");
if (!f)
return -1;
fprintf(f, "%s", content);
diff --git a/tests/test_helpers.h b/tests/test_helpers.h
index f7d2ae6de..0fce50e47 100644
--- a/tests/test_helpers.h
+++ b/tests/test_helpers.h
@@ -54,7 +54,7 @@ static inline int th_write_file(const char *path, const char *content) {
cbm_mkdir_p(dir, 0755);
}
- FILE *f = fopen(path, "w");
+ FILE *f = cbm_fopen(path, "wb");
if (!f) {
return -1;
}
@@ -67,7 +67,7 @@ static inline int th_write_file(const char *path, const char *content) {
/* Append content to a file. */
static inline int th_append_file(const char *path, const char *content) {
- FILE *f = fopen(path, "a");
+ FILE *f = cbm_fopen(path, "ab");
if (!f) {
return -1;
}
diff --git a/tests/test_security.c b/tests/test_security.c
index e8aa1dc27..34676620e 100644
--- a/tests/test_security.c
+++ b/tests/test_security.c
@@ -49,6 +49,21 @@ static char *security_read_file(const char *path) {
return content;
}
+static void security_normalize_crlf(char *content) {
+ if (!content) {
+ return;
+ }
+ char *read_cursor = content;
+ char *write_cursor = content;
+ while (*read_cursor) {
+ if (read_cursor[0] == '\r' && read_cursor[1] == '\n') {
+ read_cursor++;
+ }
+ *write_cursor++ = *read_cursor++;
+ }
+ *write_cursor = '\0';
+}
+
TEST(vendored_integrity_manifest_is_relocatable_and_fail_closed) {
FILE *checksums = fopen("scripts/vendored-checksums.txt", "r");
ASSERT_NOT_NULL(checksums);
@@ -68,6 +83,7 @@ TEST(vendored_integrity_manifest_is_relocatable_and_fail_closed) {
char *script = security_read_file("scripts/security-vendored.sh");
ASSERT_NOT_NULL(script);
+ security_normalize_crlf(script);
ASSERT_NOT_NULL(strstr(script, "MISSING=$((MISSING + 1))\n CONTENT_DRIFT=1"));
ASSERT_NOT_NULL(
strstr(script,