Files
VCCPlusOSS/tests/toolchain/indexed-subtraction/check.py
T

35 lines
1.7 KiB
Python

# SPDX-License-Identifier: GPL-3.0-or-later
"""Execute CMOC byte-subtraction regression cases on both emulated CPUs."""
import argparse
import subprocess
import tempfile
from pathlib import Path
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("runtime", type=Path, help="staged CMOC toolchain")
parser.add_argument("core", type=Path, help="libVCCCore.a")
parser.add_argument("rom", type=Path, help="locally supplied CoCo 3 ROM")
args = parser.parse_args()
fixture = Path(__file__).resolve().parent
compiler = args.runtime.resolve(strict=True) / "bin/cmoc"
with tempfile.TemporaryDirectory(prefix="vcc-indexed-subtraction-") as work:
runner = Path(work) / "run-compiled"
subprocess.run(["xcrun", "clang++", "-std=c++17", "-O2", "-mmacosx-version-min=14.0",
fixture.parent / "run-compiled.cpp", args.core.resolve(strict=True), "-o", runner],
check=True)
for optimization in ("-O0", "-O2"):
print("Checking indexed subtraction", optimization, flush=True)
subprocess.run([compiler, "--coco", "--org=2800", optimization, "-Werror", "-o", "TEST.BIN",
fixture / "qualification.c"], cwd=work, check=True)
# Terrain, equal/unequal pairs, pointer indexing, byte index, reversed subtraction and two reads.
expected = [172, 150, 128, 106, 0, 1, 169, 240, 0, 128, 0, 234, 66, 190]
marker = "HX " + "".join(f"{value:02X}" for value in expected)
subprocess.run([runner, args.rom.resolve(strict=True), "TEST.BIN", marker],
cwd=work, check=True)
if __name__ == "__main__":
main()