annotate comparetests.py @ 989:d70000fdff0b

Implemented IR and undefined bits of info word for address error exception frames
author Michael Pavone <pavone@retrodev.com>
date Wed, 27 Apr 2016 21:39:17 -0700
parents 0f32f52fc98e
children
rev   line source
pavone@214 1 #!/usr/bin/env python
pavone@214 2 from glob import glob
pavone@214 3 import subprocess
pavone@220 4 from sys import exit,argv
pavone@220 5
pavone@220 6 prefixes = []
pavone@224 7 skip = set()
pavone@220 8 for i in range(1, len(argv)):
pavone@224 9 if '.' in argv[i]:
pavone@224 10 f = open(argv[i])
pavone@224 11 for line in f:
pavone@224 12 parts = line.split()
pavone@224 13 for part in parts:
pavone@224 14 if part.endswith('.bin'):
pavone@224 15 skip.add(part)
pavone@224 16 f.close()
pavone@224 17 print 'Skipping',len(skip),'entries from previous report.'
pavone@224 18 else:
pavone@224 19 prefixes.append(argv[i])
pavone@214 20
pavone@572 21 def print_mismatch(path, b, m):
pavone@572 22 blines = b.split('\n')
pavone@572 23 mlines = m.split('\n')
pavone@572 24 if len(blines) != len(mlines):
pavone@572 25 print '-----------------------------'
pavone@572 26 print 'Unknown mismatch in', path
pavone@572 27 print 'blastem output:'
pavone@572 28 print b
pavone@572 29 print 'musashi output:'
pavone@572 30 print m
pavone@572 31 print '-----------------------------'
pavone@572 32 return
pavone@572 33 prevline = ''
pavone@572 34 differences = []
pavone@572 35 flagmismatch = False
pavone@572 36 regmismatch = False
pavone@572 37 for i in xrange(0, len(blines)):
pavone@572 38 if blines[i] != mlines[i]:
pavone@572 39 if prevline == 'XNZVC':
pavone@572 40 differences.append((prevline, prevline))
pavone@572 41 flagmismatch = True
pavone@572 42 else:
pavone@572 43 regmismatch = True
pavone@572 44 differences.append((blines[i], mlines[i]))
pavone@572 45 prevline = blines[i]
pavone@572 46 if flagmismatch and regmismatch:
pavone@572 47 mtype = 'General'
pavone@572 48 elif flagmismatch:
pavone@572 49 mtype = 'Flag'
pavone@572 50 elif regmismatch:
pavone@572 51 mtype = 'Register'
pavone@572 52 else:
pavone@572 53 mtype = 'Unknown'
pavone@572 54 print '-----------------------------'
pavone@572 55 print mtype, 'mismatch in', path
pavone@572 56 for i in xrange(0, 2):
pavone@572 57 print 'musashi' if i else 'blastem', 'output:'
pavone@572 58 for diff in differences:
pavone@572 59 print diff[i]
pavone@572 60 print '-----------------------------'
pavone@572 61
pavone@572 62
pavone@572 63
pavone@224 64 for path in glob('generated_tests/*/*.bin'):
pavone@224 65 if path in skip:
pavone@224 66 continue
pavone@220 67 if prefixes:
pavone@220 68 good = False
pavone@224 69 fname = path.split('/')[-1]
pavone@220 70 for prefix in prefixes:
pavone@224 71 if fname.startswith(prefix):
pavone@220 72 good = True
pavone@220 73 break
pavone@220 74 if not good:
pavone@220 75 continue
pavone@214 76 try:
pavone@440 77 b = subprocess.check_output(['./trans', path])
pavone@214 78 try:
pavone@214 79 m = subprocess.check_output(['musashi/mustrans', path])
pavone@217 80 #_,_,b = b.partition('\n')
pavone@214 81 if b != m:
pavone@572 82 print_mismatch(path, b, m)
pavone@572 83
pavone@214 84 else:
pavone@214 85 print path, 'passed'
pavone@214 86 except subprocess.CalledProcessError as e:
pavone@214 87 print '-----------------------------'
pavone@214 88 print 'musashi exited with code', e.returncode, 'for test', path
pavone@214 89 print 'blastem output:'
pavone@214 90 print b
pavone@214 91 print '-----------------------------'
pavone@214 92 except subprocess.CalledProcessError as e:
pavone@214 93 print '-----------------------------'
pavone@214 94 print 'blastem exited with code', e.returncode, 'for test', path
pavone@214 95 print '-----------------------------'
pavone@214 96