#!/usr/bin/env python3 # SPDX-License-Identifier: GPL-3.0-or-later """Validate the Phase-1.0BA callsite and profile-delta audit.""" from __future__ import annotations import argparse import hashlib import json import subprocess from pathlib import Path def git(repo: Path, *args: str) -> str: return subprocess.run(["git", *args], cwd=repo, check=True, capture_output=True, text=True).stdout.strip() def main() -> int: parser = argparse.ArgumentParser() parser.add_argument("--root", type=Path, required=True) parser.add_argument("--retroarch-root", type=Path, required=True) args = parser.parse_args() path = args.root / "manifests/retroarch/phase-1.0ba-target-profile-callsite-audit.json" data = json.loads(path.read_text(encoding="utf-8")) bind = data["source_bindings"] az = args.root / "manifests/retroarch/phase-1.0az-host-av-source.json" assert hashlib.sha256(az.read_bytes()).hexdigest() == bind["phase10az_manifest_sha256"] commit = bind["retroarch_commit"] paths = {"retroarch_c": "retroarch.c", "platform_ps5_c": "frontend/drivers/platform_ps5.c", "makefile": "Makefile.ps5"} for key, source in paths.items(): assert git(args.retroarch_root, "rev-parse", f"{commit}:{source}") == bind[f"{key}_blob"] source = git(args.retroarch_root, "show", f"{commit}:retroarch.c") sequence = "int result = rarch_main(argc, argv, NULL);" sequence += "\n#if defined(CHIMERA_PS5_SMOKE_MODE)" sequence += "\n chimera_ps5_smoke_set_phase(CHIMERA_SMOKE_S15_COMPLETE);\n _Exit(result);" assert sequence in source assert "main_exit(data);\n#endif\n\n return 0;" in source assert not data["authorizations"]["target_build_authorized"] assert data["decision"]["source_patch_allowed"] assert not data["decision"]["cross_build_allowed"] print("Phase-1.0BA callsite/profile audit validation passed") return 0 if __name__ == "__main__": raise SystemExit(main())