Mercurial > repos > blastem
comparison comparetests.py @ 572:0f32f52fc98e
Make some small changes in trans so that it is more likely to produce the same output as mustrans when given misbehaving programs. Add lea to testcases.txt. Improve the output of comparetest.py so that known issues can easily be separated from new ones.
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 03 Mar 2014 21:08:43 -0800 |
parents | 306986209cba |
children | 18555c44a5e7 |
comparison
equal
deleted
inserted
replaced
571:c90fc522e7e3 | 572:0f32f52fc98e |
---|---|
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): | |
22 blines = b.split('\n') | |
23 mlines = m.split('\n') | |
24 if len(blines) != len(mlines): | |
25 print '-----------------------------' | |
26 print 'Unknown mismatch in', path | |
27 print 'blastem output:' | |
28 print b | |
29 print 'musashi output:' | |
30 print m | |
31 print '-----------------------------' | |
32 return | |
33 prevline = '' | |
34 differences = [] | |
35 flagmismatch = False | |
36 regmismatch = False | |
37 for i in xrange(0, len(blines)): | |
38 if blines[i] != mlines[i]: | |
39 if prevline == 'XNZVC': | |
40 differences.append((prevline, prevline)) | |
41 flagmismatch = True | |
42 else: | |
43 regmismatch = True | |
44 differences.append((blines[i], mlines[i])) | |
45 prevline = blines[i] | |
46 if flagmismatch and regmismatch: | |
47 mtype = 'General' | |
48 elif flagmismatch: | |
49 mtype = 'Flag' | |
50 elif regmismatch: | |
51 mtype = 'Register' | |
52 else: | |
53 mtype = 'Unknown' | |
54 print '-----------------------------' | |
55 print mtype, 'mismatch in', path | |
56 for i in xrange(0, 2): | |
57 print 'musashi' if i else 'blastem', 'output:' | |
58 for diff in differences: | |
59 print diff[i] | |
60 print '-----------------------------' | |
61 | |
62 | |
63 | |
21 for path in glob('generated_tests/*/*.bin'): | 64 for path in glob('generated_tests/*/*.bin'): |
22 if path in skip: | 65 if path in skip: |
23 continue | 66 continue |
24 if prefixes: | 67 if prefixes: |
25 good = False | 68 good = False |
34 b = subprocess.check_output(['./trans', path]) | 77 b = subprocess.check_output(['./trans', path]) |
35 try: | 78 try: |
36 m = subprocess.check_output(['musashi/mustrans', path]) | 79 m = subprocess.check_output(['musashi/mustrans', path]) |
37 #_,_,b = b.partition('\n') | 80 #_,_,b = b.partition('\n') |
38 if b != m: | 81 if b != m: |
39 print '-----------------------------' | 82 print_mismatch(path, b, m) |
40 print 'Mismatch in ' + path | 83 |
41 print 'blastem output:' | |
42 print b | |
43 print 'musashi output:' | |
44 print m | |
45 print '-----------------------------' | |
46 else: | 84 else: |
47 print path, 'passed' | 85 print path, 'passed' |
48 except subprocess.CalledProcessError as e: | 86 except subprocess.CalledProcessError as e: |
49 print '-----------------------------' | 87 print '-----------------------------' |
50 print 'musashi exited with code', e.returncode, 'for test', path | 88 print 'musashi exited with code', e.returncode, 'for test', path |