summaryrefslogtreecommitdiff
path: root/src/tape.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-08 23:49:04 -0300
committerGabriel Schneider <[email protected]>2026-11-09 01:28:28 -0300
commit174e031985db910b4907ba324d6fd12c67898a5a (patch)
tree5bcb0dbc1dbab457fcf4a4b95572a1631bb3ade1 /src/tape.zig
parent21277ffc6b08f458eb9a1210a3818e40b14293d2 (diff)
downloadpardes-174e031985db910b4907ba324d6fd12c67898a5a.tar.gz
pardes-174e031985db910b4907ba324d6fd12c67898a5a.zip
tests: monkey and replay are modes of the T1 runner and snapshot.zig goes: behaviour-test runs test/monkey9p.zig bare (its smoke), `-- --monkey <seeds>` drives an in-process session with test/monkey.zig's input (keys, leader bursts, the mouse, tiny resizes, over /kbdin, /mousein and Session.resize) hunting panics and hangs, `-- --replay` records each seed's sessions as a tape in memory and replays it (tape.replayBytes, replayMain's loop: three replicas and the dump), and `process-test -- --replay` records and replays the tty cases' real sessions as `zig build replay` did (with the addons it lacked, so images passes); the snap, snap-driver-test, monkey, monkey-test (it no longer compiled), replay and monkey-session steps, pardes-snap and build/snap.zig (now build/process.zig) go; checked: a counter outside the core bumped at the 40th update diverges every T1 seed and 89 of 103 old tapes, one bumped on terminal output diverges no T1 seed but 69 tty cases and 70 old tapes (why the tty replay stays), a panic on a window under 5x5 is found by the T1 monkey (seeds 1 8 17 20) and the old one (seed 13)
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'src/tape.zig')
-rw-r--r--src/tape.zig39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/tape.zig b/src/tape.zig
index 2354fb06..b1bcc31d 100644
--- a/src/tape.zig
+++ b/src/tape.zig
@@ -129,21 +129,20 @@ pub const Site = enum(u16) {
/// listed is a compile error (`call`). An error union is listed as
/// `anyerror!` its payload: an error goes by its name (walk.encode).
pub const results = .{
- void, bool,
- u32, i64,
- [8]u8, ?u64,
- []const u8, ?[]const u8,
- ?std.Io.File.Kind, ?pardes.filesystem.Resolved,
- pardes.filesystem.OsReadWrite, anyerror!pardes.filesystem.OsStat,
- anyerror![]const u8,
- anyerror![]u8, anyerror!void,
- terminal.Told, ?pardes.ctlfs.pty.Printed,
- @typeInfo(@TypeOf(terminal.greeting)).@"fn".return_type.?,
+ void, bool,
+ u32, i64,
+ [8]u8, ?u64,
+ []const u8, ?[]const u8,
+ ?std.Io.File.Kind, ?pardes.filesystem.Resolved,
+ pardes.filesystem.OsReadWrite, anyerror!pardes.filesystem.OsStat,
+ anyerror![]const u8, anyerror![]u8,
+ anyerror!void, terminal.Told,
+ ?pardes.ctlfs.pty.Printed, @typeInfo(@TypeOf(terminal.greeting)).@"fn".return_type.?,
[]pardes.Stream.Batch,
- // What only the authority holds (`authority`): a closed pane's record,
- // Recent's entry for a closed jump, the closed panes' names.
- ?@import("Store.zig").Record, ?@import("recent.zig").Entry,
- []const @import("Store.zig").Named,
+ // What only the authority holds (`authority`): a closed pane's record,
+ // Recent's entry for a closed jump, the closed panes' names.
+ ?@import("Store.zig").Record,
+ ?@import("recent.zig").Entry, []const @import("Store.zig").Named,
@import("Kind.zig").Outcome,
};
@@ -1253,6 +1252,14 @@ pub fn replayMain(io: std.Io, path: []const u8) u8 {
std.debug.print("replay: cannot read {s}: {t}\n", .{ path, err });
return 2;
};
+ return if (replayBytes(gpa, bytes, path, libc.getenv("PARDES_REPLAY_DUMP") != null)) 0 else 1;
+}
+
+/// `bytes`, a tape named `path`, replayed into three replicas, each digest
+/// checked, and with `dump` the session's dump at its end loaded to its
+/// digest and dumped to its bytes again: true when none diverged. An
+/// in-process session's tape too (test/session.zig's replayTape).
+pub fn replayBytes(gpa: std.mem.Allocator, bytes: []const u8, path: []const u8, dump: bool) bool {
const runs = [_]struct { name: []const u8, headless: bool }{
.{ .name = "first", .headless = false },
// The first replica's memory is still held: this one's lies elsewhere.
@@ -1262,7 +1269,7 @@ pub fn replayMain(io: std.Io, path: []const u8) u8 {
var failed = false;
for (runs) |run| {
var t: Tape = .{ .gpa = gpa, .replay = true, .headless = run.headless, .scratch = .init(gpa), .arena = .init(gpa) };
- t.dump_check = std.mem.eql(u8, run.name, "first") and libc.getenv("PARDES_REPLAY_DUMP") != null;
+ t.dump_check = std.mem.eql(u8, run.name, "first") and dump;
on = &t;
defer on = null;
_ = replayUnit(&t, bytes);
@@ -1279,7 +1286,7 @@ pub fn replayMain(io: std.Io, path: []const u8) u8 {
} else std.debug.print("replay {s}: {s} replica: {d} digests agree\n", .{ path, run.name, t.digests });
if (t.dump_check and t.diverged == null) std.debug.print("replay {s}: {d} dumps loaded to their digests and dumped to their bytes again ({d} bytes)\n", .{ path, t.dumps, t.dump_bytes });
}
- return if (failed) 1 else 0;
+ return !failed;
}
test "a syscall that is no site, made replaying, diverges the replay and poisons a speculation" {