From 76f02201031d6521026d6078726364076b95900b Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Mon, 21 Mar 2022 15:07:51 +0100
Subject: [PATCH] L2SS-676: Split off packet parsing tests, add one for
 read_packet.

---
 .../tangostationcontrol/devices/sdp/packet.py |  3 +++
 .../test/devices/test_statistics_collector.py | 20 -------------------
 2 files changed, 3 insertions(+), 20 deletions(-)

diff --git a/tangostationcontrol/tangostationcontrol/devices/sdp/packet.py b/tangostationcontrol/tangostationcontrol/devices/sdp/packet.py
index 61ff69c1b..ae21c8f5a 100644
--- a/tangostationcontrol/tangostationcontrol/devices/sdp/packet.py
+++ b/tangostationcontrol/tangostationcontrol/devices/sdp/packet.py
@@ -543,6 +543,9 @@ def main(args=None, **kwargs):
         # read the packet from input
         packet = read_packet(sys.stdin.buffer.read)
 
+        if not packet:
+            break
+
         # print header
         print(f"# Packet {nr} of class {packet.__class__.__name__} starting at offset {offset} with length {packet.size()}")
         pprint.pprint(packet.header())
diff --git a/tangostationcontrol/tangostationcontrol/test/devices/test_statistics_collector.py b/tangostationcontrol/tangostationcontrol/test/devices/test_statistics_collector.py
index c5e0ca48f..b2bde8e74 100644
--- a/tangostationcontrol/tangostationcontrol/test/devices/test_statistics_collector.py
+++ b/tangostationcontrol/tangostationcontrol/test/devices/test_statistics_collector.py
@@ -209,23 +209,3 @@ class TestXSTCollector(base.TestCase):
 
         self.assertEqual(0, collector.parameters["nof_valid_payloads"][fpga_index])
         self.assertEqual(1, collector.parameters["nof_payload_errors"][fpga_index])
-
-
-
-class TestBeamletPacket(base.TestCase):
-    def test_valid_packet(self):
-        # a valid packet as obtained from SDP, with 4 samples for 488 beamlets
-        packet = b'b\x05\x00\x00\x00\x00\x03\x85\x11\n\x00\x00\x00\x00\x00\x80\x00\x00\x00\x04\x01\xe8\x14\x00\x00\x01$\x8dI\x9c\xac\x00' + (4*488) * b'\x00\x00\x00\x00'
-
-        # parse it
-        fields = BeamletPacket(packet)
-
-        # check some fields from the header
-        self.assertEqual(0,    fields.payload_error)
-        self.assertEqual(8,    fields.beamlet_width)
-        self.assertEqual(4,    fields.nof_blocks_per_packet)
-        self.assertEqual(488,  fields.nof_beamlets_per_block)
-        self.assertEqual(7840, fields.expected_size())
-
-        # check payload dimensions: 4 time slots of 488 beamlets, x/y, real/imag
-        self.assertEqual((4,488,2,2), fields.payload.shape)
-- 
GitLab