46 lines
1.9 KiB
Python
46 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Phase-1.0BT corrected-timeout 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 Phase10BTGuardrails(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.data = json.loads((root / "manifests/retroarch/phase-1.0bt-corrected-timeout-one-shot-gate.json").read_text(encoding="utf-8"))
|
|
|
|
def test_parent_and_only_timeout_changed(self) -> None:
|
|
parent = root / "manifests/retroarch/phase-1.0bs-read-only-status-timeout.json"
|
|
self.assertEqual(hashlib.sha256(parent.read_bytes()).hexdigest(), self.data["source_bindings"]["phase10bs_manifest_sha256"])
|
|
correction = self.data["correction"]
|
|
self.assertEqual((correction["operation"], correction["timeout_seconds"], correction["output_limit"]), ("verify_sdl_clean", 120, 4096))
|
|
self.assertTrue(correction["argv_unchanged"])
|
|
self.assertTrue(correction["all_other_requests_unchanged"])
|
|
|
|
def test_one_shot_scope(self) -> None:
|
|
for value in self.data["preflight"].values():
|
|
self.assertTrue(value)
|
|
invocation = self.data["invocation"]
|
|
self.assertEqual(invocation["attempts_authorized"], 1)
|
|
self.assertFalse(invocation["automatic_retry"])
|
|
self.assertFalse(invocation["cleanup_authorized"])
|
|
auth = self.data["authorizations"]
|
|
for key, value in auth.items():
|
|
if key in ("exact_script_entrypoint_invocation_authorized", "materializer_invocation_authorized", "cmake_invocation_authorized", "sdl_build_authorized"):
|
|
self.assertTrue(value, key)
|
|
else:
|
|
self.assertFalse(value, key)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(argv=[__file__])
|