52 lines
2.5 KiB
Python
52 lines
2.5 KiB
Python
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Exercise guest C printer output and compare the emulator's raw captured bytes."""
|
|
import argparse
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
import tempfile
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("runtime", type=Path)
|
|
parser.add_argument("core", type=Path)
|
|
parser.add_argument("roms", type=Path)
|
|
parser.add_argument("--capture", type=Path, help="save a real guest screen as a PNG")
|
|
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
|
|
root = fixture.parents[2]
|
|
env = dict(os.environ, VCC_CMOC_COMPAT="1", PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
|
|
with tempfile.TemporaryDirectory(prefix="vcc-printer-") as tmp:
|
|
work = Path(tmp)
|
|
|
|
def run(*cmd):
|
|
subprocess.run(cmd, cwd=work, env=env, check=True)
|
|
|
|
run("xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
|
|
"-I", root / "src", fixture / "run.cpp", core, "-o", "run")
|
|
card = work / "card"
|
|
card.mkdir()
|
|
(card / "startup.cfg").write_text("0=VOL.DSK\n")
|
|
for opt in ("-O0", "-O2"):
|
|
for source, binary in ((root / "examples/cmoc/manual/flightreport.c", "FLIGHT.BIN"),
|
|
(fixture / "qualification.c", "QUAL.BIN")):
|
|
run(runtime / "bin/cmoc", "--coco", opt, "-Werror", "--org=2800",
|
|
"-o", binary, source, "-lvcccompat")
|
|
shutil.copyfile(root / "docs/manuals/software-storage-and-peripherals/media/BLANK.DSK", card / "VOL.DSK")
|
|
run(runtime / "bin/writecocofile", card / "VOL.DSK", "FLIGHT.BIN")
|
|
for cpu in ("6809", "6309"):
|
|
for profile in ("disk", "rgb-hd", "sdc"):
|
|
capture = args.capture and (cpu, opt, profile) == ("6809", "-O2", "disk")
|
|
run("./run", roms, cpu, profile, "capture" if capture else "check")
|
|
if capture:
|
|
run("sips", "-s", "format", "png", "flight.ppm", "--out", args.capture.resolve())
|
|
print(f"PASS {cpu} {opt} {profile}: direct and disk launch, capture off/on, raw flight report, "
|
|
"variadic formatting, device and console hook restoration, BASIC return", flush=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|