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.0CK native-SDK materializer 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 Phase10CKGuardrails(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.data = json.loads((root / "manifests/retroarch/phase-1.0ck-native-sdk-sdl-materializer-one-shot-gate.json").read_text(encoding="utf-8"))
|
|
|
|
def test_parent_and_sources(self) -> None:
|
|
parent = root / "manifests/retroarch/phase-1.0cj-native-sdk-stage-design-gate.json"
|
|
self.assertEqual(hashlib.sha256(parent.read_bytes()).hexdigest(), self.data["source_bindings"]["phase10cj_manifest_sha256"])
|
|
self.assertEqual(self.data["source_bindings"]["retroarch_commit"], "57f00244a374b771cddf259a70c144a1dff96457")
|
|
|
|
def test_one_attempt_without_retry(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_at_native_archive(self) -> None:
|
|
auth = self.data["authorizations"]
|
|
self.assertTrue(auth["native_sdk_stage_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__])
|