changeset 2632:5c7e1277517b

Improve comparetests script
author Michael Pavone <pavone@retrodev.com>
date Sun, 23 Feb 2025 13:55:24 -0800
parents 94c05d4ead51
children 1ef2734ac052
files comparetests.py
diffstat 1 files changed, 34 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/comparetests.py	Sun Feb 23 12:09:09 2025 -0800
+++ b/comparetests.py	Sun Feb 23 13:55:24 2025 -0800
@@ -17,6 +17,21 @@
 		print('Skipping',len(skip),'entries from previous report.')
 	else:
 		prefixes.append(argv[i])
+		
+def is_sr_in_dreg(a, b):
+	if not a.startswith('d'):
+		return False
+	if not b.startswith('d'):
+		return False
+	_,_,a = a.partition(' ')
+	_,_,b = b.partition(' ')
+	try:
+		a = int(a.strip(), 16)
+		b = int(b.strip(), 16)
+	except:
+		return False
+	return (a & 0xFFE0) == 0x2700 and (b & 0xFFE0) == 0x2700 
+	
 
 def print_mismatch(path, b, m):
 	blines = b.split('\n')
@@ -34,21 +49,26 @@
 	differences = []
 	flagmismatch = False
 	regmismatch = False
+	cyclemismatch = False
 	for i in range(0, len(blines)):
 		if blines[i] != mlines[i]:
-			if prevline == 'XNZVC':
+			if prevline == 'XNZVC' or is_sr_in_dreg(blines[i], mlines[i]):
 				differences.append((prevline, prevline))
 				flagmismatch = True
+			elif blines[i].startswith('cycles: ') and mlines[i].startswith('cycles: '):
+				cyclemismatch = True
 			else:
 				regmismatch = True
 			differences.append((blines[i], mlines[i]))
 		prevline = blines[i]
-	if flagmismatch and regmismatch:
+	if (flagmismatch + regmismatch + cyclemismatch) > 1:
 		mtype = 'General'
 	elif flagmismatch:
 		mtype = 'Flag'
 	elif regmismatch:
 		mtype = 'Register'
+	elif cyclemismatch:
+		mtype = 'Cycle'
 	else:
 		mtype = 'Unknown'
 	print('-----------------------------')
@@ -74,9 +94,9 @@
 		if not good:
 			continue
 	try:
-		b = subprocess.check_output(['./trans', path]).decode('utf-8')
+		b = subprocess.check_output(['./trans', path], timeout=5).decode('utf-8')
 		try:
-			m = subprocess.check_output(['../blastem_clean/trans', path]).decode('utf-8')
+			m = subprocess.check_output(['../blastem_clean/trans', path], timeout=5).decode('utf-8')
 			#_,_,b = b.partition('\n')
 			if b != m:
 				print_mismatch(path, b, m)
@@ -89,8 +109,17 @@
 			print('blastem output:')
 			print(b)
 			print('-----------------------------')
+		except subprocess.TimeoutExpired as e:
+			print('-----------------------------')
+			print('clean timed out ', e, ' for test', path)
+			print('blastem output:')
+			print(b)
+			print('-----------------------------')
 	except subprocess.CalledProcessError as e:
 		print('-----------------------------')
 		print('blastem exited with code', e.returncode, 'for test', path)
 		print('-----------------------------')
-
+	except subprocess.TimeoutExpired as e:
+		print('-----------------------------')
+		print('blastem timed out ', e, ' for test', path)
+		print('-----------------------------')