Implement AXIS parity UI and execution baseline
This commit is contained in:
35
scripts/test_device_io_s2_report.py
Normal file
35
scripts/test_device_io_s2_report.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import hashlib
|
||||
import json
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import generate_device_io_s2_report
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
class DeviceIoS2ReportTests(unittest.TestCase):
|
||||
def test_contract(self):
|
||||
report = json.loads((ROOT / "coverage/device-io-s2.report.json").read_text(encoding="utf-8"))
|
||||
self.assertEqual(report["schema"], "device-io-s2-report.v1")
|
||||
self.assertEqual(report["task_id"], "S2-03")
|
||||
self.assertEqual(report["status"], "verified")
|
||||
self.assertTrue(report["tests"]["native_wasm_byte_identical"])
|
||||
|
||||
def test_self_hash(self):
|
||||
report = json.loads((ROOT / "coverage/device-io-s2.report.json").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(json.dumps(unsigned, ensure_ascii=False, sort_keys=True, separators=(",", ":")).encode()).hexdigest())
|
||||
|
||||
def test_deterministic_generation(self):
|
||||
first = ROOT / "coverage/.device-io-s2-one.json"
|
||||
second = ROOT / "coverage/.device-io-s2-two.json"
|
||||
try:
|
||||
self.assertEqual(generate_device_io_s2_report.generate(first), generate_device_io_s2_report.generate(second))
|
||||
finally:
|
||||
first.unlink(missing_ok=True)
|
||||
second.unlink(missing_ok=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user