summaryrefslogtreecommitdiff
path: root/gr-blocks/python
diff options
context:
space:
mode:
authorJohnathan Corgan <johnathan@corganlabs.com>2017-08-27 11:04:47 -0700
committerJohnathan Corgan <johnathan@corganlabs.com>2017-08-27 11:04:47 -0700
commit765040724dfe02b9f6533c60de1a6d67a975f388 (patch)
tree586262690050a7ebbea679fac180d7441556a14b /gr-blocks/python
parentbb10a47f37ad0d0fbe9ed4494595de384168a414 (diff)
parenta9b1f1a8747ae97db9e2473832e54159454649f5 (diff)
Merge branch 'next' into python3
Diffstat (limited to 'gr-blocks/python')
-rw-r--r--gr-blocks/python/blocks/qa_socket_pdu.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/gr-blocks/python/blocks/qa_socket_pdu.py b/gr-blocks/python/blocks/qa_socket_pdu.py
index 60da3d6bdd..2e033491d3 100644
--- a/gr-blocks/python/blocks/qa_socket_pdu.py
+++ b/gr-blocks/python/blocks/qa_socket_pdu.py
@@ -101,6 +101,34 @@ class qa_socket_pdu (gr_unittest.TestCase):
#self.tb.connect(pdu_to_ts, head, sink)
self.tb.run()
+ def test_004 (self):
+ # Test that the TCP server can stream PDUs <= the MTU size.
+ port = str(random.Random().randint(0, 30000) + 10000)
+ mtu = 10000
+ srcdata = tuple([x % 256 for x in xrange(mtu)])
+ data = pmt.init_u8vector(srcdata.__len__(), srcdata)
+ pdu_msg = pmt.cons(pmt.PMT_NIL, data)
+
+ self.pdu_source = blocks.message_strobe(pdu_msg, 500)
+ self.pdu_send = blocks.socket_pdu("TCP_SERVER", "localhost", port, mtu)
+ self.pdu_recv = blocks.socket_pdu("TCP_CLIENT", "localhost", port, mtu)
+ self.pdu_sink = blocks.message_debug()
+
+ self.tb.msg_connect(self.pdu_source, "strobe", self.pdu_send, "pdus")
+ self.tb.msg_connect(self.pdu_recv, "pdus", self.pdu_sink, "store")
+
+ self.tb.start()
+ time.sleep(1)
+ self.tb.stop()
+ self.tb.wait()
+
+ received = self.pdu_sink.get_message(0)
+ received_data = pmt.cdr(received)
+ msg_data = []
+ for i in xrange(mtu):
+ msg_data.append(pmt.u8vector_ref(received_data, i))
+ self.assertEqual(srcdata, tuple(msg_data))
+
if __name__ == '__main__':
gr_unittest.run(qa_socket_pdu, "qa_socket_pdu.xml")