Implement AXIS parity UI and execution baseline
This commit is contained in:
48
scripts/test_linuxcnc_source_hal_s5.py
Normal file
48
scripts/test_linuxcnc_source_hal_s5.py
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Tests for the S5-05 HAL/.comp source adapter report."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
import generate_linuxcnc_source_hal_s5
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
REPORT = ROOT / "coverage/linuxcnc-source-hal-s5.report.json"
|
||||
|
||||
|
||||
class LinuxCncSourceHalS5Tests(unittest.TestCase):
|
||||
def test_report_contract(self):
|
||||
report = json.loads(REPORT.read_text(encoding="utf-8"))
|
||||
self.assertEqual(report["schema"], "linuxcnc-source-hal-execution.v1")
|
||||
self.assertEqual(report["task_id"], "S5-05")
|
||||
self.assertEqual(report["status"], "verified")
|
||||
self.assertEqual(report["counts"]["selected_cases"], 8)
|
||||
self.assertEqual(report["counts"]["PASSED"], 3)
|
||||
self.assertEqual(report["counts"]["SOURCE_BLOCKED"], 2)
|
||||
self.assertEqual(report["counts"]["HOST_EXCLUDED"], 3)
|
||||
self.assertTrue(report["native_wasm"]["golden_diff"]["byte_identical"])
|
||||
self.assertTrue(report["worker"]["fixture_hashes_verified"])
|
||||
self.assertEqual(report["expected_checkresult_comparison"]["status"], "SOURCE_BLOCKED")
|
||||
|
||||
def test_self_hash(self):
|
||||
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_linuxcnc_source_hal_s5.canonical(unsigned).encode()).hexdigest())
|
||||
|
||||
def test_deterministic(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
first = generate_linuxcnc_source_hal_s5.generate(ROOT, Path(directory) / "one.json")
|
||||
second = generate_linuxcnc_source_hal_s5.generate(ROOT, Path(directory) / "two.json")
|
||||
self.assertEqual(first, second)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user