fix(stream): payload-length cap, quiet-port resync, main-thread error teardown
This commit is contained in:
@@ -96,6 +96,45 @@ def test_leaving_live_mode_stops_stream(controller):
|
||||
assert not controller._repaint_timer.isActive()
|
||||
|
||||
|
||||
def test_binary_frame_decode_bounded_to_loaded_layout(controller, monkeypatch):
|
||||
"""Regression for phantom sensor #239 polluting MIN/MAX/AVG: the wire
|
||||
payload carries a fixed-width channel array (up to 244 slots) wider than
|
||||
any single wafer family's real sensor count. Family "A" (aepwafer.yaml)
|
||||
has 48 real sensors — everything past that in the payload is an
|
||||
unpopulated hardware slot and must never reach Frame.values."""
|
||||
fake_transport = MagicMock()
|
||||
fake_transport.read.return_value = b""
|
||||
monkeypatch.setattr(
|
||||
"pygui.serialcomm.serial_port.SerialPort.open_port",
|
||||
lambda *a, **k: fake_transport,
|
||||
)
|
||||
|
||||
controller.startStream("COM_FAKE", "A")
|
||||
try:
|
||||
assert len(controller._sensors) == 48 # sanity: aepwafer.yaml loaded
|
||||
parse = controller._reader._parse
|
||||
payload = bytes(244 * 2) # full-width wire payload, well beyond the real 48
|
||||
frame = parse(payload, seq=1)
|
||||
assert len(frame.values) == 48
|
||||
finally:
|
||||
controller.stopStream()
|
||||
|
||||
|
||||
def test_live_error_surfaces_message_and_stops_stream(controller):
|
||||
"""A fatal StreamReader error must reach QML with its message (for the
|
||||
Activity Log) and must tear the stream down cleanly."""
|
||||
controller.setMode("live")
|
||||
controller._reader = MagicMock()
|
||||
|
||||
error_seen = MagicMock()
|
||||
controller.liveError.connect(error_seen)
|
||||
|
||||
controller._on_live_error("Binary stream resync failed: no sync marker")
|
||||
|
||||
error_seen.assert_called_once_with("Binary stream resync failed: no sync marker")
|
||||
assert controller._reader is None
|
||||
|
||||
|
||||
def test_compare_files_integration(controller):
|
||||
# Mock the comparisonResult signal
|
||||
mock_slot = MagicMock()
|
||||
|
||||
Reference in New Issue
Block a user