Files
chimera-gfx-Public/tests/test_retroarch_phase10r.py
Chimera GFX release export a6037502d7
phase0-ci / build-and-audit (push) Successful in 2m14s
Publish Chimera GFX source
2026-09-03 03:27:14 +02:00

129 lines
5.2 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Mutation guardrails for Phase-1.0R launch-context analysis."""
from __future__ import annotations
import argparse
import importlib.util
from pathlib import Path
import sys
def load(path: Path):
spec = importlib.util.spec_from_file_location("phase10r", path)
assert spec and spec.loader
module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = module
spec.loader.exec_module(module)
return module
def require(value: bool, message: str) -> None:
if not value:
raise RuntimeError(message)
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--root", type=Path, required=True)
args = parser.parse_args()
root = args.root.resolve()
validator = load(root / "tools/validate_retroarch_phase10r.py")
record = validator.load_json(
root / "manifests/retroarch/phase-1.0r-launch-context-analysis.json")
cases = []
def case(name):
def register(function):
cases.append((name, function))
return function
return register
@case("01 authorizations remain false")
def _(): require(validator.all_false(record["authorizations"], validator.AUTHORIZATION_FIELDS), "authority active")
@case("02 target build authorization fails")
def _():
value = dict(record["authorizations"]); value["target_build_authorized"] = True
require(not validator.all_false(value, validator.AUTHORIZATION_FIELDS), "target build allowed")
@case("03 automatic retry fails")
def _():
value = dict(record["authorizations"]); value["automatic_retry"] = True
require(not validator.all_false(value, validator.AUTHORIZATION_FIELDS), "retry allowed")
@case("04 source identities are exact")
def _(): require(validator.source_identities_are_exact(record["source_identities"]), "identity rejected")
@case("05 SDL2main remains lifecycle only")
def _(): require(validator.sdl2main_is_lifecycle_only(record["sdl2main"]), "wrapper rejected")
@case("06 invented app registration fails")
def _():
value = dict(record["sdl2main"]); value["adds_application_registration"] = True
require(not validator.sdl2main_is_lifecycle_only(value), "registration invented")
@case("07 LoadExec cannot become pre-submit")
def _():
value = dict(record["sdl2main"]); value["post_return_action"] = "PRE_SUBMIT_LOAD_EXEC"
require(not validator.sdl2main_is_lifecycle_only(value), "timing promoted")
@case("08 exact RetroArch path omits SDL2main")
def _(): require(validator.retroarch_path_is_exact(record["exact_retroarch_path"]), "path rejected")
@case("09 exact RetroArch path retains splash hide")
def _(): require(record["exact_retroarch_path"]["system_service_hide_splash_imported"] is True, "hide missing")
@case("10 exact RetroArch path links SDK CRT")
def _(): require(record["exact_retroarch_path"]["sdk_crt1_linked"] is True, "CRT missing")
@case("11 direct and manager routes share elfldr")
def _(): require(validator.launch_routes_are_fail_closed(record["launch_routes"]), "routes rejected")
@case("12 manager route cannot become distinct context")
def _():
value = dict(record["launch_routes"]); value["controlled_route_creates_distinct_app_context"] = True
require(not validator.launch_routes_are_fail_closed(value), "context invented")
@case("13 PacBrew is not promoted to launcher")
def _(): require(validator.packaging_is_not_launcher_proof(record["packaging_and_ports"]), "packaging rejected")
@case("14 homebrew descriptor is not registration")
def _(): require(record["packaging_and_ports"]["homebrew_js_is_app_registration"] is False, "descriptor promoted")
@case("15 unbound hbldr keeps launcher partial")
def _(): require(record["launch_routes"]["port_launcher_contract"] == "PARTIAL_UNBOUND", "launcher promoted")
@case("16 LNC log is not root cause")
def _(): require(validator.runtime_observation_is_not_promoted(record["runtime_observation"]), "runtime promoted")
@case("17 root cause remains unresolved")
def _(): require(record["decision"]["root_cause_resolved"] is False, "root cause invented")
@case("18 parameter and VideoOut changes remain blocked")
def _(): require(validator.decision_is_blocked(record["decision"]), "decision rejected")
@case("19 target source and artifact remain absent")
def _(): require(record["performed_actions"]["target_source_changed"] is False and record["performed_actions"]["target_artifact_created"] is False, "target action claimed")
@case("20 host audit is not hardware evidence")
def _(): require(record["tests"]["hardware_claim_from_host_test"] is False, "host audit promoted")
failures = []
for name, function in cases:
try:
function()
print(f"PASS {name}")
except Exception as error: # noqa: BLE001 - mutation harness
failures.append(f"{name}: {error}")
print(f"FAIL {name}: {error}")
if failures:
return 1
print(f"Phase-1.0R guardrails passed: {len(cases)}")
return 0
if __name__ == "__main__":
raise SystemExit(main())