diff options
Diffstat (limited to 'gr-howto-write-a-block/lib')
-rw-r--r-- | gr-howto-write-a-block/lib/.gitignore | 12 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/CMakeLists.txt | 54 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/Makefile.am | 79 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/howto_square2_ff.h | 77 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/howto_square_ff.h | 78 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/qa_howto.cc | 41 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/qa_howto.h | 36 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/qa_howto_square2_ff.cc | 19 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/qa_howto_square2_ff.h | 39 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/qa_howto_square_ff.cc | 19 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/qa_howto_square_ff.h | 39 | ||||
-rw-r--r-- | gr-howto-write-a-block/lib/test_all.cc | 42 |
12 files changed, 70 insertions, 465 deletions
diff --git a/gr-howto-write-a-block/lib/.gitignore b/gr-howto-write-a-block/lib/.gitignore deleted file mode 100644 index b1e56d39e..000000000 --- a/gr-howto-write-a-block/lib/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/*.pyc -/howto.cc -/howto.py -/test_all
\ No newline at end of file diff --git a/gr-howto-write-a-block/lib/CMakeLists.txt b/gr-howto-write-a-block/lib/CMakeLists.txt new file mode 100644 index 000000000..835ae02d6 --- /dev/null +++ b/gr-howto-write-a-block/lib/CMakeLists.txt @@ -0,0 +1,54 @@ +# Copyright 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. + +######################################################################## +# Setup library +######################################################################## +include(GrPlatform) #define LIB_SUFFIX + +add_library(gnuradio-howto SHARED howto_square_ff.cc howto_square2_ff.cc) +target_link_libraries(gnuradio-howto ${Boost_LIBRARIES} ${GRUEL_LIBRARIES} ${GNURADIO_CORE_LIBRARIES}) +set_target_properties(gnuradio-howto PROPERTIES DEFINE_SYMBOL "gnuradio_howto_EXPORTS") + +######################################################################## +# Install built library files +######################################################################## +install(TARGETS gnuradio-howto + LIBRARY DESTINATION lib${LIB_SUFFIX} # .so/.dylib file + ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file + RUNTIME DESTINATION bin # .dll file +) + +######################################################################## +# Build and register unit test +######################################################################## +find_package(Boost COMPONENTS unit_test_framework) + +include(GrTest) +set(GR_TEST_TARGET_DEPS gnuradio-howto) +#turn each test cpp file into an executable with an int main() function +add_definitions(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN) + +add_executable(qa_howto_square_ff qa_howto_square_ff.cc) +target_link_libraries(qa_howto_square_ff gnuradio-howto ${Boost_LIBRARIES}) +GR_ADD_TEST(qa_howto_square_ff qa_howto_square_ff) + +add_executable(qa_howto_square2_ff qa_howto_square2_ff.cc) +target_link_libraries(qa_howto_square2_ff gnuradio-howto ${Boost_LIBRARIES}) +GR_ADD_TEST(qa_howto_square2_ff qa_howto_square2_ff) diff --git a/gr-howto-write-a-block/lib/Makefile.am b/gr-howto-write-a-block/lib/Makefile.am deleted file mode 100644 index f0a18358f..000000000 --- a/gr-howto-write-a-block/lib/Makefile.am +++ /dev/null @@ -1,79 +0,0 @@ -# -# Copyright 2004,2005,2006,2008,2009,2010 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. -# - -include $(top_srcdir)/Makefile.common - -# list of programs run by "make check" and "make distcheck" -TESTS = test_all - -# ---------------------------------------------------------------- -# howto C++ library: libgnuradio-howto.so -# ---------------------------------------------------------------- - -# C/C++ headers get installed in ${prefix}/include/$(modname) -modinclude_HEADERS = \ - howto_square_ff.h \ - howto_square2_ff.h - -lib_LTLIBRARIES = libgnuradio-howto.la - -libgnuradio_howto_la_SOURCES = \ - howto_square_ff.cc \ - howto_square2_ff.cc - -libgnuradio_howto_la_LIBADD = \ - $(GNURADIO_CORE_LA) - -libgnuradio_howto_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) - -# ---------------------------------------------------------------- -# howto C++ QA library: libgnuradio-howto-qa.so (not installed) -# ---------------------------------------------------------------- - -noinst_LTLIBRARIES = libgnuradio-howto-qa.la - -libgnuradio_howto_qa_la_SOURCES = \ - qa_howto.cc \ - qa_howto_square_ff.cc \ - qa_howto_square2_ff.cc - -libgnuradio_howto_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 - -libgnuradio_howto_qa_la_LIBADD = \ - libgnuradio-howto.la \ - $(CPPUNIT_LIBS) - -# ---------------------------------------------------------------- -# headers that don't get installed -# ---------------------------------------------------------------- -noinst_HEADERS = \ - qa_howto.h \ - qa_howto_square_ff.h \ - qa_howto_square2_ff.h - -# ---------------------------------------------------------------- -# test program -# ---------------------------------------------------------------- -noinst_PROGRAMS = \ - test_all - -test_all_SOURCES = test_all.cc -test_all_LDADD = libgnuradio-howto-qa.la diff --git a/gr-howto-write-a-block/lib/howto_square2_ff.h b/gr-howto-write-a-block/lib/howto_square2_ff.h deleted file mode 100644 index 536b04fab..000000000 --- a/gr-howto-write-a-block/lib/howto_square2_ff.h +++ /dev/null @@ -1,77 +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_HOWTO_SQUARE2_FF_H -#define INCLUDED_HOWTO_SQUARE2_FF_H - -#include <gr_sync_block.h> - -class howto_square2_ff; - -/* - * We use boost::shared_ptr's instead of raw pointers for all access - * to gr_blocks (and many other data structures). The shared_ptr gets - * us transparent reference counting, which greatly simplifies storage - * management issues. This is especially helpful in our hybrid - * C++ / Python system. - * - * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm - * - * As a convention, the _sptr suffix indicates a boost::shared_ptr - */ -typedef boost::shared_ptr<howto_square2_ff> howto_square2_ff_sptr; - -/*! - * \brief Return a shared_ptr to a new instance of howto_square2_ff. - * - * To avoid accidental use of raw pointers, howto_square2_ff's - * constructor is private. howto_make_square2_ff is the public - * interface for creating new instances. - */ -howto_square2_ff_sptr howto_make_square2_ff (); - -/*! - * \brief square2 a stream of floats. - * \ingroup block - * - * This uses the preferred technique: subclassing gr_sync_block. - */ -class howto_square2_ff : public gr_sync_block -{ -private: - // The friend declaration allows howto_make_square2_ff to - // access the private constructor. - - friend howto_square2_ff_sptr howto_make_square2_ff (); - - howto_square2_ff (); // private constructor - - public: - ~howto_square2_ff (); // public destructor - - // Where all the action really happens - - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_HOWTO_SQUARE2_FF_H */ diff --git a/gr-howto-write-a-block/lib/howto_square_ff.h b/gr-howto-write-a-block/lib/howto_square_ff.h deleted file mode 100644 index 092b93698..000000000 --- a/gr-howto-write-a-block/lib/howto_square_ff.h +++ /dev/null @@ -1,78 +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_HOWTO_SQUARE_FF_H -#define INCLUDED_HOWTO_SQUARE_FF_H - -#include <gr_block.h> - -class howto_square_ff; - -/* - * We use boost::shared_ptr's instead of raw pointers for all access - * to gr_blocks (and many other data structures). The shared_ptr gets - * us transparent reference counting, which greatly simplifies storage - * management issues. This is especially helpful in our hybrid - * C++ / Python system. - * - * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm - * - * As a convention, the _sptr suffix indicates a boost::shared_ptr - */ -typedef boost::shared_ptr<howto_square_ff> howto_square_ff_sptr; - -/*! - * \brief Return a shared_ptr to a new instance of howto_square_ff. - * - * To avoid accidental use of raw pointers, howto_square_ff's - * constructor is private. howto_make_square_ff is the public - * interface for creating new instances. - */ -howto_square_ff_sptr howto_make_square_ff (); - -/*! - * \brief square a stream of floats. - * \ingroup block - * - * \sa howto_square2_ff for a version that subclasses gr_sync_block. - */ -class howto_square_ff : public gr_block -{ -private: - // The friend declaration allows howto_make_square_ff to - // access the private constructor. - - friend howto_square_ff_sptr howto_make_square_ff (); - - howto_square_ff (); // private constructor - - public: - ~howto_square_ff (); // public destructor - - // Where all the action really happens - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_HOWTO_SQUARE_FF_H */ diff --git a/gr-howto-write-a-block/lib/qa_howto.cc b/gr-howto-write-a-block/lib/qa_howto.cc deleted file mode 100644 index f1411a388..000000000 --- a/gr-howto-write-a-block/lib/qa_howto.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2009 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 example - * directory into a single test suite. As you create new test cases, - * add them here. - */ - -#include <qa_howto.h> -#include <qa_howto_square_ff.h> -#include <qa_howto_square2_ff.h> - -CppUnit::TestSuite * -qa_howto::suite() -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite("howto"); - - s->addTest(qa_howto_square_ff::suite()); - s->addTest(qa_howto_square2_ff::suite()); - - return s; -} diff --git a/gr-howto-write-a-block/lib/qa_howto.h b/gr-howto-write-a-block/lib/qa_howto.h deleted file mode 100644 index fa5a42fd3..000000000 --- a/gr-howto-write-a-block/lib/qa_howto.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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_HOWTO_H -#define INCLUDED_QA_HOWTO_H - -#include <cppunit/TestSuite.h> - -//! collect all the tests for the example directory - -class qa_howto { - public: - //! return suite of tests for all of example directory - static CppUnit::TestSuite *suite (); -}; - -#endif /* INCLUDED_QA_HOWTO_H */ diff --git a/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc b/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc index a37465104..9c37b62c1 100644 --- a/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc +++ b/gr-howto-write-a-block/lib/qa_howto_square2_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Free Software Foundation, Inc. + * Copyright 2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,17 +19,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <qa_howto_square2_ff.h> -#include <cppunit/TestAssert.h> +#include <boost/test/unit_test.hpp> -void -qa_howto_square2_ff::t1() -{ - // Insert CPPUNIT tests/asserts here +BOOST_AUTO_TEST_CASE(qa_howto_square2_ff_t1){ + BOOST_CHECK_EQUAL(2 + 2, 4); + // TODO BOOST_* test macros here } -void -qa_howto_square2_ff::t2() -{ - // Insert CPPUNIT tests/asserts here +BOOST_AUTO_TEST_CASE(qa_howto_square2_ff_t2){ + BOOST_CHECK_EQUAL(2 + 2, 4); + // TODO BOOST_* test macros here } diff --git a/gr-howto-write-a-block/lib/qa_howto_square2_ff.h b/gr-howto-write-a-block/lib/qa_howto_square2_ff.h deleted file mode 100644 index c74d0866f..000000000 --- a/gr-howto-write-a-block/lib/qa_howto_square2_ff.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_QA_HOWTO_SQUARE2_FF_H -#define INCLUDED_QA_HOWTO_SQUARE2_FF_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_howto_square2_ff : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_howto_square2_ff); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST_SUITE_END (); - - private: - void t1 (); - void t2 (); -}; - -#endif /* INCLUDED_QA_HOWTO_SQUARE2_FF_H */ diff --git a/gr-howto-write-a-block/lib/qa_howto_square_ff.cc b/gr-howto-write-a-block/lib/qa_howto_square_ff.cc index 2f0b59773..da1d3040a 100644 --- a/gr-howto-write-a-block/lib/qa_howto_square_ff.cc +++ b/gr-howto-write-a-block/lib/qa_howto_square_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Free Software Foundation, Inc. + * Copyright 2011 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,17 +19,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include <qa_howto_square_ff.h> -#include <cppunit/TestAssert.h> +#include <boost/test/unit_test.hpp> -void -qa_howto_square_ff::t1() -{ - // Insert CPPUNIT tests/asserts here +BOOST_AUTO_TEST_CASE(qa_howto_square_ff_t1){ + BOOST_CHECK_EQUAL(2 + 2, 4); + // TODO BOOST_* test macros here } -void -qa_howto_square_ff::t2() -{ - // Insert CPPUNIT tests/asserts here +BOOST_AUTO_TEST_CASE(qa_howto_square_ff_t2){ + BOOST_CHECK_EQUAL(2 + 2, 4); + // TODO BOOST_* test macros here } diff --git a/gr-howto-write-a-block/lib/qa_howto_square_ff.h b/gr-howto-write-a-block/lib/qa_howto_square_ff.h deleted file mode 100644 index 1b7c5e99f..000000000 --- a/gr-howto-write-a-block/lib/qa_howto_square_ff.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_QA_HOWTO_SQUARE_FF_H -#define INCLUDED_QA_HOWTO_SQUARE_FF_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_howto_square_ff : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_howto_square_ff); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST_SUITE_END (); - - private: - void t1 (); - void t2 (); -}; - -#endif /* INCLUDED_QA_HOWTO_SQUARE_FF_H */ diff --git a/gr-howto-write-a-block/lib/test_all.cc b/gr-howto-write-a-block/lib/test_all.cc deleted file mode 100644 index c12958691..000000000 --- a/gr-howto-write-a-block/lib/test_all.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009,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. - */ - -#include <cppunit/TextTestRunner.h> -#include <cppunit/XmlOutputter.h> - -#include <gr_unittests.h> -#include <qa_howto.h> - -int -main (int argc, char **argv) -{ - CppUnit::TextTestRunner runner; - std::ofstream xmlfile(get_unittest_path("gr_howto_write_a_block.xml").c_str()); - CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); - - runner.addTest(qa_howto::suite ()); - runner.setOutputter(xmlout); - - bool was_successful = runner.run("", false); - - return was_successful ? 0 : 1; -} |