Mercurial > repos > blastem
comparison comparetests.py @ 2446:18555c44a5e7
Update comparetests to python3 and change it to use a "clean" build of a core from blatem for comparison
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 15 Feb 2024 21:47:14 -0800 |
parents | 0f32f52fc98e |
children | 5c7e1277517b |
comparison
equal
deleted
inserted
replaced
2445:339eff5dc350 | 2446:18555c44a5e7 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python3 |
2 from glob import glob | 2 from glob import glob |
3 import subprocess | 3 import subprocess |
4 from sys import exit,argv | 4 from sys import exit,argv |
5 | 5 |
6 prefixes = [] | 6 prefixes = [] |
12 parts = line.split() | 12 parts = line.split() |
13 for part in parts: | 13 for part in parts: |
14 if part.endswith('.bin'): | 14 if part.endswith('.bin'): |
15 skip.add(part) | 15 skip.add(part) |
16 f.close() | 16 f.close() |
17 print 'Skipping',len(skip),'entries from previous report.' | 17 print('Skipping',len(skip),'entries from previous report.') |
18 else: | 18 else: |
19 prefixes.append(argv[i]) | 19 prefixes.append(argv[i]) |
20 | 20 |
21 def print_mismatch(path, b, m): | 21 def print_mismatch(path, b, m): |
22 blines = b.split('\n') | 22 blines = b.split('\n') |
23 mlines = m.split('\n') | 23 mlines = m.split('\n') |
24 if len(blines) != len(mlines): | 24 if len(blines) != len(mlines): |
25 print '-----------------------------' | 25 print('-----------------------------') |
26 print 'Unknown mismatch in', path | 26 print('Unknown mismatch in', path) |
27 print 'blastem output:' | 27 print('blastem output:') |
28 print b | 28 print(b) |
29 print 'musashi output:' | 29 print('clean output:') |
30 print m | 30 print(m) |
31 print '-----------------------------' | 31 print('-----------------------------') |
32 return | 32 return |
33 prevline = '' | 33 prevline = '' |
34 differences = [] | 34 differences = [] |
35 flagmismatch = False | 35 flagmismatch = False |
36 regmismatch = False | 36 regmismatch = False |
37 for i in xrange(0, len(blines)): | 37 for i in range(0, len(blines)): |
38 if blines[i] != mlines[i]: | 38 if blines[i] != mlines[i]: |
39 if prevline == 'XNZVC': | 39 if prevline == 'XNZVC': |
40 differences.append((prevline, prevline)) | 40 differences.append((prevline, prevline)) |
41 flagmismatch = True | 41 flagmismatch = True |
42 else: | 42 else: |
49 mtype = 'Flag' | 49 mtype = 'Flag' |
50 elif regmismatch: | 50 elif regmismatch: |
51 mtype = 'Register' | 51 mtype = 'Register' |
52 else: | 52 else: |
53 mtype = 'Unknown' | 53 mtype = 'Unknown' |
54 print '-----------------------------' | 54 print('-----------------------------') |
55 print mtype, 'mismatch in', path | 55 print(mtype, 'mismatch in', path) |
56 for i in xrange(0, 2): | 56 for i in range(0, 2): |
57 print 'musashi' if i else 'blastem', 'output:' | 57 print('clean' if i else 'blastem', 'output:') |
58 for diff in differences: | 58 for diff in differences: |
59 print diff[i] | 59 print(diff[i]) |
60 print '-----------------------------' | 60 print('-----------------------------') |
61 | 61 |
62 | 62 |
63 | 63 |
64 for path in glob('generated_tests/*/*.bin'): | 64 for path in glob('generated_tests/*/*.bin'): |
65 if path in skip: | 65 if path in skip: |
72 good = True | 72 good = True |
73 break | 73 break |
74 if not good: | 74 if not good: |
75 continue | 75 continue |
76 try: | 76 try: |
77 b = subprocess.check_output(['./trans', path]) | 77 b = subprocess.check_output(['./trans', path]).decode('utf-8') |
78 try: | 78 try: |
79 m = subprocess.check_output(['musashi/mustrans', path]) | 79 m = subprocess.check_output(['../blastem_clean/trans', path]).decode('utf-8') |
80 #_,_,b = b.partition('\n') | 80 #_,_,b = b.partition('\n') |
81 if b != m: | 81 if b != m: |
82 print_mismatch(path, b, m) | 82 print_mismatch(path, b, m) |
83 | 83 |
84 else: | 84 else: |
85 print path, 'passed' | 85 print(path, 'passed') |
86 except subprocess.CalledProcessError as e: | 86 except subprocess.CalledProcessError as e: |
87 print '-----------------------------' | 87 print('-----------------------------') |
88 print 'musashi exited with code', e.returncode, 'for test', path | 88 print('clean exited with code', e.returncode, 'for test', path) |
89 print 'blastem output:' | 89 print('blastem output:') |
90 print b | 90 print(b) |
91 print '-----------------------------' | 91 print('-----------------------------') |
92 except subprocess.CalledProcessError as e: | 92 except subprocess.CalledProcessError as e: |
93 print '-----------------------------' | 93 print('-----------------------------') |
94 print 'blastem exited with code', e.returncode, 'for test', path | 94 print('blastem exited with code', e.returncode, 'for test', path) |
95 print '-----------------------------' | 95 print('-----------------------------') |
96 | 96 |