diff options
30 files changed, 550 insertions, 1200 deletions
diff --git a/gr-atsc/lib/CMakeLists.txt b/gr-atsc/lib/CMakeLists.txt index d7da2fbde9..25037f8390 100644 --- a/gr-atsc/lib/CMakeLists.txt +++ b/gr-atsc/lib/CMakeLists.txt @@ -155,31 +155,39 @@ endif(ENABLE_STATIC_LIBS) # Build and register unit test ######################################################################## if(ENABLE_TESTING) + include(GrTest) -include_directories(${CPPUNIT_INCLUDE_DIRS}) -link_directories(${CPPUNIT_LIBRARY_DIRS}) - -list(APPEND test_atsci_sources - qa_atsci_basic_trellis_encoder.cc - qa_atsci_data_interleaver.cc - qa_atsci_equalizer_nop.cc - qa_atsci_fake_single_viterbi.cc - qa_atsci_fs_correlator.cc - qa_atsci_single_viterbi.cc - qa_atsci_randomizer.cc - qa_atsci_reed_solomon.cc - qa_atsci_sliding_correlator.cc - qa_atsci_trellis_encoder.cc - qa_atsci_viterbi_decoder.cc - qa_convolutional_interleaver.cc - qa_atsci.cc - qa_interleaver_fifo.cc -) + include_directories( + ${GNURADIO_RUNTIME_INCLUDE_DIRS} + ) + + list(APPEND test_gr_atsc_source + qa_atsci_basic_trellis_encoder.cc + qa_atsci_data_interleaver.cc + qa_atsci_equalizer_nop.cc + qa_atsci_fake_single_viterbi.cc + qa_atsci_fs_correlator.cc + qa_atsci_single_viterbi.cc + qa_atsci_randomizer.cc + qa_atsci_reed_solomon.cc + qa_atsci_sliding_correlator.cc + qa_atsci_trellis_encoder.cc + qa_atsci_viterbi_decoder.cc + qa_convolutional_interleaver.cc + qa_interleaver_fifo.cc + ) + list(APPEND GR_TEST_TARGET_DEPS + gnuradio-atsc + gnuradio-fec + gnuradio-filter + gnuradio-analog + gnuradio-fft + ) -include(GrTest) -list(APPEND GR_TEST_TARGET_DEPS gnuradio-atsc gnuradio-fec gnuradio-filter gnuradio-analog gnuradio-fft) -add_executable(test_atsci ${test_atsci_sources} test_atsci.cc) -target_link_libraries(test_atsci gnuradio-atsc gnuradio-runtime ${CPPUNIT_LIBRARIES}) -GR_ADD_TEST(atsci-test test_atsci) + foreach(qa_file ${test_gr_atsc_source}) + GR_ADD_CPP_TEST("atsc_${qa_file}" + ${CMAKE_CURRENT_SOURCE_DIR}/${qa_file} + ) + endforeach(qa_file) endif(ENABLE_TESTING) diff --git a/gr-atsc/lib/qa_atsci.cc b/gr-atsc/lib/qa_atsci.cc deleted file mode 100644 index 611440e96f..0000000000 --- a/gr-atsc/lib/qa_atsci.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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. - */ - -/* - * This class gathers together all the test cases for the atsc - * directory into a single test suite. As you create new test cases, - * add them here. - */ - -#include "qa_atsci.h" -#include "qa_atsci_randomizer.h" -#include "qa_atsci_reed_solomon.h" -#include "qa_interleaver_fifo.h" -#include "qa_convolutional_interleaver.h" -#include "qa_atsci_data_interleaver.h" -#include "qa_atsci_basic_trellis_encoder.h" -#include "qa_atsci_sliding_correlator.h" -#include "qa_atsci_fake_single_viterbi.h" -#include "qa_atsci_single_viterbi.h" -#include "qa_atsci_trellis_encoder.h" -#include "qa_atsci_viterbi_decoder.h" -#include "qa_atsci_fs_correlator.h" -#include "qa_atsci_equalizer_nop.h" - -CppUnit::TestSuite * -qa_atsc::suite () -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite ("atsc"); - - s->addTest (qa_atsci_randomizer::suite ()); - s->addTest (qa_atsci_reed_solomon::suite ()); - s->addTest (qa_interleaver_fifo::suite ()); - s->addTest (qa_convolutional_interleaver::suite ()); - s->addTest (qa_atsci_data_interleaver::suite ()); - s->addTest (qa_atsci_basic_trellis_encoder::suite ()); - s->addTest (qa_atsci_sliding_correlator::suite ()); - s->addTest (qa_atsci_fake_single_viterbi::suite ()); - s->addTest (qa_atsci_single_viterbi::suite ()); - s->addTest (qa_atsci_trellis_encoder::suite ()); - s->addTest (qa_atsci_viterbi_decoder::suite ()); - s->addTest (qa_atsci_fs_correlator::suite ()); - s->addTest (qa_atsci_equalizer_nop::suite ()); - - return s; -} diff --git a/gr-atsc/lib/qa_atsci.h b/gr-atsc/lib/qa_atsci.h deleted file mode 100644 index 86aca2d32b..0000000000 --- a/gr-atsc/lib/qa_atsci.h +++ /dev/null @@ -1,37 +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_ATSC_H_ -#define _QA_ATSC_H_ - -#include <cppunit/TestSuite.h> - -//! collect all the tests for the dtv directory - -class qa_atsc { - public: - //! return suite of tests for all of dtv directory - static CppUnit::TestSuite *suite (); -}; - - -#endif /* _QA_ATSC_H_ */ diff --git a/gr-atsc/lib/qa_atsci_basic_trellis_encoder.cc b/gr-atsc/lib/qa_atsci_basic_trellis_encoder.cc index 2b64759c1f..46f1d38876 100644 --- a/gr-atsc/lib/qa_atsci_basic_trellis_encoder.cc +++ b/gr-atsc/lib/qa_atsci_basic_trellis_encoder.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,14 +24,15 @@ #include <config.h> #endif -#include <cppunit/TestAssert.h> -#include "qa_atsci_basic_trellis_encoder.h" +#include <gnuradio/atsc/basic_trellis_encoder_impl.h> +#include <boost/test/unit_test.hpp> #include <stdlib.h> #include <stdio.h> -void -qa_atsci_basic_trellis_encoder::t0 () +BOOST_AUTO_TEST_CASE(t0) { + atsci_basic_trellis_encoder enc; + const static unsigned char in[14] = { 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 2, 3 }; @@ -41,19 +42,19 @@ qa_atsci_basic_trellis_encoder::t0 () }; for (unsigned i = 0; i < sizeof (in); i++) - CPPUNIT_ASSERT_EQUAL ((int) expected_out[i], enc.encode (in[i])); + BOOST_REQUIRE_EQUAL((int) expected_out[i], enc.encode(in[i])); // reset encoder and test again. enc.reset (); for (unsigned i = 0; i < sizeof (in); i++) - CPPUNIT_ASSERT_EQUAL ((int) expected_out[i], enc.encode (in[i])); + BOOST_REQUIRE_EQUAL((int) expected_out[i], enc.encode(in[i])); } -void -qa_atsci_basic_trellis_encoder::t1 () +BOOST_AUTO_TEST_CASE(t1) { + atsci_basic_trellis_encoder enc; // Print data to externally check distribution. // looks OK. #if 0 diff --git a/gr-atsc/lib/qa_atsci_basic_trellis_encoder.h b/gr-atsc/lib/qa_atsci_basic_trellis_encoder.h deleted file mode 100644 index 6102d72071..0000000000 --- a/gr-atsc/lib/qa_atsci_basic_trellis_encoder.h +++ /dev/null @@ -1,44 +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_ATSC_BASIC_TRELLIS_ENCODER_H_ -#define _QA_ATSC_BASIC_TRELLIS_ENCODER_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -#include <gnuradio/atsc/basic_trellis_encoder_impl.h> - -class qa_atsci_basic_trellis_encoder : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_atsci_basic_trellis_encoder); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - atsci_basic_trellis_encoder enc; - - void t0 (); - void t1 (); -}; - -#endif /* _QA_ATSC_BASIC_TRELLIS_ENCODER_H_ */ diff --git a/gr-atsc/lib/qa_atsci_data_interleaver.cc b/gr-atsc/lib/qa_atsci_data_interleaver.cc index 87cb45f49e..fd80af0361 100644 --- a/gr-atsc/lib/qa_atsci_data_interleaver.cc +++ b/gr-atsc/lib/qa_atsci_data_interleaver.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,86 +20,111 @@ * Boston, MA 02110-1301, USA. */ -#include <cppunit/TestAssert.h> -#include "qa_atsci_data_interleaver.h" +#include <gnuradio/atsc/data_interleaver_impl.h> +#include <boost/test/unit_test.hpp> #include <string.h> +#include <stdio.h> -/*! - * write an easy to identify pattern into the packet - */ -void -qa_atsci_data_interleaver::init_test_packet (int counter, - atsc_mpeg_packet_rs_encoded &out) +// This class is a remnant of the CppUnit style testing +class qa_atsci_data_interleaver { - out.data[0] = 0xf0; - out.data[1] = 0xff; - out.data[2] = (counter >> 8) & 0xff; - out.data[3] = counter & 0xff; + public: + qa_atsci_data_interleaver() { setUp(); } - for (int i = 4; i < 205; i++) - out.data[i] = i; + void t0 (); + void t1 (); - out.data[205] = 0xa0; - out.data[206] = 0xaf; -} + private: + atsci_data_interleaver outbound; + atsci_data_deinterleaver inbound; -void -qa_atsci_data_interleaver::print_packet (FILE *fp, - int frame_number, - int field_number, - int segment_number, - const atsc_mpeg_packet_rs_encoded &in) -{ - fprintf (fp, "%04d:%d:%03d ", frame_number, field_number, segment_number); + void setUp (){ + outbound.reset(); + inbound.reset(); + } - const unsigned char *p = &in.data[0]; - for (int i = 0; i < 8; i++) - fprintf (fp, "%02X", p[i]); + /*! + * write an easy to identify pattern into the packet + */ + void init_test_packet( + int counter, atsc_mpeg_packet_rs_encoded &out + ) { + atsci_data_interleaver outbound; + atsci_data_deinterleaver inbound; + + out.data[0] = 0xf0; + out.data[1] = 0xff; + out.data[2] = (counter >> 8) & 0xff; + out.data[3] = counter & 0xff; + + for (int i = 4; i < 205; i++) + out.data[i] = i; + + out.data[205] = 0xa0; + out.data[206] = 0xaf; + } - fprintf (fp, " "); - p = &in.data[8]; - for (int i = 0; i < 8; i++) - fprintf (fp, "%02X", p[i]); - fprintf (fp, " ... "); - p = &in.data[191]; - for (int i = 0; i < 8; i++) - fprintf (fp, "%02X", p[i]); - fprintf (fp, " "); - p = &in.data[199]; - for (int i = 0; i < 8; i++) - fprintf (fp, "%02X", p[i]); + void print_packet (FILE *fp, + int frame_number, + int field_number, + int segment_number, + const atsc_mpeg_packet_rs_encoded &in + ) { + fprintf (fp, "%04d:%d:%03d ", frame_number, field_number, segment_number); - fprintf (fp, "\n"); -} + const unsigned char *p = &in.data[0]; + for (int i = 0; i < 8; i++) + fprintf (fp, "%02X", p[i]); -void -qa_atsci_data_interleaver::chk_assert (const atsc_mpeg_packet_rs_encoded &expected, - const atsc_mpeg_packet_rs_encoded &actual) -{ - if (expected == actual) - return; + fprintf (fp, " "); + p = &in.data[8]; + for (int i = 0; i < 8; i++) + fprintf (fp, "%02X", p[i]); - FILE *fp = stderr; - fprintf (fp, "Expected: "); - print_packet (fp, 0, 0, 0, expected); + fprintf (fp, " ... "); + p = &in.data[191]; + for (int i = 0; i < 8; i++) + fprintf (fp, "%02X", p[i]); - fprintf (fp, "Actual: "); - print_packet (fp, 0, 0, 0, actual); + fprintf (fp, " "); + p = &in.data[199]; + for (int i = 0; i < 8; i++) + fprintf (fp, "%02X", p[i]); - CPPUNIT_ASSERT (expected == actual); -} + fprintf (fp, "\n"); + } + + void chk_assert( + const atsc_mpeg_packet_rs_encoded &expected, + const atsc_mpeg_packet_rs_encoded &actual + ) { + if (expected == actual) + return; + + FILE *fp = stderr; + + fprintf (fp, "Expected: "); + print_packet (fp, 0, 0, 0, expected); + + fprintf (fp, "Actual: "); + print_packet (fp, 0, 0, 0, actual); + + BOOST_REQUIRE(expected == actual); + } + +}; void -qa_atsci_data_interleaver::t0 () +qa_atsci_data_interleaver::t0() { int counter = 0; - atsc_mpeg_packet_rs_encoded in, enc, out; - atsc_mpeg_packet_rs_encoded zero; + atsc_mpeg_packet_rs_encoded in, enc, out; + atsc_mpeg_packet_rs_encoded zero; memset (&zero, 0, sizeof (zero)); @@ -118,13 +143,11 @@ qa_atsci_data_interleaver::t0 () inbound.deinterleave (out, enc); if (counter < 52) - // CPPUNIT_ASSERT (zero == out); chk_assert (zero, out); else if (counter >= 52){ atsc_mpeg_packet_rs_encoded expected; init_test_packet (counter - 52, expected); - // CPPUNIT_ASSERT (expected == out); chk_assert (expected, out); } } @@ -140,9 +163,8 @@ qa_atsci_data_interleaver::t0 () // the deinterleaver recovers. This would be part of what you'd see // on a channel change. // - void -qa_atsci_data_interleaver::t1 () +qa_atsci_data_interleaver::t1() { int counter = 0; atsc_mpeg_packet_rs_encoded in, enc, out; @@ -188,10 +210,17 @@ qa_atsci_data_interleaver::t1 () else if (counter >= starting_counter + 52 + NCRAP){ atsc_mpeg_packet_rs_encoded expected; init_test_packet (counter - 52, expected); - // CPPUNIT_ASSERT (expected == out); chk_assert (expected, out); } } } } } + +BOOST_AUTO_TEST_CASE(run) +{ + qa_atsci_data_interleaver Q; + Q.t0(); + Q.t1(); +} + diff --git a/gr-atsc/lib/qa_atsci_data_interleaver.h b/gr-atsc/lib/qa_atsci_data_interleaver.h deleted file mode 100644 index d7b94f8e2b..0000000000 --- a/gr-atsc/lib/qa_atsci_data_interleaver.h +++ /dev/null @@ -1,60 +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_ATSC_DATA_INTERLEAVER_H_ -#define _QA_ATSC_DATA_INTERLEAVER_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdio.h> - -#include <gnuradio/atsc/data_interleaver_impl.h> - -class qa_atsci_data_interleaver : public CppUnit::TestCase { - public: - - void setUp (){ - outbound.reset (); - inbound.reset (); - } - - CPPUNIT_TEST_SUITE (qa_atsci_data_interleaver); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - atsci_data_interleaver outbound; - atsci_data_deinterleaver inbound; - - void t0 (); - void t1 (); - - void init_test_packet (int counter, atsc_mpeg_packet_rs_encoded &out); - void print_packet (FILE *fp, int frame_number, int field_number, int segment_number, - const atsc_mpeg_packet_rs_encoded &in); - void chk_assert (const atsc_mpeg_packet_rs_encoded &expected, - const atsc_mpeg_packet_rs_encoded &actual); -}; - - -#endif /* _QA_ATSC_DATA_INTERLEAVER_H_ */ diff --git a/gr-atsc/lib/qa_atsci_equalizer_nop.cc b/gr-atsc/lib/qa_atsci_equalizer_nop.cc index b7aad835d5..ef0d86ff37 100644 --- a/gr-atsc/lib/qa_atsci_equalizer_nop.cc +++ b/gr-atsc/lib/qa_atsci_equalizer_nop.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,12 +20,12 @@ * Boston, MA 02110-1301, USA. */ -#include "qa_atsci_equalizer_nop.h" #include <gnuradio/atsc/equalizer_impl.h> #include <gnuradio/atsc/equalizer_nop_impl.h> #include <gnuradio/atsc/pnXXX_impl.h> #include <gnuradio/atsc/types.h> -#include <cppunit/TestAssert.h> +#include <boost/test/unit_test.hpp> +#include <cmath> #include <assert.h> #include <iostream> #include <string.h> @@ -147,24 +147,11 @@ init_field_sync_common (float *p, int mask) assert (i == ATSC_DATA_SEGMENT_LENGTH); } -void -qa_atsci_equalizer_nop::setUp () -{ - eq = new atsci_equalizer_nop (); -} - -void -qa_atsci_equalizer_nop::tearDown () -{ - delete eq; - eq = 0; -} - static void setup_test_data (float *data, atsc::syminfo *tags) { - int mask = 0; - int i = 0; + int mask = 0; + int i = 0; for (i = 0; i < PAD; i++){ data[i] = (float) i; @@ -185,63 +172,84 @@ setup_test_data (float *data, atsc::syminfo *tags) } mask ^= 1; } - assert (i == INPUT_SIZE); + BOOST_REQUIRE(i == INPUT_SIZE); } -void -qa_atsci_equalizer_nop::t0 () +// This class is a remnant of the CppUnit testing style +class qa_atsci_equalizer_nop { - // these are dynamically allocated because they are bigger - // than the default stack limit. +public: + void setUp () + { + eq = new atsci_equalizer_nop (); + } - float *input_data = new float[INPUT_SIZE]; - atsc::syminfo *input_tags = new atsc::syminfo[INPUT_SIZE]; - float *output_data = new float[INPUT_SIZE]; + void tearDown() + { + delete eq; + eq = 0; + } - try { + void t0() + { + // these are dynamically allocated because they are bigger + // than the default stack limit. - memset (input_data, 0, sizeof(*input_data)*INPUT_SIZE); - memset (input_tags, 0, sizeof(*input_tags)*INPUT_SIZE); - memset (output_data, 0, sizeof(*output_data)*INPUT_SIZE); + float *input_data = new float[INPUT_SIZE]; + atsc::syminfo *input_tags = new atsc::syminfo[INPUT_SIZE]; + float *output_data = new float[INPUT_SIZE]; - setup_test_data (input_data, input_tags); + try { - eq->filter (input_data, input_tags, - output_data, INPUT_SIZE); + memset (input_data, 0, sizeof(*input_data)*INPUT_SIZE); + memset (input_tags, 0, sizeof(*input_tags)*INPUT_SIZE); + memset (output_data, 0, sizeof(*output_data)*INPUT_SIZE); + setup_test_data (input_data, input_tags); - // now check that data values got copied correctly + eq->filter (input_data, input_tags, + output_data, INPUT_SIZE); - for (int i = 0; i < INPUT_SIZE; i++){ - if (input_tags[i].segment_num == atsc::SI_FIELD_SYNC_SEGMENT_NUM){ - // ignore entire field sync data segment - } - else if (input_tags[i].symbol_num <= 3){ - // ignore 4 symbols of data segment sync (+5, -5, -5, +5) - } - else { - if (output_data[i] != (float) i){ - cerr << "output_data[" << i << "] == " << output_data[i] << endl; - CPPUNIT_ASSERT_DOUBLES_EQUAL ((float) i, output_data[i], 1e-6); + // now check that data values got copied correctly + + for (int i = 0; i < INPUT_SIZE; i++){ + + if (input_tags[i].segment_num == atsc::SI_FIELD_SYNC_SEGMENT_NUM){ + // ignore entire field sync data segment + } + else if (input_tags[i].symbol_num <= 3){ + // ignore 4 symbols of data segment sync (+5, -5, -5, +5) + } + else { + if (output_data[i] != (float) i){ + cerr << "output_data[" << i << "] == " << output_data[i] << endl; + BOOST_CHECK(std::abs(float(i) - output_data[i]) <= 1e-6f); + } } } + + delete [] input_data; + delete [] input_tags; + delete [] output_data; } - delete [] input_data; - delete [] input_tags; - delete [] output_data; + catch ( ... ){ + delete [] input_data; + delete [] input_tags; + delete [] output_data; + } } - catch ( ... ){ - delete [] input_data; - delete [] input_tags; - delete [] output_data; - } -} +private: + atsci_equalizer *eq; +}; + -void -qa_atsci_equalizer_nop::t1 () +BOOST_AUTO_TEST_CASE(run_t0) { - // think of another test... + qa_atsci_equalizer_nop qa_runner; + qa_runner.setUp(); + qa_runner.t0(); + qa_runner.tearDown(); } diff --git a/gr-atsc/lib/qa_atsci_equalizer_nop.h b/gr-atsc/lib/qa_atsci_equalizer_nop.h deleted file mode 100644 index 244daf8b3f..0000000000 --- a/gr-atsc/lib/qa_atsci_equalizer_nop.h +++ /dev/null @@ -1,51 +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_ATSC_EQUALIZER_NOP_H_ -#define _QA_ATSC_EQUALIZER_NOP_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class atsci_equalizer; - -class qa_atsci_equalizer_nop : public CppUnit::TestCase { -private: - atsci_equalizer *eq; - -public: - void setUp (); - void tearDown (); - - CPPUNIT_TEST_SUITE (qa_atsci_equalizer_nop); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - -private: - - void t0 (); - void t1 (); - -}; - -#endif /* _QA_ATSC_EQUALIZER_NOP_H_ */ diff --git a/gr-atsc/lib/qa_atsci_fake_single_viterbi.cc b/gr-atsc/lib/qa_atsci_fake_single_viterbi.cc index 8c761986c3..b15d1c8c74 100644 --- a/gr-atsc/lib/qa_atsci_fake_single_viterbi.cc +++ b/gr-atsc/lib/qa_atsci_fake_single_viterbi.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,13 +24,13 @@ #include <config.h> #endif -#include <cppunit/TestAssert.h> -#include <stdio.h> #include <gnuradio/atsc/fake_single_viterbi_impl.h> -#include "qa_atsci_fake_single_viterbi.h" +#include <gnuradio/atsc/fake_single_viterbi_impl.h> +#include <gnuradio/atsc/basic_trellis_encoder_impl.h> #include <gnuradio/random.h> +#include <boost/test/unit_test.hpp> #include <string.h> - +#include <stdio.h> static const int NTRIALS = 50; static const int MAXERRORS = 10; @@ -40,106 +40,117 @@ static const int MAXDIBIT = 3; static gr::random rndm; -void -qa_atsci_fake_single_viterbi::encode_block (unsigned char *out, unsigned char *in, - unsigned int n) +class qa_atsci_fake_single_viterbi { - for (unsigned int i = 0; i < n; i++) { - out[i] = encoder.encode(in[i]); - } -} + public: + void t0 () + { + static const int blocklen = NN; + unsigned char in[blocklen]; + unsigned char enc[blocklen]; + unsigned char out[blocklen]; + int decoder_errors = 0; + int delay = decoder.delay (); + int i; + // printf (" Delay is %d.\n", delay); -void -qa_atsci_fake_single_viterbi::decode_block (unsigned char *out, unsigned char *in, - unsigned int n) -{ - for (unsigned int i = 0; i < n; i++) { - out[i] = decoder.decode ((2*in[i]-7) + noise ()); - } -} + srandom (27) ;// reproducible sequence of "random" values -float -qa_atsci_fake_single_viterbi::noise () -{ -#if 1 - return 2.0 * (rndm.ran1() - 0.5);; -#else - return 0; -#endif -} + for (int nt = 0; nt < NTRIALS; nt++){ -void -qa_atsci_fake_single_viterbi::t0 () -{ - static const int blocklen = NN; - unsigned char in[blocklen]; - unsigned char enc[blocklen]; - unsigned char out[blocklen]; - int decoder_errors = 0; - int delay = decoder.delay (); - int i; + // load block with random data and encode - // printf (" Delay is %d.\n", delay); + for (i = 0; i < (blocklen-delay); i++) + in[i] = random () & MAXDIBIT; + for ( ; i < blocklen; i++) + in[i] = 0; /* To empty the delay buffers */ - srandom (27); // reproducible sequence of "random" values + encoder.reset (); + encode_block (enc, in, blocklen); - for (int nt = 0; nt < NTRIALS; nt++){ + decoder.reset (); - // load block with random data and encode + // decode the block + decode_block (out, enc, blocklen); - for (i = 0; i < (blocklen-delay); i++) - in[i] = random () & MAXDIBIT; - for ( ; i < blocklen; i++) - in[i] = 0; /* To empty the delay buffers */ + // int offset = delay/4; + int offset = 2; + bool differs = (memcmp (in+offset, + out+delay+offset, blocklen-(delay+offset))); - encoder.reset (); - encode_block (enc, in, blocklen); + // initial values after reset are 0 + for (i = 0; i < delay; i++){ + if (out[i] != 0) + printf (" initial output at %i is %X, not 0\n", + i, out[i]); + } - decoder.reset (); + if (differs){ + printf (" incorrect data, trial #%d\n", nt); + + printf ("\n Erroneous result dibits:"); + for (int erri = 0; erri < (NN-delay); erri++) { + if (in[erri] != out[erri+delay]) + printf (" %d", erri); + } + printf ("\n In: "); + for (int erri = 0; erri < (NN-delay); erri++) { + printf (" %d", in[erri]); + } + printf ("\n Out: "); + for (int erri = 0; erri < (NN-delay); erri++) { + printf (" %d", out[erri+delay]); + } + printf ("\n Errs:"); + for (int erri = 0; erri < (NN-delay); erri++) { + printf (" %c", (in[erri] != out[erri+delay])? '*': ' '); + } + printf ("\n THIS IS A REAL PROBLEM.\n"); + decoder_errors++; + } + } + + printf (" Summary: %d decoder errors out of %d trials.\n", + decoder_errors, NTRIALS); - // decode the block - decode_block (out, enc, blocklen); + BOOST_REQUIRE(decoder_errors == 0); + } - // int offset = delay/4; - int offset = 2; - bool differs = (memcmp (in+offset, - out+delay+offset, blocklen-(delay+offset))); + private: + atsci_fake_single_viterbi decoder; + atsci_basic_trellis_encoder encoder; - // initial values after reset are 0 - for (i = 0; i < delay; i++){ - if (out[i] != 0) - printf (" initial output at %i is %X, not 0\n", - i, out[i]); + void encode_block( + unsigned char *out, unsigned char *in, unsigned n) + { + for (unsigned int i = 0; i < n; i++) { + out[i] = encoder.encode(in[i]); } + } - if (differs){ - printf (" incorrect data, trial #%d\n", nt); - - printf ("\n Erroneous result dibits:"); - for (int erri = 0; erri < (NN-delay); erri++) { - if (in[erri] != out[erri+delay]) - printf (" %d", erri); - } - printf ("\n In: "); - for (int erri = 0; erri < (NN-delay); erri++) { - printf (" %d", in[erri]); - } - printf ("\n Out: "); - for (int erri = 0; erri < (NN-delay); erri++) { - printf (" %d", out[erri+delay]); - } - printf ("\n Errs:"); - for (int erri = 0; erri < (NN-delay); erri++) { - printf (" %c", (in[erri] != out[erri+delay])? '*': ' '); - } - printf ("\n THIS IS A REAL PROBLEM.\n"); - decoder_errors++; + void decode_block( + unsigned char *out, unsigned char *in, unsigned n) + { + for (unsigned int i = 0; i < n; i++) { + out[i] = decoder.decode ((2*in[i]-7) + noise ()); } } - printf (" Summary: %d decoder errors out of %d trials.\n", - decoder_errors, NTRIALS); + float noise () + { +#if 1 + return 2.0 * (rndm.ran1() - 0.5); +#else + return 0; +#endif + } +}; + - CPPUNIT_ASSERT (decoder_errors == 0); +BOOST_AUTO_TEST_CASE(run_t0) +{ + qa_atsci_fake_single_viterbi Q; + Q.t0(); } + diff --git a/gr-atsc/lib/qa_atsci_fake_single_viterbi.h b/gr-atsc/lib/qa_atsci_fake_single_viterbi.h deleted file mode 100644 index 42915ac6e8..0000000000 --- a/gr-atsc/lib/qa_atsci_fake_single_viterbi.h +++ /dev/null @@ -1,51 +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_ATSC_FAKE_SINGLE_VITERBI_H -#define _QA_ATSC_FAKE_SINGLE_VITERBI_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -#include <gnuradio/atsc/fake_single_viterbi_impl.h> -#include <gnuradio/atsc/basic_trellis_encoder_impl.h> - -class qa_atsci_fake_single_viterbi : public CppUnit::TestCase { - private: - atsci_fake_single_viterbi decoder; - atsci_basic_trellis_encoder encoder; - - CPPUNIT_TEST_SUITE (qa_atsci_fake_single_viterbi); - CPPUNIT_TEST (t0); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t0 (); - - void encode_block(unsigned char *out, unsigned char *in, unsigned n); - void decode_block(unsigned char *out, unsigned char *in, unsigned n); - float noise (); - -}; - -#endif /* _QA_ATSC_FAKE_SINGLE_VITERBI_H_ */ diff --git a/gr-atsc/lib/qa_atsci_fs_correlator.cc b/gr-atsc/lib/qa_atsci_fs_correlator.cc index b92e63bad8..8b9b549b4a 100644 --- a/gr-atsc/lib/qa_atsci_fs_correlator.cc +++ b/gr-atsc/lib/qa_atsci_fs_correlator.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,17 +24,16 @@ #include <config.h> #endif -#include "qa_atsci_fs_correlator.h" #include <gnuradio/atsc/fs_correlator_impl.h> #include <gnuradio/atsc/create_atsci_fs_correlator.h> #include <gnuradio/atsc/sync_tag_impl.h> -#include <stdlib.h> -#include <algorithm> #include <gnuradio/atsc/pnXXX_impl.h> #include <gnuradio/atsc/types.h> -#include <cppunit/TestAssert.h> -#include <assert.h> #include <gnuradio/random.h> +#include <boost/test/unit_test.hpp> +#include <assert.h> +#include <stdlib.h> +#include <algorithm> static gr::random rndm; @@ -144,6 +143,28 @@ cause_errors (float *p, int nerrs1, int nerrs2) } } +// Remnant of CppUnit style testing +class qa_atsci_fs_correlator +{ + public: + + void setUp (); + void tearDown (); + + void t0 (); + void t1 (); + void t2 (); + void t3 (); + void t4 (); + + private: + + atsci_fs_correlator *fsc; + + void util (int which_field, int nerr1, int nerr2); + +}; + void qa_atsci_fs_correlator::setUp () @@ -170,14 +191,14 @@ qa_atsci_fs_correlator::t0 () for (i = 0; i < delay; i++){ fsc->filter ((float) i, &output_sample, &output_tag); - CPPUNIT_ASSERT_DOUBLES_EQUAL (0.0, output_sample, 1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL (atsc_sync_tag::NORMAL, output_tag, 1e-6); + BOOST_REQUIRE(std::abs(0.0 - output_sample) <= 1e-6); + BOOST_REQUIRE(std::abs(atsc_sync_tag::NORMAL - output_tag) <= 1e-6); } for (; i < delay + 5000; i++){ fsc->filter ((float) i, &output_sample, &output_tag); - CPPUNIT_ASSERT_DOUBLES_EQUAL ((float) (i - delay), output_sample, 1e-6); - CPPUNIT_ASSERT_DOUBLES_EQUAL (atsc_sync_tag::NORMAL, output_tag, 1e-6); + BOOST_REQUIRE(std::abs((float) (i - delay) - output_sample) <= 1e-6); + BOOST_REQUIRE(std::abs(atsc_sync_tag::NORMAL - output_tag) <= 1e-6); } } @@ -211,12 +232,12 @@ qa_atsci_fs_correlator::util (int which_field, int nerrs1, int nerrs2) fsc->filter (input[i], &output_sample, &output_tag); if (i == delay + PAD){ // should be field sync if (which_field == 0) - CPPUNIT_ASSERT_DOUBLES_EQUAL (atsc_sync_tag::START_FIELD_SYNC_1, output_tag, 1e-6); + BOOST_REQUIRE(std::abs(atsc_sync_tag::START_FIELD_SYNC_1 - output_tag) <= 1e-6); else - CPPUNIT_ASSERT_DOUBLES_EQUAL (atsc_sync_tag::START_FIELD_SYNC_2, output_tag, 1e-6); + BOOST_REQUIRE(std::abs(atsc_sync_tag::START_FIELD_SYNC_2 - output_tag) <= 1e-6); } else { - CPPUNIT_ASSERT_DOUBLES_EQUAL (atsc_sync_tag::NORMAL, output_tag, 1e-6); + BOOST_REQUIRE(std::abs(atsc_sync_tag::NORMAL - output_tag) <= 1e-6); } } } @@ -254,3 +275,43 @@ qa_atsci_fs_correlator::t4 () } } +BOOST_AUTO_TEST_CASE(run_t0) +{ + qa_atsci_fs_correlator Q; + Q.setUp(); + Q.t0(); + Q.tearDown(); +} + +BOOST_AUTO_TEST_CASE(run_t1) +{ + qa_atsci_fs_correlator Q; + Q.setUp(); + Q.t1(); + Q.tearDown(); +} + +BOOST_AUTO_TEST_CASE(run_t2) +{ + qa_atsci_fs_correlator Q; + Q.setUp(); + Q.t2(); + Q.tearDown(); +} + +BOOST_AUTO_TEST_CASE(run_t3) +{ + qa_atsci_fs_correlator Q; + Q.setUp(); + Q.t3(); + Q.tearDown(); +} + +BOOST_AUTO_TEST_CASE(run_t4) +{ + qa_atsci_fs_correlator Q; + Q.setUp(); + Q.t4(); + Q.tearDown(); +} + diff --git a/gr-atsc/lib/qa_atsci_fs_correlator.h b/gr-atsc/lib/qa_atsci_fs_correlator.h deleted file mode 100644 index 4785f096ec..0000000000 --- a/gr-atsc/lib/qa_atsci_fs_correlator.h +++ /dev/null @@ -1,58 +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_ATSC_FS_CORRELATOR_H_ -#define _QA_ATSC_FS_CORRELATOR_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class atsci_fs_correlator; - -class qa_atsci_fs_correlator : public CppUnit::TestCase { -private: - atsci_fs_correlator *fsc; - - public: - - void setUp (); - void tearDown (); - - CPPUNIT_TEST_SUITE (qa_atsci_fs_correlator); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST (t4); - CPPUNIT_TEST_SUITE_END (); - - private: - - void util (int which_field, int nerr1, int nerr2); - - void t0 (); - void t1 (); - void t2 (); - void t3 (); - void t4 (); -}; - -#endif /* _QA_ATSC_FS_CORRELATOR_H_ */ diff --git a/gr-atsc/lib/qa_atsci_randomizer.cc b/gr-atsc/lib/qa_atsci_randomizer.cc index a750fbb5da..fcd9ce7ba5 100644 --- a/gr-atsc/lib/qa_atsci_randomizer.cc +++ b/gr-atsc/lib/qa_atsci_randomizer.cc @@ -20,9 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#include "qa_atsci_randomizer.h" - -#include <cppunit/TestAssert.h> +#include <gnuradio/atsc/randomizer_impl.h> +#include <boost/test/unit_test.hpp> #include <string.h> static unsigned int expected_initial_states[] = { @@ -49,13 +48,26 @@ static unsigned char expected_initial_values[] = { #define NELEMENTS(ary) ((sizeof (ary)) / sizeof (ary[0])) +class qa_atsci_randomizer { + public: + void t0_compare_output_maps(); + void t1_initial_states(); + void t2_initial_values(); + void t3_reset(); + void t4_high_level(); + + private: + //atsci_randomizer randomizer; +}; + void qa_atsci_randomizer::t0_compare_output_maps () { + atsci_randomizer randomizer; for (int i = 0; i < 0x10000; i++){ unsigned char slow = atsci_randomizer::slow_output_map(i); unsigned char fast = atsci_randomizer::fast_output_map(i); - CPPUNIT_ASSERT_EQUAL (slow, fast); + BOOST_REQUIRE_EQUAL (slow, fast); } } @@ -63,11 +75,12 @@ void qa_atsci_randomizer::t1_initial_states () { // LFSR should start with expected states + atsci_randomizer randomizer; for (unsigned int i = 0; i < NELEMENTS (expected_initial_values); i++){ unsigned int got = randomizer.state(); randomizer.clk (); - CPPUNIT_ASSERT_EQUAL (expected_initial_states[i], got); + BOOST_REQUIRE_EQUAL (expected_initial_states[i], got); } } @@ -75,10 +88,11 @@ void qa_atsci_randomizer::t2_initial_values () { // LFSR should start with expected values + atsci_randomizer randomizer; for (unsigned int i = 0; i < NELEMENTS (expected_initial_values); i++){ unsigned char got = randomizer.output_and_clk (); - CPPUNIT_ASSERT_EQUAL (expected_initial_values[i], got); + BOOST_REQUIRE_EQUAL (expected_initial_values[i], got); } } @@ -86,10 +100,11 @@ void qa_atsci_randomizer::t3_reset () { // LFSR should start with expected values + atsci_randomizer randomizer; for (unsigned int i = 0; i < NELEMENTS (expected_initial_values); i++){ unsigned char got = randomizer.output_and_clk (); - CPPUNIT_ASSERT_EQUAL (expected_initial_values[i], got); + BOOST_REQUIRE_EQUAL (expected_initial_values[i], got); } randomizer.reset (); // reset LFSR @@ -98,7 +113,7 @@ qa_atsci_randomizer::t3_reset () for (unsigned int i = 0; i < NELEMENTS (expected_initial_values); i++){ unsigned char got = randomizer.output_and_clk (); - CPPUNIT_ASSERT_EQUAL (expected_initial_values[i], got); + BOOST_REQUIRE_EQUAL (expected_initial_values[i], got); } } @@ -106,6 +121,7 @@ void qa_atsci_randomizer::t4_high_level () { static const int N = 5; + atsci_randomizer randomizer; atsc_mpeg_packet in[N]; atsc_mpeg_packet_no_sync middle[N]; @@ -139,7 +155,17 @@ qa_atsci_randomizer::t4_high_level () // compare packets for (int n = 0; n < N; n++){ - CPPUNIT_ASSERT (in[n] == out[n]); + BOOST_REQUIRE (in[n] == out[n]); } } + +BOOST_AUTO_TEST_CASE(run_qa_atsci_randomizer) { + qa_atsci_randomizer qa_runner; + qa_runner.t0_compare_output_maps(); + qa_runner.t1_initial_states(); + qa_runner.t2_initial_values(); + qa_runner.t3_reset(); + qa_runner.t4_high_level(); +} + diff --git a/gr-atsc/lib/qa_atsci_randomizer.h b/gr-atsc/lib/qa_atsci_randomizer.h deleted file mode 100644 index e0e293e85c..0000000000 --- a/gr-atsc/lib/qa_atsci_randomizer.h +++ /dev/null @@ -1,62 +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_ATSC_RANDOMIZER_H_ -#define _QA_ATSC_RANDOMIZER_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -#include <gnuradio/atsc/randomizer_impl.h> - -class qa_atsci_randomizer : public CppUnit::TestCase { - private: - atsci_randomizer randomizer; - - public: - - void setUp (){ - // nop - } - - void tearDown (){ - // nop - } - - CPPUNIT_TEST_SUITE (qa_atsci_randomizer); - CPPUNIT_TEST (t0_compare_output_maps); - CPPUNIT_TEST (t1_initial_states); - CPPUNIT_TEST (t2_initial_values); - CPPUNIT_TEST (t3_reset); - CPPUNIT_TEST (t4_high_level); - CPPUNIT_TEST_SUITE_END (); - - - private: - void t0_compare_output_maps (); - void t1_initial_states (); - void t2_initial_values (); - void t3_reset (); - void t4_high_level (); - -}; - -#endif /* _QA_ATSC_RANDOMIZER_H_ */ diff --git a/gr-atsc/lib/qa_atsci_reed_solomon.cc b/gr-atsc/lib/qa_atsci_reed_solomon.cc index f6c21dd8ce..6b62486f13 100644 --- a/gr-atsc/lib/qa_atsci_reed_solomon.cc +++ b/gr-atsc/lib/qa_atsci_reed_solomon.cc @@ -24,21 +24,22 @@ #include <config.h> #endif -#include <cppunit/TestAssert.h> -#include <stdlib.h> -#include <stdio.h> #include <gnuradio/atsc/reed_solomon_impl.h> -#include "qa_atsci_reed_solomon.h" +#include <boost/test/unit_test.hpp> #include <string.h> +#include <stdlib.h> +#include <stdio.h> static const int NROOTS = 20; static const int NTRIALS = 100; static const int NN = ATSC_MPEG_RS_ENCODED_LENGTH; -void -qa_atsci_reed_solomon::t0_reed_solomon () + +BOOST_AUTO_TEST_CASE(t0_reed_solomon) { + atsci_reed_solomon rs; + atsc_mpeg_packet_no_sync in; atsc_mpeg_packet_rs_encoded enc; atsc_mpeg_packet_no_sync out; @@ -111,5 +112,5 @@ qa_atsci_reed_solomon::t0_reed_solomon () } } - CPPUNIT_ASSERT (decoder_errors == 0); + BOOST_REQUIRE(decoder_errors == 0); } diff --git a/gr-atsc/lib/qa_atsci_reed_solomon.h b/gr-atsc/lib/qa_atsci_reed_solomon.h deleted file mode 100644 index 0afcd1398b..0000000000 --- a/gr-atsc/lib/qa_atsci_reed_solomon.h +++ /dev/null @@ -1,43 +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_ATSC_REED_SOLOMON_H_ -#define _QA_ATSC_REED_SOLOMON_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -#include <gnuradio/atsc/reed_solomon_impl.h> - -class qa_atsci_reed_solomon : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_atsci_reed_solomon); - CPPUNIT_TEST (t0_reed_solomon); - CPPUNIT_TEST_SUITE_END (); - - private: - atsci_reed_solomon rs; - - void t0_reed_solomon (); -}; - -#endif /* _QA_ATSC_REED_SOLOMON_H_ */ diff --git a/gr-atsc/lib/qa_atsci_single_viterbi.cc b/gr-atsc/lib/qa_atsci_single_viterbi.cc index f813666c27..1d427705bf 100644 --- a/gr-atsc/lib/qa_atsci_single_viterbi.cc +++ b/gr-atsc/lib/qa_atsci_single_viterbi.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,13 +24,16 @@ #include <config.h> #endif -#include <cppunit/TestAssert.h> -#include <stdlib.h> -#include <stdio.h> #include <gnuradio/atsc/single_viterbi_impl.h> -#include "qa_atsci_single_viterbi.h" +#include <gnuradio/atsc/single_viterbi_impl.h> +#include <gnuradio/atsc/basic_trellis_encoder_impl.h> +#include <gnuradio/atsc/single_viterbi_impl.h> +#include <gnuradio/atsc/basic_trellis_encoder_impl.h> #include <gnuradio/random.h> +#include <boost/test/unit_test.hpp> #include <string.h> +#include <stdlib.h> +#include <stdio.h> static const int NTRIALS = 50; @@ -41,9 +44,24 @@ static const int MAXDIBIT = 3; static gr::random rndm; +class qa_atsci_single_viterbi +{ + public: + void t0 (); + void t1 (); + + private: + atsci_single_viterbi decoder; + atsci_basic_trellis_encoder encoder; + + void encode_block(unsigned char *out, unsigned char *in, unsigned n); + void decode_block(unsigned char *out, unsigned char *in, unsigned n, float noise_factor); + float noise (); +}; + void -qa_atsci_single_viterbi::encode_block (unsigned char *out, unsigned char *in, - unsigned int n) +qa_atsci_single_viterbi::encode_block( + unsigned char *out, unsigned char *in, unsigned int n) { for (unsigned int i = 0; i < n; i++) { out[i] = encoder.encode(in[i]); @@ -52,8 +70,8 @@ qa_atsci_single_viterbi::encode_block (unsigned char *out, unsigned char *in, void -qa_atsci_single_viterbi::decode_block (unsigned char *out, unsigned char *in, - unsigned int n, float noise_factor) +qa_atsci_single_viterbi::decode_block( + unsigned char *out, unsigned char *in, unsigned int n, float noise_factor) { for (unsigned int i = 0; i < n; i++) { out[i] = decoder.decode((2*in[i]-7) + noise () * noise_factor); @@ -61,9 +79,9 @@ qa_atsci_single_viterbi::decode_block (unsigned char *out, unsigned char *in, } float -qa_atsci_single_viterbi::noise () +qa_atsci_single_viterbi::noise() { - return 2.0 * (rndm.ran1() - 0.5); // uniformly (-1, 1) + return 2.0 * (rndm.ran1() - 0.5); // uniformly (-1, 1) } void @@ -138,7 +156,7 @@ qa_atsci_single_viterbi::t0 () printf (" Summary: %d decoder errors out of %d trials.\n", decoder_errors, NTRIALS); - CPPUNIT_ASSERT (decoder_errors == 0); + BOOST_REQUIRE (decoder_errors == 0); } void @@ -282,5 +300,12 @@ qa_atsci_single_viterbi::t1 () printf (" Summary: %d decoder errors out of %d trials.\n", decoder_errors, (MAXERRORS*NTRIALS)); - CPPUNIT_ASSERT (decoder_errors <= (MAXERRORS*NTRIALS) * .1); + BOOST_REQUIRE(decoder_errors <= (MAXERRORS*NTRIALS) * .1); +} + +BOOST_AUTO_TEST_CASE(run_single_viterbi) +{ + qa_atsci_single_viterbi Q; + Q.t0(); + Q.t1(); } diff --git a/gr-atsc/lib/qa_atsci_single_viterbi.h b/gr-atsc/lib/qa_atsci_single_viterbi.h deleted file mode 100644 index 571988c559..0000000000 --- a/gr-atsc/lib/qa_atsci_single_viterbi.h +++ /dev/null @@ -1,53 +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_ATSC_SINGLE_VITERBI_H -#define _QA_ATSC_SINGLE_VITERBI_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -#include <gnuradio/atsc/single_viterbi_impl.h> -#include <gnuradio/atsc/basic_trellis_encoder_impl.h> - -class qa_atsci_single_viterbi : public CppUnit::TestCase { - private: - atsci_single_viterbi decoder; - atsci_basic_trellis_encoder encoder; - - CPPUNIT_TEST_SUITE (qa_atsci_single_viterbi); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t0 (); - void t1 (); - - void encode_block(unsigned char *out, unsigned char *in, unsigned n); - void decode_block(unsigned char *out, unsigned char *in, unsigned n, float noise_factor); - float noise (); - -}; - -#endif /* _QA_ATSC_SINGLE_VITERBI_H_ */ diff --git a/gr-atsc/lib/qa_atsci_sliding_correlator.cc b/gr-atsc/lib/qa_atsci_sliding_correlator.cc index 8b00e0ff08..0a57ed23d8 100644 --- a/gr-atsc/lib/qa_atsci_sliding_correlator.cc +++ b/gr-atsc/lib/qa_atsci_sliding_correlator.cc @@ -20,13 +20,14 @@ * Boston, MA 02110-1301, USA. */ -#include <cppunit/TestAssert.h> -#include "qa_atsci_sliding_correlator.h" +#include <gnuradio/atsc/sliding_correlator_impl.h> +#include <boost/test/unit_test.hpp> #include <cstdio> -void -qa_atsci_sliding_correlator::t0 () +BOOST_AUTO_TEST_CASE(t0) { + atsci_sliding_correlator corr; + corr.reset (); #if 0 int count = 0; @@ -47,5 +48,4 @@ qa_atsci_sliding_correlator::t0 () printf ("%6d: %3d\n", count++, corr.input_bit (atsc_pn511[i] ^ atsc_pn511[i+31])); #endif - } diff --git a/gr-atsc/lib/qa_atsci_sliding_correlator.h b/gr-atsc/lib/qa_atsci_sliding_correlator.h deleted file mode 100644 index ea02449711..0000000000 --- a/gr-atsc/lib/qa_atsci_sliding_correlator.h +++ /dev/null @@ -1,52 +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_ATSC_SLIDING_CORRELATOR_H_ -#define _QA_ATSC_SLIDING_CORRELATOR_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdio.h> - -#include <gnuradio/atsc/sliding_correlator_impl.h> - -class qa_atsci_sliding_correlator : public CppUnit::TestCase { - - public: - - void setUp (void) - { - corr.reset (); - } - - CPPUNIT_TEST_SUITE (qa_atsci_sliding_correlator); - CPPUNIT_TEST (t0); - CPPUNIT_TEST_SUITE_END (); - - private: - atsci_sliding_correlator corr; - - void t0 (); -}; - - -#endif /* _QA_ATSC_SLIDING_CORRELATOR_H_ */ diff --git a/gr-atsc/lib/qa_atsci_trellis_encoder.cc b/gr-atsc/lib/qa_atsci_trellis_encoder.cc index 902dcebf82..4d82bb4b3f 100644 --- a/gr-atsc/lib/qa_atsci_trellis_encoder.cc +++ b/gr-atsc/lib/qa_atsci_trellis_encoder.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,22 +24,24 @@ #include <config.h> #endif -#include <cppunit/TestAssert.h> -#include "qa_atsci_trellis_encoder.h" -#include <cstdio> +#include <gnuradio/atsc/trellis_encoder_impl.h> +#include <boost/test/unit_test.hpp> #include <string.h> #include <stdlib.h> #include <time.h> #include <string.h> +#include <stdio.h> + #define NELEM(x) (sizeof (x) / sizeof (x[0])) static const int NCODERS = atsci_trellis_encoder::NCODERS; -void -qa_atsci_trellis_encoder::t0 () -{ +atsci_trellis_encoder enc; + +BOOST_AUTO_TEST_CASE(t0) { + enc.reset(); #if 0 // generate i/o test data for t1 atsc_mpeg_packet_rs_encoded in[NCODERS]; @@ -72,9 +74,7 @@ qa_atsci_trellis_encoder::t0 () #endif } -void -qa_atsci_trellis_encoder::t1 () -{ +BOOST_AUTO_TEST_CASE(t1) { atsc_mpeg_packet_rs_encoded in[NCODERS]; atsc_data_segment expected_out[NCODERS]; atsc_data_segment actual_out[NCODERS]; @@ -110,7 +110,7 @@ qa_atsci_trellis_encoder::t1 () enc.encode (actual_out, in); // trellis code test data for (int i = 0; i < NCODERS; i++){ // check the result - CPPUNIT_ASSERT (expected_out[i] == actual_out[i]); - CPPUNIT_ASSERT (expected_out[i].pli == actual_out[i].pli); + BOOST_REQUIRE (expected_out[i] == actual_out[i]); + BOOST_REQUIRE (expected_out[i].pli == actual_out[i].pli); } } diff --git a/gr-atsc/lib/qa_atsci_trellis_encoder.h b/gr-atsc/lib/qa_atsci_trellis_encoder.h deleted file mode 100644 index 16567488c8..0000000000 --- a/gr-atsc/lib/qa_atsci_trellis_encoder.h +++ /dev/null @@ -1,54 +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_ATSC_TRELLIS_ENCODER_H_ -#define _QA_ATSC_TRELLIS_ENCODER_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdio.h> - -#include <gnuradio/atsc/trellis_encoder_impl.h> - -class qa_atsci_trellis_encoder : public CppUnit::TestCase { - - public: - - void setUp (void) - { - enc.reset (); - } - - CPPUNIT_TEST_SUITE (qa_atsci_trellis_encoder); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - atsci_trellis_encoder enc; - - void t0 (); - void t1 (); -}; - - -#endif /* _QA_ATSC_TRELLIS_ENCODER_H_ */ diff --git a/gr-atsc/lib/qa_atsci_viterbi_decoder.cc b/gr-atsc/lib/qa_atsci_viterbi_decoder.cc index 7f72b22c14..c46903c87e 100644 --- a/gr-atsc/lib/qa_atsci_viterbi_decoder.cc +++ b/gr-atsc/lib/qa_atsci_viterbi_decoder.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,10 +24,9 @@ #include <config.h> #endif -#include <cppunit/TestAssert.h> -#include "qa_atsci_viterbi_decoder.h" -#include "qa_atsci_trellis_encoder.h" -#include <cstdio> +#include <gnuradio/atsc/viterbi_decoder_impl.h> +#include <boost/test/unit_test.hpp> +#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> @@ -63,9 +62,10 @@ pad_decoder_input (atsc_soft_data_segment out[NCODERS]) } } -void -qa_atsci_viterbi_decoder::t0 () -{ +atsci_viterbi_decoder viterbi; + +BOOST_AUTO_TEST_CASE(t0) { + viterbi.reset (); #if 0 atsci_trellis_encoder enc; atsc_mpeg_packet_rs_encoded encoder_in[NCODERS]; @@ -129,9 +129,7 @@ qa_atsci_viterbi_decoder::t0 () #endif } -void -qa_atsci_viterbi_decoder::t1 () -{ +BOOST_AUTO_TEST_CASE(t1) { atsc_soft_data_segment decoder_in[NCODERS]; atsc_soft_data_segment decoder_in_pad[NCODERS]; atsc_mpeg_packet_rs_encoded decoder_out[NCODERS]; @@ -172,7 +170,8 @@ qa_atsci_viterbi_decoder::t1 () pad_decoder_input (decoder_in_pad); viterbi.decode (decoder_out, decoder_in_pad); - for (int i = 0; i < NCODERS; i++){ // check the result - CPPUNIT_ASSERT (expected_out[i] == decoder_out[i]); + for (int i = 0; i < NCODERS; i++){ + BOOST_REQUIRE (expected_out[i] == decoder_out[i]); } } + diff --git a/gr-atsc/lib/qa_atsci_viterbi_decoder.h b/gr-atsc/lib/qa_atsci_viterbi_decoder.h deleted file mode 100644 index 47b2776af8..0000000000 --- a/gr-atsc/lib/qa_atsci_viterbi_decoder.h +++ /dev/null @@ -1,54 +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_ATSC_VITERBI_DECODER_H_ -#define _QA_ATSC_VITERBI_DECODER_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -#include <stdio.h> -#include <gnuradio/atsc/viterbi_decoder_impl.h> - -class qa_atsci_viterbi_decoder : public CppUnit::TestCase { - - public: - - void setUp (void) - { - viterbi.reset (); - } - - CPPUNIT_TEST_SUITE (qa_atsci_viterbi_decoder); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST_SUITE_END (); - - private: - atsci_viterbi_decoder viterbi; - - void t0 (); - void t1 (); -}; - - -#endif /* _QA_ATSC_VITERBI_DECODER_H_ */ diff --git a/gr-atsc/lib/qa_convolutional_interleaver.cc b/gr-atsc/lib/qa_convolutional_interleaver.cc index c7b8494f1e..7a282173ce 100644 --- a/gr-atsc/lib/qa_convolutional_interleaver.cc +++ b/gr-atsc/lib/qa_convolutional_interleaver.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2018 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,8 +20,35 @@ * Boston, MA 02110-1301, USA. */ -#include <cppunit/TestAssert.h> -#include "qa_convolutional_interleaver.h" +#include <gnuradio/atsc/convolutional_interleaver.h> +#include <boost/test/unit_test.hpp> + +class qa_convolutional_interleaver +{ + public: + + void t0 (); + void t1 (); + void t2 (); + void t3 (); + void t4 (); + + void setUp (){ + intl = 0; + deintl = 0; + } + + void tearDown (){ + delete intl; + intl = 0; + delete deintl; + deintl = 0; + } + + private: + convolutional_interleaver<int> *intl; + convolutional_interleaver<int> *deintl; +}; void qa_convolutional_interleaver::t0 () @@ -44,7 +71,7 @@ qa_convolutional_interleaver::t0 () intl = new convolutional_interleaver<int>(true, 4, 1); for (int i = 0; i < 16; i++) - CPPUNIT_ASSERT_EQUAL (output[i], intl->transform (input[i])); + BOOST_REQUIRE_EQUAL (output[i], intl->transform (input[i])); } void @@ -68,7 +95,7 @@ qa_convolutional_interleaver::t1 () intl = new convolutional_interleaver<int>(false, 4, 1); for (int i = 0; i < 16; i++) - CPPUNIT_ASSERT_EQUAL (output[i], intl->transform (input[i])); + BOOST_REQUIRE_EQUAL (output[i], intl->transform (input[i])); } void @@ -82,11 +109,11 @@ qa_convolutional_interleaver::t2 () int end_to_end_delay = intl->end_to_end_delay (); for (int i = 0; i < end_to_end_delay; i++){ - CPPUNIT_ASSERT_EQUAL (0, deintl->transform (intl->transform (icount++))); + BOOST_REQUIRE_EQUAL (0, deintl->transform (intl->transform (icount++))); } for (int i = 0; i < 3 * end_to_end_delay; i++){ - CPPUNIT_ASSERT_EQUAL (dcount++, deintl->transform (intl->transform (icount++))); + BOOST_REQUIRE_EQUAL (dcount++, deintl->transform (intl->transform (icount++))); } } @@ -101,11 +128,11 @@ qa_convolutional_interleaver::t3 () int end_to_end_delay = intl->end_to_end_delay (); for (int i = 0; i < end_to_end_delay; i++){ - CPPUNIT_ASSERT_EQUAL (0, deintl->transform (intl->transform (icount++))); + BOOST_REQUIRE_EQUAL (0, deintl->transform (intl->transform (icount++))); } for (int i = 0; i < 3 * end_to_end_delay; i++){ - CPPUNIT_ASSERT_EQUAL (dcount++, deintl->transform (intl->transform (icount++))); + BOOST_REQUIRE_EQUAL (dcount++, deintl->transform (intl->transform (icount++))); } } @@ -119,13 +146,24 @@ qa_convolutional_interleaver::t4 () int dcount = 6000; int end_to_end_delay = intl->end_to_end_delay (); - CPPUNIT_ASSERT_EQUAL (10608, end_to_end_delay); + BOOST_REQUIRE_EQUAL (10608, end_to_end_delay); for (int i = 0; i < end_to_end_delay; i++){ - CPPUNIT_ASSERT_EQUAL (0, deintl->transform (intl->transform (icount++))); + BOOST_REQUIRE_EQUAL (0, deintl->transform (intl->transform (icount++))); } for (int i = 0; i < 3 * end_to_end_delay; i++){ - CPPUNIT_ASSERT_EQUAL (dcount++, deintl->transform (intl->transform (icount++))); + BOOST_REQUIRE_EQUAL (dcount++, deintl->transform (intl->transform (icount++))); } } + +BOOST_AUTO_TEST_CASE(run_qa_convolutional_interleaver) { + qa_convolutional_interleaver qa_runner; + qa_runner.setUp(); + qa_runner.t0(); + qa_runner.t1(); + qa_runner.t2(); + qa_runner.t3(); + qa_runner.t4(); + qa_runner.tearDown(); +} diff --git a/gr-atsc/lib/qa_convolutional_interleaver.h b/gr-atsc/lib/qa_convolutional_interleaver.h deleted file mode 100644 index 5fc73dd70c..0000000000 --- a/gr-atsc/lib/qa_convolutional_interleaver.h +++ /dev/null @@ -1,69 +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_CONVOLUTIONAL_INTERLEAVER_H_ -#define _QA_CONVOLUTIONAL_INTERLEAVER_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -#include <gnuradio/atsc/convolutional_interleaver.h> - -class qa_convolutional_interleaver : public CppUnit::TestCase { - private: - convolutional_interleaver<int> *intl; - convolutional_interleaver<int> *deintl; - - CPPUNIT_TEST_SUITE (qa_convolutional_interleaver); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST (t4); - CPPUNIT_TEST_SUITE_END (); - - public: - - void setUp (){ - intl = 0; - deintl = 0; - } - - void tearDown (){ - delete intl; - intl = 0; - delete deintl; - deintl = 0; - } - - private: - - void t0 (); - void t1 (); - void t2 (); - void t3 (); - void t4 (); - -}; - - -#endif /* _QA_CONVOLUTIONAL_INTERLEAVER_H_ */ diff --git a/gr-atsc/lib/qa_interleaver_fifo.cc b/gr-atsc/lib/qa_interleaver_fifo.cc index 7ce98630ec..62f1831e07 100644 --- a/gr-atsc/lib/qa_interleaver_fifo.cc +++ b/gr-atsc/lib/qa_interleaver_fifo.cc @@ -20,39 +20,36 @@ * Boston, MA 02110-1301, USA. */ -#include <cppunit/TestAssert.h> -#include "qa_interleaver_fifo.h" +#include <gnuradio/atsc/interleaver_fifo.h> +#include <boost/test/unit_test.hpp> -void -qa_interleaver_fifo::t0 () -{ - fifo = new interleaver_fifo<int>(0); +BOOST_AUTO_TEST_CASE(t0) { + interleaver_fifo<int>* fifo = new interleaver_fifo<int>(0); for (int i = 10; i < 20; i++) - CPPUNIT_ASSERT_EQUAL (i, fifo->stuff (i)); + BOOST_REQUIRE_EQUAL(i, fifo->stuff(i)); + delete fifo; } -void -qa_interleaver_fifo::t1 () -{ - fifo = new interleaver_fifo<int>(1); +BOOST_AUTO_TEST_CASE(t1) { + interleaver_fifo<int>* fifo = new interleaver_fifo<int>(1); - CPPUNIT_ASSERT_EQUAL (0, fifo->stuff (2)); + BOOST_REQUIRE_EQUAL(0, fifo->stuff(2)); for (int i = 1; i < 10; i++) - CPPUNIT_ASSERT_EQUAL (i * 2, fifo->stuff ((i + 1) * 2)); + BOOST_REQUIRE_EQUAL(i * 2, fifo->stuff((i + 1) * 2)); + delete fifo; } -void -qa_interleaver_fifo::t2 () -{ - fifo = new interleaver_fifo<int>(4); +BOOST_AUTO_TEST_CASE(t2) { + interleaver_fifo<int>* fifo = new interleaver_fifo<int>(4); - CPPUNIT_ASSERT_EQUAL (0, fifo->stuff (1)); - CPPUNIT_ASSERT_EQUAL (0, fifo->stuff (2)); - CPPUNIT_ASSERT_EQUAL (0, fifo->stuff (3)); - CPPUNIT_ASSERT_EQUAL (0, fifo->stuff (4)); + BOOST_REQUIRE_EQUAL(0, fifo->stuff (1)); + BOOST_REQUIRE_EQUAL(0, fifo->stuff (2)); + BOOST_REQUIRE_EQUAL(0, fifo->stuff (3)); + BOOST_REQUIRE_EQUAL(0, fifo->stuff (4)); for (int i = 5; i < 20; i++) - CPPUNIT_ASSERT_EQUAL (i - 4, fifo->stuff (i)); + BOOST_REQUIRE_EQUAL(i - 4, fifo->stuff (i)); + delete fifo; } diff --git a/gr-atsc/lib/qa_interleaver_fifo.h b/gr-atsc/lib/qa_interleaver_fifo.h deleted file mode 100644 index 9fea65a748..0000000000 --- a/gr-atsc/lib/qa_interleaver_fifo.h +++ /dev/null @@ -1,57 +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_INTERLEAVER_FIFO_H_ -#define _QA_INTERLEAVER_FIFO_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -#include <gnuradio/atsc/interleaver_fifo.h> - -class qa_interleaver_fifo : public CppUnit::TestCase { - private: - interleaver_fifo<int> *fifo; - - public: - - void tearDown (){ - delete fifo; - fifo = 0; - } - - CPPUNIT_TEST_SUITE (qa_interleaver_fifo); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST_SUITE_END (); - - private: - - void t0 (); - void t1 (); - void t2 (); - -}; - - -#endif /* _QA_INTERLEAVER_FIFO_H_ */ diff --git a/gr-atsc/lib/test_atsci.cc b/gr-atsc/lib/test_atsci.cc deleted file mode 100644 index edbe24f0b6..0000000000 --- a/gr-atsc/lib/test_atsci.cc +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2006,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 <gnuradio/unittests.h> -#include <cppunit/TextTestRunner.h> -#include <cppunit/XmlOutputter.h> -#include "qa_atsci.h" -#include <fstream> - -int -main (int argc, char **argv) -{ - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(get_unittest_path("gr_atsc.xml").c_str()); - CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); - - runner.addTest (qa_atsc::suite ()); - runner.setOutputter(xmlout); - - bool was_successful = runner.run ("", false); - - return was_successful ? 0 : 1; -} |