diff options
Diffstat (limited to 'anim/test')
| -rw-r--r-- | anim/test/asan.script | 10 | ||||
| -rw-r--r-- | anim/test/intro_code.script | 12 | ||||
| -rw-r--r-- | anim/test/intro_memory.script | 13 | ||||
| -rw-r--r-- | anim/test/intro_stack.script | 10 | ||||
| -rw-r--r-- | anim/test/recordings.zig | 25 |
5 files changed, 70 insertions, 0 deletions
diff --git a/anim/test/asan.script b/anim/test/asan.script new file mode 100644 index 0000000..db1dc2c --- /dev/null +++ b/anim/test/asan.script @@ -0,0 +1,10 @@ +# The ASan pair, headless: it runs to three instants of its timeline without failing +# (the two runs together, plain alone with ASan stopped on its report, the close). +frames 2 +console set playing false +console set t 20 +screenshot .zig-cache/canim/asan-early.png +console set t 70 +screenshot .zig-cache/canim/asan-mid.png +console set t 999 +screenshot .zig-cache/canim/asan-end.png diff --git a/anim/test/intro_code.script b/anim/test/intro_code.script new file mode 100644 index 0000000..58811a4 --- /dev/null +++ b/anim/test/intro_code.script @@ -0,0 +1,12 @@ +# The introduction's third chapter, headless: it runs to four instants of its +# timeline without failing (the bytes decoded, the two forms, the working frame, the map). +frames 2 +console set playing false +console set t 8 +screenshot .zig-cache/canim/intro_code-decode.png +console set t 20 +screenshot .zig-cache/canim/intro_code-columns.png +console set t 30 +screenshot .zig-cache/canim/intro_code-frame.png +console set t 999 +screenshot .zig-cache/canim/intro_code-end.png diff --git a/anim/test/intro_memory.script b/anim/test/intro_memory.script new file mode 100644 index 0000000..a36d36a --- /dev/null +++ b/anim/test/intro_memory.script @@ -0,0 +1,13 @@ +# The introduction's first chapter, headless: it runs to four instants of its +# timeline without failing (the bytes regrouping, the address space enlarged, +# the dump tied to its place, the close). +frames 2 +console set playing false +console set t 14 +screenshot .zig-cache/canim/intro_memory-words.png +console set t 40 +screenshot .zig-cache/canim/intro_memory-segments.png +console set t 50 +screenshot .zig-cache/canim/intro_memory-place.png +console set t 999 +screenshot .zig-cache/canim/intro_memory-end.png diff --git a/anim/test/intro_stack.script b/anim/test/intro_stack.script new file mode 100644 index 0000000..7bb93ca --- /dev/null +++ b/anim/test/intro_stack.script @@ -0,0 +1,10 @@ +# The introduction's second chapter, headless: it runs to three instants of +# its timeline without failing (the words becoming the stack, the push, the close). +frames 2 +console set playing false +console set t 2 +screenshot .zig-cache/canim/intro_stack-become.png +console set t 6 +screenshot .zig-cache/canim/intro_stack-push.png +console set t 999 +screenshot .zig-cache/canim/intro_stack-end.png diff --git a/anim/test/recordings.zig b/anim/test/recordings.zig index 5f9ceb3..31cefdb 100644 --- a/anim/test/recordings.zig +++ b/anim/test/recordings.zig @@ -341,3 +341,28 @@ test "the source follows the pc into musl's own files and back to main's line" { for (files) |seen| try expect(seen); try expect(back); } + +test "the pair's runs: plain faults at its ret on the letters; ASan stops at the first byte past buf, its shadow f3" { + const plain = canim.open(recordings.overflow); + const asan = canim.open(recordings.overflow_asan); + const report = canim.open(recordings.overflow_report); + var buf: [256]u8 = undefined; + // Plain: the run ends at a `ret` whose return address is all letters (the signal's stop, rip still on it). + var last = plain.end() - 1; + while (last > 0) : (last -= 1) { + const here = plain.instruction(last, plain.register(last, "rip"), &buf) orelse continue; + if (std.mem.eql(u8, here.text, "ret")) break; + } + try expectEqual(@as(?u64, 0x4141414141414141), try canim.Recording.word(plain.moment(last), plain.register(last, "rsp"), 8)); + // ASan: its last moment is the report's first instruction, rdi the byte past buf: f3; buf's last byte addressable. + const at = asan.end() - 1; + const past = asan.register(at, "rdi"); + try expectEqual(@as(?u8, 0xf3), (try canim.ztrace.telescope.shadow(asan.moment(at), past)).?.value); + try expectEqual(@as(?u8, 0), (try canim.ztrace.telescope.shadow(asan.moment(at), past - 1)).?.value); + // Its report, as written to fd 2, names it; the run exits 1. + var arena: std.heap.ArenaAllocator = .init(std.testing.allocator); + defer arena.deinit(); + const said = canim.pair.Report.stderr(report, arena.allocator()); + try expect(std.mem.indexOf(u8, said, "stack-buffer-overflow") != null); + try expectEqual(@as(?u64, 1), canim.pair.Report.status(report)); +} |
