diff options
author | Martin Braun <martin.braun@ettus.com> | 2018-06-21 16:12:51 -0700 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2018-06-23 00:17:18 +0200 |
commit | 1f30b5b14f6d5a189a44565d0f7e4e8618bfa864 (patch) | |
tree | 38c38c2e2e98ee04e721cc01b9251052835a110f | |
parent | 136fc7225ea99fae34813b0b2968dced6abdf95f (diff) |
runtime: Replace QA test framework w/ Boost UTF
27 files changed, 193 insertions, 904 deletions
diff --git a/gnuradio-runtime/include/gnuradio/gr_complex.h b/gnuradio-runtime/include/gnuradio/gr_complex.h index bd94c0f0f8..807f208b41 100644 --- a/gnuradio-runtime/include/gnuradio/gr_complex.h +++ b/gnuradio-runtime/include/gnuradio/gr_complex.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -35,11 +35,5 @@ inline bool is_complex (int x) { (void) x; return false;} inline bool is_complex (char x) { (void) x; return false;} inline bool is_complex (short x) { (void) x; return false;} -// this doesn't really belong here, but there are worse places for it... - -#define CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected,actual,delta) \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected.real(), actual.real(), delta); \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected.imag(), actual.imag(), delta); - #endif /* INCLUDED_GR_COMPLEX_H */ diff --git a/gnuradio-runtime/lib/CMakeLists.txt b/gnuradio-runtime/lib/CMakeLists.txt index 466b29a527..558138ec76 100644 --- a/gnuradio-runtime/lib/CMakeLists.txt +++ b/gnuradio-runtime/lib/CMakeLists.txt @@ -244,40 +244,41 @@ endif(ENABLE_STATIC_LIBS) # Setup tests ######################################################################## if(ENABLE_TESTING) -include(GrTest) - -######################################################################## -# Append gnuradio-runtime test sources -######################################################################## -list(APPEND test_gnuradio_runtime_sources - math/qa_fxpt.cc - math/qa_fxpt_nco.cc - math/qa_fxpt_vco.cc - math/qa_math.cc - math/qa_sincos.cc - math/qa_fast_atan2f.cc - qa_buffer.cc - qa_io_signature.cc - qa_circular_file.cc - qa_logger.cc - qa_vmcircbuf.cc - qa_runtime.cc -) - -include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/math) -include_directories(${CPPUNIT_INCLUDE_DIRS}) -link_directories(${CPPUNIT_LIBRARY_DIRS}) - -add_library(test-gnuradio-runtime SHARED ${test_gnuradio_runtime_sources}) -target_link_libraries(test-gnuradio-runtime gnuradio-runtime gnuradio-pmt ${CPPUNIT_LIBRARIES} ${Boost_LIBRARIES} ${LOG4CPP_LIBRARIES}) - -######################################################################## -# Build the test executable -# Set the test environment so the build libs will be found under MSVC. -######################################################################## -list(APPEND GR_TEST_TARGET_DEPS test-gnuradio-runtime) -add_executable(gr_runtime_test test_runtime.cc) -target_link_libraries(gr_runtime_test test-gnuradio-runtime) -GR_ADD_TEST(gr-runtime-test gr_runtime_test) + include(GrTest) + + # Regular runtime tests: + list(APPEND test_gnuradio_runtime_sources + qa_buffer.cc + qa_io_signature.cc + qa_circular_file.cc + qa_logger.cc + qa_vmcircbuf.cc + ) + list(APPEND GR_TEST_TARGET_DEPS gnuradio-runtime gnuradio-pmt) + + foreach(qa_file ${test_gnuradio_runtime_sources}) + GR_ADD_CPP_TEST("runtime_${qa_file}" + ${CMAKE_CURRENT_SOURCE_DIR}/${qa_file} + ) + endforeach(qa_file) + + # Math tests: + include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/math) + list(APPEND test_gnuradio_math_sources + qa_fxpt.cc + qa_fxpt_nco.cc + qa_fxpt_vco.cc + qa_math.cc + qa_sincos.cc + qa_fast_atan2f.cc + ) + list(APPEND GR_TEST_TARGET_DEPS gnuradio-runtime gnuradio-pmt) + + foreach(qa_file ${test_gnuradio_math_sources}) + GR_ADD_CPP_TEST("math_${qa_file}" + ${CMAKE_CURRENT_SOURCE_DIR}/math/${qa_file} + ) + endforeach(qa_file) endif(ENABLE_TESTING) + diff --git a/gnuradio-runtime/lib/math/qa_fast_atan2f.cc b/gnuradio-runtime/lib/math/qa_fast_atan2f.cc index 9584a578a1..423a8bc415 100644 --- a/gnuradio-runtime/lib/math/qa_fast_atan2f.cc +++ b/gnuradio-runtime/lib/math/qa_fast_atan2f.cc @@ -24,9 +24,8 @@ #include <config.h> #endif -#include <qa_fast_atan2f.h> #include <gnuradio/math.h> -#include <cppunit/TestAssert.h> +#include <boost/test/unit_test.hpp> #include <cmath> #include <limits> @@ -36,9 +35,7 @@ #define ISNAN std::isnan #endif -void -qa_fast_atan2f::t1() -{ +BOOST_AUTO_TEST_CASE(t1) { static const unsigned int N = 100; float c_atan2; float gr_atan2f; @@ -51,14 +48,12 @@ qa_fast_atan2f::t1() gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0); + BOOST_CHECK_CLOSE(c_atan2, gr_atan2f, 0.0); } } } -void -qa_fast_atan2f::t2() -{ +BOOST_AUTO_TEST_CASE(t2) { float c_atan2; float gr_atan2f; float x, y; @@ -71,13 +66,13 @@ qa_fast_atan2f::t2() y = 0; c_atan2 = atan2(y, x); gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0); + BOOST_CHECK_CLOSE(c_atan2, gr_atan2f, 0.0); x = -inf; y = 0; c_atan2 = atan2(y, x); gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0); + BOOST_CHECK_CLOSE(c_atan2, gr_atan2f, 0.0); /* Test y as INF */ @@ -85,53 +80,53 @@ qa_fast_atan2f::t2() y = inf; c_atan2 = atan2(y, x); gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0); + BOOST_CHECK_CLOSE(c_atan2, gr_atan2f, 0.0); x = 0; y = -inf; c_atan2 = atan2(y, x); gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT_DOUBLES_EQUAL(c_atan2, gr_atan2f, 0.0); + BOOST_CHECK_CLOSE(c_atan2, gr_atan2f, 0.0); /* Test x and y as INF */ x = inf; y = inf; gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT(ISNAN(gr_atan2f)); + BOOST_CHECK(ISNAN(gr_atan2f)); /* Test x as NAN */ x = nan; y = 0; gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0f, gr_atan2f, 0.0001); + BOOST_CHECK_CLOSE(0.0f, gr_atan2f, 0.0001); x = -nan; y = 0; gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0f, gr_atan2f, 0.0001); + BOOST_CHECK_CLOSE(0.0f, gr_atan2f, 0.0001); /* Test y as NAN */ x = 0; y = nan; gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0f, gr_atan2f, 0.0001); + BOOST_CHECK_CLOSE(0.0f, gr_atan2f, 0.0001); x = 0; y = -nan; gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0f, gr_atan2f, 0.0001); + BOOST_CHECK_CLOSE(0.0f, gr_atan2f, 0.0001); /* Test mixed NAN and INF */ x = inf; y = nan; gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT(ISNAN(gr_atan2f)); + BOOST_CHECK(ISNAN(gr_atan2f)); x = nan; y = inf; gr_atan2f = gr::fast_atan2f(y, x); - CPPUNIT_ASSERT(ISNAN(gr_atan2f)); + BOOST_CHECK(ISNAN(gr_atan2f)); } diff --git a/gnuradio-runtime/lib/math/qa_fast_atan2f.h b/gnuradio-runtime/lib/math/qa_fast_atan2f.h deleted file mode 100644 index d72ad671d7..0000000000 --- a/gnuradio-runtime/lib/math/qa_fast_atan2f.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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_FAST_ATAN2F_H_ -#define _QA_FAST_ATAN2F_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_fast_atan2f : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_fast_atan2f); - CPPUNIT_TEST(t1); - CPPUNIT_TEST(t2); - CPPUNIT_TEST_SUITE_END(); - -private: - void t1(); - void t2(); -}; - -#endif /* _QA_FAST_ATAN2F_H_ */ diff --git a/gnuradio-runtime/lib/math/qa_fxpt.cc b/gnuradio-runtime/lib/math/qa_fxpt.cc index d3aadf85b1..f369cd356a 100644 --- a/gnuradio-runtime/lib/math/qa_fxpt.cc +++ b/gnuradio-runtime/lib/math/qa_fxpt.cc @@ -24,9 +24,8 @@ #include <config.h> #endif -#include <qa_fxpt.h> #include <gnuradio/fxpt.h> -#include <cppunit/TestAssert.h> +#include <boost/test/unit_test.hpp> #include <iostream> #include <stdio.h> #include <unistd.h> @@ -34,12 +33,10 @@ static const float SIN_COS_TOLERANCE = 1e-5; -void -qa_fxpt::t0() -{ - CPPUNIT_ASSERT_DOUBLES_EQUAL(M_PI/2, gr::fxpt::fixed_to_float(0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, gr::fxpt::fixed_to_float(0x00000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-M_PI, gr::fxpt::fixed_to_float(0x80000000), SIN_COS_TOLERANCE); +BOOST_AUTO_TEST_CASE(t0) { + BOOST_CHECK(std::abs(M_PI/2 - gr::fxpt::fixed_to_float(0x40000000)) <= SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(0.0 - gr::fxpt::fixed_to_float(0x00000000)) <= SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(-M_PI - gr::fxpt::fixed_to_float(0x80000000)) <= SIN_COS_TOLERANCE); if(0) { /* @@ -51,52 +48,46 @@ qa_fxpt::t0() * sometimes the answer is off by a few bits at the bottom. * Hence, the disabled check. */ - CPPUNIT_ASSERT_EQUAL((int32_t)0x40000000, gr::fxpt::float_to_fixed(M_PI/2)); - CPPUNIT_ASSERT_EQUAL((int32_t)0, gr::fxpt::float_to_fixed(0)); - CPPUNIT_ASSERT_EQUAL((int32_t)0x80000000, gr::fxpt::float_to_fixed(-M_PI)); + BOOST_CHECK_EQUAL((int32_t)0x40000000, gr::fxpt::float_to_fixed(M_PI/2)); + BOOST_CHECK_EQUAL((int32_t)0, gr::fxpt::float_to_fixed(0)); + BOOST_CHECK_EQUAL((int32_t)0x80000000, gr::fxpt::float_to_fixed(-M_PI)); } } -void -qa_fxpt::t1() -{ - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, gr::fxpt::sin(0x00000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.707106781, gr::fxpt::sin(0x20000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1, gr::fxpt::sin(0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.707106781, gr::fxpt::sin(0x60000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, gr::fxpt::sin(0x7fffffff), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, gr::fxpt::sin(0x80000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0, gr::fxpt::sin(0x80000001), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1, gr::fxpt::sin(-0x40000000), SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-0.707106781, gr::fxpt::sin(-0x20000000), SIN_COS_TOLERANCE); +BOOST_AUTO_TEST_CASE(t1) { + BOOST_CHECK(std::abs( 0 - gr::fxpt::sin(0x00000000)) <= SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs( 0.707106781 - gr::fxpt::sin(0x20000000)) <= SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs( 1 - gr::fxpt::sin(0x40000000)) <= SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs( 0.707106781 - gr::fxpt::sin(0x60000000)) <= SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs( 0 - gr::fxpt::sin(0x7fffffff)) <= SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs( 0 - gr::fxpt::sin(0x80000000)) <= SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs( 0 - gr::fxpt::sin(0x80000001)) <= SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(-1 - gr::fxpt::sin(-0x40000000)) <= SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(-0.707106781 - gr::fxpt::sin(-0x20000000)) <= SIN_COS_TOLERANCE); for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) { float expected = sin(p); float actual = gr::fxpt::sin(gr::fxpt::float_to_fixed (p)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(expected - actual) <= SIN_COS_TOLERANCE); } } -void -qa_fxpt::t2() -{ +BOOST_AUTO_TEST_CASE(t2) { for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) { float expected = cos(p); float actual = gr::fxpt::cos(gr::fxpt::float_to_fixed(p)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(expected - actual) <= SIN_COS_TOLERANCE); } } -void -qa_fxpt::t3() -{ +BOOST_AUTO_TEST_CASE(t3) { for(float p = -M_PI; p < M_PI; p += 2 * M_PI / 3600) { float expected_sin = sin(p); float expected_cos = cos(p); float actual_sin; float actual_cos; gr::fxpt::sincos(gr::fxpt::float_to_fixed (p), &actual_sin, &actual_cos); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_sin, actual_sin, SIN_COS_TOLERANCE); - CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_cos, actual_cos, SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(expected_sin - actual_sin) <= SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(expected_cos - actual_cos) <= SIN_COS_TOLERANCE); } } diff --git a/gnuradio-runtime/lib/math/qa_fxpt.h b/gnuradio-runtime/lib/math/qa_fxpt.h deleted file mode 100644 index 58a6f02d1b..0000000000 --- a/gnuradio-runtime/lib/math/qa_fxpt.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,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_GR_FXPT_H -#define INCLUDED_QA_GR_FXPT_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_fxpt : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_fxpt); - 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_FXPT_H */ - - diff --git a/gnuradio-runtime/lib/math/qa_fxpt_nco.cc b/gnuradio-runtime/lib/math/qa_fxpt_nco.cc index 16ea120381..cd05747630 100644 --- a/gnuradio-runtime/lib/math/qa_fxpt_nco.cc +++ b/gnuradio-runtime/lib/math/qa_fxpt_nco.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2013 Free Software Foundation, Inc. + * Copyright 2004,2013,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,10 +24,9 @@ #include <config.h> #endif -#include <qa_fxpt_nco.h> #include <gnuradio/fxpt_nco.h> #include <gnuradio/nco.h> -#include <cppunit/TestAssert.h> +#include <boost/test/unit_test.hpp> #include <iostream> #include <stdio.h> #include <unistd.h> @@ -45,9 +44,8 @@ static double max_d(double a, double b) return fabs(a) > fabs(b) ? a : b; } -void -qa_fxpt_nco::t0() -{ + +BOOST_AUTO_TEST_CASE(t0) { gr::nco<float,float> ref_nco; gr::fxpt_nco new_nco; double max_error = 0, max_phase_error = 0; @@ -55,35 +53,33 @@ qa_fxpt_nco::t0() ref_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ)); new_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_nco.get_freq() - new_nco.get_freq()) <= SIN_COS_TOLERANCE); for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) { float ref_sin = ref_nco.sin(); float new_sin = new_nco.sin(); //printf ("i = %6d\n", i); - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_sin, new_sin, SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_sin - new_sin) <= SIN_COS_TOLERANCE); max_error = max_d(max_error, ref_sin-new_sin); float ref_cos = ref_nco.cos(); float new_cos = new_nco.cos(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_cos, new_cos, SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_cos - new_cos) <= SIN_COS_TOLERANCE); max_error = max_d(max_error, ref_cos-new_cos); ref_nco.step(); new_nco.step(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_nco.get_phase() - new_nco.get_phase()) <= SIN_COS_TOLERANCE); max_phase_error = max_d(max_phase_error, ref_nco.get_phase()-new_nco.get_phase()); } // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); } -void -qa_fxpt_nco::t1() -{ +BOOST_AUTO_TEST_CASE(t1) { gr::nco<float,float> ref_nco; gr::fxpt_nco new_nco; gr_complex* ref_block = new gr_complex[SIN_COS_BLOCK_SIZE]; @@ -93,30 +89,21 @@ qa_fxpt_nco::t1() ref_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ)); new_nco.set_freq((float)(2 * M_PI / SIN_COS_FREQ)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_nco.get_freq(), new_nco.get_freq(), SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_nco.get_freq() - new_nco.get_freq()) <= SIN_COS_TOLERANCE); ref_nco.sincos((gr_complex*)ref_block, SIN_COS_BLOCK_SIZE); new_nco.sincos((gr_complex*)new_block, SIN_COS_BLOCK_SIZE); for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].real(), new_block[i].real(), SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_block[i].real() - new_block[i].real()) <= SIN_COS_TOLERANCE); max_error = max_d (max_error, ref_block[i].real()-new_block[i].real()); - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_block[i].imag(), new_block[i].imag(), SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_block[i].imag() - new_block[i].imag()) <= SIN_COS_TOLERANCE); max_error = max_d (max_error, ref_block[i].imag()-new_block[i].imag()); } - CPPUNIT_ASSERT_DOUBLES_EQUAL (ref_nco.get_phase(), new_nco.get_phase(), SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_nco.get_phase() - new_nco.get_phase()) <= SIN_COS_TOLERANCE); // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); delete[] ref_block; delete[] new_block; } -void -qa_fxpt_nco::t2() -{ -} - -void -qa_fxpt_nco::t3() -{ -} diff --git a/gnuradio-runtime/lib/math/qa_fxpt_nco.h b/gnuradio-runtime/lib/math/qa_fxpt_nco.h deleted file mode 100644 index 1b2cdaede6..0000000000 --- a/gnuradio-runtime/lib/math/qa_fxpt_nco.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,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_GR_FXPT_NCO_H -#define INCLUDED_QA_GR_FXPT_NCO_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_fxpt_nco : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_fxpt_nco); - 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_FXPT_NCO_H */ - - diff --git a/gnuradio-runtime/lib/math/qa_fxpt_vco.cc b/gnuradio-runtime/lib/math/qa_fxpt_vco.cc index a406c12c0f..d4952fe25c 100644 --- a/gnuradio-runtime/lib/math/qa_fxpt_vco.cc +++ b/gnuradio-runtime/lib/math/qa_fxpt_vco.cc @@ -24,10 +24,9 @@ #include <config.h> #endif -#include <qa_fxpt_vco.h> +#include "vco.h" #include <gnuradio/fxpt_vco.h> -#include <vco.h> -#include <cppunit/TestAssert.h> +#include <boost/test/unit_test.hpp> #include <iostream> #include <stdio.h> #include <unistd.h> @@ -45,9 +44,7 @@ static double max_d(double a, double b) return fabs(a) > fabs(b) ? a : b; } -void -qa_fxpt_vco::t0() -{ +BOOST_AUTO_TEST_CASE(t0) { gr::vco<float,float> ref_vco; gr::fxpt_vco new_vco; double max_error = 0, max_phase_error = 0; @@ -60,23 +57,21 @@ qa_fxpt_vco::t0() for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) { float ref_cos = ref_vco.cos(); float new_cos = new_vco.cos(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_cos, new_cos, SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_cos - new_cos) <= SIN_COS_TOLERANCE); max_error = max_d(max_error, ref_cos-new_cos); ref_vco.adjust_phase(input[i]); new_vco.adjust_phase(input[i]); - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_vco.get_phase() - new_vco.get_phase()) <= SIN_COS_TOLERANCE); max_phase_error = max_d(max_phase_error, ref_vco.get_phase()-new_vco.get_phase()); } // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, max_phase_error); } -void -qa_fxpt_vco::t1() -{ +BOOST_AUTO_TEST_CASE(t1) { gr::vco<float,float> ref_vco; gr::fxpt_vco new_vco; float *ref_block = new float[SIN_COS_BLOCK_SIZE]; @@ -92,19 +87,18 @@ qa_fxpt_vco::t1() new_vco.cos(new_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_block[i], new_block[i], SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_block[i] - new_block[i]) <= SIN_COS_TOLERANCE); max_error = max_d(max_error, ref_block[i]-new_block[i]); } - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_vco.get_phase() - new_vco.get_phase()) <= SIN_COS_TOLERANCE); // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, ref_vco.get_phase()-new_vco.get_phase()); delete[] ref_block; delete[] new_block; delete[] input; } -void -qa_fxpt_vco::t2() -{ + +BOOST_AUTO_TEST_CASE(t2) { gr::vco<gr_complex,float> ref_vco; gr::fxpt_vco new_vco; gr_complex *ref_block = new gr_complex[SIN_COS_BLOCK_SIZE]; @@ -120,17 +114,15 @@ qa_fxpt_vco::t2() new_vco.sincos(new_block, input, SIN_COS_BLOCK_SIZE, SIN_COS_K, SIN_COS_AMPL); for(int i = 0; i < SIN_COS_BLOCK_SIZE; i++) { - CPPUNIT_ASSERT_COMPLEXES_EQUAL(ref_block[i], new_block[i], SIN_COS_TOLERANCE); + BOOST_CHECK(std::abs(ref_block[i] - new_block[i]) <= SIN_COS_TOLERANCE); max_error = max_d(max_error, abs(ref_block[i]-new_block[i])); } - CPPUNIT_ASSERT_DOUBLES_EQUAL(ref_vco.get_phase(), new_vco.get_phase(), SIN_COS_TOLERANCE); + BOOST_CHECK( + std::abs(ref_vco.get_phase() - new_vco.get_phase()) <= SIN_COS_TOLERANCE + ); // printf ("Fxpt max error %.9f, max phase error %.9f\n", max_error, ref_vco.get_phase()-new_vco.get_phase()); delete[] ref_block; delete[] new_block; delete[] input; } -void -qa_fxpt_vco::t3() -{ -} diff --git a/gnuradio-runtime/lib/math/qa_fxpt_vco.h b/gnuradio-runtime/lib/math/qa_fxpt_vco.h deleted file mode 100644 index 72693f32e2..0000000000 --- a/gnuradio-runtime/lib/math/qa_fxpt_vco.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2005,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_GR_FXPT_VCO_H -#define INCLUDED_QA_GR_FXPT_VCO_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_fxpt_vco : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_fxpt_vco); - 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_FXPT_VCO_H */ - - diff --git a/gnuradio-runtime/lib/math/qa_math.cc b/gnuradio-runtime/lib/math/qa_math.cc index 1fb43cc67f..da8322059c 100644 --- a/gnuradio-runtime/lib/math/qa_math.cc +++ b/gnuradio-runtime/lib/math/qa_math.cc @@ -20,13 +20,11 @@ */ #include <gnuradio/math.h> -#include <qa_math.h> -#include <cppunit/TestAssert.h> +#include <boost/test/unit_test.hpp> #include <stdio.h> +#include <cmath> -void -qa_math::test_binary_slicer1() -{ +BOOST_AUTO_TEST_CASE(test_binary_slicer1) { float x[5] = {-1, -0.5, 0, 0.5, 1.0}; unsigned int z[5] = {0, 0, 1, 1, 1}; unsigned int y; @@ -36,7 +34,7 @@ qa_math::test_binary_slicer1() y = gr::binary_slicer(x[i]); //printf("in: %f out: %d desired: %d\n", x[i], y, z[i]); - CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9); + BOOST_CHECK_EQUAL(y, z[i]); } //printf("\nBranchless Binary\n"); @@ -44,13 +42,11 @@ qa_math::test_binary_slicer1() y = gr::branchless_binary_slicer(x[i]); //printf("in: %f out: %d desired: %d\n", x[i], y, z[i]); - CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9); + BOOST_CHECK_EQUAL(y, z[i]); } } -void -qa_math::test_quad_0deg_slicer1() -{ +BOOST_AUTO_TEST_CASE(test_quad_0deg_slicer1) { gr_complex x[4] = {gr_complex(1, 0), gr_complex(0, 1), gr_complex(-1, 0), @@ -64,7 +60,7 @@ qa_math::test_quad_0deg_slicer1() y = gr::quad_0deg_slicer(x[i]); //printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(), x[i].imag(), y, z[i]); - CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9); + BOOST_CHECK_EQUAL(y, z[i]); } //printf("\nBranchless Quad0\n"); @@ -72,13 +68,11 @@ qa_math::test_quad_0deg_slicer1() y = gr::branchless_quad_0deg_slicer(x[i]); //printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(), x[i].imag(), y, z[i]); - CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9); + BOOST_CHECK_EQUAL(y, z[i]); } } -void -qa_math::test_quad_45deg_slicer1() -{ +BOOST_AUTO_TEST_CASE(test_quad_45deg_slicer1) { gr_complex x[4] = {gr_complex(0.707, 0.707), gr_complex(-0.707, 0.707), gr_complex(-0.707, -0.707), @@ -92,7 +86,7 @@ qa_math::test_quad_45deg_slicer1() y = gr::quad_45deg_slicer(x[i]); //printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(), x[i].imag(), y, z[i]); - CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9); + BOOST_CHECK_EQUAL(y, z[i]); } //printf("\nBranchless Quad45\n"); @@ -100,6 +94,6 @@ qa_math::test_quad_45deg_slicer1() y = gr::branchless_quad_45deg_slicer(x[i]); //printf("in: %.4f+j%.4f out: %d desired: %d\n", x[i].real(), x[i].imag(), y, z[i]); - CPPUNIT_ASSERT_DOUBLES_EQUAL(y, z[i], 1e-9); + BOOST_CHECK_EQUAL(y, z[i]); } } diff --git a/gnuradio-runtime/lib/math/qa_math.h b/gnuradio-runtime/lib/math/qa_math.h deleted file mode 100644 index 3621283b37..0000000000 --- a/gnuradio-runtime/lib/math/qa_math.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 _QA_GR_MATH_H_ -#define _QA_GR_MATH_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_math : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_math); - CPPUNIT_TEST(test_binary_slicer1); - CPPUNIT_TEST(test_quad_0deg_slicer1); - CPPUNIT_TEST(test_quad_45deg_slicer1); - CPPUNIT_TEST_SUITE_END(); - - private: - void test_binary_slicer1(); - void test_quad_0deg_slicer1(); - void test_quad_45deg_slicer1(); -}; - -#endif /* _QA_GR_MATH_H_ */ diff --git a/gnuradio-runtime/lib/math/qa_sincos.cc b/gnuradio-runtime/lib/math/qa_sincos.cc index a6234d19d6..4ce81fb4f8 100644 --- a/gnuradio-runtime/lib/math/qa_sincos.cc +++ b/gnuradio-runtime/lib/math/qa_sincos.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2012 Free Software Foundation, Inc. + * Copyright 2012,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,14 +24,11 @@ #include <config.h> #endif -#include <qa_sincos.h> #include <gnuradio/sincos.h> -#include <cppunit/TestAssert.h> +#include <boost/test/unit_test.hpp> #include <cmath> -void -qa_sincos::t1() -{ +BOOST_AUTO_TEST_CASE(t1) { static const unsigned int N = 1000; double c_sin, c_cos; double gr_sin, gr_cos; @@ -43,14 +40,12 @@ qa_sincos::t1() gr::sincos(x, &gr_sin, &gr_cos); - CPPUNIT_ASSERT_DOUBLES_EQUAL(c_sin, gr_sin, 0.0001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(c_cos, gr_cos, 0.0001); + BOOST_CHECK_CLOSE(c_sin, gr_sin, 0.0001); + BOOST_CHECK_CLOSE(c_cos, gr_cos, 0.0001); } } -void -qa_sincos::t2() -{ +BOOST_AUTO_TEST_CASE(t2) { static const unsigned int N = 1000; float c_sin, c_cos; float gr_sin, gr_cos; @@ -62,7 +57,7 @@ qa_sincos::t2() gr::sincosf(x, &gr_sin, &gr_cos); - CPPUNIT_ASSERT_DOUBLES_EQUAL(c_sin, gr_sin, 0.0001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(c_cos, gr_cos, 0.0001); + BOOST_CHECK_CLOSE(c_sin, gr_sin, 0.0001); + BOOST_CHECK_CLOSE(c_cos, gr_cos, 0.0001); } } diff --git a/gnuradio-runtime/lib/math/qa_sincos.h b/gnuradio-runtime/lib/math/qa_sincos.h deleted file mode 100644 index 9fec5958c0..0000000000 --- a/gnuradio-runtime/lib/math/qa_sincos.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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_SINCOS_H_ -#define _QA_SINCOS_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_sincos : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_sincos); - CPPUNIT_TEST(t1); - CPPUNIT_TEST(t2); - CPPUNIT_TEST_SUITE_END(); - -private: - void t1(); - void t2(); -}; - -#endif /* _QA_SINCOS_H_ */ diff --git a/gnuradio-runtime/lib/qa_buffer.cc b/gnuradio-runtime/lib/qa_buffer.cc index 5f1dece0ad..0d995f2084 100644 --- a/gnuradio-runtime/lib/qa_buffer.cc +++ b/gnuradio-runtime/lib/qa_buffer.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,22 +24,26 @@ #include <config.h> #endif -#include <qa_buffer.h> + +#include <gnuradio/random.h> #include <gnuradio/buffer.h> -#include <cppunit/TestAssert.h> +#include <boost/test/unit_test.hpp> #include <stdlib.h> -#include <gnuradio/random.h> + static void leak_check(void f()) { - long buffer_count = gr::buffer_ncurrently_allocated(); - long buffer_reader_count = gr::buffer_reader_ncurrently_allocated(); + long buffer_count = gr::buffer_ncurrently_allocated(); + long buffer_reader_count = gr::buffer_reader_ncurrently_allocated(); f(); - CPPUNIT_ASSERT_EQUAL(buffer_reader_count, gr::buffer_reader_ncurrently_allocated()); - CPPUNIT_ASSERT_EQUAL(buffer_count, gr::buffer_ncurrently_allocated()); + BOOST_CHECK_EQUAL( + buffer_reader_count, + gr::buffer_reader_ncurrently_allocated() + ); + BOOST_CHECK_EQUAL(buffer_count, gr::buffer_ncurrently_allocated()); } @@ -59,16 +63,16 @@ t0_body() int sa; sa = buf->space_available(); - CPPUNIT_ASSERT(sa > 0); + BOOST_CHECK(sa > 0); last_sa = sa; for(int i = 0; i < 5; i++) { sa = buf->space_available(); - CPPUNIT_ASSERT_EQUAL(last_sa, sa); + BOOST_CHECK_EQUAL(last_sa, sa); last_sa = sa; int *p = (int*)buf->write_pointer(); - CPPUNIT_ASSERT(p != 0); + BOOST_CHECK(p != 0); for(int j = 0; j < sa; j++) *p++ = counter++; @@ -96,10 +100,10 @@ t1_body() // write 1/3 of buffer sa = buf->space_available(); - CPPUNIT_ASSERT(sa > 0); + BOOST_CHECK(sa > 0); int *p = (int*)buf->write_pointer(); - CPPUNIT_ASSERT(p != 0); + BOOST_CHECK(p != 0); for(int j = 0; j < sa/3; j++) { *p++ = write_counter++; @@ -109,10 +113,10 @@ t1_body() // write the next 1/3 (1/2 of what's left) sa = buf->space_available(); - CPPUNIT_ASSERT(sa > 0); + BOOST_CHECK(sa > 0); p = (int*)buf->write_pointer(); - CPPUNIT_ASSERT(p != 0); + BOOST_CHECK(p != 0); for(int j = 0; j < sa/2; j++) { *p++ = write_counter++; @@ -122,13 +126,13 @@ t1_body() // check that we can read it OK int ia = r1->items_available(); - CPPUNIT_ASSERT_EQUAL(write_counter, ia); + BOOST_CHECK_EQUAL(write_counter, ia); int *rp = (int*)r1->read_pointer(); - CPPUNIT_ASSERT(rp != 0); + BOOST_CHECK(rp != 0); for(int i = 0; i < ia/2; i++) { - CPPUNIT_ASSERT_EQUAL(read_counter, *rp); + BOOST_CHECK_EQUAL(read_counter, *rp); read_counter++; rp++; } @@ -138,10 +142,10 @@ t1_body() ia = r1->items_available(); rp = (int *) r1->read_pointer(); - CPPUNIT_ASSERT(rp != 0); + BOOST_CHECK(rp != 0); for(int i = 0; i < ia; i++) { - CPPUNIT_ASSERT_EQUAL(read_counter, *rp); + BOOST_CHECK_EQUAL(read_counter, *rp); read_counter++; rp++; } @@ -181,11 +185,11 @@ t2_body() // Now read it all int m = r1->items_available(); - CPPUNIT_ASSERT_EQUAL(n, m); + BOOST_CHECK_EQUAL(n, m); rp = (int*)r1->read_pointer(); for(int i = 0; i < m; i++) { - CPPUNIT_ASSERT_EQUAL(read_counter, *rp); + BOOST_CHECK_EQUAL(read_counter, *rp); read_counter++; rp++; } @@ -195,7 +199,7 @@ t2_body() // This will wrap around the buffer n = buf->space_available(); - CPPUNIT_ASSERT_EQUAL(nitems - 1, n); // white box test + BOOST_CHECK_EQUAL(nitems - 1, n); // white box test wp = (int*)buf->write_pointer(); for(int i = 0; i < n; i++) @@ -205,11 +209,11 @@ t2_body() // now read it all m = r1->items_available(); - CPPUNIT_ASSERT_EQUAL(n, m); + BOOST_CHECK_EQUAL(n, m); rp = (int*)r1->read_pointer(); for(int i = 0; i < m; i++) { - CPPUNIT_ASSERT_EQUAL(read_counter, *rp); + BOOST_CHECK_EQUAL(read_counter, *rp); read_counter++; rp++; } @@ -252,13 +256,13 @@ t3_body() // pick a random reader and read some int r = (int)(N * random.ran1()); - CPPUNIT_ASSERT(0 <= r && r < N); + BOOST_CHECK(0 <= r && r < N); int m = reader[r]->items_available(); int *rp = (int*)reader[r]->read_pointer(); for(int i = 0; i < m; i++) { - CPPUNIT_ASSERT_EQUAL(read_counter[r], *rp); + BOOST_CHECK_EQUAL(read_counter[r], *rp); read_counter[r]++; rp++; } @@ -268,37 +272,19 @@ t3_body() // ---------------------------------------------------------------------------- - -void -qa_buffer::t0() -{ +BOOST_AUTO_TEST_CASE(t0) { leak_check(t0_body); } -void -qa_buffer::t1() -{ +BOOST_AUTO_TEST_CASE(t1) { leak_check(t1_body); } -void -qa_buffer::t2() -{ +BOOST_AUTO_TEST_CASE(t2) { leak_check(t2_body); } -void -qa_buffer::t3() -{ +BOOST_AUTO_TEST_CASE(t3) { leak_check(t3_body); } -void -qa_buffer::t4() -{ -} - -void -qa_buffer::t5() -{ -} diff --git a/gnuradio-runtime/lib/qa_buffer.h b/gnuradio-runtime/lib/qa_buffer.h deleted file mode 100644 index a41e69dd48..0000000000 --- a/gnuradio-runtime/lib/qa_buffer.h +++ /dev/null @@ -1,49 +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_BUFFER_H -#define INCLUDED_QA_GR_BUFFER_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_buffer : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_buffer); - 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_GR_BUFFER_H */ diff --git a/gnuradio-runtime/lib/qa_circular_file.cc b/gnuradio-runtime/lib/qa_circular_file.cc index d80831b4b9..06599caaab 100644 --- a/gnuradio-runtime/lib/qa_circular_file.cc +++ b/gnuradio-runtime/lib/qa_circular_file.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002,2013 Free Software Foundation, Inc. + * Copyright 2002,2013,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,20 +24,15 @@ #include "config.h" #endif -#include "qa_circular_file.h" #include "circular_file.h" -#include <cppunit/TestAssert.h> -#include <iostream> -#include <stdio.h> +#include <boost/test/unit_test.hpp> #include <unistd.h> static const char *test_file = "qa_gr_circular_file.data"; static const int BUFFER_SIZE = 8192; static const int NWRITE = 8192 * 9 / 8; -void -qa_circular_file::t1() -{ +BOOST_AUTO_TEST_CASE(t1) { #ifdef HAVE_MMAP gr::circular_file *cf_writer; gr::circular_file *cf_reader; @@ -58,12 +53,12 @@ qa_circular_file::t1() cf_reader = new gr::circular_file(test_file); for(int i = 0; i < BUFFER_SIZE; i++) { int n = cf_reader->read (&sd, sizeof(sd)); - CPPUNIT_ASSERT_EQUAL((int) sizeof (sd), n); - CPPUNIT_ASSERT_EQUAL(NWRITE - BUFFER_SIZE + i, (int)sd); + BOOST_CHECK_EQUAL((int) sizeof (sd), n); + BOOST_CHECK_EQUAL(NWRITE - BUFFER_SIZE + i, (int)sd); } int n = cf_reader->read(&sd, sizeof(sd)); - CPPUNIT_ASSERT_EQUAL(0, n); + BOOST_CHECK_EQUAL(0, n); delete cf_reader; unlink(test_file); diff --git a/gnuradio-runtime/lib/qa_circular_file.h b/gnuradio-runtime/lib/qa_circular_file.h deleted file mode 100644 index fd5c156b56..0000000000 --- a/gnuradio-runtime/lib/qa_circular_file.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,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_CIRCULAR_FILE_H -#define QA_GR_CIRCULAR_FILE_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_circular_file : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_circular_file); - CPPUNIT_TEST(t1); - CPPUNIT_TEST_SUITE_END(); - -private: - void t1(); -}; - -#endif /* QA_GR_CIRCULAR_FILE_H */ diff --git a/gnuradio-runtime/lib/qa_io_signature.cc b/gnuradio-runtime/lib/qa_io_signature.cc index bc3509a260..d09188ed74 100644 --- a/gnuradio-runtime/lib/qa_io_signature.cc +++ b/gnuradio-runtime/lib/qa_io_signature.cc @@ -24,42 +24,37 @@ #include <config.h> #endif -#include <qa_io_signature.h> #include <gnuradio/io_signature.h> +#include <boost/test/unit_test.hpp> +#include <stdexcept> -void -qa_io_signature::t0() -{ - gr::io_signature::make(1, 1, sizeof(int)); +BOOST_AUTO_TEST_CASE(t0) { + gr::io_signature::make(1, 1, sizeof(int)); } -void -qa_io_signature::t1() -{ - gr::io_signature::make(3, 1, sizeof(int)); // throws std::invalid_argument +BOOST_AUTO_TEST_CASE(t1) { + BOOST_REQUIRE_THROW( + gr::io_signature::make(3, 1, sizeof(int)), + std::invalid_argument + ); } -void -qa_io_signature::t2() -{ - gr::io_signature::sptr p = - gr::io_signature::make(3, gr::io_signature::IO_INFINITE, sizeof(int)); +BOOST_AUTO_TEST_CASE(t2) { + gr::io_signature::sptr p = + gr::io_signature::make(3, gr::io_signature::IO_INFINITE, sizeof(int)); - CPPUNIT_ASSERT_EQUAL(p->min_streams(), 3); - CPPUNIT_ASSERT_EQUAL(p->sizeof_stream_item(0), (int)sizeof(int)); + BOOST_CHECK_EQUAL(p->min_streams(), 3); + BOOST_CHECK_EQUAL(p->sizeof_stream_item(0), (int)sizeof(int)); } -void -qa_io_signature::t3() -{ - gr::io_signature::sptr p = - gr::io_signature::make3(0, 5, 1, 2, 3); +BOOST_AUTO_TEST_CASE(t3) { + gr::io_signature::sptr p = gr::io_signature::make3(0, 5, 1, 2, 3); - CPPUNIT_ASSERT_EQUAL(p->min_streams(), 0); - CPPUNIT_ASSERT_EQUAL(p->max_streams(), 5); - CPPUNIT_ASSERT_EQUAL(p->sizeof_stream_item(0), 1); - CPPUNIT_ASSERT_EQUAL(p->sizeof_stream_item(1), 2); - CPPUNIT_ASSERT_EQUAL(p->sizeof_stream_item(2), 3); - CPPUNIT_ASSERT_EQUAL(p->sizeof_stream_item(3), 3); - CPPUNIT_ASSERT_EQUAL(p->sizeof_stream_item(4), 3); + BOOST_CHECK_EQUAL(p->min_streams(), 0); + BOOST_CHECK_EQUAL(p->max_streams(), 5); + BOOST_CHECK_EQUAL(p->sizeof_stream_item(0), 1); + BOOST_CHECK_EQUAL(p->sizeof_stream_item(1), 2); + BOOST_CHECK_EQUAL(p->sizeof_stream_item(2), 3); + BOOST_CHECK_EQUAL(p->sizeof_stream_item(3), 3); + BOOST_CHECK_EQUAL(p->sizeof_stream_item(4), 3); } diff --git a/gnuradio-runtime/lib/qa_io_signature.h b/gnuradio-runtime/lib/qa_io_signature.h deleted file mode 100644 index 981ad03b59..0000000000 --- a/gnuradio-runtime/lib/qa_io_signature.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,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_GR_IO_SIGNATURE_H -#define INCLUDED_QA_GR_IO_SIGNATURE_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_io_signature : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_io_signature); - CPPUNIT_TEST(t0); - CPPUNIT_TEST_EXCEPTION(t1, std::invalid_argument); - CPPUNIT_TEST(t2); - CPPUNIT_TEST(t3); - CPPUNIT_TEST_SUITE_END(); - - private: - void t0(); - void t1(); - void t2(); - void t3(); -}; - -#endif /* INCLUDED_QA_GR_IO_SIGNATURE_H */ diff --git a/gnuradio-runtime/lib/qa_logger.cc b/gnuradio-runtime/lib/qa_logger.cc index 904893cc4d..b74a0c0e27 100644 --- a/gnuradio-runtime/lib/qa_logger.cc +++ b/gnuradio-runtime/lib/qa_logger.cc @@ -29,12 +29,10 @@ #include <config.h> #endif -#include <qa_logger.h> #include <gnuradio/logger.h> +#include <boost/test/unit_test.hpp> -void -qa_logger::t1() -{ +BOOST_AUTO_TEST_CASE(t1) { #ifdef ENABLE_GR_LOG // This doesn't really test anything, more just // making sure nothing's gone horribly wrong. @@ -47,6 +45,6 @@ qa_logger::t1() GR_LOG_WARN(LOG,"test from c++ WARN"); GR_LOG_ERROR(LOG,"test from c++ ERROR"); GR_LOG_FATAL(LOG,"test from c++ FATAL"); - CPPUNIT_ASSERT(true); + BOOST_CHECK(true); #endif } diff --git a/gnuradio-runtime/lib/qa_logger.h b/gnuradio-runtime/lib/qa_logger.h deleted file mode 100644 index 2e237eebf8..0000000000 --- a/gnuradio-runtime/lib/qa_logger.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2012 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 Example 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 Example Public License for more details. - * - * You should have received a copy of the GNU Example 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_LOG_H -#define INCLUDED_QA_GR_LOG_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestSuite.h> - -//! collect all the tests for the example directory - -class qa_logger : public CppUnit::TestCase -{ -public: - CPPUNIT_TEST_SUITE(qa_logger); - CPPUNIT_TEST(t1); - CPPUNIT_TEST_SUITE_END(); - - private: - void t1(); -}; - -#endif /* INCLUDED_QA_GR_LOG_H */ diff --git a/gnuradio-runtime/lib/qa_runtime.cc b/gnuradio-runtime/lib/qa_runtime.cc deleted file mode 100644 index 886ef0d476..0000000000 --- a/gnuradio-runtime/lib/qa_runtime.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2002,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. - */ - -/* - * This class gathers together all the test cases for the gr - * directory into a single test suite. As you create new test cases, - * add them here. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <qa_runtime.h> -#include <qa_buffer.h> -#include <qa_io_signature.h> -#include <qa_circular_file.h> -#include <qa_fxpt.h> -#include <qa_fxpt_nco.h> -#include <qa_fxpt_vco.h> -#include <qa_logger.h> -#include <qa_math.h> -#include <qa_vmcircbuf.h> -#include <qa_sincos.h> -#include <qa_fast_atan2f.h> - -CppUnit::TestSuite * -qa_runtime::suite() -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite("runtime"); - - s->addTest(qa_buffer::suite()); - s->addTest(qa_io_signature::suite()); - s->addTest(qa_circular_file::suite()); - s->addTest(qa_fxpt::suite()); - s->addTest(qa_fxpt_nco::suite()); - s->addTest(qa_fxpt_vco::suite()); - s->addTest(qa_logger::suite()); - s->addTest(qa_math::suite()); - s->addTest(qa_vmcircbuf::suite()); - s->addTest(qa_sincos::suite()); - s->addTest(qa_fast_atan2f::suite()); - - return s; -} diff --git a/gnuradio-runtime/lib/qa_runtime.h b/gnuradio-runtime/lib/qa_runtime.h deleted file mode 100644 index a1e58190d6..0000000000 --- a/gnuradio-runtime/lib/qa_runtime.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_RUNTIME_H_ -#define _QA_RUNTIME_H_ - -#include <gnuradio/attributes.h> -#include <cppunit/TestSuite.h> - -//! collect all the tests for the runtime directory - -class __GR_ATTR_EXPORT qa_runtime { - public: - //! return suite of tests for all of runtime directory - static CppUnit::TestSuite *suite (); -}; - - -#endif /* _QA_RUNTIME_H_ */ diff --git a/gnuradio-runtime/lib/qa_vmcircbuf.cc b/gnuradio-runtime/lib/qa_vmcircbuf.cc index 7301b4cf17..4b8b8273fb 100644 --- a/gnuradio-runtime/lib/qa_vmcircbuf.cc +++ b/gnuradio-runtime/lib/qa_vmcircbuf.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002,2013 Free Software Foundation, Inc. + * Copyright 2002,2013,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,17 +24,11 @@ #include <config.h> #endif -#include <qa_vmcircbuf.h> -#include <cppunit/TestAssert.h> #include "vmcircbuf.h" -#include <stdio.h> +#include <boost/test/unit_test.hpp> -void -qa_vmcircbuf::test_all() -{ +BOOST_AUTO_TEST_CASE(test_all) { int verbose = 1; // summary - bool ok = gr::vmcircbuf_sysconfig::test_all_factories(verbose); - - CPPUNIT_ASSERT_EQUAL(true, ok); + BOOST_REQUIRE(gr::vmcircbuf_sysconfig::test_all_factories(verbose)); } diff --git a/gnuradio-runtime/lib/qa_vmcircbuf.h b/gnuradio-runtime/lib/qa_vmcircbuf.h deleted file mode 100644 index 93f46cf4a8..0000000000 --- a/gnuradio-runtime/lib/qa_vmcircbuf.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,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_VMCIRCBUF_H -#define QA_GR_VMCIRCBUF_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_vmcircbuf : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_vmcircbuf); - CPPUNIT_TEST(test_all); - CPPUNIT_TEST_SUITE_END(); - -private: - void test_all(); -}; - -#endif /* QA_GR_VMCIRCBUF_H */ diff --git a/gnuradio-runtime/lib/test_runtime.cc b/gnuradio-runtime/lib/test_runtime.cc deleted file mode 100644 index 6f75bcc1b1..0000000000 --- a/gnuradio-runtime/lib/test_runtime.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2010,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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <cppunit/TextTestRunner.h> -#include <cppunit/XmlOutputter.h> - -#include <gnuradio/unittests.h> -#include <qa_runtime.h> -#include <fstream> - -int -main (int argc, char **argv) -{ - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(get_unittest_path("gnuradio_runtime_runtime.xml").c_str()); - CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); - - runner.addTest(qa_runtime::suite()); - runner.setOutputter(xmlout); - - bool was_successful = runner.run("", false); - - return was_successful ? 0 : 1; -} |