Files
chimera-gfx-Public/tests/test_retroarch_phase10g_result.py
T
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

73 lines
3.1 KiB
Python

#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-3.0-or-later
"""Mutation guardrails for the consumed Phase-1.0G result."""
from __future__ import annotations
import argparse
import importlib.util
from pathlib import Path
import sys
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("--root", type=Path, required=True)
args = parser.parse_args()
root = args.root.resolve()
spec = importlib.util.spec_from_file_location(
"phase10g_result", root / "tools/validate_retroarch_phase10g_result.py"
)
assert spec and spec.loader
module = importlib.util.module_from_spec(spec)
sys.modules[spec.name] = module
spec.loader.exec_module(module)
record = module.load(root / "manifests/retroarch/phase-1.0g-device-result.json")
cases = []
def check(name, condition):
cases.append((name, bool(condition)))
check("current authorizations false", module.all_false(record["current_authorizations"]))
active = dict(record["current_authorizations"])
active["ps5_connection_authorized"] = True
check("future connection rejected", not module.all_false(active))
check("one-shot transport exact", module.transport_is_exact(record["transport"]))
retry = dict(record["transport"])
retry["retry_count"] = 1
check("retry rejected", not module.transport_is_exact(retry))
reconnect = dict(record["transport"])
reconnect["reconnect_count"] = 1
check("reconnect rejected", not module.transport_is_exact(reconnect))
truncated = dict(record["transport"])
truncated["raw_stream_truncated"] = True
check("truncation rejected", not module.transport_is_exact(truncated))
check("frame sequence exact", module.protocol_is_exact(record["protocol_result"]))
invented = dict(record["protocol_result"])
invented["stages"] = list(invented["stages"]) + ["I04"]
invented["frame_count"] = 8
check("invented I04 rejected", not module.protocol_is_exact(invented))
terminal = dict(record["protocol_result"])
terminal["terminal_stage"] = "D11"
check("invented terminal rejected", not module.protocol_is_exact(terminal))
check("authorization consumed", record["authorization"]["consumed"] is True)
check("authority not inherited", record["authorization"]["authority_inherited_by_future_action"] is False)
check("no device write", record["performed_actions"]["device_write_performed"] is False)
check("no installation", record["performed_actions"]["installation_performed"] is False)
check("no autoload", record["performed_actions"]["autoload_performed"] is False)
check("SDL not claimed", record["source_binding"]["sdl_videoout_reached"] is False)
check("rendering not claimed", record["source_binding"]["rendering_reached"] is False)
check("cleanup unproven", record["source_binding"]["terminal_cleanup_proven"] is False)
failed = [name for name, passed in cases if not passed]
for name, passed in cases:
print(f"{'PASS' if passed else 'FAIL'} {name}")
if failed:
return 1
print(f"Phase-1.0G result guardrails passed: {len(cases)}")
return 0
if __name__ == "__main__":
raise SystemExit(main())