diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-24 02:56:05 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-24 04:15:45 -0300 |
| commit | da985ae98180c2394ccdf48cf8bdf5bd85873c2f (patch) | |
| tree | 282ba1bd8907e920f017320d72d0fef7403e4e0a /core/fuzz.zig | |
| parent | 2645734806155dac927967289b0f11683eb3a1d0 (diff) | |
| download | pardes-da985ae98180c2394ccdf48cf8bdf5bd85873c2f.tar.gz pardes-da985ae98180c2394ccdf48cf8bdf5bd85873c2f.zip | |
fuzz: a loaded core is used as its user would, on both roads: drawn at its own size, at 40x12 and at 200x60 (a resize each), then given keys (`j w x d u`, PageDown, PageUp, `k`, Escape) and a wheel notch each way, and drawn again (core/fuzz.zig `use`): a load that draws and then dies at a key is the same fault as one that dies drawing; the join road's byte dump is digested first, as a join's is; in the suite 2048 join seeds and 1024 image seeds (Debug: about 2.5 ms and 5 ms a seed); the image road past seed 1779 reaches xitdb's own reader (a slot's tag past its kinds: a `switch` on it), a dependency's, for build/patches.zig; what this fuzz reached is held by the change before (each seed in its description)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
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); } |
