45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Tracked guardrails for Phase-1.0AH."""
|
|
|
|
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 Phase10AHGuardrails(unittest.TestCase):
|
|
@classmethod
|
|
def setUpClass(cls) -> None:
|
|
cls.data = json.loads((ROOT / "manifests/retroarch/phase-1.0ah-dynamic-contract.json").read_text(encoding="utf-8"))
|
|
|
|
def test_relocation_split_is_exact(self) -> None:
|
|
contract = self.data["contract"]
|
|
self.assertEqual(contract["loader_applied_relocation_types"],
|
|
["R_X86_64_RELATIVE"])
|
|
self.assertEqual(contract["crt_applied_relocation_types"],
|
|
["R_X86_64_GLOB_DAT"])
|
|
self.assertFalse(contract["unknown_relocation_types_allowed"])
|
|
|
|
def test_historical_metadata_is_not_byte_evidence(self) -> None:
|
|
reference = self.data["historical_phase10m_reference"]
|
|
self.assertFalse(reference["exact_bytes_present"])
|
|
self.assertFalse(reference["validated_by_phase10ah"])
|
|
|
|
def test_no_mapping_or_authority(self) -> None:
|
|
self.assertFalse(any(self.data["authorizations"].values()))
|
|
self.assertFalse(self.data["decision"]["target_mapping_allowed"])
|
|
self.assertFalse(self.data["decision"]["target_implementation_allowed"])
|
|
self.assertFalse(self.data["decision"]["device_action_allowed"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main(argv=[__file__])
|