From 7e6834ba5eff5c0e61891ec1935e5e0ca8291c2f Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 29 Oct 2026 12:32:23 -0300 Subject: tests on FreeBSD: Linux's /proc/1 fixtures, the builtins lists, daemon.py and fs.py without /proc - The refusing directory some tests name is Linux's /proc/1/root: that part skips elsewhere. The committed builtins-*.json are Linux builds' (Tty9p): their check skips, and a key the docs give a word this build leaves out is found in the other's list. - kitty: a shared memory object is sized before it is written (FreeBSD's write does not grow it); a FIFO in /dev/shm is Linux's case. - daemon.py asks ps and procstat where there is no /proc, and finds bash on PATH. fs.py runs printenv once a name, and skips two permission checks as root, who searches and writes anywhere. Co-Authored-By: Claude Opus 5.5 --- src/builtins_json.zig | 4 +++- src/config.zig | 5 ++++- src/fs.zig | 3 ++- src/ninep/ctl.zig | 15 ++++++++++----- 4 files changed, 19 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/builtins_json.zig b/src/builtins_json.zig index 4440130d..3598a3e2 100644 --- a/src/builtins_json.zig +++ b/src/builtins_json.zig @@ -66,7 +66,9 @@ pub fn write(w: *std.Io.Writer) !void { } test "docs/typ/builtins-.json is what the registry says now" { - // a terminal build checks its file, a window build its own + // a terminal build checks its file, a window build its own; both are + // Linux builds' lists (Tty9p is Linux's) + if (comptime @import("builtin").os.tag != .linux) return error.SkipZigTest; const file = switch (pardes.platform) { .tty => "builtins-tty.json", .gui => "builtins-gui.json", diff --git a/src/config.zig b/src/config.zig index 66b11c72..f0023193 100644 --- a/src/config.zig +++ b/src/config.zig @@ -2277,7 +2277,10 @@ const doc_typ = struct { for (std.enums.values(Builtin)) |b| if (leader_path.get(b)) |p| if (std.mem.eql(u8, p, path[0..n])) return true; for (leader_args) |la| if (std.mem.eql(u8, la.path, path[0..n])) return true; - return false; + // A word this build leaves out (Tty9p off Linux) keeps its leader in the other's. + var buf: [96]u8 = undefined; + const needle = std.fmt.bufPrint(&buf, "\"leader\": \"{s}\"", .{k}) catch return false; + return std.mem.indexOf(u8, other_build, needle) != null; } toks.reset(); while (toks.next()) |t| if (!bound(chord(t) orelse return false)) return false; diff --git a/src/fs.zig b/src/fs.zig index 08379697..9104c93f 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -708,7 +708,8 @@ pub fn deniedAbove(dir: []const u8) bool { } test "a directory under one that may not be searched or written is denied, one merely missing is not" { - try std.testing.expect(deniedAbove("/proc/1/root/x/y")); + // The refusing directory is Linux's /proc/1/root. + if (comptime @import("builtin").os.tag == .linux) try std.testing.expect(deniedAbove("/proc/1/root/x/y")); try std.testing.expect(!deniedAbove("/tmp/pardes-surely-missing-dir/a/b")); } diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 9cb96667..3176ebc8 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -4676,8 +4676,8 @@ test "pager answers its +Pager on the open that asked, whatever another client e try testing.expectEqualStrings("/tmp/+Pager", second_pane.file.?.path); try testing.expect(p.paneBySerial(paged) != null); _ = call(p, .{ .tag = 14, .op = .release, .node = pager, .handle = resolved, .opened = true }); - // One that may not be written is refused, permission denied. - try testing.expectEqual(E.PERM, wr(p, pager, "/proc/1\n").errno()); + // One that may not be written is refused, permission denied (Linux's /proc/1). + if (comptime @import("builtin").os.tag == .linux) try testing.expectEqual(E.PERM, wr(p, pager, "/proc/1\n").errno()); // One directory a write, absolute, and there. try testing.expectEqual(E.INVAL, wr(p, pager, "/a\n/b\n").errno()); // One directory an open: one refused is not followed by another, as a @@ -4786,8 +4786,11 @@ test "a command pane an exec open was answered is leased to it while it stays op test "a Save whose directory is missing because one above refuses says permission denied, not no such directory" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); - p.saveFailed(0, "/proc/1/root/x/f.txt", error.FileNotFound); - try testing.expect(th.logHas(p, "Save /proc/1/root/x/f.txt: permission denied")); + // The refusing directory is Linux's /proc/1/root. + if (comptime @import("builtin").os.tag == .linux) { + p.saveFailed(0, "/proc/1/root/x/f.txt", error.FileNotFound); + try testing.expect(th.logHas(p, "Save /proc/1/root/x/f.txt: permission denied")); + } p.saveFailed(0, "/tmp/pardes-surely-missing-dir/f.txt", error.FileNotFound); try testing.expect(th.logHas(p, "no such directory")); } @@ -5036,8 +5039,10 @@ test "DumpDir refuses a relative directory and one that may not be written, up f defer p.deinit(); const root_ctl = @backingInt(tree.TopFile.ctl); try testing.expectEqual(E.INVAL, wr(p, root_ctl, "DumpDir dumps\n").errno()); - try testing.expectEqual(E.INVAL, wr(p, root_ctl, "DumpDir /proc/1/root/dumps\n").errno()); try testing.expectEqual(Status.ok, wr(p, root_ctl, "DumpDir /tmp/pardes-dumps-test\n").reply.status); + // The refusing directory is Linux's /proc/1/root. + if (comptime @import("builtin").os.tag != .linux) return; + try testing.expectEqual(E.INVAL, wr(p, root_ctl, "DumpDir /proc/1/root/dumps\n").errno()); p.fs.late_failure_len = 0; p.dumpFailed("/proc/1/root/x/pardes.dump.zon", error.FileNotFound); try testing.expect(std.mem.endsWith(u8, p.fs.late_failure[0..p.fs.late_failure_len], ": permission denied")); -- cgit v1.3