diff options
Diffstat (limited to 'gr-blocks/python')
-rw-r--r-- | gr-blocks/python/blocks/CMakeLists.txt | 2 | ||||
-rw-r--r-- | gr-blocks/python/blocks/qa_skiphead.py | 32 |
2 files changed, 34 insertions, 0 deletions
diff --git a/gr-blocks/python/blocks/CMakeLists.txt b/gr-blocks/python/blocks/CMakeLists.txt index aa6de297b2..2f9c94f9f2 100644 --- a/gr-blocks/python/blocks/CMakeLists.txt +++ b/gr-blocks/python/blocks/CMakeLists.txt @@ -37,6 +37,8 @@ if(ENABLE_TESTING) set(GR_TEST_LIBRARY_DIRS "") set(GR_TEST_PYTHON_DIRS ${CMAKE_BINARY_DIR}/gnuradio-runtime/python + ${CMAKE_BINARY_DIR}/gnuradio-runtime/swig + ${CMAKE_BINARY_DIR}/gr-blocks/swig ) include(GrTest) diff --git a/gr-blocks/python/blocks/qa_skiphead.py b/gr-blocks/python/blocks/qa_skiphead.py index 6eed7b465f..36f3f3e797 100644 --- a/gr-blocks/python/blocks/qa_skiphead.py +++ b/gr-blocks/python/blocks/qa_skiphead.py @@ -22,6 +22,19 @@ from gnuradio import gr, gr_unittest, blocks +import pmt +import numpy + + +def make_tag(key, value, offset, srcid=None): + tag = gr.tag_t() + tag.key = pmt.string_to_symbol(key) + tag.value = pmt.to_pmt(value) + tag.offset = offset + if srcid is not None: + tag.srcid = pmt.to_pmt(srcid) + return tag + class test_skiphead(gr_unittest.TestCase): @@ -98,6 +111,25 @@ class test_skiphead(gr_unittest.TestCase): dst_data = dst1.data() self.assertEqual(expected_result, dst_data) + def test_skip_tags(self): + skip_cnt = 25 + expected_result = tuple(self.src_data[skip_cnt:]) + + src_tags = tuple([make_tag('foo', 'bar', 1, 'src'), + make_tag('baz', 'qux', 50, 'src')]) + src1 = blocks.vector_source_i(self.src_data, tags=src_tags) + op = blocks.skiphead(gr.sizeof_int, skip_cnt) + dst1 = blocks.vector_sink_i() + self.tb.connect(src1, op, dst1) + self.tb.run() + dst_data = dst1.data() + self.assertEqual(expected_result, dst_data) + self.assertEqual(dst1.tags()[0].offset, 25, "Tag offset is incorrect") + self.assertEqual(len(dst1.tags()), 1, "Wrong number of tags received") + self.assertEqual(pmt.to_python( + dst1.tags()[0].key), "baz", "Tag key is incorrect") + self.assertEqual(pmt.to_python( + dst1.tags()[0].value), "qux", "Tag value is incorrect") if __name__ == '__main__': gr_unittest.run(test_skiphead, "test_skiphead.xml") |