From 4b4752d66cfdb45d9d5bcaa3c7bb132c35b591f4 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 17:13:31 -0300 Subject: test: review of the mky port: the monkey's child exits 3 (a harness failure the parent reports) when its run errors out, as when a fresh session's /index will not parse or its log refuses `follow new`, where it exited 1 with no failure line and the parent took it for a clean run (both breaks passed the smoke before); /index's blank line unparsable again, as Python's splitlines saw it (tokenizing skipped it); served_lines' fourth self-check back (a piece that fills its Twrite goes on), its room a parameter again; the port checked against nine breaks of the reviewer's own, each failing: /index ending in a blank line (harness, now), log's `follow new` refused (harness, now), /pane's readdir listing new twice (chunked equals whole), a repeat counted (x+2) (one failure rule's upper bound, at 3x3000 steps, not the smoke), a held name's fault no longer said by its write (close runs only line files, at 3x3000 steps), a panic on writing 1 to scroll (a crash, shrunk 188 -> 1 op), /screen answering .again (a hang), pty/data swallowing ^U (all three terminal cases), a terminal's body from the active screen alone (history, raw key); behaviour, process, fs-unit and core tests and agent_session_test.py pass Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/monkey9p.zig | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/monkey9p.zig b/test/monkey9p.zig index 03c42f2a..45c5d12f 100644 --- a/test/monkey9p.zig +++ b/test/monkey9p.zig @@ -588,7 +588,9 @@ fn removeFile(a: Allocator, dir: []const u8, name: []const u8) void { fn serialsOf(a: Allocator, index: []const u8) ![]u32 { var out: std.ArrayList(u32) = .empty; - var lines = std.mem.tokenizeScalar(u8, index, '\n'); + if (index.len == 0) return out.items; + // A blank line is unparsable too, as Python's splitlines saw it. + var lines = std.mem.splitScalar(u8, if (index[index.len - 1] == '\n') index[0 .. index.len - 1] else index, '\n'); while (lines.next()) |line| { var it = std.mem.tokenizeAny(u8, line, " \t"); try out.append(a, std.fmt.parseInt(u32, it.next() orelse return error.Unparsable, 10) catch return error.Unparsable); @@ -711,7 +713,7 @@ fn clunk(c: *Ctx, a: Allocator, res: *Res, f: *Fid, path: []const u8) !bool { /// unended tail of a piece shorter than a Twrite holds, or of one not a /// multiple of 4096 bytes, as acme takes each write. An upper bound: the /// tree now waits for the newline whatever a piece's size. -fn servedLines(a: Allocator, data: []const u8, sizes: []const usize) []const []const u8 { +fn servedLines(a: Allocator, data: []const u8, sizes: []const usize, room_: usize) []const []const u8 { var lines: std.ArrayList([]const u8) = .empty; var pending: []const u8 = ""; var at: usize = 0; @@ -723,7 +725,7 @@ fn servedLines(a: Allocator, data: []const u8, sizes: []const usize) []const []c lines.append(a, pending[0..nl]) catch oom(); pending = pending[nl + 1 ..]; } - if (pending.len > 0 and piece.len < room and piece.len % 4096 != 0) { + if (pending.len > 0 and piece.len < room_ and piece.len % 4096 != 0) { lines.append(a, pending) catch oom(); pending = ""; } @@ -738,8 +740,11 @@ fn selfCheck(a: Allocator) void { .{ "ab\n", &[_]usize{ 1, 1, 1 }, &[_][]const u8{ "a", "b", "" } }, .{ "ab\ncd", &[_]usize{ 3, 2 }, &[_][]const u8{ "ab", "cd" } }, }; + // A piece that fills its Twrite goes on into the next. + const full = servedLines(a, "abcd", &.{ 2, 2 }, 2); + if (full.len != 1 or !std.mem.eql(u8, full[0], "abcd")) @panic("servedLines"); inline for (cases) |case| { - const got = servedLines(a, case[0], case[1]); + const got = servedLines(a, case[0], case[1], room); if (got.len != case[2].len) @panic("servedLines"); for (got, case[2]) |g, w| if (!std.mem.eql(u8, g, w)) @panic("servedLines"); } @@ -751,7 +756,7 @@ fn selfCheck(a: Allocator) void { /// Edit block whose text never ended runs, and fails, at the close. fn allowances(a: Allocator, res: *Res, path: []const u8, data: []const u8, sizes: []const usize) void { const b = base(path); - const served = servedLines(a, data, sizes); + const served = servedLines(a, data, sizes, room); var n: usize = 0; var lines: usize = 0; for (served) |line| { @@ -1539,7 +1544,7 @@ fn spawn(gpa: Allocator, seed: u64, steps: usize, only: ?[]const usize, verbose: else null; if (lost) |why| { - if (!quiet) std.debug.print("{s}[seed {d} step {d}] FAIL {s}\n", .{ if (sig != 0) said.items else "", seed, last_step, why }); + if (!quiet) std.debug.print("{s}[seed {d} step {d}] FAIL {s}\n", .{ if (sig != 0 or code > 1) said.items else "", seed, last_step, why }); try found.append(gpa, .{ .step = last_step, .sig = try gpa.dupe(u8, why) }); } return found.toOwnedSlice(gpa); @@ -1647,7 +1652,13 @@ pub fn main(init: std.process.Init) !void { var check: std.heap.ArenaAllocator = .init(gpa); selfCheck(check.allocator()); check.deinit(); - std.process.exit(try fuzz(gpa, if (seeds.items.len > 0) seeds.items[0] else 1, steps orelse 1000, only, verbose, std.mem.span(root))); + // An error out of the run (a fresh session's /index unparsable, its + // log refusing `follow new`) is a harness failure, not exit 1 with no + // failure line, which the parent would take for a clean run. + std.process.exit(fuzz(gpa, if (seeds.items.len > 0) seeds.items[0] else 1, steps orelse 1000, only, verbose, std.mem.span(root)) catch |err| { + std.debug.print("mky error {t}\n", .{err}); + std.process.exit(3); + }); } if (smoke) { // A short fixed-seed run that fails on any failure. -- cgit v1.3