Mercurial > repos > blastem
annotate zcompare.py @ 2688:b42f00a3a937 default tip
Fix default target. Ensure m68k.h and z80.h are built before anything else when no dep info is available
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 31 Mar 2025 21:06:18 -0700 |
parents | 898386e48243 |
children |
rev | line source |
---|---|
2608
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
1 #!/usr/bin/env python3 |
600
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 from glob import glob |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 import subprocess |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 from sys import exit,argv |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 prefixes = [] |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 skip = set() |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 for i in range(1, len(argv)): |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 if '.' in argv[i]: |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 f = open(argv[i]) |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 for line in f: |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 parts = line.split() |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 for part in parts: |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 if part.endswith('.bin'): |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 skip.add(part) |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 f.close() |
2608
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
17 print('Skipping',len(skip),'entries from previous report.') |
600
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 else: |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 prefixes.append(argv[i]) |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 for path in glob('ztests/*/*.bin'): |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 if path in skip: |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 continue |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 if prefixes: |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 good = False |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 fname = path.split('/')[-1] |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 for prefix in prefixes: |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 if fname.startswith(prefix): |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 good = True |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 break |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 if not good: |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 continue |
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 try: |
2608
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
34 b = subprocess.check_output(['./ztestrun', path]).decode() |
600
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 try: |
2608
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
36 m = subprocess.check_output(['../blastem_clean/ztestrun', path]).decode() |
600
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 #_,_,b = b.partition('\n') |
2608
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
38 m = m.split('\n') |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
39 b = b.split('\n') |
600
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 if b != m: |
2608
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
41 lastWasFlags = False |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
42 bdiff = [] |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
43 mdiff = [] |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
44 for i in range(0, max(len(b), len(m))): |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
45 bl = b[i] if i < len(b) else '' |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
46 ml = m[i] if i < len(m) else '' |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
47 if bl != ml: |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
48 if lastWasFlags: |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
49 bdiff.append(b[i - 1]) |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
50 mdiff.append(m[i - 1]) |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
51 bdiff.append(bl) |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
52 mdiff.append(ml) |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
53 lastWasFlags = bl.startswith('Flags: ') |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
54 print('-----------------------------') |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
55 print('Mismatch in ' + path) |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
56 print('blastem output:') |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
57 for b in bdiff: |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
58 print(b) |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
59 print('clean output:') |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
60 for m in mdiff: |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
61 print(m) |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
62 print('-----------------------------') |
600
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 else: |
2608
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
64 print(path, 'passed') |
600
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 except subprocess.CalledProcessError as e: |
2608
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
66 print('-----------------------------') |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
67 print('clean exited with code', e.returncode, 'for test', path) |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
68 print('blastem output:') |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
69 print(b) |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
70 print('-----------------------------') |
600
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 except subprocess.CalledProcessError as e: |
2608
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
72 print('-----------------------------') |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
73 print('blastem exited with code', e.returncode, 'for test', path) |
898386e48243
Update zcompare for Python 3, to use another blastem as comparison source and to more clearly report differences
Michael Pavone <pavone@retrodev.com>
parents:
600
diff
changeset
|
74 print('-----------------------------') |
600
a9dcaacdc0c5
Add Z80 test runner Python script I wrote a while back and forgot to commit
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 |