diff options
author | Nathan West <nathan.west@okstate.edu> | 2016-03-24 15:41:17 -0400 |
---|---|---|
committer | Nathan West <nathan.west@okstate.edu> | 2016-03-24 15:41:17 -0400 |
commit | 5297e411f206b9c3c45ee022b8f123994b5e7c6e (patch) | |
tree | 2e773e391fbe0375c954065e9d567fd4a8a08f38 /gr-blocks/python | |
parent | aa33fb0b4940eefc9c193dc8e3b0eadbcc4ee52e (diff) |
blocks: annotate QA and add tests for vector_sourc_sink setters
Diffstat (limited to 'gr-blocks/python')
-rwxr-xr-x | gr-blocks/python/blocks/qa_vector_sink_source.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gr-blocks/python/blocks/qa_vector_sink_source.py b/gr-blocks/python/blocks/qa_vector_sink_source.py index 5dab7014cd..026713f5f4 100755 --- a/gr-blocks/python/blocks/qa_vector_sink_source.py +++ b/gr-blocks/python/blocks/qa_vector_sink_source.py @@ -46,6 +46,7 @@ class test_vector_sink_source(gr_unittest.TestCase): self.tb = None def test_001(self): + # Test that sink has data set in source for the simplest case src_data = [float(x) for x in range(16)] expected_result = tuple(src_data) @@ -58,6 +59,7 @@ class test_vector_sink_source(gr_unittest.TestCase): self.assertEqual(expected_result, result_data) def test_002(self): + # Test vectors (the gnuradio vector I/O type) src_data = [float(x) for x in range(16)] expected_result = tuple(src_data) @@ -70,11 +72,14 @@ class test_vector_sink_source(gr_unittest.TestCase): self.assertEqual(expected_result, result_data) def test_003(self): + # Test that we can only make vectors (the I/O type) if the input + # vector has sufficient size src_data = [float(x) for x in range(16)] expected_result = tuple(src_data) self.assertRaises(RuntimeError, lambda : blocks.vector_source_f(src_data, False, 3)) def test_004(self): + # Test sending and receiving tagged streams src_data = [float(x) for x in range(16)] expected_result = tuple(src_data) src_tags = tuple([make_tag('key', 'val', 0, 'src')]) @@ -92,6 +97,7 @@ class test_vector_sink_source(gr_unittest.TestCase): self.assertTrue(compare_tags(expected_tags[0], result_tags[0])) def test_005(self): + # Test that repeat works (with tagged streams) length = 16 src_data = [float(x) for x in range(length)] expected_result = tuple(src_data + src_data) @@ -112,6 +118,36 @@ class test_vector_sink_source(gr_unittest.TestCase): self.assertTrue(compare_tags(expected_tags[0], result_tags[0])) self.assertTrue(compare_tags(expected_tags[1], result_tags[1])) + def test_006(self): + # Test set_data + src_data = [float(x) for x in range(16)] + expected_result = tuple(src_data) + + src = blocks.vector_source_f((3,1,4)) + dst = blocks.vector_sink_f() + src.set_data(src_data) + + self.tb.connect(src, dst) + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + def test_007(self): + # Test set_repeat + src_data = [float(x) for x in range(16)] + expected_result = tuple(src_data) + + src = blocks.vector_source_f(src_data, True) + dst = blocks.vector_sink_f() + src.set_repeat(False) + + self.tb.connect(src, dst) + # will timeout if set_repeat does not work + self.tb.run() + result_data = dst.data() + self.assertEqual(expected_result, result_data) + + if __name__ == '__main__': gr_unittest.run(test_vector_sink_source, "test_vector_sink_source.xml") |