47 lines
1.9 KiB
Python
47 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Tracked guardrails for Phase-1.0AS."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
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 Phase10ASGuardrails(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.data = json.loads((ROOT / "manifests/retroarch/phase-1.0as-channel-primitive-audit.json").read_text(encoding="utf-8"))
|
|
|
|
def test_candidates_are_not_composition_proof(self) -> None:
|
|
primitives = self.data["channel_primitives"]
|
|
self.assertTrue(primitives["pipe_used_by_official_shsrv"])
|
|
self.assertTrue(primitives["poll_used_by_official_shsrv"])
|
|
self.assertFalse(primitives["pipe_poll_monotonic_deadline_composition_present"])
|
|
self.assertFalse(primitives["nonblocking_result_read_callsite_present"])
|
|
|
|
def test_current_worker_closes_result_fd(self) -> None:
|
|
ownership = self.data["fd_ownership"]
|
|
self.assertTrue(ownership["rfcfdg_documented_as_close_all_fds"])
|
|
self.assertTrue(ownership["official_shsrv_worker_uses_rfcfdg"])
|
|
self.assertFalse(ownership["result_fd_inherited_by_worker"])
|
|
self.assertFalse(ownership["exclusive_parent_child_end_close_order_present"])
|
|
|
|
def test_no_live_target_or_authority(self) -> None:
|
|
self.assertFalse(any(self.data["authorizations"].values()))
|
|
self.assertFalse(self.data["decision"]["live_channel_architecture_feasible"])
|
|
self.assertFalse(self.data["decision"]["copy_current_shsrv_code_allowed"])
|
|
self.assertFalse(self.data["decision"]["target_implementation_allowed"])
|
|
self.assertFalse(self.data["decision"]["device_action_allowed"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(argv=[__file__])
|