comparison zcompare.py @ 2608:898386e48243

Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
author Michael Pavone <pavone@retrodev.com>
date Sat, 15 Feb 2025 01:35:23 -0800
parents a9dcaacdc0c5
children
comparison
equal deleted inserted replaced
2607:6b3b411f3339 2608:898386e48243
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 for path in glob('ztests/*/*.bin'): 21 for path in glob('ztests/*/*.bin'):
22 if path in skip: 22 if path in skip:
29 good = True 29 good = True
30 break 30 break
31 if not good: 31 if not good:
32 continue 32 continue
33 try: 33 try:
34 b = subprocess.check_output(['./ztestrun', path]) 34 b = subprocess.check_output(['./ztestrun', path]).decode()
35 try: 35 try:
36 m = subprocess.check_output(['gxz80/gxzrun', path]) 36 m = subprocess.check_output(['../blastem_clean/ztestrun', path]).decode()
37 #_,_,b = b.partition('\n') 37 #_,_,b = b.partition('\n')
38 m = m.split('\n')
39 b = b.split('\n')
38 if b != m: 40 if b != m:
39 print '-----------------------------' 41 lastWasFlags = False
40 print 'Mismatch in ' + path 42 bdiff = []
41 print 'blastem output:' 43 mdiff = []
42 print b 44 for i in range(0, max(len(b), len(m))):
43 print 'gxz80 output:' 45 bl = b[i] if i < len(b) else ''
44 print m 46 ml = m[i] if i < len(m) else ''
45 print '-----------------------------' 47 if bl != ml:
48 if lastWasFlags:
49 bdiff.append(b[i - 1])
50 mdiff.append(m[i - 1])
51 bdiff.append(bl)
52 mdiff.append(ml)
53 lastWasFlags = bl.startswith('Flags: ')
54 print('-----------------------------')
55 print('Mismatch in ' + path)
56 print('blastem output:')
57 for b in bdiff:
58 print(b)
59 print('clean output:')
60 for m in mdiff:
61 print(m)
62 print('-----------------------------')
46 else: 63 else:
47 print path, 'passed' 64 print(path, 'passed')
48 except subprocess.CalledProcessError as e: 65 except subprocess.CalledProcessError as e:
49 print '-----------------------------' 66 print('-----------------------------')
50 print 'gxz80 exited with code', e.returncode, 'for test', path 67 print('clean exited with code', e.returncode, 'for test', path)
51 print 'blastem output:' 68 print('blastem output:')
52 print b 69 print(b)
53 print '-----------------------------' 70 print('-----------------------------')
54 except subprocess.CalledProcessError as e: 71 except subprocess.CalledProcessError as e:
55 print '-----------------------------' 72 print('-----------------------------')
56 print 'blastem exited with code', e.returncode, 'for test', path 73 print('blastem exited with code', e.returncode, 'for test', path)
57 print '-----------------------------' 74 print('-----------------------------')
58 75