diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-05 16:26:07 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-05 22:03:21 -0300 |
| commit | 9b525aca9b1fc177873bc3a581bd2a7887bee63d (patch) | |
| tree | a902794d5ca75f0269f85db1485ab85ad455c8eb /test/behaviour | |
| parent | ce7273b3de52b3d42fedf21fc8cc96316ccab9ed (diff) | |
| download | pardes-9b525aca9b1fc177873bc3a581bd2a7887bee63d.tar.gz pardes-9b525aca9b1fc177873bc3a581bd2a7887bee63d.zip | |
ninep: a ctl write refused for a control character takes the line it is in with it, as one refused for its length does: the start an earlier write held, which ran at the clunk as a second err record for one failed write (the 9P monkey's seed 2, shrunk to zig build monkey-session -Dplatform=tui -- --seed 2 --steps 763 --only 761,762), and the rest the next write brings, through its newline (src/ninep/tree.zig writeLines, ninep's file, the one place); a T1 test pins it (test/behaviour/rules.zig, 'a write refused for a control character takes its line with it'), failing before on the third write, which ran the held start and the tail as one line; gates on tui: core-test 960/960, behaviour-test 238/238; monkey-session seeds 1 to 10 clean
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/rules.zig | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/behaviour/rules.zig b/test/behaviour/rules.zig index 8f5597ae..80f94406 100644 --- a/test/behaviour/rules.zig +++ b/test/behaviour/rules.zig @@ -18,6 +18,23 @@ test "rules: a control character in a write to any ctl refuses the whole write, try std.testing.expect(std.mem.indexOfScalar(u8, s.said, '\t') == null); } +test "rules: a write refused for a control character takes its line with it: the start a write before held, and the rest the next write brings" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + const ctl = try s.hold("/ctl", 1); + try std.testing.expectEqual(@as(u16, 0), try s.writeFid(ctl, "bogus")); + try std.testing.expectEqual(@as(u16, 22), try s.writeFid(ctl, "wo\x01rd")); + // The refused line's rest goes through its newline unread; what follows + // is a line of its own, which runs at the close. + try std.testing.expectEqual(@as(u16, 0), try s.writeFid(ctl, "tail\nnext")); + s.clunk(ctl); + const log = try s.read("/log"); + try std.testing.expectEqual(@as(usize, 2), std.mem.count(u8, log, "err ")); + try std.testing.expect(std.mem.indexOf(u8, log, "bogus") == null); + try std.testing.expect(std.mem.indexOf(u8, log, "tail") == null); + try std.testing.expect(std.mem.indexOf(u8, log, "\"next\"") != null); +} + test "rules: body reads at any offset and writes append; a stat says its length, and its version moves with each edit" { var s = try Session.initFile(std.testing.allocator, "one\ntwo\n"); defer s.deinit(); |
