from frame_shm import LatestFrameReader, LatestFrameWriter, frame_bytes def test_latest_frame_roundtrip(tmp_path): path = str(tmp_path / "cam-01.i420") w, h = 16, 16 n = frame_bytes(w, h) writer = LatestFrameWriter(path, w, h) payload = bytes(range(256)) * (n // 256 + 1) payload = payload[:n] seq = writer.write(payload) assert seq == 1 reader = LatestFrameReader(path) got = reader.latest() assert got is not None assert got[0] == 1 assert got[1] == payload seq2 = writer.write(bytes([3]) * n) got2 = reader.latest() assert got2 is not None assert got2[0] == seq2 assert got2[1][0] == 3 writer.close()