-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
56 lines (47 loc) · 1.6 KB
/
Copy pathrun_tests.py
File metadata and controls
56 lines (47 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import os
import sys
import signal
import subprocess
from termcolor import cprint
EXECUTABLE_PATH = "./build/garbageboy"
TESTS_BASE_PATH = "./tests/gb-test-roms/cpu_instrs/individual"
TEST_ROMS = [
os.path.join(TESTS_BASE_PATH, "01-special.gb"),
os.path.join(TESTS_BASE_PATH, "02-interrupts.gb"),
os.path.join(TESTS_BASE_PATH, "03-op sp,hl.gb"),
os.path.join(TESTS_BASE_PATH, "04-op r,imm.gb"),
os.path.join(TESTS_BASE_PATH, "05-op rp.gb"),
os.path.join(TESTS_BASE_PATH, "06-ld r,r.gb"),
os.path.join(TESTS_BASE_PATH, "07-jr,jp,call,ret,rst.gb"),
os.path.join(TESTS_BASE_PATH, "08-misc instrs.gb"),
os.path.join(TESTS_BASE_PATH, "09-op r,r.gb"),
os.path.join(TESTS_BASE_PATH, "10-bit ops.gb"),
os.path.join(TESTS_BASE_PATH, "11-op a,(hl).gb"),
]
def run_test(rom):
cmd = [EXECUTABLE_PATH, "--headless", "--rom_path", rom]
with subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=0) as p:
char = p.stdout.read(1)
output = char.decode()
while char != b'':
output += char.decode()
char = p.stdout.read(1)
if "Passed" in output:
p.kill()
return True
if "Failed" in output:
p.kill()
return False
def main():
for rom in TEST_ROMS:
test_name = os.path.basename(rom)
passed = run_test(rom)
if passed:
cprint(f"{test_name}: PASSED!!!", "green")
else:
cprint(f"{test_name}: FAILED!!!", "red")
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
sys.exit(1)