#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Run Lynx Hardware Tests suites (drhelius, MIT; built by build_lynx_tests.py) and judge them. Each suite runs through the real boot ROM until ``run_tests`` returns; its result bytes are judged with its own expectation table (``lynx_python.testrom``). python -I scripts/hwtests.py [--row lynx2|lynx1|both] [SUITE ...] With no suite named, the milestone 2 suites run. ``--quiet`` prints one line per suite. The exit status is 0 when every test passes. """ from __future__ import annotations import argparse import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / "src")) from lynx_python import testrom from lynx_python.machine import MACHINES M2 = ["cpu", "page-mode", "memio", "timers", "timers2", "math", "sdoneack"] M4 = ["sprites1", "sprites2", "sprites3", "sprites4", "sprites5"] M6 = ["audio", "audio2", "uart", "uart2", "uart3"] GROUPS = {"m2": M2, "m4": M4, "m6": M6, "all": M2 + M4 + M6} def main(argv: list[str]) -> int: parser = argparse.ArgumentParser() parser.add_argument("suites", nargs="*") parser.add_argument("--row", default="both") parser.add_argument("--quiet", action="store_true") args = parser.parse_args(argv) suites: list[str] = [] for name in args.suites or ["m2"]: suites.extend(GROUPS.get(name, [name])) rows = ["lynx2", "lynx1"] if args.row == "both" else [args.row] failed = 0 for row in rows: passed = total = 0 for suite in suites: outcome = testrom.run(suite, MACHINES[row]) passed += sum(outcome.passed) total += len(outcome.passed) failed += len(outcome.passed) - sum(outcome.passed) if args.quiet: print(f"{row} {suite}: {outcome.summary()}", flush=True) else: print(testrom.report(outcome), flush=True) print(f"{row}: {passed}/{total}", flush=True) return 0 if failed == 0 else 1 if __name__ == "__main__": sys.exit(main(sys.argv[1:]))