summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 17:07:16 -0300
committerGabriel Schneider <[email protected]>2026-11-04 17:11:04 -0300
commitb5fa0b7e8f7d69dc34e3e832eaf4f56805e78dd2 (patch)
treeec3266b31ad06128f31010ebb13b2008f2a7f145 /test
parent6bcb18e021a09d51539e628106a594748637ead2 (diff)
downloadpardes-b5fa0b7e8f7d69dc34e3e832eaf4f56805e78dd2.tar.gz
pardes-b5fa0b7e8f7d69dc34e3e832eaf4f56805e78dd2.zip
test: review of the fsb port: the held ctl line (no newline, 20000 bytes, run at the close, its failure in the log) moved to T1 (test/behaviour/limits.zig), the process case dropped from test/process/tree.zig; the 256-byte-frame listing checked name by name (entry-00 to entry-23), not by count and prefix; the daemon cases (a killed tty editor, a signalled session) wait for the daemon before their root is removed on a failure's way out too, which left an empty /tmp/pardes-process-* root; each port checked to fail against a further nine breaks ($winid never exported, the dead-socket sweep skipped, the restore record renamed, Unmount let go with a pane open on the mount, /screen re-rendered on a later read, Find's miss reworded, the socket never unlinked on a signal, a closed open's held line dropped, a body's truncate ignored, a Python block given one Enter); behaviour, process, fs-unit and core tests and the rest of fs.py pass
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
-rw-r--r--test/behaviour/limits.zig11
-rw-r--r--test/process/flags.zig4
-rw-r--r--test/process/tree.zig28
3 files changed, 20 insertions, 23 deletions
diff --git a/test/behaviour/limits.zig b/test/behaviour/limits.zig
index d84d4490..35dde65e 100644
--- a/test/behaviour/limits.zig
+++ b/test/behaviour/limits.zig
@@ -38,3 +38,14 @@ test "limits: a ctl line over 1 MiB is refused once, EINVAL, and its tail is not
// What came after the long line's newline ran.
try s.expect(s.at("/pane/{d}/body", .{n}), "");
}
+
+test "limits: a ctl line with no newline is held whatever its write's size, and runs at the close, its failure in the log" {
+ var s = try Session.initFile(std.testing.allocator, "x\n");
+ defer s.deinit();
+ const ctl = try s.hold(s.at("/pane/{d}/ctl", .{try s.focused()}), 1);
+ const line = "bogus" ++ @as([20000]u8, @splat('x'));
+ try std.testing.expectEqual(@as(u16, 0), try s.writeFid(ctl, line));
+ try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), "ctl: unknown control message") == null);
+ s.clunk(ctl);
+ try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), "ctl: unknown control message") != null);
+}
diff --git a/test/process/flags.zig b/test/process/flags.zig
index 2ae8d0c7..a6797901 100644
--- a/test/process/flags.zig
+++ b/test/process/flags.zig
@@ -701,6 +701,8 @@ fn killedTty(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
const a = arena.allocator();
var d = try process.Detached.start(gpa, exe, "killed", .{});
defer d.deinit();
+ // Before the deinit, a failure's way out too: else the root comes back.
+ defer daemonGone(&d);
// Killed with SIGTERM or SIGHUP, a tty editor puts its terminal back
// (main screen, cooked mode) before it dies, and its 9P socket goes
// with it. One a dead editor left (no process has its pid) is swept at
@@ -761,6 +763,7 @@ fn signalCleansUp(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
for ([_]libc.SIG{ .TERM, .INT, .HUP }) |first| {
var d = try process.Detached.start(gpa, exe, "sig", .{ .env = &.{.{ "PARDES_DAEMON", "on" }} });
defer d.deinit();
+ defer daemonGone(&d);
try std.testing.expect(d.exists("pardes-9p-sig.sock"));
var sig = first;
if (sig == .HUP) {
@@ -773,6 +776,5 @@ fn signalCleansUp(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
const deadline = process.nowMs() + 5_000;
while (d.exists("pardes-9p-sig.sock") and process.nowMs() < deadline) process.nap(10);
try check(!d.exists("pardes-9p-sig.sock"), "{t}: the socket left", .{first});
- daemonGone(&d);
}
}
diff --git a/test/process/tree.zig b/test/process/tree.zig
index c7b9e657..d0a8173d 100644
--- a/test/process/tree.zig
+++ b/test/process/tree.zig
@@ -9,7 +9,6 @@ const check = process.check;
pub const cases = .{
.{ "tree: the root lists its files and not self; /os reads the disk, `..` taken as a walk takes it, and writes it truncated", rootAndOs },
.{ "tree: a client of 256-byte frames lists /os whole, a dangling link left out; one of 64 KiB is agreed", frames },
- .{ "tree: a ctl line with no newline is held whatever its write's size, and runs at the close, its failure in the log", heldLine },
.{ "tree: /screen freezes at its open; a dozen connections in turn each read a body", frozenScreen },
.{ "tree: a Look at a relative name finds the disk's file first; /n/self is the session's tree, /n/os the disk", looks },
.{ "tree: names up to 255 bytes list, read, write and open through /os and /n/os, and a directory lists them", longNames },
@@ -58,7 +57,12 @@ fn frames(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
defer small.deinit(gpa);
const names = try small.list(a, try std.fmt.allocPrint(a, "/os{s}/listing", .{d.root()}));
try check(names.len == 24, "listed {d}: {any}", .{ names.len, names });
- for (names) |n| try check(std.mem.startsWith(u8, n, "entry-"), "listed {s}", .{n});
+ for (0..24) |i| {
+ const want = try std.fmt.allocPrint(a, "entry-{d:0>2}", .{i});
+ for (names) |n| {
+ if (std.mem.eql(u8, n, want)) break;
+ } else return error.NotListed;
+ }
const big = try Conn.dial(gpa, d.socket());
defer big.deinit(gpa);
try std.testing.expectEqual(@as(u32, 65536), big.msizeAgreed());
@@ -66,26 +70,6 @@ fn frames(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
extern "c" fn symlink(target: [*:0]const u8, path: [*:0]const u8) c_int;
-fn heldLine(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
- var arena = std.heap.ArenaAllocator.init(gpa);
- defer arena.deinit();
- const a = arena.allocator();
- var d = try process.Detached.start(gpa, exe, "held", .{});
- defer d.deinit();
- // 64 KiB frames: a line with no newline is held whatever the size of its
- // write (a mount cuts lines anywhere), and runs at the close.
- const c = try Conn.dial(gpa, d.socket());
- defer c.deinit(gpa);
- const ctl = try c.hold("/pane/1/ctl", 1);
- const line = try a.alloc(u8, 5 + 20000);
- @memcpy(line[0..5], "bogus");
- @memset(line[5..], 'x');
- _ = try c.writeFid(ctl, 0, line);
- try check(!has(try c.read(a, "/log"), "ctl: unknown control message"), "ran before the close", .{});
- c.clunk(ctl);
- try check(has(try c.read(a, "/log"), "ctl: unknown control message"), "never ran", .{});
-}
-
fn frozenScreen(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
var arena = std.heap.ArenaAllocator.init(gpa);
defer arena.deinit();