Files
Brian Holman 5534005799 Sync VCC Plus 3.7.1 build 67 source
Refresh reviewed MCP output export, four-drive owned playtests, bounded BASIC readiness, and pinned CMOC 0.1.101 source/patches. Preserve independent source-edition identity, empty libraries, notices and privacy boundaries.

Validated 74 export/privacy checks, pinned dependency sources, and an independent unsigned universal Release build. A subsequent documentation-only correction removes an excluded qualification link; all build inputs remain identical.
2026-11-17 08:42:27 -07:00

62 lines
2.9 KiB
Python

# SPDX-License-Identifier: GPL-3.0-or-later
"""Compile and execute CMOC 0.1.101 correctness cases on both emulated CPUs."""
import argparse
import os
from pathlib import Path
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("rom", type=Path)
parser.add_argument("--host-arch", choices=("arm64", "x86_64"))
args = parser.parse_args()
fixture = Path(__file__).resolve().parent
runtime = args.runtime.resolve(strict=True)
command = (["/usr/bin/arch", "-" + args.host_arch] if args.host_arch else []) + [runtime / "bin/cmoc"]
env = dict(os.environ, PATH=str(runtime / "bin") + os.pathsep + os.environ["PATH"])
# Build values independently on the host. Include every initialized byte,
# terminating zero and neighboring sentinel rather than an in-guest assert.
language = "LANG 03F807E0 12345678 444 41424300 41424300 5541424300AA END"
cases = [("qualification.c", language),
("handler-addresses.c", "HANDLERS N1 S1 P1 END")]
with tempfile.TemporaryDirectory(prefix="vcc-cmoc-0.1.101-") as work:
diagnostics = Path(work) / "diagnostics.c"
diagnostics.write_text('''struct Empty { char; };
union EmptyUnion { long; };
int main(void) {
int;
char *pointer = (char *) 123;
int array[4];
switch (pointer) {}
switch (array) {}
return 0;
}
''')
result = subprocess.run(command + ["--coco", "-S", diagnostics], cwd=work,
env=env, capture_output=True, text=True)
output = result.stdout + result.stderr
if (result.returncode != 0 or "error:" in output
or output.count("warning: declaration specifies a type but no declarator name") != 3
or output.count("warning: switch() expression is an address") != 2):
raise RuntimeError("Unexpected CMOC diagnostics:\n" + output)
print("PASS diagnostics: three unnamed declarations, pointer and array switch warnings", flush=True)
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 source, expected in cases:
for optimization in ("-O0", "-O2"):
print("Checking CMOC 0.1.101", source, optimization, flush=True)
subprocess.run(command + ["--coco", optimization, "--org=2800", "--intermediate", "-Werror",
"-o", "TEST.BIN", fixture / source], cwd=work, env=env, check=True)
subprocess.run([runner, args.rom.resolve(strict=True), "TEST.BIN", expected],
cwd=work, check=True)
if __name__ == "__main__":
main()