diff options
-rw-r--r-- | gnuradio-core/src/lib/runtime/qa_block_tags.cc | 83 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/qa_block_tags.h | 2 |
2 files changed, 84 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gnuradio-core/src/lib/runtime/qa_block_tags.cc index 0c96052e3..4dc096f27 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.cc @@ -30,11 +30,13 @@ #include <gr_null_sink.h> #include <gr_head.h> #include <gr_annotator_1toall.h> +#include <gr_annotator_1to1.h> #include <gruel/pmt.h> // ---------------------------------------------------------------- +using namespace pmt; void qa_block_tags::t0 () @@ -73,7 +75,85 @@ qa_block_tags::t1 () gr_top_block_sptr tb = gr_make_top_block("top"); gr_block_sptr src (gr_make_null_source(sizeof(int))); gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_block_sptr ann0 (gr_make_annotator_1toall(sizeof(int))); + gr_annotator_1toall_sptr ann0 (gr_make_annotator_1toall(sizeof(int))); + gr_annotator_1toall_sptr ann1 (gr_make_annotator_1toall(sizeof(int))); + gr_annotator_1toall_sptr ann2 (gr_make_annotator_1toall(sizeof(int))); + gr_annotator_1toall_sptr ann3 (gr_make_annotator_1toall(sizeof(int))); + gr_annotator_1toall_sptr ann4 (gr_make_annotator_1toall(sizeof(int))); + gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); + gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); + + tb->connect(src, 0, head, 0); + tb->connect(head, 0, ann0, 0); + + tb->connect(ann0, 0, ann1, 0); + tb->connect(ann0, 1, ann2, 0); + tb->connect(ann1, 0, ann3, 0); + tb->connect(ann2, 0, ann4, 0); + + tb->connect(ann3, 0, snk0, 0); + tb->connect(ann4, 0, snk1, 0); + + tb->run(); + + // Kludge together the tags that we know should result from the above graph + std::stringstream str0, str1, str2; + str0 << ann0->name() << ann0->unique_id(); + str1 << ann1->name() << ann1->unique_id(); + str2 << ann2->name() << ann2->unique_id(); + + pmt_t expected_tags3[8]; + expected_tags3[0] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(0)); + expected_tags3[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(0)); + expected_tags3[2] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(1)); + expected_tags3[3] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags3[4] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(2)); + expected_tags3[5] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags3[6] = mp(pmt_from_uint64(40000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags3[7] = mp(pmt_from_uint64(40000), mp(str0.str()), mp("seq"), mp(6)); + + pmt_t expected_tags4[8]; + expected_tags4[0] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(0)); + expected_tags4[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); + expected_tags4[2] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(1)); + expected_tags4[3] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags4[4] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(2)); + expected_tags4[5] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags4[6] = mp(pmt_from_uint64(40000), mp(str2.str()), mp("seq"), mp(3)); + expected_tags4[7] = mp(pmt_from_uint64(40000), mp(str0.str()), mp("seq"), mp(7)); + + std::vector<pmt::pmt_t> tags0 = ann0->data(); + std::vector<pmt::pmt_t> tags3 = ann3->data(); + std::vector<pmt::pmt_t> tags4 = ann4->data(); + + // The first annotator does not receive any tags from the null sink upstream + CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); + + // For annotator 3, we know it gets tags from ann0 and ann1, test this + for(size_t i = 0; i < tags3.size(); i++) { + std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; + //pmt_equal(tags3[i], expected_tags3[i]) + CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags3[i]), pmt_write_string(expected_tags3[i])); + } + + // For annotator 4, we know it gets tags from ann0 and ann2, test this + for(size_t i = 0; i < tags4.size(); i++) { + std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; + CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); + } +} + + +void +qa_block_tags::t2 () +{ + printf("\nqa_block_tags::t2\n"); + + int N = 40000; + gr_top_block_sptr tb = gr_make_top_block("top"); + gr_block_sptr src (gr_make_null_source(sizeof(int))); + gr_block_sptr head (gr_make_head(sizeof(int), N)); + gr_block_sptr ann0 (gr_make_annotator_1to1(sizeof(int))); gr_block_sptr ann1 (gr_make_annotator_1toall(sizeof(int))); gr_block_sptr ann2 (gr_make_annotator_1toall(sizeof(int))); gr_block_sptr ann3 (gr_make_annotator_1toall(sizeof(int))); @@ -83,6 +163,7 @@ qa_block_tags::t1 () tb->connect(src, 0, head, 0); tb->connect(head, 0, ann0, 0); + tb->connect(head, 0, ann0, 1); tb->connect(ann0, 0, ann1, 0); tb->connect(ann0, 1, ann2, 0); diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.h b/gnuradio-core/src/lib/runtime/qa_block_tags.h index b7388885f..69bc0480c 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.h +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.h @@ -32,11 +32,13 @@ class qa_block_tags : public CppUnit::TestCase { CPPUNIT_TEST_SUITE (qa_block_tags); CPPUNIT_TEST (t0); CPPUNIT_TEST (t1); + //CPPUNIT_TEST (t2); CPPUNIT_TEST_SUITE_END (); private: void t0 (); void t1 (); + void t2 (); }; |