further digging and basic emulator
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import io
|
||||
import json
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from h8536.protocol_capture import analyze_capture_text, format_text_report, main, parse_capture_text
|
||||
|
||||
@@ -15,6 +16,15 @@ class ProtocolCaptureTest(unittest.TestCase):
|
||||
self.assertEqual(chunks[0].device_direction, "tx")
|
||||
self.assertEqual(chunks[0].bytes, (0x00, 0x00, 0x15, 0x80, 0x00, 0xCF))
|
||||
|
||||
def test_parses_idle_frame_lines_without_direction_token(self):
|
||||
chunks = parse_capture_text("11:54:40.567 frame 006 00 00 00 00 80 DA\n")
|
||||
|
||||
self.assertEqual(len(chunks), 1)
|
||||
self.assertEqual(chunks[0].timestamp_ms, 42880567)
|
||||
self.assertEqual(chunks[0].analyzer_direction, "rx")
|
||||
self.assertEqual(chunks[0].device_direction, "tx")
|
||||
self.assertEqual(chunks[0].bytes, (0x00, 0x00, 0x00, 0x00, 0x80, 0xDA))
|
||||
|
||||
def test_recombines_user_split_rx_chunks_into_valid_call_frame(self):
|
||||
analysis = analyze_capture_text(
|
||||
"16:06:15.502 RX 003 bytes 00 00 15\n"
|
||||
@@ -140,6 +150,23 @@ class ProtocolCaptureTest(unittest.TestCase):
|
||||
payload = json.loads(output.getvalue())
|
||||
self.assertEqual(payload["frames"][0]["report_candidate"]["index"], 0x15)
|
||||
|
||||
def test_idle_reference_capture_when_present(self):
|
||||
path = Path("ROM/rcp-txd-idle-only.txt")
|
||||
if not path.exists():
|
||||
self.skipTest("idle reference capture is not present")
|
||||
|
||||
analysis = analyze_capture_text(path.read_text(encoding="utf-8"))
|
||||
|
||||
self.assertGreaterEqual(analysis["frame_count"], 10)
|
||||
self.assertEqual(
|
||||
analysis["gate_session_hints"]["observed_autonomous_report_names"],
|
||||
["heartbeat_alive_candidate"],
|
||||
)
|
||||
heartbeat = analysis["gate_session_hints"]["heartbeat_cadence_ms"]
|
||||
self.assertEqual(heartbeat["count"], analysis["frame_count"])
|
||||
self.assertGreater(heartbeat["average"], 600)
|
||||
self.assertLess(heartbeat["average"], 800)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user