diff options
Diffstat (limited to 'gr-blocks/lib/qa_gr_top_block.cc')
-rw-r--r-- | gr-blocks/lib/qa_gr_top_block.cc | 328 |
1 files changed, 165 insertions, 163 deletions
diff --git a/gr-blocks/lib/qa_gr_top_block.cc b/gr-blocks/lib/qa_gr_top_block.cc index 7c456e312a..04e4379e97 100644 --- a/gr-blocks/lib/qa_gr_top_block.cc +++ b/gr-blocks/lib/qa_gr_top_block.cc @@ -36,259 +36,261 @@ BOOST_AUTO_TEST_CASE(t0) { - if (VERBOSE) std::cout << "qa_top_block::t0()\n"; + if (VERBOSE) + std::cout << "qa_top_block::t0()\n"; - gr::top_block_sptr tb = gr::make_top_block("top"); + gr::top_block_sptr tb = gr::make_top_block("top"); - BOOST_REQUIRE(tb); + BOOST_REQUIRE(tb); } BOOST_AUTO_TEST_CASE(t1_run) { - if (VERBOSE) std::cout << "qa_top_block::t1()\n"; + if (VERBOSE) + std::cout << "qa_top_block::t1()\n"; - gr::top_block_sptr tb = gr::make_top_block("top"); + gr::top_block_sptr tb = gr::make_top_block("top"); - gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); - gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); - gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); + gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->run(); + tb->connect(src, 0, head, 0); + tb->connect(head, 0, dst, 0); + tb->run(); } BOOST_AUTO_TEST_CASE(t2_start_stop_wait) { - if(VERBOSE) - std::cout << "qa_top_block::t2()\n"; + if (VERBOSE) + std::cout << "qa_top_block::t2()\n"; - gr::top_block_sptr tb = gr::make_top_block("top"); + gr::top_block_sptr tb = gr::make_top_block("top"); - gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); - gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); - gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); + gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); + tb->connect(src, 0, head, 0); + tb->connect(head, 0, dst, 0); - tb->start(); - tb->stop(); - tb->wait(); + tb->start(); + tb->stop(); + tb->wait(); } BOOST_AUTO_TEST_CASE(t3_lock_unlock) { - if(VERBOSE) - std::cout << "qa_top_block::t3()\n"; + if (VERBOSE) + std::cout << "qa_top_block::t3()\n"; - gr::top_block_sptr tb = gr::make_top_block("top"); + gr::top_block_sptr tb = gr::make_top_block("top"); - gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); - gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); + gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); - tb->connect(src, 0, dst, 0); + tb->connect(src, 0, dst, 0); - tb->start(); + tb->start(); - tb->lock(); - tb->unlock(); + tb->lock(); + tb->unlock(); - tb->stop(); - tb->wait(); + tb->stop(); + tb->wait(); } BOOST_AUTO_TEST_CASE(t4_reconfigure) { - if(VERBOSE) - std::cout << "qa_top_block::t4()\n"; + if (VERBOSE) + std::cout << "qa_top_block::t4()\n"; - gr::top_block_sptr tb = gr::make_top_block("top"); + gr::top_block_sptr tb = gr::make_top_block("top"); - gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); - gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); - gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); + gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); - // Start infinite flowgraph - tb->connect(src, 0, dst, 0); - tb->start(); + // Start infinite flowgraph + tb->connect(src, 0, dst, 0); + tb->start(); - // Reconfigure with gr_head in the middle - tb->lock(); - tb->disconnect(src, 0, dst, 0); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->unlock(); + // Reconfigure with gr_head in the middle + tb->lock(); + tb->disconnect(src, 0, dst, 0); + tb->connect(src, 0, head, 0); + tb->connect(head, 0, dst, 0); + tb->unlock(); - // Wait for flowgraph to end on its own - tb->wait(); + // Wait for flowgraph to end on its own + tb->wait(); } BOOST_AUTO_TEST_CASE(t5_max_noutputs) { - if(VERBOSE) - std::cout << "qa_top_block::t5()\n"; + if (VERBOSE) + std::cout << "qa_top_block::t5()\n"; - gr::top_block_sptr tb = gr::make_top_block("top"); + gr::top_block_sptr tb = gr::make_top_block("top"); - gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); - gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); - gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); + gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); - // Start infinite flowgraph - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->start(100); - tb->wait(); + // Start infinite flowgraph + tb->connect(src, 0, head, 0); + tb->connect(head, 0, dst, 0); + tb->start(100); + tb->wait(); } BOOST_AUTO_TEST_CASE(t6_reconfig_max_noutputs) { - if(VERBOSE) - std::cout << "qa_top_block::t6()\n"; - - gr::top_block_sptr tb = gr::make_top_block("top"); - - gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); - gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); - gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); - - // Start infinite flowgraph - tb->connect(src, 0, dst, 0); - tb->start(100); - - // Reconfigure with gr_head in the middle - tb->lock(); - tb->disconnect(src, 0, dst, 0); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->set_max_noutput_items(1000); - head->set_max_noutput_items(500); - tb->unlock(); - - // Wait for flowgraph to end on its own - tb->wait(); + if (VERBOSE) + std::cout << "qa_top_block::t6()\n"; + + gr::top_block_sptr tb = gr::make_top_block("top"); + + gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); + + // Start infinite flowgraph + tb->connect(src, 0, dst, 0); + tb->start(100); + + // Reconfigure with gr_head in the middle + tb->lock(); + tb->disconnect(src, 0, dst, 0); + tb->connect(src, 0, head, 0); + tb->connect(head, 0, dst, 0); + tb->set_max_noutput_items(1000); + head->set_max_noutput_items(500); + tb->unlock(); + + // Wait for flowgraph to end on its own + tb->wait(); } BOOST_AUTO_TEST_CASE(t7_max_noutputs_per_block) { - if(VERBOSE) - std::cout << "qa_top_block::t7()\n"; + if (VERBOSE) + std::cout << "qa_top_block::t7()\n"; - gr::top_block_sptr tb = gr::make_top_block("top"); + gr::top_block_sptr tb = gr::make_top_block("top"); - gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); - gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); - gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); + gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); - head->set_max_noutput_items(100); + head->set_max_noutput_items(100); - // Start infinite flowgraph - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->start(); - tb->wait(); + // Start infinite flowgraph + tb->connect(src, 0, head, 0); + tb->connect(head, 0, dst, 0); + tb->start(); + tb->wait(); } BOOST_AUTO_TEST_CASE(t8_reconfig_max_noutputs_per_block) { - if(VERBOSE) - std::cout << "qa_top_block::t8()\n"; + if (VERBOSE) + std::cout << "qa_top_block::t8()\n"; - gr::top_block_sptr tb = gr::make_top_block("top"); + gr::top_block_sptr tb = gr::make_top_block("top"); - gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); - gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); - gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); + gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); - head->set_max_noutput_items(99); + head->set_max_noutput_items(99); - // Start infinite flowgraph - tb->connect(src, 0, dst, 0); - tb->start(201); + // Start infinite flowgraph + tb->connect(src, 0, dst, 0); + tb->start(201); - // Reconfigure with gr_head in the middle - tb->lock(); - tb->disconnect(src, 0, dst, 0); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->set_max_noutput_items(1023); - head->set_max_noutput_items(513); - tb->unlock(); + // Reconfigure with gr_head in the middle + tb->lock(); + tb->disconnect(src, 0, dst, 0); + tb->connect(src, 0, head, 0); + tb->connect(head, 0, dst, 0); + tb->set_max_noutput_items(1023); + head->set_max_noutput_items(513); + tb->unlock(); - // Wait for flowgraph to end on its own - tb->wait(); + // Wait for flowgraph to end on its own + tb->wait(); } BOOST_AUTO_TEST_CASE(t9_max_output_buffer) { - if(VERBOSE) - std::cout << "qa_top_block::t9()\n"; + if (VERBOSE) + std::cout << "qa_top_block::t9()\n"; - gr::top_block_sptr tb = gr::make_top_block("top"); + gr::top_block_sptr tb = gr::make_top_block("top"); - gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); - gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); - gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); + gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); - head->set_max_output_buffer(1024); + head->set_max_output_buffer(1024); - // Start infinite flowgraph - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->start(); - tb->wait(); + // Start infinite flowgraph + tb->connect(src, 0, head, 0); + tb->connect(head, 0, dst, 0); + tb->start(); + tb->wait(); } BOOST_AUTO_TEST_CASE(t10_reconfig_max_output_buffer) { - if(VERBOSE) - std::cout << "qa_top_block::t10()\n"; + if (VERBOSE) + std::cout << "qa_top_block::t10()\n"; - gr::top_block_sptr tb = gr::make_top_block("top"); + gr::top_block_sptr tb = gr::make_top_block("top"); - gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); - gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); - gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); + gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); + gr::block_sptr head = gr::blocks::head::make(sizeof(int), 100000); + gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); - head->set_max_output_buffer(1000); + head->set_max_output_buffer(1000); - // Start infinite flowgraph - tb->connect(src, 0, dst, 0); - tb->start(201); + // Start infinite flowgraph + tb->connect(src, 0, dst, 0); + tb->start(201); - // Reconfigure with gr_head in the middle - tb->lock(); - gr::block_sptr nop = gr::blocks::nop::make(sizeof(int)); - nop->set_max_output_buffer(4000); - tb->disconnect(src, 0, dst, 0); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, nop, 0); - tb->connect(nop, 0, dst, 0); - tb->unlock(); + // Reconfigure with gr_head in the middle + tb->lock(); + gr::block_sptr nop = gr::blocks::nop::make(sizeof(int)); + nop->set_max_output_buffer(4000); + tb->disconnect(src, 0, dst, 0); + tb->connect(src, 0, head, 0); + tb->connect(head, 0, nop, 0); + tb->connect(nop, 0, dst, 0); + tb->unlock(); - // Wait for flowgraph to end on its own - tb->wait(); + // Wait for flowgraph to end on its own + tb->wait(); } BOOST_AUTO_TEST_CASE(t11_set_block_affinity) { - gr::top_block_sptr tb = gr::make_top_block("top"); - gr::block_sptr src (gr::blocks::null_source::make(sizeof(float))); - gr::block_sptr snk (gr::blocks::null_sink::make(sizeof(float))); + gr::top_block_sptr tb = gr::make_top_block("top"); + gr::block_sptr src(gr::blocks::null_source::make(sizeof(float))); + gr::block_sptr snk(gr::blocks::null_sink::make(sizeof(float))); - std::vector<int> set(1, 0), ret; - src->set_processor_affinity(set); + std::vector<int> set(1, 0), ret; + src->set_processor_affinity(set); - tb->connect(src, 0, snk, 0); - tb->start(); - tb->stop(); - tb->wait(); + tb->connect(src, 0, snk, 0); + tb->start(); + tb->stop(); + tb->wait(); - ret = src->processor_affinity(); + ret = src->processor_affinity(); - // We only set the core affinity to 0 because we always know at - // least one thread core exists to use. - BOOST_CHECK_EQUAL(set[0], ret[0]); + // We only set the core affinity to 0 because we always know at + // least one thread core exists to use. + BOOST_CHECK_EQUAL(set[0], ret[0]); } |