40 lines
1.6 KiB
Python
40 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Phase-1.0CN measured native build 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 Phase10CNGuardrails(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.data = json.loads((root / "manifests/retroarch/phase-1.0cn-measured-native-sdl-materializer-one-shot-gate.json").read_text(encoding="utf-8"))
|
|
|
|
def test_parent_and_exact_bound(self) -> None:
|
|
parent = root / "manifests/retroarch/phase-1.0cm-measured-configure-timeout-correction-gate.json"
|
|
self.assertEqual(hashlib.sha256(parent.read_bytes()).hexdigest(), self.data["source_bindings"]["phase10cm_manifest_sha256"])
|
|
one = self.data["one_shot"]
|
|
self.assertEqual(one["attempts_authorized"], 1)
|
|
self.assertEqual(one["configure_timeout_seconds"], 1800)
|
|
self.assertEqual(one["build_timeout_seconds"], 600)
|
|
self.assertFalse(one["automatic_retry"])
|
|
|
|
def test_no_export_target_or_device(self) -> None:
|
|
auth = self.data["authorizations"]
|
|
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__])
|