diff 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
line wrap: on
line diff
--- a/comparetests.py	Sun Mar 02 17:53:32 2014 -0800
+++ b/comparetests.py	Mon Mar 03 21:08:43 2014 -0800
@@ -18,6 +18,49 @@
 	else:
 		prefixes.append(argv[i])
 
+def print_mismatch(path, b, m):
+	blines = b.split('\n')
+	mlines = m.split('\n')
+	if len(blines) != len(mlines):
+		print '-----------------------------'
+		print 'Unknown mismatch in', path
+		print 'blastem output:'
+		print b
+		print 'musashi output:'
+		print m
+		print '-----------------------------'
+		return
+	prevline = ''
+	differences = []
+	flagmismatch = False
+	regmismatch = False
+	for i in xrange(0, len(blines)):
+		if blines[i] != mlines[i]:
+			if prevline == 'XNZVC':
+				differences.append((prevline, prevline))
+				flagmismatch = True
+			else:
+				regmismatch = True
+			differences.append((blines[i], mlines[i]))
+		prevline = blines[i]
+	if flagmismatch and regmismatch:
+		mtype = 'General'
+	elif flagmismatch:
+		mtype = 'Flag'
+	elif regmismatch:
+		mtype = 'Register'
+	else:
+		mtype = 'Unknown'
+	print '-----------------------------'
+	print mtype, 'mismatch in', path
+	for i in xrange(0, 2):
+		print 'musashi' if i else 'blastem', 'output:'
+		for diff in differences:
+			print diff[i]
+	print '-----------------------------'
+
+
+
 for path in glob('generated_tests/*/*.bin'):
 	if path in skip:
 		continue
@@ -36,13 +79,8 @@
 			m = subprocess.check_output(['musashi/mustrans', path])
 			#_,_,b = b.partition('\n')
 			if b != m:
-				print '-----------------------------'
-				print 'Mismatch in ' + path
-				print 'blastem output:'
-				print b
-				print 'musashi output:'
-				print m
-				print '-----------------------------'
+				print_mismatch(path, b, m)
+
 			else:
 				print path, 'passed'
 		except subprocess.CalledProcessError as e: