test: write Windows fixtures byte-exactly

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
This commit is contained in:
Martin Vogel committed 2026-07-13 04:17:58 +02:00
1 parent eb203ff6fa
commit be1e98fd99
3 files changed
+19 -3

No files matched your search

+1 -1
View File
@@ -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);
+2 -2
View File
@@ -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;
}
+16
View File
@@ -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,