diff options
-rw-r--r-- | gr-blocks/lib/CMakeLists.txt | 41 | ||||
-rw-r--r-- | gr-blocks/lib/qa_block_tags.cc | 77 | ||||
-rw-r--r-- | gr-blocks/lib/qa_block_tags.h | 50 | ||||
-rw-r--r-- | gr-blocks/lib/qa_blocks.cc | 46 | ||||
-rw-r--r-- | gr-blocks/lib/qa_blocks.h | 38 | ||||
-rw-r--r-- | gr-blocks/lib/qa_gr_block.cc | 66 | ||||
-rw-r--r-- | gr-blocks/lib/qa_gr_block.h | 48 | ||||
-rw-r--r-- | gr-blocks/lib/qa_gr_flowgraph.cc | 74 | ||||
-rw-r--r-- | gr-blocks/lib/qa_gr_flowgraph.h | 75 | ||||
-rw-r--r-- | gr-blocks/lib/qa_gr_hier_block2.cc | 22 | ||||
-rw-r--r-- | gr-blocks/lib/qa_gr_hier_block2.h | 42 | ||||
-rw-r--r-- | gr-blocks/lib/qa_gr_hier_block2_derived.cc | 6 | ||||
-rw-r--r-- | gr-blocks/lib/qa_gr_hier_block2_derived.h | 41 | ||||
-rw-r--r-- | gr-blocks/lib/qa_gr_top_block.cc | 30 | ||||
-rw-r--r-- | gr-blocks/lib/qa_gr_top_block.h | 66 | ||||
-rw-r--r-- | gr-blocks/lib/qa_rotator.cc | 17 | ||||
-rw-r--r-- | gr-blocks/lib/qa_rotator.h | 41 | ||||
-rw-r--r-- | gr-blocks/lib/qa_set_msg_handler.cc | 9 | ||||
-rw-r--r-- | gr-blocks/lib/qa_set_msg_handler.h | 43 |
19 files changed, 157 insertions, 675 deletions
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index e6eabd8f99..e038586f9c 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -302,33 +302,24 @@ if(ENABLE_TESTING) include_directories( ${GR_BLOCKS_INCLUDE_DIRS} ${GNURADIO_RUNTIME_INCLUDE_DIRS} - ${CPPUNIT_INCLUDE_DIRS}) - link_directories(${CPPUNIT_LIBRARY_DIRS}) + ) list(APPEND test_gr_blocks_sources - ${CMAKE_CURRENT_SOURCE_DIR}/test_gr_blocks.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_flowgraph.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_set_msg_handler.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_block.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_top_block.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2_derived.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_blocks.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_block_tags.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_rotator.cc - ) - - add_executable(test-gr-blocks ${test_gr_blocks_sources}) - - list(APPEND GR_TEST_TARGET_DEPS test-gr-blocks gnuradio-blocks) - - target_link_libraries( - test-gr-blocks - gnuradio-runtime - gnuradio-blocks - ${Boost_LIBRARIES} - ${CPPUNIT_LIBRARIES} + qa_block_tags.cc + qa_gr_block.cc + qa_gr_flowgraph.cc + qa_gr_hier_block2.cc + qa_gr_hier_block2_derived.cc + qa_gr_top_block.cc + qa_rotator.cc + qa_set_msg_handler.cc ) + list(APPEND GR_TEST_TARGET_DEPS gnuradio-blocks) + + foreach(qa_file ${test_gr_blocks_sources}) + GR_ADD_CPP_TEST("blocks_${qa_file}" + ${CMAKE_CURRENT_SOURCE_DIR}/${qa_file} + ) + endforeach(qa_file) - GR_ADD_TEST(test_gr_blocks test-gr-blocks) endif(ENABLE_TESTING) diff --git a/gr-blocks/lib/qa_block_tags.cc b/gr-blocks/lib/qa_block_tags.cc index d794f8edfe..fc61065e95 100644 --- a/gr-blocks/lib/qa_block_tags.cc +++ b/gr-blocks/lib/qa_block_tags.cc @@ -24,7 +24,6 @@ #include <config.h> #endif -#include <qa_block_tags.h> #include <gnuradio/block.h> #include <gnuradio/top_block.h> #include <gnuradio/blocks/null_source.h> @@ -33,6 +32,7 @@ #include <gnuradio/blocks/annotator_alltoall.h> #include <gnuradio/blocks/annotator_1to1.h> #include <gnuradio/blocks/keep_one_in_n.h> +#include <boost/test/unit_test.hpp> // ---------------------------------------------------------------- @@ -59,8 +59,8 @@ std::ostream& operator << (std::ostream& os, const gr::tag_t &t) { return os; } -void -qa_block_tags::t0() + +BOOST_AUTO_TEST_CASE(t0) { unsigned int N = 1000; gr::top_block_sptr tb = gr::make_top_block("top"); @@ -71,20 +71,19 @@ qa_block_tags::t0() tb->connect(src, 0, head, 0); tb->connect(head, 0, snk, 0); - CPPUNIT_ASSERT_EQUAL(src->nitems_read(0), (uint64_t)0); - CPPUNIT_ASSERT_EQUAL(src->nitems_written(0), (uint64_t)0); + BOOST_REQUIRE_EQUAL(src->nitems_read(0), (uint64_t)0); + BOOST_REQUIRE_EQUAL(src->nitems_written(0), (uint64_t)0); tb->run(); - CPPUNIT_ASSERT_THROW(src->nitems_read(0), std::invalid_argument); - CPPUNIT_ASSERT(src->nitems_written(0) >= N); - CPPUNIT_ASSERT_EQUAL(snk->nitems_read(0), (uint64_t)1000); - CPPUNIT_ASSERT_THROW(snk->nitems_written(0), std::invalid_argument); + BOOST_REQUIRE_THROW(src->nitems_read(0), std::invalid_argument); + BOOST_REQUIRE(src->nitems_written(0) >= N); + BOOST_REQUIRE_EQUAL(snk->nitems_read(0), (uint64_t)1000); + BOOST_REQUIRE_THROW(snk->nitems_written(0), std::invalid_argument); } -void -qa_block_tags::t1() +BOOST_AUTO_TEST_CASE(t1) { int N = 40000; gr::top_block_sptr tb = gr::make_top_block("top"); @@ -116,9 +115,9 @@ qa_block_tags::t1() std::vector<gr::tag_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); - CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8); - CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8); + BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0); + BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)8); + BOOST_REQUIRE_EQUAL(tags4.size(), (size_t)8); #if QA_TAGS_DEBUG // Kludge together the tags that we know should result from the above graph @@ -152,20 +151,19 @@ qa_block_tags::t1() // 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; - CPPUNIT_ASSERT_EQUAL(tags3[i], expected_tags3[i]); + BOOST_REQUIRE_EQUAL(tags3[i], expected_tags3[i]); } // For annotator 4, we know it gets tags from ann0 and ann2, test this std::cout << std::endl; 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(tags4[i], expected_tags4[i]); + BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]); } #endif } -void -qa_block_tags::t2 () +BOOST_AUTO_TEST_CASE(t2) { int N = 40000; gr::top_block_sptr tb = gr::make_top_block("top"); @@ -202,13 +200,13 @@ qa_block_tags::t2 () std::vector<gr::tag_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); - CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)8); + BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0); + BOOST_REQUIRE_EQUAL(tags1.size(), (size_t)8); // Make sure the rest all have 12 tags - CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)12); - CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)12); - CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)12); + BOOST_REQUIRE_EQUAL(tags2.size(), (size_t)12); + BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)12); + BOOST_REQUIRE_EQUAL(tags4.size(), (size_t)12); #if QA_TAGS_DEBUG @@ -253,20 +251,19 @@ qa_block_tags::t2 () // inconceivable for ann3 to have it wrong. for(size_t i = 0; i < tags2.size(); i++) { std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(tags2[i], expected_tags2[i]); + BOOST_REQUIRE_EQUAL(tags2[i], expected_tags2[i]); } std::cout << std::endl; for(size_t i = 0; i < tags4.size(); i++) { std::cout << "tags2[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(tags4[i], expected_tags4[i]); + BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]); } #endif } -void -qa_block_tags::t3() +BOOST_AUTO_TEST_CASE(t3) { int N = 40000; gr::top_block_sptr tb = gr::make_top_block("top"); @@ -300,9 +297,9 @@ qa_block_tags::t3() std::vector<gr::tag_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); - CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8); - CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8); + BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0); + BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)8); + BOOST_REQUIRE_EQUAL(tags4.size(), (size_t)8); #if QA_TAGS_DEBUG // Kludge together the tags that we know should result from the above graph @@ -336,21 +333,20 @@ qa_block_tags::t3() // 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; - CPPUNIT_ASSERT_EQUAL(tags3[i], expected_tags3[i]); + BOOST_REQUIRE_EQUAL(tags3[i], expected_tags3[i]); } // For annotator 4, we know it gets tags from ann0 and ann2, test this std::cout << std::endl; 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(tags4[i], expected_tags4[i]); + BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]); } #endif } -void -qa_block_tags::t4() +BOOST_AUTO_TEST_CASE(t4) { int N = 40000; gr::top_block_sptr tb = gr::make_top_block("top"); @@ -378,8 +374,7 @@ qa_block_tags::t4() } -void -qa_block_tags::t5() +BOOST_AUTO_TEST_CASE(t5) { int N = 40000; gr::top_block_sptr tb = gr::make_top_block("top"); @@ -407,9 +402,9 @@ qa_block_tags::t5() std::vector<gr::tag_t> tags2 = ann2->data(); // The first annotator does not receive any tags from the null sink upstream - CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); - CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)4); - CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)8); + BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0); + BOOST_REQUIRE_EQUAL(tags1.size(), (size_t)4); + BOOST_REQUIRE_EQUAL(tags2.size(), (size_t)8); #if QA_TAGS_DEBUG @@ -443,7 +438,7 @@ qa_block_tags::t5() std::cout << "tags1.size(): " << tags1.size() << std::endl; for(size_t i = 0; i < tags1.size(); i++) { std::cout << "tags1[" << i << "] = " << tags1[i] << "\t\t" << expected_tags1[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(tags1[i], expected_tags1[i]); + BOOST_REQUIRE_EQUAL(tags1[i], expected_tags1[i]); } // annotator 2 gets tags from annotators 0 and 1 @@ -451,7 +446,7 @@ qa_block_tags::t5() std::cout << "tags2.size(): " << tags2.size() << std::endl; for(size_t i = 0; i < tags2.size(); i++) { std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(tags2[i], expected_tags2[i]); + BOOST_REQUIRE_EQUAL(tags2[i], expected_tags2[i]); } #endif } diff --git a/gr-blocks/lib/qa_block_tags.h b/gr-blocks/lib/qa_block_tags.h deleted file mode 100644 index 83bebe23f6..0000000000 --- a/gr-blocks/lib/qa_block_tags.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2010,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_BLOCK_TAGS_H -#define INCLUDED_QA_BLOCK_TAGS_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_block_tags : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_block_tags); - CPPUNIT_TEST(t0); - CPPUNIT_TEST(t1); - CPPUNIT_TEST(t2); - CPPUNIT_TEST(t3); - CPPUNIT_TEST(t4); - CPPUNIT_TEST(t5); - CPPUNIT_TEST_SUITE_END(); - - private: - void t0(); - void t1(); - void t2(); - void t3(); - void t4(); - void t5(); -}; - -#endif /* INCLUDED_QA_BLOCK_TAGS_H */ diff --git a/gr-blocks/lib/qa_blocks.cc b/gr-blocks/lib/qa_blocks.cc deleted file mode 100644 index c7d76ed3d7..0000000000 --- a/gr-blocks/lib/qa_blocks.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2012-2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -/* - * This class gathers together all the test cases for the gr-blocks - * directory into a single test suite. As you create new test cases, - * add them here. - */ - -#include <qa_blocks.h> -#include <qa_block_tags.h> -#include <qa_rotator.h> -#include <qa_gr_block.h> -#include <qa_gr_flowgraph.h> -#include <qa_set_msg_handler.h> - -CppUnit::TestSuite * -qa_blocks::suite() -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite("gr-blocks"); - - s->addTest(qa_block_tags::suite()); - s->addTest(qa_rotator::suite()); - s->addTest(qa_gr_block::suite()); - s->addTest(qa_gr_flowgraph::suite()); - s->addTest(qa_set_msg_handler::suite()); - return s; -} diff --git a/gr-blocks/lib/qa_blocks.h b/gr-blocks/lib/qa_blocks.h deleted file mode 100644 index 4d52878454..0000000000 --- a/gr-blocks/lib/qa_blocks.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012-2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _QA_GR_BLOCKS_H_ -#define _QA_GR_BLOCKS_H_ - -#include <gnuradio/attributes.h> -#include <cppunit/TestSuite.h> - -//! collect all the tests for the gr-blocks directory - -class __GR_ATTR_EXPORT qa_blocks -{ - public: - //! return suite of tests for all of gr-blocks directory - static CppUnit::TestSuite *suite(); -}; - -#endif /* _QA_GR_BLOCKS_H_ */ diff --git a/gr-blocks/lib/qa_gr_block.cc b/gr-blocks/lib/qa_gr_block.cc index 36ec128b6e..46079165b0 100644 --- a/gr-blocks/lib/qa_gr_block.cc +++ b/gr-blocks/lib/qa_gr_block.cc @@ -24,56 +24,51 @@ #include <config.h> #endif -#include <qa_gr_block.h> #include <gnuradio/block.h> #include <gnuradio/blocks/null_sink.h> #include <gnuradio/blocks/null_source.h> +#include <boost/test/unit_test.hpp> -// ---------------------------------------------------------------- - - -void -qa_gr_block::t0 () +BOOST_AUTO_TEST_CASE(t0) { // test creation of sources gr::block_sptr src1(gr::blocks::null_source::make(sizeof (int))); - CPPUNIT_ASSERT_EQUAL(std::string("null_source"), src1->name ()); - CPPUNIT_ASSERT_EQUAL(0, src1->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL(1, src1->output_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL(-1, src1->output_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL((int) sizeof(int), + BOOST_REQUIRE_EQUAL(std::string("null_source"), src1->name ()); + BOOST_REQUIRE_EQUAL(0, src1->input_signature()->max_streams ()); + BOOST_REQUIRE_EQUAL(1, src1->output_signature()->min_streams ()); + BOOST_REQUIRE_EQUAL(-1, src1->output_signature()->max_streams ()); + BOOST_REQUIRE_EQUAL((int) sizeof(int), src1->output_signature()->sizeof_stream_item (0)); gr::block_sptr src2(gr::blocks::null_source::make(sizeof(short))); - CPPUNIT_ASSERT_EQUAL(std::string ("null_source"), src2->name ()); - CPPUNIT_ASSERT_EQUAL(0, src2->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL(1, src2->output_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL(-1, src2->output_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL((int)sizeof (short), + BOOST_REQUIRE_EQUAL(std::string ("null_source"), src2->name ()); + BOOST_REQUIRE_EQUAL(0, src2->input_signature()->max_streams ()); + BOOST_REQUIRE_EQUAL(1, src2->output_signature()->min_streams ()); + BOOST_REQUIRE_EQUAL(-1, src2->output_signature()->max_streams ()); + BOOST_REQUIRE_EQUAL((int)sizeof (short), src2->output_signature()->sizeof_stream_item (0)); } -void -qa_gr_block::t1 () +BOOST_AUTO_TEST_CASE(t1) { // test creation of sinks gr::block_sptr dst1 (gr::blocks::null_sink::make (sizeof (int))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_sink"), dst1->name ()); - CPPUNIT_ASSERT_EQUAL (1, dst1->input_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (-1, dst1->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof (int), + BOOST_REQUIRE_EQUAL (std::string ("null_sink"), dst1->name ()); + BOOST_REQUIRE_EQUAL (1, dst1->input_signature()->min_streams ()); + BOOST_REQUIRE_EQUAL (-1, dst1->input_signature()->max_streams ()); + BOOST_REQUIRE_EQUAL ((int) sizeof (int), dst1->input_signature()->sizeof_stream_item (0)); - CPPUNIT_ASSERT_EQUAL (0, dst1->output_signature()->max_streams ()); + BOOST_REQUIRE_EQUAL (0, dst1->output_signature()->max_streams ()); gr::block_sptr dst2 (gr::blocks::null_sink::make (sizeof (short))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_sink"), dst2->name ()); - CPPUNIT_ASSERT_EQUAL (1, dst2->input_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (-1, dst2->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof (short), + BOOST_REQUIRE_EQUAL (std::string ("null_sink"), dst2->name ()); + BOOST_REQUIRE_EQUAL (1, dst2->input_signature()->min_streams ()); + BOOST_REQUIRE_EQUAL (-1, dst2->input_signature()->max_streams ()); + BOOST_REQUIRE_EQUAL ((int) sizeof (short), dst2->input_signature()->sizeof_stream_item (0)); - CPPUNIT_ASSERT_EQUAL (0, dst2->output_signature()->max_streams ()); + BOOST_REQUIRE_EQUAL (0, dst2->output_signature()->max_streams ()); } #include <gnuradio/top_block.h> @@ -81,8 +76,7 @@ qa_gr_block::t1 () #include <gnuradio/block_detail.h> #include <gnuradio/blocks/nop.h> -void -qa_gr_block::t2 () +BOOST_AUTO_TEST_CASE(t2) { gr::block_sptr src1(gr::blocks::null_source::make(sizeof (int))); gr::block_sptr nop(gr::blocks::nop::make(sizeof (int))); @@ -98,16 +92,12 @@ qa_gr_block::t2 () const char *ibuf = nop->detail()->input(0)->buffer()->base(); int ibsize = nop->detail()->input(0)->buffer()->bufsize(); - CPPUNIT_ASSERT(obuf != NULL); - CPPUNIT_ASSERT(ibuf != NULL); - CPPUNIT_ASSERT(obsize > 0); - CPPUNIT_ASSERT(ibsize > 0); + BOOST_REQUIRE(obuf != NULL); + BOOST_REQUIRE(ibuf != NULL); + BOOST_REQUIRE(obsize > 0); + BOOST_REQUIRE(ibsize > 0); tb->stop(); tb->wait(); } -void -qa_gr_block::t3 () -{ -} diff --git a/gr-blocks/lib/qa_gr_block.h b/gr-blocks/lib/qa_gr_block.h deleted file mode 100644 index 14c7c40d1f..0000000000 --- a/gr-blocks/lib/qa_gr_block.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_BLOCK_H -#define INCLUDED_QA_GR_BLOCK_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_gr_block : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_block); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void t0 (); - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* INCLUDED_QA_GR_BLOCK_H */ diff --git a/gr-blocks/lib/qa_gr_flowgraph.cc b/gr-blocks/lib/qa_gr_flowgraph.cc index 1933c8252d..2626b9bbda 100644 --- a/gr-blocks/lib/qa_gr_flowgraph.cc +++ b/gr-blocks/lib/qa_gr_flowgraph.cc @@ -24,11 +24,11 @@ #include <config.h> #endif -#include <qa_gr_flowgraph.h> #include <gnuradio/flowgraph.h> #include <gnuradio/blocks/nop.h> #include <gnuradio/blocks/null_source.h> #include <gnuradio/blocks/null_sink.h> +#include <boost/test/unit_test.hpp> namespace gr { namespace blocks { @@ -78,14 +78,14 @@ namespace gr { } /* namespace blocks */ } /* namespace gr */ -void qa_gr_flowgraph::t0() +BOOST_AUTO_TEST_CASE(t0) { gr::flowgraph_sptr fg = gr::make_flowgraph(); - CPPUNIT_ASSERT(fg); + BOOST_REQUIRE(fg); } -void qa_gr_flowgraph::t1_connect() +BOOST_AUTO_TEST_CASE(t1_connect) { gr::flowgraph_sptr fg = gr::make_flowgraph(); @@ -95,47 +95,47 @@ void qa_gr_flowgraph::t1_connect() fg->connect(nop1, 0, nop2, 0); } -void qa_gr_flowgraph::t2_connect_invalid_src_port_neg() +BOOST_AUTO_TEST_CASE(t2_connect_invalid_src_port_neg) { gr::flowgraph_sptr fg = gr::make_flowgraph(); gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); - CPPUNIT_ASSERT_THROW(fg->connect(nop1, -1, nop2, 0), std::invalid_argument); + BOOST_REQUIRE_THROW(fg->connect(nop1, -1, nop2, 0), std::invalid_argument); } -void qa_gr_flowgraph::t3_connect_src_port_exceeds() +BOOST_AUTO_TEST_CASE(t3_connect_src_port_exceeds) { gr::flowgraph_sptr fg = gr::make_flowgraph(); gr::block_sptr src = gr::blocks::null_qa_source::make(sizeof(int)); gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); - CPPUNIT_ASSERT_THROW(fg->connect(src, 1, dst, 0), std::invalid_argument); + BOOST_REQUIRE_THROW(fg->connect(src, 1, dst, 0), std::invalid_argument); } -void qa_gr_flowgraph::t4_connect_invalid_dst_port_neg() +BOOST_AUTO_TEST_CASE(t4_connect_invalid_dst_port_neg) { gr::flowgraph_sptr fg = gr::make_flowgraph(); gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int)); gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); - CPPUNIT_ASSERT_THROW(fg->connect(nop1, 0, nop2, -1), std::invalid_argument); + BOOST_REQUIRE_THROW(fg->connect(nop1, 0, nop2, -1), std::invalid_argument); } -void qa_gr_flowgraph::t5_connect_dst_port_exceeds() +BOOST_AUTO_TEST_CASE(t5_connect_dst_port_exceeds) { gr::flowgraph_sptr fg = gr::make_flowgraph(); gr::block_sptr src = gr::blocks::null_source::make(sizeof(int)); gr::block_sptr dst = gr::blocks::null_qa_sink::make(sizeof(int)); - CPPUNIT_ASSERT_THROW(fg->connect(src, 0, dst, 1), std::invalid_argument); + BOOST_REQUIRE_THROW(fg->connect(src, 0, dst, 1), std::invalid_argument); } -void qa_gr_flowgraph::t6_connect_dst_in_use() +BOOST_AUTO_TEST_CASE(t6_connect_dst_in_use) { gr::flowgraph_sptr fg = gr::make_flowgraph(); @@ -144,10 +144,10 @@ void qa_gr_flowgraph::t6_connect_dst_in_use() gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int)); fg->connect(src1, 0, dst, 0); - CPPUNIT_ASSERT_THROW(fg->connect(src2, 0, dst, 0), std::invalid_argument); + BOOST_REQUIRE_THROW(fg->connect(src2, 0, dst, 0), std::invalid_argument); } -void qa_gr_flowgraph::t7_connect_one_src_two_dst() +BOOST_AUTO_TEST_CASE(t7_connect_one_src_two_dst) { gr::flowgraph_sptr fg = gr::make_flowgraph(); @@ -159,17 +159,17 @@ void qa_gr_flowgraph::t7_connect_one_src_two_dst() fg->connect(src, 0, dst2, 0); } -void qa_gr_flowgraph::t8_connect_type_mismatch() +BOOST_AUTO_TEST_CASE(t8_connect_type_mismatch) { gr::flowgraph_sptr fg = gr::make_flowgraph(); gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(char)); gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); - CPPUNIT_ASSERT_THROW(fg->connect(nop1, 0, nop2, 0), std::invalid_argument); + BOOST_REQUIRE_THROW(fg->connect(nop1, 0, nop2, 0), std::invalid_argument); } -void qa_gr_flowgraph::t9_disconnect() +BOOST_AUTO_TEST_CASE(t9_disconnect) { gr::flowgraph_sptr fg = gr::make_flowgraph(); @@ -180,7 +180,7 @@ void qa_gr_flowgraph::t9_disconnect() fg->disconnect(nop1, 0, nop2, 0); } -void qa_gr_flowgraph::t10_disconnect_unconnected_block() +BOOST_AUTO_TEST_CASE(t10_disconnect_unconnected_block) { gr::flowgraph_sptr fg = gr::make_flowgraph(); @@ -189,10 +189,10 @@ void qa_gr_flowgraph::t10_disconnect_unconnected_block() gr::block_sptr nop3 = gr::blocks::nop::make(sizeof(int)); fg->connect(nop1, 0, nop2, 0); - CPPUNIT_ASSERT_THROW(fg->disconnect(nop1, 0, nop3, 0), std::invalid_argument); + BOOST_REQUIRE_THROW(fg->disconnect(nop1, 0, nop3, 0), std::invalid_argument); } -void qa_gr_flowgraph::t11_disconnect_unconnected_port() +BOOST_AUTO_TEST_CASE(t11_disconnect_unconnected_port) { gr::flowgraph_sptr fg = gr::make_flowgraph(); @@ -200,10 +200,10 @@ void qa_gr_flowgraph::t11_disconnect_unconnected_port() gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int)); fg->connect(nop1, 0, nop2, 0); - CPPUNIT_ASSERT_THROW(fg->disconnect(nop1, 0, nop2, 1), std::invalid_argument); + BOOST_REQUIRE_THROW(fg->disconnect(nop1, 0, nop2, 1), std::invalid_argument); } -void qa_gr_flowgraph::t12_validate() +BOOST_AUTO_TEST_CASE(t12_validate) { gr::flowgraph_sptr fg = gr::make_flowgraph(); @@ -214,7 +214,7 @@ void qa_gr_flowgraph::t12_validate() fg->validate(); } -void qa_gr_flowgraph::t13_validate_missing_input_assignment() +BOOST_AUTO_TEST_CASE(t13_validate_missing_input_assignment) { gr::flowgraph_sptr fg = gr::make_flowgraph(); @@ -223,10 +223,10 @@ void qa_gr_flowgraph::t13_validate_missing_input_assignment() fg->connect(nop1, 0, nop2, 0); fg->connect(nop1, 0, nop2, 2); - CPPUNIT_ASSERT_THROW(fg->validate(), std::runtime_error); + BOOST_REQUIRE_THROW(fg->validate(), std::runtime_error); } -void qa_gr_flowgraph::t14_validate_missing_output_assignment() +BOOST_AUTO_TEST_CASE(t14_validate_missing_output_assignment) { gr::flowgraph_sptr fg = gr::make_flowgraph(); @@ -235,10 +235,10 @@ void qa_gr_flowgraph::t14_validate_missing_output_assignment() fg->connect(nop1, 0, nop2, 0); fg->connect(nop1, 2, nop2, 1); - CPPUNIT_ASSERT_THROW(fg->validate(), std::runtime_error); + BOOST_REQUIRE_THROW(fg->validate(), std::runtime_error); } -void qa_gr_flowgraph::t15_clear() +BOOST_AUTO_TEST_CASE(t15_clear) { gr::flowgraph_sptr fg = gr::make_flowgraph(); @@ -247,16 +247,16 @@ void qa_gr_flowgraph::t15_clear() fg->connect(nop1, 0, nop2, 0); - CPPUNIT_ASSERT(fg->edges().size() == 1); - CPPUNIT_ASSERT(fg->calc_used_blocks().size() == 2); + BOOST_REQUIRE(fg->edges().size() == 1); + BOOST_REQUIRE(fg->calc_used_blocks().size() == 2); fg->clear(); - CPPUNIT_ASSERT(fg->edges().size() == 0); - CPPUNIT_ASSERT(fg->calc_used_blocks().size() == 0); + BOOST_REQUIRE(fg->edges().size() == 0); + BOOST_REQUIRE(fg->calc_used_blocks().size() == 0); } -void qa_gr_flowgraph::t16_partition() +BOOST_AUTO_TEST_CASE(t16_partition) { gr::flowgraph_sptr fg = gr::make_flowgraph(); @@ -286,8 +286,8 @@ void qa_gr_flowgraph::t16_partition() std::vector<gr::basic_block_vector_t> graphs = fg->partition(); - CPPUNIT_ASSERT(graphs.size() == 3); - CPPUNIT_ASSERT(graphs[0].size() == 4); - CPPUNIT_ASSERT(graphs[1].size() == 3); - CPPUNIT_ASSERT(graphs[2].size() == 2); + BOOST_REQUIRE(graphs.size() == 3); + BOOST_REQUIRE(graphs[0].size() == 4); + BOOST_REQUIRE(graphs[1].size() == 3); + BOOST_REQUIRE(graphs[2].size() == 2); } diff --git a/gr-blocks/lib/qa_gr_flowgraph.h b/gr-blocks/lib/qa_gr_flowgraph.h deleted file mode 100644 index 2c2686f71b..0000000000 --- a/gr-blocks/lib/qa_gr_flowgraph.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_FLOWGRAPH_H -#define INCLUDED_QA_GR_FLOWGRAPH_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_gr_flowgraph : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_gr_flowgraph); - - CPPUNIT_TEST(t0); - CPPUNIT_TEST(t1_connect); - CPPUNIT_TEST(t2_connect_invalid_src_port_neg); - CPPUNIT_TEST(t3_connect_src_port_exceeds); - CPPUNIT_TEST(t4_connect_invalid_dst_port_neg); - CPPUNIT_TEST(t5_connect_dst_port_exceeds); - CPPUNIT_TEST(t6_connect_dst_in_use); - CPPUNIT_TEST(t7_connect_one_src_two_dst); - CPPUNIT_TEST(t8_connect_type_mismatch); - CPPUNIT_TEST(t9_disconnect); - CPPUNIT_TEST(t10_disconnect_unconnected_block); - CPPUNIT_TEST(t11_disconnect_unconnected_port); - CPPUNIT_TEST(t12_validate); - CPPUNIT_TEST(t13_validate_missing_input_assignment); - CPPUNIT_TEST(t14_validate_missing_output_assignment); - CPPUNIT_TEST(t15_clear); - CPPUNIT_TEST(t16_partition); - - CPPUNIT_TEST_SUITE_END(); - -private: - - void t0(); - void t1_connect(); - void t2_connect_invalid_src_port_neg(); - void t3_connect_src_port_exceeds(); - void t4_connect_invalid_dst_port_neg(); - void t5_connect_dst_port_exceeds(); - void t6_connect_dst_in_use(); - void t7_connect_one_src_two_dst(); - void t8_connect_type_mismatch(); - void t9_disconnect(); - void t10_disconnect_unconnected_block(); - void t11_disconnect_unconnected_port(); - void t12_validate(); - void t13_validate_missing_input_assignment(); - void t14_validate_missing_output_assignment(); - void t15_clear(); - void t16_partition(); -}; - -#endif /* INCLUDED_QA_GR_FLOWGRAPH_H */ diff --git a/gr-blocks/lib/qa_gr_hier_block2.cc b/gr-blocks/lib/qa_gr_hier_block2.cc index bf9a167b14..fcc9e6fdc9 100644 --- a/gr-blocks/lib/qa_gr_hier_block2.cc +++ b/gr-blocks/lib/qa_gr_hier_block2.cc @@ -24,32 +24,30 @@ #include <config.h> #endif -#include <qa_gr_hier_block2.h> #include <gnuradio/hier_block2.h> #include <gnuradio/io_signature.h> +#include <boost/test/unit_test.hpp> -void qa_hier_block2::test_make() +BOOST_AUTO_TEST_CASE(test_make) { gr::hier_block2_sptr src1(gr::make_hier_block2("test", gr::io_signature::make(1, 1, 1 * sizeof(int)), gr::io_signature::make(1, 1, 1 * sizeof(int)))); - CPPUNIT_ASSERT(src1); - CPPUNIT_ASSERT_EQUAL(std::string("test"), src1->name()); + BOOST_REQUIRE(src1); + BOOST_REQUIRE_EQUAL(std::string("test"), src1->name()); - CPPUNIT_ASSERT_EQUAL(1 * (int) sizeof(int), + BOOST_REQUIRE_EQUAL(1 * (int) sizeof(int), src1->input_signature()->sizeof_stream_item(0)); - CPPUNIT_ASSERT_EQUAL(1, src1->input_signature()->min_streams()); - CPPUNIT_ASSERT_EQUAL(1, src1->input_signature()->max_streams()); + BOOST_REQUIRE_EQUAL(1, src1->input_signature()->min_streams()); + BOOST_REQUIRE_EQUAL(1, src1->input_signature()->max_streams()); - CPPUNIT_ASSERT_EQUAL(1 * (int) sizeof(int), + BOOST_REQUIRE_EQUAL(1 * (int) sizeof(int), src1->output_signature()->sizeof_stream_item(0)); - CPPUNIT_ASSERT_EQUAL(1, src1->output_signature()->min_streams()); - CPPUNIT_ASSERT_EQUAL(1, src1->output_signature()->max_streams()); - + BOOST_REQUIRE_EQUAL(1, src1->output_signature()->min_streams()); + BOOST_REQUIRE_EQUAL(1, src1->output_signature()->max_streams()); } - diff --git a/gr-blocks/lib/qa_gr_hier_block2.h b/gr-blocks/lib/qa_gr_hier_block2.h deleted file mode 100644 index 34a77256c6..0000000000 --- a/gr-blocks/lib/qa_gr_hier_block2.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_HIER_BLOCK2_H -#define INCLUDED_QA_GR_HIER_BLOCK2_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_hier_block2 : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_hier_block2); - - CPPUNIT_TEST(test_make); - - CPPUNIT_TEST_SUITE_END(); - -private: - void test_make(); -}; - -#endif /* INCLUDED_QA_GR_HIER_BLOCK2_H */ diff --git a/gr-blocks/lib/qa_gr_hier_block2_derived.cc b/gr-blocks/lib/qa_gr_hier_block2_derived.cc index 1d45c89233..519a23d97e 100644 --- a/gr-blocks/lib/qa_gr_hier_block2_derived.cc +++ b/gr-blocks/lib/qa_gr_hier_block2_derived.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2008,2013 Free Software Foundation, Inc. + * Copyright 2006,2008,2013,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,13 +24,13 @@ #include <config.h> #endif -#include <qa_gr_hier_block2_derived.h> #include <gnuradio/top_block.h> #include <gnuradio/io_signature.h> #include <gnuradio/blocks/null_source.h> #include <gnuradio/blocks/null_sink.h> #include <gnuradio/blocks/head.h> #include <gnuradio/blocks/copy.h> +#include <boost/test/unit_test.hpp> // Declare a test C++ hierarchical block @@ -70,7 +70,7 @@ gr_derived_block::~gr_derived_block() { } -void qa_hier_block2_derived::test_1() +BOOST_AUTO_TEST_CASE(test_1) { gr::top_block_sptr tb(gr::make_top_block("test")); diff --git a/gr-blocks/lib/qa_gr_hier_block2_derived.h b/gr-blocks/lib/qa_gr_hier_block2_derived.h deleted file mode 100644 index 2c0a74356f..0000000000 --- a/gr-blocks/lib/qa_gr_hier_block2_derived.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_HIER_BLOCK2_DERIVED_H -#define INCLUDED_QA_GR_HIER_BLOCK2_DERIVED_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -// Declare a QA test case -class qa_hier_block2_derived : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_hier_block2_derived); - CPPUNIT_TEST(test_1); - CPPUNIT_TEST_SUITE_END(); - -private: - void test_1(); -}; - -#endif /* INCLUDED_QA_GR_HIER_BLOCK2_DERIVED_H */ diff --git a/gr-blocks/lib/qa_gr_top_block.cc b/gr-blocks/lib/qa_gr_top_block.cc index 39709d23d2..7c456e312a 100644 --- a/gr-blocks/lib/qa_gr_top_block.cc +++ b/gr-blocks/lib/qa_gr_top_block.cc @@ -24,26 +24,26 @@ #include <config.h> #endif -#include <qa_gr_top_block.h> #include <gnuradio/top_block.h> #include <gnuradio/blocks/head.h> #include <gnuradio/blocks/nop.h> #include <gnuradio/blocks/null_source.h> #include <gnuradio/blocks/null_sink.h> +#include <boost/test/unit_test.hpp> #include <iostream> #define VERBOSE 0 -void qa_top_block::t0() +BOOST_AUTO_TEST_CASE(t0) { if (VERBOSE) std::cout << "qa_top_block::t0()\n"; gr::top_block_sptr tb = gr::make_top_block("top"); - CPPUNIT_ASSERT(tb); + BOOST_REQUIRE(tb); } -void qa_top_block::t1_run() +BOOST_AUTO_TEST_CASE(t1_run) { if (VERBOSE) std::cout << "qa_top_block::t1()\n"; @@ -58,7 +58,7 @@ void qa_top_block::t1_run() tb->run(); } -void qa_top_block::t2_start_stop_wait() +BOOST_AUTO_TEST_CASE(t2_start_stop_wait) { if(VERBOSE) std::cout << "qa_top_block::t2()\n"; @@ -77,7 +77,7 @@ void qa_top_block::t2_start_stop_wait() tb->wait(); } -void qa_top_block::t3_lock_unlock() +BOOST_AUTO_TEST_CASE(t3_lock_unlock) { if(VERBOSE) std::cout << "qa_top_block::t3()\n"; @@ -98,7 +98,7 @@ void qa_top_block::t3_lock_unlock() tb->wait(); } -void qa_top_block::t4_reconfigure() +BOOST_AUTO_TEST_CASE(t4_reconfigure) { if(VERBOSE) std::cout << "qa_top_block::t4()\n"; @@ -125,7 +125,7 @@ void qa_top_block::t4_reconfigure() } -void qa_top_block::t5_max_noutputs() +BOOST_AUTO_TEST_CASE(t5_max_noutputs) { if(VERBOSE) std::cout << "qa_top_block::t5()\n"; @@ -143,7 +143,7 @@ void qa_top_block::t5_max_noutputs() tb->wait(); } -void qa_top_block::t6_reconfig_max_noutputs() +BOOST_AUTO_TEST_CASE(t6_reconfig_max_noutputs) { if(VERBOSE) std::cout << "qa_top_block::t6()\n"; @@ -171,7 +171,7 @@ void qa_top_block::t6_reconfig_max_noutputs() tb->wait(); } -void qa_top_block::t7_max_noutputs_per_block() +BOOST_AUTO_TEST_CASE(t7_max_noutputs_per_block) { if(VERBOSE) std::cout << "qa_top_block::t7()\n"; @@ -191,7 +191,7 @@ void qa_top_block::t7_max_noutputs_per_block() tb->wait(); } -void qa_top_block::t8_reconfig_max_noutputs_per_block() +BOOST_AUTO_TEST_CASE(t8_reconfig_max_noutputs_per_block) { if(VERBOSE) std::cout << "qa_top_block::t8()\n"; @@ -221,7 +221,7 @@ void qa_top_block::t8_reconfig_max_noutputs_per_block() tb->wait(); } -void qa_top_block::t9_max_output_buffer() +BOOST_AUTO_TEST_CASE(t9_max_output_buffer) { if(VERBOSE) std::cout << "qa_top_block::t9()\n"; @@ -241,7 +241,7 @@ void qa_top_block::t9_max_output_buffer() tb->wait(); } -void qa_top_block::t10_reconfig_max_output_buffer() +BOOST_AUTO_TEST_CASE(t10_reconfig_max_output_buffer) { if(VERBOSE) std::cout << "qa_top_block::t10()\n"; @@ -272,7 +272,7 @@ void qa_top_block::t10_reconfig_max_output_buffer() tb->wait(); } -void qa_top_block::t11_set_block_affinity() +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))); @@ -290,5 +290,5 @@ void qa_top_block::t11_set_block_affinity() // We only set the core affinity to 0 because we always know at // least one thread core exists to use. - CPPUNIT_ASSERT_EQUAL(set[0], ret[0]); + BOOST_CHECK_EQUAL(set[0], ret[0]); } diff --git a/gr-blocks/lib/qa_gr_top_block.h b/gr-blocks/lib/qa_gr_top_block.h deleted file mode 100644 index e3ea3227e9..0000000000 --- a/gr-blocks/lib/qa_gr_top_block.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_TOP_BLOCK_H -#define INCLUDED_QA_GR_TOP_BLOCK_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_top_block : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_top_block); - - CPPUNIT_TEST(t0); - CPPUNIT_TEST(t1_run); - CPPUNIT_TEST(t2_start_stop_wait); - CPPUNIT_TEST(t3_lock_unlock); - CPPUNIT_TEST(t4_reconfigure); // triggers 'join never returns' bug - CPPUNIT_TEST(t5_max_noutputs); - CPPUNIT_TEST(t6_reconfig_max_noutputs); - CPPUNIT_TEST(t7_max_noutputs_per_block); - CPPUNIT_TEST(t8_reconfig_max_noutputs_per_block); - CPPUNIT_TEST(t9_max_output_buffer); - CPPUNIT_TEST(t10_reconfig_max_output_buffer); - CPPUNIT_TEST(t11_set_block_affinity); - - CPPUNIT_TEST_SUITE_END(); - -private: - - void t0(); - void t1_run(); - void t2_start_stop_wait(); - void t3_lock_unlock(); - void t4_reconfigure(); - void t5_max_noutputs(); - void t6_reconfig_max_noutputs(); - void t7_max_noutputs_per_block(); - void t8_reconfig_max_noutputs_per_block(); - void t9_max_output_buffer(); - void t10_reconfig_max_output_buffer(); - void t11_set_block_affinity(); - -}; - -#endif /* INCLUDED_QA_GR_TOP_BLOCK_H */ diff --git a/gr-blocks/lib/qa_rotator.cc b/gr-blocks/lib/qa_rotator.cc index c63d150113..ae5a135de9 100644 --- a/gr-blocks/lib/qa_rotator.cc +++ b/gr-blocks/lib/qa_rotator.cc @@ -24,13 +24,12 @@ #include <config.h> #endif +#include <boost/test/unit_test.hpp> #include <gnuradio/attributes.h> -#include <cppunit/TestAssert.h> -#include <qa_rotator.h> #include <gnuradio/blocks/rotator.h> +#include <gnuradio/expj.h> #include <stdio.h> #include <cmath> -#include <gnuradio/expj.h> // error vector magnitude __GR_ATTR_UNUSED static float @@ -39,8 +38,7 @@ error_vector_mag(gr_complex a, gr_complex b) return abs(a-b); } -void -qa_rotator::t1() +BOOST_AUTO_TEST_CASE(t1) { static const unsigned int N = 100000; @@ -66,7 +64,8 @@ qa_rotator::t1() i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm); #endif - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); + BOOST_CHECK(std::abs(expected - actual) <= 0.0001); + //CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); phase += phase_incr; if(phase >= 2*M_PI) @@ -74,8 +73,7 @@ qa_rotator::t1() } } -void -qa_rotator::t2() +BOOST_AUTO_TEST_CASE(t2) { static const unsigned int N = 100000; @@ -107,7 +105,8 @@ qa_rotator::t2() i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm); #endif - CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); + BOOST_CHECK(std::abs(expected - actual) <= 0.0001); + //CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001); phase += phase_incr; if(phase >= 2*M_PI) diff --git a/gr-blocks/lib/qa_rotator.h b/gr-blocks/lib/qa_rotator.h deleted file mode 100644 index 96fe9628b9..0000000000 --- a/gr-blocks/lib/qa_rotator.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _QA_GR_ROTATOR_H_ -#define _QA_GR_ROTATOR_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_rotator : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_rotator); - CPPUNIT_TEST(t1); - CPPUNIT_TEST(t2); - CPPUNIT_TEST_SUITE_END(); - - private: - void t1(); - void t2(); -}; - -#endif /* _QA_GR_ROTATOR_H_ */ diff --git a/gr-blocks/lib/qa_set_msg_handler.cc b/gr-blocks/lib/qa_set_msg_handler.cc index c5b463ca63..94bd6e4249 100644 --- a/gr-blocks/lib/qa_set_msg_handler.cc +++ b/gr-blocks/lib/qa_set_msg_handler.cc @@ -24,23 +24,22 @@ #include <config.h> #endif -#include <qa_set_msg_handler.h> #include <gnuradio/top_block.h> #include <gnuradio/blocks/head.h> #include <gnuradio/blocks/null_source.h> #include <gnuradio/blocks/null_sink.h> #include <gnuradio/blocks/nop.h> #include <gnuradio/messages/msg_passing.h> -#include <iostream> #include <boost/thread/thread.hpp> +#include <boost/test/unit_test.hpp> +#include <iostream> /* * The gr::block::nop block has been instrumented so that it counts * the number of messages sent to it. We use this feature to confirm * that gr::blocks::nop's call to set_msg_handler is working correctly. */ - -void qa_set_msg_handler::t0() +BOOST_AUTO_TEST_CASE(t0) { static const int NMSGS = 10; @@ -68,5 +67,5 @@ void qa_set_msg_handler::t0() tb->wait(); // Confirm that the nop block received the right number of messages. - CPPUNIT_ASSERT_EQUAL(NMSGS, nop->nmsgs_received()); + BOOST_CHECK_EQUAL(NMSGS, nop->nmsgs_received()); } diff --git a/gr-blocks/lib/qa_set_msg_handler.h b/gr-blocks/lib/qa_set_msg_handler.h deleted file mode 100644 index 60277a12cc..0000000000 --- a/gr-blocks/lib/qa_set_msg_handler.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_SET_MSG_HANDLER_H -#define INCLUDED_QA_SET_MSG_HANDLER_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_set_msg_handler : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_set_msg_handler); - - CPPUNIT_TEST(t0); - - CPPUNIT_TEST_SUITE_END(); - -private: - - void t0(); -}; - -#endif /* INCLUDED_QA_SET_MSG_HANDLER_H */ |