# SPDX-License-Identifier: GPL-3.0-or-later """Run the guest input and audio qualification on both CoCo 3 processors.""" import argparse import os from pathlib import Path import re import subprocess import tempfile def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("runtime", type=Path, help="staged CMOC toolchain") parser.add_argument("core", type=Path, help="current libVCCCore.a") parser.add_argument("roms", type=Path, help="local CoCo 3 and Speech/Sound ROM directory") args = parser.parse_args() runtime, core, roms = (p.resolve(strict=True) for p in (args.runtime, args.core, args.roms)) fixture = Path(__file__).resolve().parent env = dict(os.environ, PATH=str(runtime / "bin") + ":/usr/bin:/bin", VCC_CMOC_COMPAT="0") with tempfile.TemporaryDirectory(prefix="vcc-input-") as folder: work = Path(folder) subprocess.run(["xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0", "-I", fixture.parents[2] / "src", fixture / "run.cpp", core, "-o", work / "run"], check=True) for optimization in ("-O0", "-O2"): subprocess.run([runtime / "bin/cmoc", "--coco", "--intermediate", "--org=2800", optimization, "-Werror", "-o", "QUAL.bin", fixture / "qualification.c", "-linput", "-lbcontrol", "-lssc", "-lorch90"], env=env, cwd=work, check=True) symbols = dict(re.findall(r"^Symbol: _(\w+) \(.+?\) = ([0-9A-F]+)$", (work / "QUAL.map").read_text(), re.MULTILINE)) print("Checking compiled input caller", optimization, flush=True) subprocess.run([work / "run", roms, work / "QUAL.bin", *(symbols[n] for n in ("stage", "ack", "report"))], check=True) if __name__ == "__main__": main()