48 lines
1.9 KiB
Python
48 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Phase-1.0CJ native SDK stage design 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 Phase10CJGuardrails(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.data = json.loads((root / "manifests/retroarch/phase-1.0cj-native-sdk-stage-design-gate.json").read_text(encoding="utf-8"))
|
|
|
|
def test_parent_and_full_tree_binding(self) -> None:
|
|
parent = root / "manifests/retroarch/phase-1.0ci-native-sdk-bottleneck-and-cleanup-gate.json"
|
|
self.assertEqual(hashlib.sha256(parent.read_bytes()).hexdigest(), self.data["source_bindings"]["phase10ci_manifest_sha256"])
|
|
tree = self.data["sdk_tree"]
|
|
self.assertEqual(tree["regular_files"], 2923)
|
|
self.assertEqual(tree["symbolic_links"], 0)
|
|
self.assertRegex(tree["normalized_tar_sha256"], r"^[0-9a-f]{64}$")
|
|
|
|
def test_design_verifies_before_configure(self) -> None:
|
|
design = self.data["design_contract"]
|
|
self.assertTrue(design["copy_exclusive"])
|
|
self.assertTrue(design["verify_complete_tree_before_configure"])
|
|
self.assertTrue(design["configure_uses_native_sdk_only"])
|
|
self.assertFalse(design["archive_export_included"])
|
|
|
|
def test_only_source_and_fake_tests_are_open(self) -> None:
|
|
auth = self.data["authorizations"]
|
|
self.assertTrue(auth["native_sdk_stage_source_design_authorized"])
|
|
self.assertTrue(auth["fake_host_tests_authorized"])
|
|
for key, value in auth.items():
|
|
if key not in ("native_sdk_stage_source_design_authorized",
|
|
"fake_host_tests_authorized"):
|
|
self.assertFalse(value, key)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(argv=[__file__])
|