Skip to content

Commit 5eef48a

Browse files
committed
Add test checker (finally!)
1 parent 1c6d091 commit 5eef48a

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

tests/runtime/check_test.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
import sys
5+
import zx
6+
7+
8+
class Tester(zx.Emulator):
9+
def __init__(self):
10+
# speed_factor=None results in maximum speed and
11+
# suppresses showing the emulator window.
12+
# super().__init__(speed_factor=0.01)
13+
super().__init__(speed_factor=None)
14+
15+
def on_breakpoint(self):
16+
self.done = True
17+
18+
def run_test(self, tape_filename, ram_filename):
19+
# Auto-load the tape.
20+
self.load_tape(tape_filename)
21+
22+
# Catch the end of test.
23+
self.set_breakpoint(8)
24+
25+
# Run the main loop until self.done is raised.
26+
self.main()
27+
28+
# Get view to the video memory.
29+
screen = self.get_memory_view(0x4000, 6 * 1024 + 768)
30+
31+
# Compare it with the etalon screenshot.
32+
with open(ram_filename, 'rb') as f:
33+
if screen != f.read():
34+
print('FAIL')
35+
sys.exit(1)
36+
37+
38+
def main():
39+
with Tester() as t:
40+
t.run_test(sys.argv[1], sys.argv[2])
41+
print('OK')
42+
43+
44+
if __name__ == "__main__":
45+
main()

0 commit comments

Comments
 (0)