summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/replicas.zig36
1 files changed, 31 insertions, 5 deletions
diff --git a/test/replicas.zig b/test/replicas.zig
index 2d199c60..69207970 100644
--- a/test/replicas.zig
+++ b/test/replicas.zig
@@ -205,6 +205,8 @@ const Totals = struct {
/// The wakes the clients' loops asked for, and the frames they drew.
wakes: u64 = 0,
draws: u64 = 0,
+ /// The clients' views' yanks, pastes and links their frontends did.
+ asked: [3]u64 = @splat(0),
stops: [32]struct { name: []const u8 = "", n: u64 = 0 } = @splat(.{}),
units: u64 = 0,
fast: u64 = 0,
@@ -285,7 +287,8 @@ const Totals = struct {
/// page and at a search's hit (plain kinds a client runs as the session
/// does, `looks` past the texts), the keys after going to its pane; a
/// search (`/`, a pattern, Enter), a sweep of B1 over the PDF and its
-/// wheel; now and then a client's Detach.
+/// wheel; a yank to the system clipboard and a paste from it; now and
+/// then a client's Detach.
fn nextEvent(random: std.Random, buf: *[64]u8, aim: Aim, looks: []const []const u8, script: *Script) pardes.Event {
const typed = "abcdefghijklmnopqrstuvwxyz0123456789 -_=+,:;()";
const normal = "hjklwbe0$xpuyoOiaAIdcv.nN%sC";
@@ -316,7 +319,7 @@ fn nextEvent(random: std.Random, buf: *[64]u8, aim: Aim, looks: []const []const
for (buf[0..n]) |*c| c.* = typed[random.uintLessThan(usize, typed.len)];
return .{ .paste = buf[0..n] };
},
- 36 => return .{ .command = switch (random.uintLessThan(u8, 14)) {
+ 36 => return .{ .command = switch (random.uintLessThan(u8, 16)) {
0 => "Newcol",
1 => "Zerox",
2 => "Undo",
@@ -332,6 +335,10 @@ fn nextEvent(random: std.Random, buf: *[64]u8, aim: Aim, looks: []const []const
// Its link ended by the session (the session's own view's,
// its terminal's: none here).
12 => if (random.uintLessThan(u8, 4) == 0) "Detach" else "Undo",
+ // The system clipboard, the client's own frontend's (client.zig
+ // `asks`): a yank of the selection to it, a paste from it.
+ 13 => "ClipYank",
+ 14 => "ClipPaste",
else => return .{ .key = .{ .cp = if (random.boolean()) 'o' else 'i', .ctrl = true } },
} },
37 => return .{ .resize = .{ .cols = @intCast(random.intRangeAtMost(u16, 60, 120)), .rows = @intCast(random.intRangeAtMost(u16, 16, 40)) } },
@@ -459,6 +466,8 @@ const Client = struct {
/// real wait's timeout is; an earlier one replaces it), and how many.
wake_at: u64 = 0,
wakes: u64 = 0,
+ /// Its view's yanks, pastes and links its frontend did.
+ asked: [3]u64 = @splat(0),
drew: bool = false,
/// What it types in a row (a search, a sweep).
script: Script = .{},
@@ -543,6 +552,19 @@ const Client = struct {
defer cl.drew = false;
return .{ .drew = cl.drew, .moving = false };
}
+
+ /// What its view asked of its machine (client.zig `asks`), counted;
+ /// its clipboard's answer a paste, as a frontend's comes.
+ pub fn copy(cl: *Client, _: []const u8) void {
+ cl.asked[0] += 1;
+ }
+ pub fn paste(cl: *Client, l: *ClientLoop) void {
+ cl.asked[1] += 1;
+ l.input(.{ .paste = "from the client's clipboard" });
+ }
+ pub fn open(cl: *Client, _: []const u8) void {
+ cl.asked[2] += 1;
+ }
};
const ClientLoop = client_loop.Loop(Client);
@@ -1253,6 +1275,7 @@ fn run(r: Run, dir: []const u8, totals: *Totals) !void {
for (clients[0..r.clients], 1..) |*cl, id| {
totals.resizes += cl.resizes;
totals.wakes += cl.wakes;
+ for (&totals.asked, cl.asked) |*t, n| t.* += n;
if (has_link[id - 1]) totals.draws += cl.loop.link.draws;
// Its quiet checks: what the session's digest was against its own.
if (readAll(cl.check)) |said| {
@@ -2525,7 +2548,7 @@ pub fn main(init: std.process.Init) !void {
t.screens_checked,
t.screens_wrong,
});
- try stop_lines.print(gpa, "{d:>4} {d:>8} {d:>6} {d:>6} ", .{ rtt, t.unlisted, t.wakes, t.draws });
+ try stop_lines.print(gpa, "{d:>4} {d:>8} {d:>6} {d:>6} {d:>3}/{d}/{d} ", .{ rtt, t.unlisted, t.wakes, t.draws, t.asked[0], t.asked[1], t.asked[2] });
for (t.stops) |st| if (st.n > 0) try stop_lines.print(gpa, "{s}:{d} ", .{ st.name, st.n });
try stop_lines.append(gpa, '\n');
try join_lines.print(gpa, "{d:>4} {d:>5} {d:>7} {d:>8} {d:>8} {d:>6} {d:>5}/{d:<5} {d:>5}/{d:<6} {d:>7} {d:>5}/{d}/{d}\n", .{ rtt, t.joins, t.refused, t.rejoined, t.detached, t.detach_words, t.agree, t.differ, t.checks, t.units, t.resizes, t.kind_panes[0], t.kind_panes[1], t.kind_panes[2] });
@@ -2535,8 +2558,8 @@ pub fn main(init: std.process.Init) !void {
std.debug.print(" rtt deltas/s delta B/s unit B/s encode p50/p99 apply p50/p99 fetched filled KB resets checked/wrong\n{s}", .{term_lines.items});
std.debug.print("clients: joins from a dump, refused (every view taken), joined again after a divergence put on them, left (of them by a Detach); quiet checks of the session's digest agreed/differed; the digests the clients compared (units and quiet), of the units they took; resizes the windows posted; the kinds' panes the session opened (image/life/pdf)\n", .{});
std.debug.print(" rtt joins refused rejoined detached detach agree/differ checks/units resizes kinds\n{s}", .{join_lines.items});
- std.debug.print("stops: what stopped the clients' inputs (a stop counted again as its input is applied again), by name; those at a name replica.may_wait does not list fail the run\n", .{});
- std.debug.print(" rtt unlisted wakes draws stops\n{s}", .{stop_lines.items});
+ std.debug.print("stops: the wakes the clients' loops asked, the frames they drew, the yanks, pastes and links their frontends did (y/p/l), and what stopped their inputs (a stop counted again as its input is applied again), by name; those at a name replica.may_wait does not list fail the run\n", .{});
+ std.debug.print(" rtt unlisted wakes draws y/p/l stops\n{s}", .{stop_lines.items});
if (failed) std.process.exit(1);
}
@@ -2637,6 +2660,9 @@ const Shows = struct {
pub fn drawn(_: *Shows) client_loop.Drawn {
return .{ .drew = true, .moving = false };
}
+ pub fn copy(_: *Shows, _: []const u8) void {}
+ pub fn paste(_: *Shows, _: *client_loop.Loop(Shows)) void {}
+ pub fn open(_: *Shows, _: []const u8) void {}
};
/// The frame corpus's scenes (test/process/window.zig `corpus`, what a