45 lines
1.8 KiB
Python
45 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Phase-1.0CH native materializer gate 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 Phase10CHGuardrails(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.data = json.loads((root / "manifests/retroarch/phase-1.0ch-native-wsl-sdl-materializer-one-shot-gate.json").read_text(encoding="utf-8"))
|
|
|
|
def test_parent_and_source_hashes(self) -> None:
|
|
parent = root / "manifests/retroarch/phase-1.0cg-native-wsl-sdl-materializer-design-gate.json"
|
|
self.assertEqual(hashlib.sha256(parent.read_bytes()).hexdigest(), self.data["source_bindings"]["phase10cg_manifest_sha256"])
|
|
self.assertEqual(self.data["source_bindings"]["retroarch_commit"], "ab419bb85d4ce54aa0d9f59671498957615d1811")
|
|
|
|
def test_exact_one_shot(self) -> None:
|
|
one = self.data["one_shot"]
|
|
self.assertEqual(one["attempts_authorized"], 1)
|
|
self.assertFalse(one["automatic_retry"])
|
|
self.assertFalse(one["cleanup_on_failure_authorized"])
|
|
self.assertTrue(self.data["preflight"]["native_root_absent"])
|
|
|
|
def test_scope_stops_before_export_and_target(self) -> None:
|
|
auth = self.data["authorizations"]
|
|
self.assertTrue(auth["native_root_creation_authorized"])
|
|
self.assertTrue(auth["sdl_build_authorized"])
|
|
for key in ("archive_export_authorized", "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__])
|