diff options
Diffstat (limited to 'test/e2e_harness.zig')
| -rw-r--r-- | test/e2e_harness.zig | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/e2e_harness.zig b/test/e2e_harness.zig index 5a181b78..eaa19b43 100644 --- a/test/e2e_harness.zig +++ b/test/e2e_harness.zig @@ -366,6 +366,18 @@ pub const Harness = struct { }; /// Write a file (helper for test setup, raw libc). +pub fn appendFile(path: [*:0]const u8, data: []const u8) !void { + const fd = libc.open(path, .{ .ACCMODE = .WRONLY, .CREAT = true, .APPEND = true }, @as(libc.mode_t, 0o644)); + if (fd < 0) return error.OpenFailed; + defer _ = libc.close(fd); + var off: usize = 0; + while (off < data.len) { + const w = libc.write(fd, data[off..].ptr, data.len - off); + if (w <= 0) break; + off += @intCast(w); + } +} + pub fn writeFile(path: [*:0]const u8, data: []const u8) !void { const fd = libc.open(path, .{ .ACCMODE = .WRONLY, .CREAT = true, .TRUNC = true }, @as(libc.mode_t, 0o644)); if (fd < 0) return error.OpenFailed; |
