howto: adds C++ QA code
authorJohnathan Corgan <jcorgan@corganenterprises.com>
Thu, 12 Nov 2009 15:24:34 +0000 (07:24 -0800)
committerJohnathan Corgan <jcorgan@corganenterprises.com>
Thu, 12 Nov 2009 15:28:02 +0000 (07:28 -0800)
gr-howto-write-a-block/config/gr_standalone.m4
gr-howto-write-a-block/lib/.gitignore
gr-howto-write-a-block/lib/Makefile.am
gr-howto-write-a-block/lib/qa_howto.cc [new file with mode: 0644]
gr-howto-write-a-block/lib/qa_howto.h [new file with mode: 0644]
gr-howto-write-a-block/lib/qa_howto_square2_ff.cc [new file with mode: 0644]
gr-howto-write-a-block/lib/qa_howto_square2_ff.h [new file with mode: 0644]
gr-howto-write-a-block/lib/qa_howto_square_ff.cc [new file with mode: 0644]
gr-howto-write-a-block/lib/qa_howto_square_ff.h [new file with mode: 0644]
gr-howto-write-a-block/lib/test_all.cc [new file with mode: 0644]

index 593583e2dde56f23f64f047113af335285d84bfb..3f8ddf1d62f74c213d43582f20622602a8b794eb 100644 (file)
@@ -124,4 +124,12 @@ m4_define([GR_STANDALONE],
     [enable_python=yes]  
   )
   AM_CONDITIONAL([PYTHON], [test x$enable_python = xyes])
+
+  dnl Define where to look for cppunit includes and libs
+  dnl sets CPPUNIT_CFLAGS and CPPUNIT_LIBS
+  dnl Try using pkg-config first, then fall back to cppunit-config.
+  PKG_CHECK_EXISTS(cppunit,
+    [PKG_CHECK_MODULES(CPPUNIT, cppunit >= 1.9.14)],
+    [AM_PATH_CPPUNIT([1.9.14],[],
+                    [AC_MSG_ERROR([GNU Radio requires cppunit.  Stop])])])
 ])
index d957a6821fac0106aad514ea8b6f761a150af03c..b1e56d39e23dfc12a68ab4d54d5d90893546f5b2 100644 (file)
@@ -9,3 +9,4 @@
 /*.pyc
 /howto.cc
 /howto.py
+/test_all
\ No newline at end of file
index e553c193de391b8848462509b14bbdbf75e99145..336cb8a203e3caf5b6ad0f73b0f79d86b2a203f8 100644 (file)
 
 include $(top_srcdir)/Makefile.common
 
-###################################
-# howto C++ library
+# 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/gnuradio
 grinclude_HEADERS =            \
@@ -40,3 +44,37 @@ libgnuradio_howto_la_LIBADD =        \
 
 libgnuradio_howto_la_LDFLAGS = \
        $(NO_UNDEFINED)
+
+# ----------------------------------------------------------------
+# 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/qa_howto.cc b/gr-howto-write-a-block/lib/qa_howto.cc
new file mode 100644 (file)
index 0000000..f1411a3
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..fa5a42f
--- /dev/null
@@ -0,0 +1,36 @@
+/* -*- 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
new file mode 100644 (file)
index 0000000..a374651
--- /dev/null
@@ -0,0 +1,35 @@
+/* -*- 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.
+ */
+
+#include <qa_howto_square2_ff.h>
+#include <cppunit/TestAssert.h>
+
+void
+qa_howto_square2_ff::t1()
+{
+  // Insert CPPUNIT tests/asserts here
+}
+
+void
+qa_howto_square2_ff::t2()
+{
+  // Insert CPPUNIT tests/asserts 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
new file mode 100644 (file)
index 0000000..c74d086
--- /dev/null
@@ -0,0 +1,39 @@
+/* -*- 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
new file mode 100644 (file)
index 0000000..2f0b597
--- /dev/null
@@ -0,0 +1,35 @@
+/* -*- 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.
+ */
+
+#include <qa_howto_square_ff.h>
+#include <cppunit/TestAssert.h>
+
+void
+qa_howto_square_ff::t1()
+{
+  // Insert CPPUNIT tests/asserts here
+}
+
+void
+qa_howto_square_ff::t2()
+{
+  // Insert CPPUNIT tests/asserts 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
new file mode 100644 (file)
index 0000000..1b7c5e9
--- /dev/null
@@ -0,0 +1,39 @@
+/* -*- 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
new file mode 100644 (file)
index 0000000..192c537
--- /dev/null
@@ -0,0 +1,38 @@
+/* -*- 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 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 <qa_howto.h>
+
+int 
+main (int argc, char **argv)
+{
+  
+  CppUnit::TextTestRunner runner;
+
+  runner.addTest(qa_howto::suite ());
+  
+  bool was_successful = runner.run("", false);
+
+  return was_successful ? 0 : 1;
+}