diff options
Diffstat (limited to 'core/fuzz.zig')
| -rw-r--r-- | core/fuzz.zig | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/core/fuzz.zig b/core/fuzz.zig index 4f291d64..616636ab 100644 --- a/core/fuzz.zig +++ b/core/fuzz.zig @@ -713,9 +713,42 @@ fn damage(r: Random, b: []u8, n: usize) usize { /// What is done with a dump once it loads: a join's is digested (the /// session's digest decides before anything draws it: replica.fromDump), -/// a Restore's or an Upgrade's image is drawn. +/// a Restore's or an Upgrade's image is not; then each is used (`use`). const Road = enum { join, restore }; +/// A core loaded used as its user would: drawn at the size it says, then +/// smaller and larger (a resize each), then given keys and a wheel notch each +/// way and drawn again. A load that draws and then dies at a key is the same +/// fault as one that dies drawing. +fn use(q: *Pardes) void { + const K = pardes.Key; + const steps = [_]pardes.Event{ + .{ .resize = .{ .cols = 40, .rows = 12 } }, + .{ .resize = .{ .cols = 200, .rows = 60 } }, + .{ .key = .{ .cp = 'j' } }, + .{ .key = .{ .cp = 'w' } }, + .{ .key = .{ .cp = 'x' } }, + .{ .key = .{ .cp = 'd' } }, + .{ .key = .{ .cp = 'u' } }, + .{ .key = .{ .cp = K.page_down } }, + .{ .key = .{ .cp = K.page_up } }, + .{ .key = .{ .cp = 'k' } }, + .{ .key = .{ .cp = K.escape } }, + .{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = 100, .row = 30 } }, + .{ .mouse = .{ .button = .wheel_up, .kind = .press, .col = 100, .row = 30 } }, + }; + for (0..steps.len + 1) |at| { + if (at < 3 or at == steps.len) { + q.sync(); + _ = q.frame_arena.reset(.retain_capacity); + _ = q.render(q.frame_arena.allocator()) catch {}; + } + if (at == steps.len) return; + q.update(steps[at]); + while (q.nextEffect()) |_| {} + } +} + fn loadSeed(whole: []const u8, road: Road, seed: u64) !void { var prng: Random.DefaultPrng = .init(seed); const r = prng.random(); @@ -733,14 +766,9 @@ fn loadSeed(whole: []const u8, road: Road, seed: u64) !void { var notes: std.ArrayList(u8) = .empty; defer notes.deinit(gpa); if (pardes.dump.load(gpa, .{ .cols = 80, .rows = 24 }, b[0..n], ¬es)) |q| { - switch (road) { - .join => _ = pardes.tape.digestOf(q), - .restore => { - _ = q.frame_arena.reset(.retain_capacity); - _ = q.render(q.frame_arena.allocator()) catch {}; - }, - } - q.deinit(); + defer q.deinit(); + if (road == .join) _ = pardes.tape.digestOf(q); + use(q); } else |err| if (seed == 0) return err; try testing.expectEqual(@as(usize, 0), cap.refused); } @@ -754,9 +782,10 @@ test "a dump and an image cut, flipped and grown: refused or loaded, never a pan defer gpa.free(bytes); const image = try pardes.dump.dumpBytes(p); defer gpa.free(image); - // Seconds a road. The image's past 1024 seeds reach xitdb's own reader - // (a slot's tag past its kinds: a `switch` on it), a dependency's. - for ([_][]const u8{ bytes, image }, [_]Road{ .join, .restore }, [_]u64{ 4096, 1024 }) |whole, road, n| { + // Seconds a road, each core used (`use`). The image's past 1779 seeds + // reach xitdb's own reader (a slot's tag past its kinds: a `switch` on + // it), a dependency's. + for ([_][]const u8{ bytes, image }, [_]Road{ .join, .restore }, [_]u64{ 2048, 1024 }) |whole, road, n| { try loadSeed(whole, road, 0); for (1..n + 1) |seed| try loadSeed(whole, road, seed); } |
