| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
import sys |
| 16 |
import urllib.request |
| 17 |
from pathlib import Path |
| 18 |
|
| 19 |
DEST = Path(__file__).resolve().parent / "klaus" |
| 20 |
BASE = ("https://raw.githubusercontent.com/Klaus2m5/" |
| 21 |
"6502_65C02_functional_tests/master/bin_files") |
| 22 |
|
| 23 |
BINARIES = ( |
| 24 |
"6502_functional_test.bin", |
| 25 |
"65C02_extended_opcodes_test.bin", |
| 26 |
) |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
LISTINGS = ( |
| 32 |
"6502_functional_test.lst", |
| 33 |
"65C02_extended_opcodes_test.lst", |
| 34 |
) |
| 35 |
|
| 36 |
EXPECTED_SIZE = 65536 |
| 37 |
|
| 38 |
|
| 39 |
def get(name, path, expect_size=None): |
| 40 |
if path.exists() and (expect_size is None or path.stat().st_size == expect_size): |
| 41 |
print(f" have {name}") |
| 42 |
return True |
| 43 |
print(f" get {name}") |
| 44 |
try: |
| 45 |
with urllib.request.urlopen(f"{BASE}/{name}", timeout=180) as r: |
| 46 |
data = r.read() |
| 47 |
except Exception as exc: |
| 48 |
print(f" FAIL {name}: {exc}") |
| 49 |
return False |
| 50 |
if expect_size is not None and len(data) != expect_size: |
| 51 |
print(f" FAIL {name}: got {len(data)} bytes, expected {expect_size}") |
| 52 |
return False |
| 53 |
path.write_bytes(data) |
| 54 |
return True |
| 55 |
|
| 56 |
|
| 57 |
def main(): |
| 58 |
DEST.mkdir(parents=True, exist_ok=True) |
| 59 |
ok = True |
| 60 |
|
| 61 |
for name in BINARIES: |
| 62 |
ok &= get(name, DEST / name, EXPECTED_SIZE) |
| 63 |
for name in LISTINGS: |
| 64 |
ok &= get(name, DEST / name) |
| 65 |
|
| 66 |
print(f"\ntest images in {DEST}") |
| 67 |
return 0 if ok else 1 |
| 68 |
|
| 69 |
|
| 70 |
if __name__ == "__main__": |
| 71 |
sys.exit(main()) |