summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/behaviour/panes.zig2
-rw-r--r--test/behaviour/settings.zig8
-rw-r--r--test/output.zig2
-rw-r--r--test/replicas.zig53
-rw-r--r--test/terminal.zig7
5 files changed, 61 insertions, 11 deletions
diff --git a/test/behaviour/panes.zig b/test/behaviour/panes.zig
index 67155776..dcde9c4d 100644
--- a/test/behaviour/panes.zig
+++ b/test/behaviour/panes.zig
@@ -888,7 +888,7 @@ test "panes: truncating body empties it, and a stat says the length after" {
}
test "panes: a rename colours a source its new name's language names, its text unchanged" {
- if (!@import("pardes_config").syntax_highlighting) return error.SkipZigTest;
+ if (@import("pardes_options").grammars == .disabled) return error.SkipZigTest;
var s = try Session.initFile(std.testing.allocator, "fn check() void {}\n");
defer s.deinit();
const n = try s.focused();
diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig
index 66cd97df..cacee701 100644
--- a/test/behaviour/settings.zig
+++ b/test/behaviour/settings.zig
@@ -37,7 +37,7 @@ test "settings: Pet is the window's: a terminal's view refuses it; a window take
defer s.deinit();
// Which build, from its options, not from the answer: a terminal's view
// taking Pet must fail here, not pass as a window.
- if (comptime @import("pardes_config").platform == .gui) {
+ if (comptime @import("pardes_options").platform == .gui) {
try std.testing.expectEqualStrings("Pet off", try setting(&s, "Pet"));
try s.write("/ctl", "Pet cat\n");
try std.testing.expectEqualStrings("Pet cat", try setting(&s, "Pet"));
@@ -106,7 +106,7 @@ test "settings: a bad setting value is quoted, so two different bad values log a
test "settings: a setting this frontend cannot show says GUI-only, never run as a command, and DumpDir reads back" {
var s = try Session.initFile(std.testing.allocator, "x\n");
defer s.deinit();
- if (comptime @import("pardes_config").platform != .gui) {
+ if (comptime @import("pardes_options").platform != .gui) {
_ = try s.refused("/ctl", "GripWidth 120\n");
try std.testing.expectEqualStrings("GripWidth is GUI-only, invalid here \"GripWidth\"", s.said);
// A builtin the GUI alone has, written to a ctl or an exec, never
@@ -158,7 +158,7 @@ test "settings: Back and Forward written to exec keep to the focused file" {
});
}
-const syntax = @import("pardes_config").syntax_highlighting;
+const syntax = @import("pardes_options").grammars != .disabled;
/// The style /screen draws the cell `into` cells into the first place
/// `text` is drawn.
@@ -314,7 +314,7 @@ test "settings: the user's startup file loads clean, every word of it known and
const ctl = try s.read("/ctl");
for ([_][]const u8{ "Theme monokai_pro_classic\n", "CallstackDepth 64\n", "InactiveDim 5\n", "Shell fish\n", "JumpTrail on\n", "LocationsConfig context:4 tscontext:on tslocations:on layout:stacked\n" }) |line| try expectHas(ctl, line);
// The window's words, which a terminal's view leaves to the window.
- const window = @import("pardes_config").platform == .gui;
+ const window = @import("pardes_options").platform == .gui;
for ([_][2][]const u8{ .{ "GripWidth", "110" }, .{ "CursorBlink", "off" }, .{ "WindowOpacity", "100" }, .{ "TaglineSize", "80" }, .{ "Pet", "frog" } }) |w|
try expectHas(ctl, if (window) s.at("\n{s} {s}\n", .{ w[0], w[1] }) else s.at("\n# {s} unsupported\n", .{w[0]}));
}
diff --git a/test/output.zig b/test/output.zig
index 4b9e7678..c5ddddd5 100644
--- a/test/output.zig
+++ b/test/output.zig
@@ -786,7 +786,7 @@ test "identical result refresh keeps warm content caches without allocation" {
const index = try panes.File.lineIndex(p.gpa, file);
const styles = try std.testing.allocator.dupe(u8, file.highlights);
defer std.testing.allocator.free(styles);
- if (@import("pardes_config").syntax_zig_grammar) try std.testing.expect(styles.len > 0);
+ if (@import("pardes_options").grammars != .disabled) try std.testing.expect(styles.len > 0);
const revision = file.revision;
const saved_revision = file.saved_revision;
const body_ptr = file.content.ptr;
diff --git a/test/replicas.zig b/test/replicas.zig
index 910c6e57..70edea75 100644
--- a/test/replicas.zig
+++ b/test/replicas.zig
@@ -53,6 +53,10 @@ const gpa = std.heap.c_allocator;
pub const std_options: std.Options = .{ .log_level = .warn };
extern "c" fn setenv(name: [*:0]const u8, value: [*:0]const u8, overwrite: c_int) c_int;
var trace = false;
+/// `--bytes`: its clients are replicas of the bytes kind, each terminal fed
+/// the pty's bytes its units carry into an emulator of its own, joined from
+/// a dump with every emulator whole (core/replica.zig `Peers.bytes`).
+var bytes_kind = false;
/// The PDF the soak opens (`--pdf`), absolute.
var pdf_path: ?[]const u8 = null;
const frame_us = 16_667;
@@ -791,6 +795,9 @@ const Soak = struct {
/// encoding cost.
framed: bool = false,
encode_ns: u64 = 0,
+ /// The session's pty told the answer to the program's kitty query
+ /// (`questions`): once, whatever the clients.
+ kitty_answers: u32 = 0,
/// A Peer's queue, swapped out as its writer swaps it (the Peers'
/// allocator's).
sending: std.ArrayListUnmanaged(u8) = .empty,
@@ -809,6 +816,9 @@ const Soak = struct {
fn ptyWrite(ctx: ?*anyopaque, id: pardes.Pane.Id, bytes: []const u8) void {
const pane = id.index();
const s = of(ctx);
+ // Only the session's emulator answers its program: a client's
+ // answers are its tape's, never written (`questions`).
+ if (std.mem.indexOf(u8, bytes, "\x1b_Gi=31;OK") != null) s.kitty_answers += 1;
s.echo.append(gpa, .{ .pane = pane, .bytes = gpa.dupe(u8, bytes) catch return }) catch {};
}
@@ -873,6 +883,7 @@ const Soak = struct {
pub fn open(s: *Soak, l: *SessionLoop) !pardes.Host {
s.l = l;
l.peers.threads = false;
+ l.peers.bytes = bytes_kind;
l.peers.flushed = .{ .ctx = s, .f = flushed };
const host: pardes.Host = .{ .ctx = s, .vtable = &vtable };
l.core.host = host;
@@ -941,6 +952,9 @@ const Soak = struct {
const at: u64 = switch (c) {
0, 1 => s.random.uintLessThan(u64, 100_000),
2 => 1_200_000,
+ // One joins in the middle of the flood, its emulators loaded
+ // whole and every other side's reloaded.
+ 3 => if (bytes_kind) flood_at + 100_000 else 2_300_000,
else => 2_000_000 + c * 100_000,
};
try net.send(.{ .at = at, .n = 0, .kind = .dial, .who = @intCast(c + 1), .bytes = &.{} });
@@ -1412,6 +1426,11 @@ const Soak = struct {
}
const rp = try replica.Replica.initDump(gpa, cl.id, cl.view, m.bytes, .{ .cols = cl.cols, .rows = cl.rows, .distrusted = &cl.distrusted });
cl.r = rp;
+ // Its terminals its own emulators, fed what the units carry.
+ if (bytes_kind) {
+ rp.t.screen_state = false;
+ rp.core().echo = null;
+ }
rp.stats.samples = true;
rp.t.local_files = true;
rp.echo.now = m.at * 1000;
@@ -1449,6 +1468,11 @@ const Soak = struct {
totals.flood_us += s.flood_end -| flood_at;
for (s.flood_deltas[0..s.clients.len]) |d| totals.flood_deltas += d;
const want = pardes.tape.digestOf(core);
+ if (bytes_kind) std.debug.print("seed {d} rtt {d} ms: a join's step at worst {d} us (the session's reloads and its dump), the last dump {d} KB ({d} KB of state)\n", .{ s.r.seed, s.r.rtt_ms, s.l.peers.join_ns / 1000, s.l.peers.dump_bytes >> 10, s.l.peers.state_bytes >> 10 });
+ if (bytes_kind and s.kitty_answers != 1) {
+ totals.unequal += 1;
+ std.debug.print("seed {d} rtt {d} ms: the program's kitty query was answered {d} times on the session's pty\n", .{ s.r.seed, s.r.rtt_ms, s.kitty_answers });
+ }
for (s.clients, 1..) |*cl, id| {
totals.resizes += cl.resizes;
totals.wakes += cl.wakes;
@@ -1560,7 +1584,11 @@ fn run(init: std.process.Init, r: Run, dir: []const u8, totals: *Totals) !void {
// flood of `yes`, read 4 KB at a time as a pty gives it.
const tui = try screen_state.tuiStream(gpa);
defer gpa.free(tui);
- const shell_session = try screen_state.shellStream(gpa);
+ const session_only = try screen_state.shellStream(gpa);
+ defer gpa.free(session_only);
+ const asked = if (bytes_kind) try questions(dir) else "";
+ defer if (bytes_kind) gpa.free(asked);
+ const shell_session = try std.mem.concat(gpa, u8, &.{ session_only, asked });
defer gpa.free(shell_session);
const yes = try screen_state.yesStream(gpa, @intCast(r.flood_mb * (1 << 20) / 3));
defer gpa.free(yes);
@@ -1584,6 +1612,23 @@ fn run(init: std.process.Init, r: Run, dir: []const u8, totals: *Totals) !void {
if (soak.err) |err| return err;
}
+/// What the shell's program asks its terminal at the end of its session
+/// (`--bytes`): device attributes, the cursor's place, the cell's size in
+/// pixels, a kitty query; then a kitty image by direct data, shown, and one
+/// by a file of the session's machine, stored (a=t), which no client loads
+/// (P32): absent there, as every live terminal's image is under screen
+/// state. Shown (a=T) it would move the session's cursor past it and not a
+/// client's: a divergence until the file's bytes are taped (a later step).
+fn questions(dir: []const u8) ![]u8 {
+ var path_buf: [300]u8 = undefined;
+ const path = try std.fmt.bufPrintSentinel(&path_buf, "{s}/pixels.rgb", .{dir}, 0);
+ try writeText(path, &@as([12]u8, @splat(0x7f)));
+ var b64: [400]u8 = undefined;
+ const name = std.base64.standard.Encoder.encode(&b64, path);
+ return std.fmt.allocPrint(gpa, "\x1b[c\x1b[6n\x1b[16t\x1b_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\x1b\\\r\n" ++
+ "\x1b_Ga=T,i=5,f=24,s=2,v=2;AAAAAAAAAAAAAAAA\x1b\\\r\n\x1b_Ga=t,i=6,t=f,f=24,s=2,v=2;{s}\x1b\\\r\n$ ", .{name});
+}
+
/// A typist: keys 50-200 ms apart, a pause now and then.
fn typistGap(random: std.Random) u64 {
return if (random.uintLessThan(u8, 12) == 0) random.intRangeAtMost(u64, 300_000, 1_500_000) else random.intRangeAtMost(u64, 50_000, 200_000);
@@ -2722,6 +2767,10 @@ pub fn main(init: std.process.Init) !void {
echo_mode = true;
continue;
}
+ if (std.mem.eql(u8, name, "--bytes")) {
+ bytes_kind = true;
+ continue;
+ }
if (i + 1 >= args.len) return error.MissingValue;
i += 1;
const value = args[i];
@@ -2787,7 +2836,9 @@ pub fn main(init: std.process.Init) !void {
defer stop_lines.deinit(gpa);
for (rtts) |rtt| {
var t: Totals = .{};
+ pardes.Term.reloads = .{};
for (first..first + seeds) |seed| try run(init, .{ .seed = seed, .rtt_ms = rtt, .steps = steps, .clients = clients, .flood_mb = flood_mb }, dir, &t);
+ if (bytes_kind) std.debug.print("rtt {d}: {d} reloads of a terminal at joins, every side (the session's own too), {d} us each, {d} us at worst\n", .{ rtt, pardes.Term.reloads.n, pardes.Term.reloads.ns / @max(1, pardes.Term.reloads.n) / 1000, pardes.Term.reloads.worst_ns / 1000 });
const rollbacks = t.mispredicted + t.foreign;
std.debug.print("{d:>4} {d:>6} {d:>7} {d:>7} {d:>6} {d:>6} {d:>6} ({d}+{d}) {d:>5.1}% {d:>6} {d:>5}/{d:<6} {d:>5}/{d:<5} ({d}) {d:>7}/{d:<7} {d:>8} {d:>7}\n", .{
rtt, t.inputs, t.speculated,
diff --git a/test/terminal.zig b/test/terminal.zig
index e6c530d5..b7b9cd33 100644
--- a/test/terminal.zig
+++ b/test/terminal.zig
@@ -34,7 +34,6 @@ const prompt = Term.prompt;
const scroll = Term.scroll;
const scrollback = Term.scrollback;
const commandOutput = Term.commandOutput;
-const petscii = Term.petscii;
const filterOf = emu.filterOf;
const filterPalette = emu.filterPalette;
const keyedRgb = emu.keyedRgb;
@@ -892,7 +891,7 @@ test "a terminal's image is a placement whatever the frontend draws, and the Pet
try pardes.dump.dumpState(p);
const restored = try pardes.dump.restore(p, p.dump_out.?, "/tmp/pardes.dump.zon");
defer restored.deinit();
- try std.testing.expectEqual(@as(?bool, true), petscii(restored.panes[0].?.terminal));
+ try std.testing.expect(restored.panes[0].?.term_petscii);
try std.testing.expect(p.executeBuiltinLine(0, "Petscii"));
_ = frame.reset(.retain_capacity);
s = try p.render(frame.allocator());
@@ -904,12 +903,12 @@ test "a new terminal draws its program's images as pixels, and one without image
const gpa = std.testing.allocator;
const p = try Pardes.init(gpa, .{ .cols = 80, .rows = 24, .shells = 1 });
defer p.deinit();
- try std.testing.expectEqual(false, petscii(p.panes[0].?.terminal).?);
+ try std.testing.expect(!p.panes[0].?.term_petscii);
// A pane without images says nothing of them.
try std.testing.expect(std.mem.indexOf(u8, try tagline.tagPrefix(p, p.panes[0].?), "petscii") == null);
const id = p.freeSlot().?;
const fresh = try p.newShell(id, "");
- try std.testing.expectEqual(false, petscii(fresh.terminal).?);
+ try std.testing.expect(!fresh.term_petscii);
}
test "a program asking the cell size in pixels (CSI 16 t) is told the shell's" {