Mercurial > repos > blastem
comparison comparetests.py @ 2632:5c7e1277517b
Improve comparetests script
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 23 Feb 2025 13:55:24 -0800 |
parents | 18555c44a5e7 |
children |
comparison
equal
deleted
inserted
replaced
2631:94c05d4ead51 | 2632:5c7e1277517b |
---|---|
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 | |
21 def is_sr_in_dreg(a, b): | |
22 if not a.startswith('d'): | |
23 return False | |
24 if not b.startswith('d'): | |
25 return False | |
26 _,_,a = a.partition(' ') | |
27 _,_,b = b.partition(' ') | |
28 try: | |
29 a = int(a.strip(), 16) | |
30 b = int(b.strip(), 16) | |
31 except: | |
32 return False | |
33 return (a & 0xFFE0) == 0x2700 and (b & 0xFFE0) == 0x2700 | |
34 | |
20 | 35 |
21 def print_mismatch(path, b, m): | 36 def print_mismatch(path, b, m): |
22 blines = b.split('\n') | 37 blines = b.split('\n') |
23 mlines = m.split('\n') | 38 mlines = m.split('\n') |
24 if len(blines) != len(mlines): | 39 if len(blines) != len(mlines): |
32 return | 47 return |
33 prevline = '' | 48 prevline = '' |
34 differences = [] | 49 differences = [] |
35 flagmismatch = False | 50 flagmismatch = False |
36 regmismatch = False | 51 regmismatch = False |
52 cyclemismatch = False | |
37 for i in range(0, len(blines)): | 53 for i in range(0, len(blines)): |
38 if blines[i] != mlines[i]: | 54 if blines[i] != mlines[i]: |
39 if prevline == 'XNZVC': | 55 if prevline == 'XNZVC' or is_sr_in_dreg(blines[i], mlines[i]): |
40 differences.append((prevline, prevline)) | 56 differences.append((prevline, prevline)) |
41 flagmismatch = True | 57 flagmismatch = True |
58 elif blines[i].startswith('cycles: ') and mlines[i].startswith('cycles: '): | |
59 cyclemismatch = True | |
42 else: | 60 else: |
43 regmismatch = True | 61 regmismatch = True |
44 differences.append((blines[i], mlines[i])) | 62 differences.append((blines[i], mlines[i])) |
45 prevline = blines[i] | 63 prevline = blines[i] |
46 if flagmismatch and regmismatch: | 64 if (flagmismatch + regmismatch + cyclemismatch) > 1: |
47 mtype = 'General' | 65 mtype = 'General' |
48 elif flagmismatch: | 66 elif flagmismatch: |
49 mtype = 'Flag' | 67 mtype = 'Flag' |
50 elif regmismatch: | 68 elif regmismatch: |
51 mtype = 'Register' | 69 mtype = 'Register' |
70 elif cyclemismatch: | |
71 mtype = 'Cycle' | |
52 else: | 72 else: |
53 mtype = 'Unknown' | 73 mtype = 'Unknown' |
54 print('-----------------------------') | 74 print('-----------------------------') |
55 print(mtype, 'mismatch in', path) | 75 print(mtype, 'mismatch in', path) |
56 for i in range(0, 2): | 76 for i in range(0, 2): |
72 good = True | 92 good = True |
73 break | 93 break |
74 if not good: | 94 if not good: |
75 continue | 95 continue |
76 try: | 96 try: |
77 b = subprocess.check_output(['./trans', path]).decode('utf-8') | 97 b = subprocess.check_output(['./trans', path], timeout=5).decode('utf-8') |
78 try: | 98 try: |
79 m = subprocess.check_output(['../blastem_clean/trans', path]).decode('utf-8') | 99 m = subprocess.check_output(['../blastem_clean/trans', path], timeout=5).decode('utf-8') |
80 #_,_,b = b.partition('\n') | 100 #_,_,b = b.partition('\n') |
81 if b != m: | 101 if b != m: |
82 print_mismatch(path, b, m) | 102 print_mismatch(path, b, m) |
83 | 103 |
84 else: | 104 else: |
87 print('-----------------------------') | 107 print('-----------------------------') |
88 print('clean exited with code', e.returncode, 'for test', path) | 108 print('clean exited with code', e.returncode, 'for test', path) |
89 print('blastem output:') | 109 print('blastem output:') |
90 print(b) | 110 print(b) |
91 print('-----------------------------') | 111 print('-----------------------------') |
112 except subprocess.TimeoutExpired as e: | |
113 print('-----------------------------') | |
114 print('clean timed out ', e, ' for test', path) | |
115 print('blastem output:') | |
116 print(b) | |
117 print('-----------------------------') | |
92 except subprocess.CalledProcessError as e: | 118 except subprocess.CalledProcessError as e: |
93 print('-----------------------------') | 119 print('-----------------------------') |
94 print('blastem exited with code', e.returncode, 'for test', path) | 120 print('blastem exited with code', e.returncode, 'for test', path) |
95 print('-----------------------------') | 121 print('-----------------------------') |
96 | 122 except subprocess.TimeoutExpired as e: |
123 print('-----------------------------') | |
124 print('blastem timed out ', e, ' for test', path) | |
125 print('-----------------------------') |