60 lines
2.5 KiB
Python
60 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Phase-1.0BW corrected materializer one-shot guardrails."""
|
|
|
|
import argparse
|
|
import hashlib
|
|
import json
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--root", type=Path, required=True)
|
|
root = parser.parse_args().root
|
|
|
|
|
|
class Phase10BWGuardrails(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.data = json.loads((root / "manifests/retroarch/phase-1.0bw-corrected-sdl-materializer-one-shot-gate.json").read_text(encoding="utf-8"))
|
|
|
|
def test_parent_and_sources_are_exactly_bound(self) -> None:
|
|
parent = root / "manifests/retroarch/phase-1.0bv-windows-git-fixture-result-and-request-correction-gate.json"
|
|
self.assertEqual(hashlib.sha256(parent.read_bytes()).hexdigest(), self.data["source_bindings"]["phase10bv_manifest_sha256"])
|
|
bindings = self.data["source_bindings"]
|
|
self.assertEqual(bindings["retroarch_commit"], "3974ee13ddac828109b3f558067378be3515f10b")
|
|
for key, value in bindings.items():
|
|
if key.endswith("_sha256"):
|
|
self.assertRegex(value, r"^[0-9a-f]{64}$", key)
|
|
|
|
def test_one_shot_is_exact_and_nonretrying(self) -> None:
|
|
one_shot = self.data["one_shot"]
|
|
self.assertEqual(one_shot["attempts_authorized"], 1)
|
|
self.assertEqual(one_shot["argv"], [
|
|
"/usr/bin/python3.14",
|
|
"tools/phase10bq_sdl_materializer_entrypoint.py"])
|
|
self.assertEqual(one_shot["environment"], {
|
|
"PYTHONDONTWRITEBYTECODE": "1"})
|
|
self.assertFalse(one_shot["automatic_retry"])
|
|
self.assertFalse(one_shot["cleanup_on_failure_authorized"])
|
|
self.assertFalse(one_shot["output_path_reuse_authorized"])
|
|
|
|
def test_scope_ends_at_offline_sdl_archive(self) -> None:
|
|
auth = self.data["authorizations"]
|
|
for key in ("materializer_invocation_authorized",
|
|
"detached_sdl_stage_authorized",
|
|
"offline_patch_application_authorized",
|
|
"cmake_invocation_authorized",
|
|
"sdl_build_authorized"):
|
|
self.assertTrue(auth[key], key)
|
|
for key in ("retroarch_target_build_authorized",
|
|
"network_access_authorized",
|
|
"ps5_connection_authorized",
|
|
"device_transfer_authorized",
|
|
"device_execution_authorized"):
|
|
self.assertFalse(auth[key], key)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(argv=[__file__])
|