summaryrefslogtreecommitdiff
path: root/src/tape.zig
diff options
context:
space:
mode:
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" {