Files
linuxcncWebWASM/scripts/test_sim_case_matrix_s8_06.py

35 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""Contract tests for the S8-06 complete sim case matrix report."""
from __future__ import annotations
import hashlib
import json
import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
import generate_sim_case_matrix_s8_06
ROOT = Path(__file__).resolve().parents[1]
REPORT = ROOT / "coverage/sim-case-matrix-s8-06.report.json"
class SimCaseMatrixS806Tests(unittest.TestCase):
def test_contract(self) -> None:
report = json.loads(REPORT.read_text(encoding="utf-8"))
self.assertEqual(report["schema"], "sim-case-matrix-s8-06-report.v1")
self.assertEqual(report["status"], "verified")
self.assertEqual(report["counts"], {"BLOCKED_HAL": 4, "BLOCKED_INI": 3, "BLOCKED_RESOURCE": 216, "BLOCKED_STARTUP": 2, "TASK_READY": 10})
def test_self_hash(self) -> None:
report = json.loads(REPORT.read_text(encoding="utf-8"))
unsigned = {key: value for key, value in report.items() if key != "report_sha256"}
self.assertEqual(report["report_sha256"], hashlib.sha256(generate_sim_case_matrix_s8_06.canonical(unsigned).encode()).hexdigest())
if __name__ == "__main__":
unittest.main()