diff options
32 files changed, 71 insertions, 2647 deletions
diff --git a/include/gnuradio/gr_complex.h b/include/gnuradio/gr_complex.h deleted file mode 100644 index 7580021..0000000 --- a/include/gnuradio/gr_complex.h +++ /dev/null @@ -1,46 +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_GR_COMPLEX_H -#define INCLUDED_GR_COMPLEX_H - -#include <complex> -typedef std::complex<float> gr_complex; -typedef std::complex<double> gr_complexd; - - -inline bool is_complex (gr_complex x) { return true;} -inline bool is_complex (gr_complexd x) { return true;} -inline bool is_complex (float x) { return false;} -inline bool is_complex (double x) { return false;} -inline bool is_complex (int x) { return false;} -inline bool is_complex (char x) { return false;} -inline bool is_complex (short x) { return false;} - - -// this doesn't really belong here, but there are worse places for it... - -#define CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected,actual,delta) \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected.real(), actual.real(), delta); \ - CPPUNIT_ASSERT_DOUBLES_EQUAL (expected.imag(), actual.imag(), delta); - -#endif /* INCLUDED_GR_COMPLEX_H */ - diff --git a/include/gnuradio/gr_message.h b/include/gnuradio/gr_message.h deleted file mode 100644 index d386ca0..0000000 --- a/include/gnuradio/gr_message.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_GR_MESSAGE_H -#define INCLUDED_GR_MESSAGE_H - -#include <gr_core_api.h> -#include <gr_types.h> -#include <string> - -class gr_message; -typedef boost::shared_ptr<gr_message> gr_message_sptr; - -/*! - * \brief public constructor for gr_message - */ -GR_CORE_API gr_message_sptr -gr_make_message(long type = 0, double arg1 = 0, double arg2 = 0, size_t length = 0); - -GR_CORE_API gr_message_sptr -gr_make_message_from_string(const std::string s, long type = 0, double arg1 = 0, double arg2 = 0); - -/*! - * \brief Message class. - * - * \ingroup misc - * The ideas and method names for adjustable message length were - * lifted from the click modular router "Packet" class. - */ -class GR_CORE_API gr_message { - gr_message_sptr d_next; // link field for msg queue - long d_type; // type of the message - double d_arg1; // optional arg1 - double d_arg2; // optional arg2 - - unsigned char *d_buf_start; // start of allocated buffer - unsigned char *d_msg_start; // where the msg starts - unsigned char *d_msg_end; // one beyond end of msg - unsigned char *d_buf_end; // one beyond end of allocated buffer - - gr_message (long type, double arg1, double arg2, size_t length); - - friend GR_CORE_API gr_message_sptr - gr_make_message (long type, double arg1, double arg2, size_t length); - - friend GR_CORE_API gr_message_sptr - gr_make_message_from_string (const std::string s, long type, double arg1, double arg2); - - friend class gr_msg_queue; - - unsigned char *buf_data() const { return d_buf_start; } - size_t buf_len() const { return d_buf_end - d_buf_start; } - -public: - ~gr_message (); - - long type() const { return d_type; } - double arg1() const { return d_arg1; } - double arg2() const { return d_arg2; } - - void set_type(long type) { d_type = type; } - void set_arg1(double arg1) { d_arg1 = arg1; } - void set_arg2(double arg2) { d_arg2 = arg2; } - - unsigned char *msg() const { return d_msg_start; } - size_t length() const { return d_msg_end - d_msg_start; } - std::string to_string() const; - -}; - -GR_CORE_API long gr_message_ncurrently_allocated (); - -#endif /* INCLUDED_GR_MESSAGE_H */ diff --git a/include/gnuradio/gr_msg_handler.h b/include/gnuradio/gr_msg_handler.h deleted file mode 100644 index 57e8a95..0000000 --- a/include/gnuradio/gr_msg_handler.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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_GR_MSG_HANDLER_H -#define INCLUDED_GR_MSG_HANDLER_H - -#include <gr_core_api.h> -#include <gr_message.h> - -class gr_msg_handler; -typedef boost::shared_ptr<gr_msg_handler> gr_msg_handler_sptr; - -/*! - * \brief abstract class of message handlers - * \ingroup base - */ -class GR_CORE_API gr_msg_handler { -public: - virtual ~gr_msg_handler (); - - //! handle \p msg - virtual void handle (gr_message_sptr msg) = 0; -}; - -#endif /* INCLUDED_GR_MSG_HANDLER_H */ diff --git a/include/gnuradio/gr_msg_queue.h b/include/gnuradio/gr_msg_queue.h deleted file mode 100644 index 86440bb..0000000 --- a/include/gnuradio/gr_msg_queue.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,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. - */ -#ifndef INCLUDED_GR_MSG_QUEUE_H -#define INCLUDED_GR_MSG_QUEUE_H - -#include <gr_core_api.h> -#include <gr_msg_handler.h> -#include <gruel/thread.h> - -class gr_msg_queue; -typedef boost::shared_ptr<gr_msg_queue> gr_msg_queue_sptr; - -GR_CORE_API gr_msg_queue_sptr gr_make_msg_queue(unsigned int limit=0); - -/*! - * \brief thread-safe message queue - * \ingroup misc - */ -class GR_CORE_API gr_msg_queue : public gr_msg_handler { - - gruel::mutex d_mutex; - gruel::condition_variable d_not_empty; - gruel::condition_variable d_not_full; - gr_message_sptr d_head; - gr_message_sptr d_tail; - unsigned int d_count; // # of messages in queue. - unsigned int d_limit; // max # of messages in queue. 0 -> unbounded - -public: - gr_msg_queue(unsigned int limit); - ~gr_msg_queue(); - - //! Generic msg_handler method: insert the message. - void handle(gr_message_sptr msg) { insert_tail (msg); } - - /*! - * \brief Insert message at tail of queue. - * \param msg message - * - * Block if queue if full. - */ - void insert_tail(gr_message_sptr msg); - - /*! - * \brief Delete message from head of queue and return it. - * Block if no message is available. - */ - gr_message_sptr delete_head(); - - /*! - * \brief If there's a message in the q, delete it and return it. - * If no message is available, return 0. - */ - gr_message_sptr delete_head_nowait(); - - //! Delete all messages from the queue - void flush(); - - //! is the queue empty? - bool empty_p() const { return d_count == 0; } - - //! is the queue full? - bool full_p() const { return d_limit != 0 && d_count >= d_limit; } - - //! return number of messages in queue - unsigned int count() const { return d_count; } - - //! return limit on number of message in queue. 0 -> unbounded - unsigned int limit() const { return d_limit; } - -}; - -#endif /* INCLUDED_GR_MSG_QUEUE_H */ diff --git a/include/gnuradio/gr_sys_paths.h b/include/gnuradio/gr_sys_paths.h deleted file mode 100644 index bd51ebd..0000000 --- a/include/gnuradio/gr_sys_paths.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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. - */ - -#ifndef _GR_SYS_PATHS_H_ -#define _GR_SYS_PATHS_H_ - -#include <gr_core_api.h> - -//! directory to create temporary files -GR_CORE_API const char *gr_tmp_path(); - -//! directory to store application data -GR_CORE_API const char *gr_appdata_path(); - -#endif /* _GR_SYS_PATHS_H_ */ diff --git a/include/gnuradio/gr_unittests.h b/include/gnuradio/gr_unittests.h deleted file mode 100644 index 9fbf228..0000000 --- a/include/gnuradio/gr_unittests.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 <gr_core_api.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <string> - -#include <boost/filesystem/operations.hpp> -#include <boost/filesystem/path.hpp> - -static std::string get_unittest_path(const std::string &filename){ - boost::filesystem::path path = boost::filesystem::current_path() / ".unittests"; - if (!boost::filesystem::is_directory(path)) boost::filesystem::create_directory(path); - return (path / filename).string(); -} diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 0fe8c50..8baa38d 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -3,9 +3,10 @@ ######################################################################## include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(${GRAS_SOURCE_DIR}/tests) set(GRAS_SOURCE_DIR ${CMAKE_SOURCE_DIR}/../) +set(GRAS_BINARY_DIR ${CMAKE_BINARY_DIR}/gruel/src) +set(RUNTIME_SOURCE_DIR ${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/runtime) ######################################################################## # Setup NumaNuma @@ -36,31 +37,50 @@ list(APPEND gnuradio_core_sources ) #sources that are in tree that have not changed -set(runtime_srcs_dir ${CMAKE_SOURCE_DIR}/gnuradio-core/src/lib/runtime) list(APPEND gnuradio_core_sources - ${runtime_srcs_dir}/gr_sys_paths.cc - ${runtime_srcs_dir}/gr_message.cc - ${runtime_srcs_dir}/gr_msg_queue.cc - ${runtime_srcs_dir}/gr_msg_handler.cc + ${RUNTIME_SOURCE_DIR}/gr_sys_paths.cc + ${RUNTIME_SOURCE_DIR}/gr_message.cc + ${RUNTIME_SOURCE_DIR}/gr_msg_queue.cc + ${RUNTIME_SOURCE_DIR}/gr_msg_handler.cc ) ######################################################################## # Append gnuradio-core test sources ######################################################################## list(APPEND test_gnuradio_core_sources - ${GRAS_SOURCE_DIR}/tests/qa_gr_block.cc - ${GRAS_SOURCE_DIR}/tests/qa_gr_hier_block2.cc - ${GRAS_SOURCE_DIR}/tests/qa_gr_hier_block2_derived.cc - #${GRAS_SOURCE_DIR}/tests/qa_gr_buffer.cc - #${GRAS_SOURCE_DIR}/tests/qa_gr_flowgraph.cc - ${GRAS_SOURCE_DIR}/tests/qa_gr_top_block.cc - ${GRAS_SOURCE_DIR}/tests/qa_gr_io_signature.cc - #${GRAS_SOURCE_DIR}/tests/qa_gr_vmcircbuf.cc - ${GRAS_SOURCE_DIR}/tests/qa_block_tags.cc - ${GRAS_SOURCE_DIR}/tests/qa_runtime.cc - #${GRAS_SOURCE_DIR}/tests/qa_set_msg_handler.cc + ${RUNTIME_SOURCE_DIR}/qa_gr_block.cc + ${RUNTIME_SOURCE_DIR}/qa_gr_hier_block2.cc + ${RUNTIME_SOURCE_DIR}/qa_gr_hier_block2_derived.cc + #${RUNTIME_SOURCE_DIR}/qa_gr_buffer.cc + #${RUNTIME_SOURCE_DIR}/qa_gr_flowgraph.cc + ${RUNTIME_SOURCE_DIR}/qa_gr_top_block.cc + ${RUNTIME_SOURCE_DIR}/qa_gr_io_signature.cc + #${RUNTIME_SOURCE_DIR}/qa_gr_vmcircbuf.cc + ${RUNTIME_SOURCE_DIR}/qa_block_tags.cc + ${GRAS_SOURCE_DIR}/lib/qa_runtime.cc + #${RUNTIME_SOURCE_DIR}/qa_set_msg_handler.cc ) +#copy test headers to include dir +set(test_headers + ${RUNTIME_SOURCE_DIR}/qa_gr_block.h + ${RUNTIME_SOURCE_DIR}/qa_gr_hier_block2.h + ${RUNTIME_SOURCE_DIR}/qa_gr_hier_block2_derived.h + #${RUNTIME_SOURCE_DIR}/qa_gr_buffer.h + #${RUNTIME_SOURCE_DIR}/qa_gr_flowgraph.h + ${RUNTIME_SOURCE_DIR}/qa_gr_top_block.h + ${RUNTIME_SOURCE_DIR}/qa_gr_io_signature.h + #${RUNTIME_SOURCE_DIR}/qa_gr_vmcircbuf.h + ${RUNTIME_SOURCE_DIR}/qa_block_tags.h + ${RUNTIME_SOURCE_DIR}/qa_runtime.h + #${RUNTIME_SOURCE_DIR}/qa_set_msg_handler.h + ${RUNTIME_SOURCE_DIR}/gr_unittests.h +) +foreach(header ${test_headers}) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${header} ${GRAS_BINARY_DIR}/include) +endforeach(header) + + ######################################################################## # Find TSBE and add to libs ######################################################################## @@ -91,9 +111,22 @@ list(APPEND gnuradio_core_libs ${NUMANUMA_LIBRARIES}) ######################################################################## # Install runtime headers ######################################################################## +set(runtime_copy_headers + ${RUNTIME_SOURCE_DIR}/gr_sys_paths.h + ${RUNTIME_SOURCE_DIR}/gr_message.h + ${RUNTIME_SOURCE_DIR}/gr_msg_queue.h + ${RUNTIME_SOURCE_DIR}/gr_msg_handler.h + ${RUNTIME_SOURCE_DIR}/gr_complex.h +) + +#copy the headers to a place that is in the include path +foreach(runtime_copy_header ${runtime_copy_headers}) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${runtime_copy_header} ${GRAS_BINARY_DIR}/include) +endforeach(runtime_copy_header) + file(GLOB runtime_headers "${GRAS_SOURCE_DIR}/include/gnuradio/*") install(FILES - ${runtime_headers} + ${runtime_headers} ${runtime_copy_headers} DESTINATION ${GR_INCLUDE_DIR}/gnuradio COMPONENT "core_devel" ) @@ -102,11 +135,11 @@ install(FILES # Install swig headers ######################################################################## if(ENABLE_PYTHON) -file(GLOB runtime_swigs "${GRAS_SOURCE_DIR}/swig/*.i") -install(FILES - ${runtime_swigs} - DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig - COMPONENT "core_swig" + +set(runtime_copy_swigs + ${RUNTIME_SOURCE_DIR}/gr_message.i + ${RUNTIME_SOURCE_DIR}/gr_msg_queue.i + ${RUNTIME_SOURCE_DIR}/gr_msg_handler.i ) #makes swig doc generator happy @@ -115,4 +148,19 @@ execute_process( COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/runtime/nop.h ) +#copy the headers to a place that is in the include path +foreach(runtime_copy_header ${runtime_copy_swigs}) + execute_process( + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig/ + COMMAND ${CMAKE_COMMAND} -E copy ${runtime_copy_header} ${CMAKE_BINARY_DIR}/gnuradio-core/src/lib/swig/ + ) +endforeach(runtime_copy_header) + +file(GLOB runtime_swigs "${GRAS_SOURCE_DIR}/swig/*.i") +install(FILES + ${runtime_swigs} ${runtime_copy_swigs} + DESTINATION ${GR_INCLUDE_DIR}/gnuradio/swig + COMPONENT "core_swig" +) + endif(ENABLE_PYTHON) diff --git a/tests/qa_runtime.cc b/lib/qa_runtime.cc index 711cf24..711cf24 100644 --- a/tests/qa_runtime.cc +++ b/lib/qa_runtime.cc diff --git a/swig/gr_message.i b/swig/gr_message.i deleted file mode 100644 index 356bba5..0000000 --- a/swig/gr_message.i +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -class gr_message; -typedef boost::shared_ptr<gr_message> gr_message_sptr; -%template(gr_message_sptr) boost::shared_ptr<gr_message>; - -%rename(message_from_string) gr_make_message_from_string; -gr_message_sptr -gr_make_message_from_string(const std::string s, long type = 0, double arg1 = 0, double arg2 = 0); - -%rename(message) gr_make_message; -gr_message_sptr -gr_make_message(long type = 0, double arg1 = 0, double arg2 = 0, size_t length = 0); - -/*! - * \brief Message. - * - * The ideas and method names for adjustable message length were - * lifted from the click modular router "Packet" class. - */ -class gr_message { - gr_message (long type, double arg1, double arg2, size_t length); - - unsigned char *buf_data() const { return d_buf_start; } - size_t buf_len() const { return d_buf_end - d_buf_start; } - -public: - ~gr_message (); - - long type() const { return d_type; } - double arg1() const { return d_arg1; } - double arg2() const { return d_arg2; } - - void set_type(long type) { d_type = type; } - void set_arg1(double arg1) { d_arg1 = arg1; } - void set_arg2(double arg2) { d_arg2 = arg2; } - - size_t length() const; - std::string to_string() const; - -}; - -%rename(message_ncurrently_allocated) gr_message_ncurrently_allocated; -long gr_message_ncurrently_allocated(); - diff --git a/swig/gr_msg_handler.i b/swig/gr_msg_handler.i deleted file mode 100644 index f493dac..0000000 --- a/swig/gr_msg_handler.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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. - */ - -/*! - * \brief abstract class of message handlers - */ -class gr_msg_handler { -public: - virtual ~gr_msg_handler () = 0; - - //! handle \p msg - virtual void handle (gr_message_sptr msg) = 0; -}; diff --git a/swig/gr_msg_queue.i b/swig/gr_msg_queue.i deleted file mode 100644 index 65cbe78..0000000 --- a/swig/gr_msg_queue.i +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,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. - */ - -class gr_msg_queue; -typedef boost::shared_ptr<gr_msg_queue> gr_msg_queue_sptr; -%template(gr_msg_queue_sptr) boost::shared_ptr<gr_msg_queue>; - -%rename(msg_queue) gr_make_msg_queue; -gr_msg_queue_sptr gr_make_msg_queue(unsigned limit=0); - -/*! - * \brief thread-safe message queue - */ -%ignore gr_msg_queue; -class gr_msg_queue : public gr_msg_handler { -public: - gr_msg_queue(unsigned int limit); - ~gr_msg_queue(); - - //! Generic msg_handler method: insert the message. - //void handle(gr_message_sptr msg) { insert_tail (msg); } - - /*! - * \brief Insert message at tail of queue. - * \param msg message - * - * Block if queue if full. - */ - //void insert_tail(gr_message_sptr msg); - - /*! - * \brief Delete message from head of queue and return it. - * Block if no message is available. - */ - //gr_message_sptr delete_head(); - - /*! - * \brief If there's a message in the q, delete it and return it. - * If no message is available, return 0. - */ - gr_message_sptr delete_head_nowait(); - - //! is the queue empty? - bool empty_p() const; - - //! is the queue full? - bool full_p() const; - - //! return number of messages in queue - unsigned int count() const; - - //! Delete all messages from the queue - void flush(); -}; - -/* - * The following kludge-o-rama releases the Python global interpreter - * lock around these potentially blocking calls. We don't want - * libgnuradio-core to be dependent on Python, thus we create these - * functions that serve as replacements for the normal C++ delete_head - * and insert_tail methods. The %pythoncode smashes these new C++ - * functions into the gr.msg_queue wrapper class, so that everything - * appears normal. (An evil laugh is heard in the distance...) - */ -#ifdef SWIGPYTHON -%inline %{ - gr_message_sptr gr_py_msg_queue__delete_head(gr_msg_queue_sptr q) { - gr_message_sptr msg; - GR_PYTHON_BLOCKING_CODE( - msg = q->delete_head(); - ) - return msg; - } - - void gr_py_msg_queue__insert_tail(gr_msg_queue_sptr q, gr_message_sptr msg) { - GR_PYTHON_BLOCKING_CODE( - q->insert_tail(msg); - ) - } -%} - -// smash in new python delete_head and insert_tail methods... -%pythoncode %{ -gr_msg_queue_sptr.delete_head = gr_py_msg_queue__delete_head -gr_msg_queue_sptr.insert_tail = gr_py_msg_queue__insert_tail -gr_msg_queue_sptr.handle = gr_py_msg_queue__insert_tail -%} -#endif // SWIGPYTHON diff --git a/tests/qa_block_tags.cc b/tests/qa_block_tags.cc deleted file mode 100644 index 4fa0a03..0000000 --- a/tests/qa_block_tags.cc +++ /dev/null @@ -1,450 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <qa_block_tags.h> -#include <gr_block.h> -#include <gr_top_block.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> -#include <gr_head.h> -#include <gr_annotator_alltoall.h> -#include <gr_annotator_1to1.h> -#include <gr_keep_one_in_n.h> -#include <gr_firdes.h> -#include <gruel/pmt.h> - - -// ---------------------------------------------------------------- - -using namespace pmt; - -// set to 1 to turn on debug output -// The debug output fully checks that the tags seen are what are expected. While -// this behavior currently works with our implementation, there is no guarentee -// that the tags will be coming in this specific order, so it's dangerous to -// rely on this as a test of the tag system working. We would really want to -// tags we know we should see and then test that they all occur once, but in no -// particular order. -#define QA_TAGS_DEBUG 0 - -void -qa_block_tags::t0 () -{ - unsigned int N = 1000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_block_sptr snk (gr_make_null_sink(sizeof(int))); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, snk, 0); - - //CPPUNIT_ASSERT_THROW(src->nitems_read(0), std::runtime_error); - //CPPUNIT_ASSERT_THROW(src->nitems_written(0), std::runtime_error); - CPPUNIT_ASSERT_EQUAL(src->nitems_read(0), (uint64_t)0); - CPPUNIT_ASSERT_EQUAL(src->nitems_written(0), (uint64_t)0); - - tb->run(); - - CPPUNIT_ASSERT_THROW(src->nitems_read(0), std::invalid_argument); - CPPUNIT_ASSERT(src->nitems_written(0) >= N); - CPPUNIT_ASSERT_EQUAL(snk->nitems_read(0), (uint64_t)1000); - CPPUNIT_ASSERT_THROW(snk->nitems_written(0), std::invalid_argument); -} - - -void -qa_block_tags::t1 () -{ - int N = 40000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann3 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann4 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, ann0, 0); - - tb->connect(ann0, 0, ann1, 0); - tb->connect(ann0, 1, ann2, 0); - tb->connect(ann1, 0, ann3, 0); - tb->connect(ann2, 0, ann4, 0); - - tb->connect(ann3, 0, snk0, 0); - tb->connect(ann4, 0, snk1, 0); - - tb->run(); - - std::vector<gr_tag_t> tags0 = ann0->data(); - std::vector<gr_tag_t> tags3 = ann3->data(); - std::vector<gr_tag_t> tags4 = ann4->data(); - - // The first annotator does not receive any tags from the null sink upstream - CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); - CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8); - CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8); - -#if QA_TAGS_DEBUG - // Kludge together the tags that we know should result from the above graph - std::stringstream str0, str1, str2; - str0 << ann0->name() << ann0->unique_id(); - str1 << ann1->name() << ann1->unique_id(); - str2 << ann2->name() << ann2->unique_id(); - - pmt_t expected_tags3[8]; - expected_tags3[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags3[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags3[2] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); - expected_tags3[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags3[4] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags3[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags3[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags3[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - - pmt_t expected_tags4[8]; - expected_tags4[0] = mp(pmt_from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); - expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[2] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[4] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[6] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); - expected_tags4[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); - - std::cout << std::endl << "qa_block_tags::t1" << std::endl; - - // For annotator 3, we know it gets tags from ann0 and ann1, test this - for(size_t i = 0; i < tags3.size(); i++) { - std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags3[i]), pmt_write_string(expected_tags3[i])); - } - - // For annotator 4, we know it gets tags from ann0 and ann2, test this - std::cout << std::endl; - for(size_t i = 0; i < tags4.size(); i++) { - std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); - } -#endif -} - -void -qa_block_tags::t2 () -{ - int N = 40000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann3 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann4 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk2 (gr_make_null_sink(sizeof(int))); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, ann0, 0); - - tb->connect(ann0, 0, ann1, 0); - tb->connect(ann0, 1, ann1, 1); - tb->connect(ann1, 0, ann2, 0); - tb->connect(ann1, 1, ann3, 0); - tb->connect(ann1, 2, ann4, 0); - - tb->connect(ann2, 0, snk0, 0); - tb->connect(ann3, 0, snk1, 0); - tb->connect(ann4, 0, snk2, 0); - - tb->run(); - - std::vector<gr_tag_t> tags0 = ann0->data(); - std::vector<gr_tag_t> tags1 = ann1->data(); - std::vector<gr_tag_t> tags2 = ann2->data(); - std::vector<gr_tag_t> tags3 = ann4->data(); - std::vector<gr_tag_t> tags4 = ann4->data(); - - // The first annotator does not receive any tags from the null sink upstream - CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); - CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)8); - - // Make sure the rest all have 12 tags - CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)12); - CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)12); - CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)12); - - -#if QA_TAGS_DEBUG - // Kludge together the tags that we know should result from the above graph - std::stringstream str0, str1; - str0 << ann0->name() << ann0->unique_id(); - str1 << ann1->name() << ann1->unique_id(); - - pmt_t expected_tags2[12]; - expected_tags2[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags2[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags2[2] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags2[3] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags2[4] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags2[5] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags2[6] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(6)); - expected_tags2[7] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags2[8] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags2[9] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(9)); - expected_tags2[10] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - expected_tags2[11] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); - - pmt_t expected_tags4[12]; - expected_tags4[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(2)); - expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags4[2] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(5)); - expected_tags4[4] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[6] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(8)); - expected_tags4[7] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags4[8] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[9] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(11)); - expected_tags4[10] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - expected_tags4[11] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); - - std::cout << std::endl << "qa_block_tags::t2" << std::endl; - - // For annotator[2-4], we know it gets tags from ann0 and ann1 - // but the tags from the different outputs of ann1 are different for each. - // Just testing ann2 and ann4; if they are correct it would be - // inconceivable for ann3 to have it wrong. - for(size_t i = 0; i < tags2.size(); i++) { - std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags2[i]), pmt_write_string(expected_tags2[i])); - } - - std::cout << std::endl; - for(size_t i = 0; i < tags4.size(); i++) { - std::cout << "tags2[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); - } -#endif -} - - -void -qa_block_tags::t3 () -{ - int N = 40000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_1to1_sptr ann0 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(10000, sizeof(int))); - gr_annotator_1to1_sptr ann3 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_1to1_sptr ann4 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, ann0, 0); - tb->connect(head, 0, ann0, 1); - - tb->connect(ann0, 0, ann1, 0); - tb->connect(ann0, 1, ann2, 0); - tb->connect(ann1, 0, ann3, 0); - tb->connect(ann2, 0, ann4, 0); - - tb->connect(ann3, 0, snk0, 0); - tb->connect(ann4, 0, snk1, 0); - - tb->run(); - - - std::vector<gr_tag_t> tags0 = ann0->data(); - std::vector<gr_tag_t> tags3 = ann3->data(); - std::vector<gr_tag_t> tags4 = ann4->data(); - - // The first annotator does not receive any tags from the null sink upstream - CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); - CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8); - CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8); - -#if QA_TAGS_DEBUG - // Kludge together the tags that we know should result from the above graph - std::stringstream str0, str1, str2; - str0 << ann0->name() << ann0->unique_id(); - str1 << ann1->name() << ann1->unique_id(); - str2 << ann2->name() << ann2->unique_id(); - - pmt_t expected_tags3[8]; - expected_tags3[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags3[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags3[2] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); - expected_tags3[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags3[4] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags3[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags3[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags3[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); - - pmt_t expected_tags4[8]; - expected_tags4[0] = mp(pmt_from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); - expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[2] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[4] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[6] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); - expected_tags4[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); - - std::cout << std::endl << "qa_block_tags::t3" << std::endl; - - // For annotator 3, we know it gets tags from ann0 and ann1, test this - for(size_t i = 0; i < tags3.size(); i++) { - std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags3[i]), pmt_write_string(expected_tags3[i])); - } - - // For annotator 4, we know it gets tags from ann0 and ann2, test this - std::cout << std::endl; - for(size_t i = 0; i < tags4.size(); i++) { - std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); - } -#endif -} - - -void -qa_block_tags::t4 () -{ - int N = 40000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(int))); - gr_block_sptr head (gr_make_head(sizeof(int), N)); - gr_annotator_1to1_sptr ann0 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_1to1_sptr ann1 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_annotator_1to1_sptr ann2 (gr_make_annotator_1to1(10000, sizeof(int))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(int))); - gr_block_sptr snk1 (gr_make_null_sink(sizeof(int))); - - // using 1-to-1 tag propagation without having equal number of - // ins and outs. Make sure this works; will just exit run early. - tb->connect(src, 0, head, 0); - tb->connect(head, 0, ann0, 0); - tb->connect(ann0, 0, ann1, 0); - tb->connect(ann0, 1, ann2, 0); - tb->connect(ann1, 0, snk0, 0); - tb->connect(ann2, 0, snk1, 0); - - std::cerr << std::endl - << "NOTE: This is supposed to produce an error from gr_block_executor" - << std::endl; - tb->run(); -} - - -void -qa_block_tags::t5 () -{ - int N = 40000; - gr_top_block_sptr tb = gr_make_top_block("top"); - gr_block_sptr src (gr_make_null_source(sizeof(float))); - gr_block_sptr head (gr_make_head(sizeof(float), N)); - gr_annotator_alltoall_sptr ann0 (gr_make_annotator_alltoall(10000, sizeof(float))); - gr_annotator_alltoall_sptr ann1 (gr_make_annotator_alltoall(10000, sizeof(float))); - gr_annotator_alltoall_sptr ann2 (gr_make_annotator_alltoall(1000, sizeof(float))); - gr_block_sptr snk0 (gr_make_null_sink(sizeof(float))); - - // Rate change blocks - gr_keep_one_in_n_sptr dec10 (gr_make_keep_one_in_n(sizeof(float), 10)); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, ann0, 0); - tb->connect(ann0, 0, ann1, 0); - tb->connect(ann1, 0, dec10, 0); - tb->connect(dec10, 0, ann2, 0); - tb->connect(ann2, 0, snk0, 0); - - tb->run(); - - std::vector<gr_tag_t> tags0 = ann0->data(); - std::vector<gr_tag_t> tags1 = ann1->data(); - std::vector<gr_tag_t> tags2 = ann2->data(); - - // The first annotator does not receive any tags from the null sink upstream - CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); - CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)4); - CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)8); - - -#if QA_TAGS_DEBUG - // Kludge together the tags that we know should result from the above graph - std::stringstream str0, str1, str2; - str0 << ann0->name() << ann0->unique_id(); - str1 << ann1->name() << ann1->unique_id(); - str2 << ann2->name() << ann2->unique_id(); - - pmt_t expected_tags1[5]; - expected_tags1[0] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags1[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); - expected_tags1[2] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags1[3] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(3)); - - pmt_t expected_tags2[10]; - expected_tags2[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); - expected_tags2[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); - expected_tags2[2] = mp(pmt_from_uint64(1000), mp(str1.str()), mp("seq"), mp(1)); - expected_tags2[3] = mp(pmt_from_uint64(1000), mp(str0.str()), mp("seq"), mp(1)); - expected_tags2[4] = mp(pmt_from_uint64(2000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags2[5] = mp(pmt_from_uint64(2000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags2[6] = mp(pmt_from_uint64(3000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags2[7] = mp(pmt_from_uint64(3000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags2[8] = mp(pmt_from_uint64(4000), mp(str1.str()), mp("seq"), mp(4)); - expected_tags2[9] = mp(pmt_from_uint64(4000), mp(str0.str()), mp("seq"), mp(4)); - - std::cout << std::endl << "qa_block_tags::t5" << std::endl; - - // annotator 1 gets tags from annotator 0 - std::cout << "tags1.size(): " << tags1.size() << std::endl; - for(size_t i = 0; i < tags1.size(); i++) { - std::cout << "tags1[" << i << "] = " << tags1[i] << "\t\t" << expected_tags1[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags1[i]), pmt_write_string(expected_tags1[i])); - } - - // annotator 2 gets tags from annotators 0 and 1 - std::cout << std::endl; - std::cout << "tags2.size(): " << tags2.size() << std::endl; - for(size_t i = 0; i < tags2.size(); i++) { - std::cout << "tags2[" << i << "] = " << tags2[i] << "\t\t" << expected_tags2[i] << std::endl; - CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags2[i]), pmt_write_string(expected_tags2[i])); - } -#endif -} - diff --git a/tests/qa_block_tags.h b/tests/qa_block_tags.h deleted file mode 100644 index 6b7e597..0000000 --- a/tests/qa_block_tags.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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. - */ - -#ifndef INCLUDED_QA_BLOCK_TAGS_H -#define INCLUDED_QA_BLOCK_TAGS_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_block_tags : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_block_tags); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST (t4); - CPPUNIT_TEST (t5); - CPPUNIT_TEST_SUITE_END (); - - private: - void t0 (); - void t1 (); - void t2 (); - void t3 (); - void t4 (); - void t5 (); - -}; - - -#endif /* INCLUDED_QA_BLOCK_TAGS_H */ diff --git a/tests/qa_gr_block.cc b/tests/qa_gr_block.cc deleted file mode 100644 index aeab5b7..0000000 --- a/tests/qa_gr_block.cc +++ /dev/null @@ -1,88 +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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <qa_gr_block.h> -#include <gr_block.h> -#include <gr_io_signature.h> -#include <gr_null_sink.h> -#include <gr_null_source.h> - - -// ---------------------------------------------------------------- - - -void -qa_gr_block::t0 () -{ - // test creation of sources - gr_block_sptr src1 (gr_make_null_source (sizeof (int))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_source"), src1->name ()); - CPPUNIT_ASSERT_EQUAL (0, src1->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src1->output_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src1->output_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof(int), - src1->output_signature()->sizeof_stream_item (0)); - - gr_block_sptr src2 (gr_make_null_source (sizeof (short))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_source"), src2->name ()); - CPPUNIT_ASSERT_EQUAL (0, src2->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src2->output_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (1, src2->output_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof (short), - src2->output_signature()->sizeof_stream_item (0)); -} - - -void -qa_gr_block::t1 () -{ - // test creation of sinks - gr_block_sptr dst1 (gr_make_null_sink (sizeof (int))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_sink"), dst1->name ()); - CPPUNIT_ASSERT_EQUAL (1, dst1->input_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (1, dst1->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof (int), - dst1->input_signature()->sizeof_stream_item (0)); - - CPPUNIT_ASSERT_EQUAL (0, dst1->output_signature()->max_streams ()); - - gr_block_sptr dst2 (gr_make_null_sink (sizeof (short))); - CPPUNIT_ASSERT_EQUAL (std::string ("null_sink"), dst2->name ()); - CPPUNIT_ASSERT_EQUAL (1, dst2->input_signature()->min_streams ()); - CPPUNIT_ASSERT_EQUAL (1, dst2->input_signature()->max_streams ()); - CPPUNIT_ASSERT_EQUAL ((int) sizeof (short), - dst2->input_signature()->sizeof_stream_item (0)); - CPPUNIT_ASSERT_EQUAL (0, dst2->output_signature()->max_streams ()); -} - -void -qa_gr_block::t2 () -{ -} - -void -qa_gr_block::t3 () -{ -} diff --git a/tests/qa_gr_block.h b/tests/qa_gr_block.h deleted file mode 100644 index 14c7c40..0000000 --- a/tests/qa_gr_block.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_BLOCK_H -#define INCLUDED_QA_GR_BLOCK_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_gr_block : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_block); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void t0 (); - void t1 (); - void t2 (); - void t3 (); - -}; - - -#endif /* INCLUDED_QA_GR_BLOCK_H */ diff --git a/tests/qa_gr_buffer.cc b/tests/qa_gr_buffer.cc deleted file mode 100644 index c74baf3..0000000 --- a/tests/qa_gr_buffer.cc +++ /dev/null @@ -1,307 +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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <qa_gr_buffer.h> -#include <gr_buffer.h> -#include <cppunit/TestAssert.h> -#include <stdlib.h> -#include <gr_random.h> - -static void -leak_check (void f ()) -{ - long buffer_count = gr_buffer_ncurrently_allocated (); - long buffer_reader_count = gr_buffer_reader_ncurrently_allocated (); - - f (); - - CPPUNIT_ASSERT_EQUAL (buffer_reader_count, gr_buffer_reader_ncurrently_allocated ()); - CPPUNIT_ASSERT_EQUAL (buffer_count, gr_buffer_ncurrently_allocated ()); -} - - -// ---------------------------------------------------------------------------- -// test single writer, no readers... -// - -static void -t0_body () -{ - int nitems = 4000 / sizeof (int); - int counter = 0; - - gr_buffer_sptr buf(gr_make_buffer(nitems, sizeof (int), gr_block_sptr())); - - int last_sa; - int sa; - - sa = buf->space_available (); - CPPUNIT_ASSERT (sa > 0); - last_sa = sa; - - for (int i = 0; i < 5; i++){ - sa = buf->space_available (); - CPPUNIT_ASSERT_EQUAL (last_sa, sa); - last_sa = sa; - - int *p = (int *) buf->write_pointer (); - CPPUNIT_ASSERT (p != 0); - - for (int j = 0; j < sa; j++) - *p++ = counter++; - - buf->update_write_pointer (sa); - } -} - -// ---------------------------------------------------------------------------- -// test single writer, single reader -// - -static void -t1_body () - { - int nitems = 4000 / sizeof (int); - int write_counter = 0; - int read_counter = 0; - - gr_buffer_sptr buf(gr_make_buffer(nitems, sizeof (int), gr_block_sptr())); - gr_buffer_reader_sptr r1 (gr_buffer_add_reader (buf, 0, gr_block_sptr())); - - - int sa; - - // write 1/3 of buffer - - sa = buf->space_available (); - CPPUNIT_ASSERT (sa > 0); - - int *p = (int *) buf->write_pointer (); - CPPUNIT_ASSERT (p != 0); - - for (int j = 0; j < sa/3; j++){ - *p++ = write_counter++; - } - buf->update_write_pointer (sa/3); - - - // write the next 1/3 (1/2 of what's left) - - sa = buf->space_available (); - CPPUNIT_ASSERT (sa > 0); - - p = (int *) buf->write_pointer (); - CPPUNIT_ASSERT (p != 0); - - for (int j = 0; j < sa/2; j++){ - *p++ = write_counter++; - } - buf->update_write_pointer (sa/2); - - - // check that we can read it OK - - int ia = r1->items_available (); - CPPUNIT_ASSERT_EQUAL (write_counter, ia); - - int *rp = (int *) r1->read_pointer (); - CPPUNIT_ASSERT (rp != 0); - - for (int i = 0; i < ia/2; i++){ - CPPUNIT_ASSERT_EQUAL (read_counter, *rp); - read_counter++; - rp++; - } - r1->update_read_pointer (ia/2); - - // read the rest - - ia = r1->items_available (); - rp = (int *) r1->read_pointer (); - CPPUNIT_ASSERT (rp != 0); - - for (int i = 0; i < ia; i++){ - CPPUNIT_ASSERT_EQUAL (read_counter, *rp); - read_counter++; - rp++; - } - r1->update_read_pointer (ia); -} - -// ---------------------------------------------------------------------------- -// single writer, single reader: check wrap-around -// - -static void -t2_body () -{ - // 64K is the largest granularity we've seen so far (MS windows file mapping). - // This allows a bit of "white box testing" - - int nitems = (64 * (1L << 10)) / sizeof (int); // 64K worth of ints - - gr_buffer_sptr buf(gr_make_buffer (nitems, sizeof (int), gr_block_sptr())); - gr_buffer_reader_sptr r1 (gr_buffer_add_reader (buf, 0, gr_block_sptr())); - - int read_counter = 0; - int write_counter = 0; - int n; - int *wp = 0; - int *rp = 0; - - // Write 3/4 of buffer - - n = (int) (buf->space_available () * 0.75); - wp = (int *) buf->write_pointer (); - - for (int i = 0; i < n; i++) - *wp++ = write_counter++; - buf->update_write_pointer (n); - - // Now read it all - - int m = r1->items_available (); - CPPUNIT_ASSERT_EQUAL (n, m); - rp = (int *) r1->read_pointer (); - - for (int i = 0; i < m; i++){ - CPPUNIT_ASSERT_EQUAL (read_counter, *rp); - read_counter++; - rp++; - } - r1->update_read_pointer (m); - - // Now write as much as we can. - // This will wrap around the buffer - - n = buf->space_available (); - CPPUNIT_ASSERT_EQUAL (nitems - 1, n); // white box test - wp = (int *) buf->write_pointer (); - - for (int i = 0; i < n; i++) - *wp++ = write_counter++; - buf->update_write_pointer (n); - - // now read it all - - m = r1->items_available (); - CPPUNIT_ASSERT_EQUAL (n, m); - rp = (int *) r1->read_pointer (); - - for (int i = 0; i < m; i++){ - CPPUNIT_ASSERT_EQUAL (read_counter, *rp); - read_counter++; - rp++; - } - r1->update_read_pointer (m); - -} - -// ---------------------------------------------------------------------------- -// single writer, N readers, randomized order and lengths -// ---------------------------------------------------------------------------- - -static void -t3_body () -{ - int nitems = (64 * (1L << 10)) / sizeof (int); - - static const int N = 5; - gr_buffer_sptr buf(gr_make_buffer(nitems, sizeof (int), gr_block_sptr())); - gr_buffer_reader_sptr reader[N]; - int read_counter[N]; - int write_counter = 0; - gr_random random; - - for (int i = 0; i < N; i++){ - read_counter[i] = 0; - reader[i] = gr_buffer_add_reader (buf, 0, gr_block_sptr()); - } - - for (int lc = 0; lc < 1000; lc++){ - - // write some - - int n = (int) (buf->space_available () * random.ran1 ()); - int *wp = (int *) buf->write_pointer (); - - for (int i = 0; i < n; i++) - *wp++ = write_counter++; - - buf->update_write_pointer (n); - - // pick a random reader and read some - - int r = (int) (N * random.ran1 ()); - CPPUNIT_ASSERT (0 <= r && r < N); - - int m = reader[r]->items_available (); - int *rp = (int *) reader[r]->read_pointer (); - - for (int i = 0; i < m; i++){ - CPPUNIT_ASSERT_EQUAL (read_counter[r], *rp); - read_counter[r]++; - rp++; - } - reader[r]->update_read_pointer (m); - } -} - - -// ---------------------------------------------------------------------------- - -void -qa_gr_buffer::t0 () -{ - leak_check (t0_body); -} - -void -qa_gr_buffer::t1 () -{ - leak_check (t1_body); -} - -void -qa_gr_buffer::t2 () -{ - leak_check (t2_body); -} - -void -qa_gr_buffer::t3 () -{ - leak_check (t3_body); -} - -void -qa_gr_buffer::t4 () -{ -} - -void -qa_gr_buffer::t5 () -{ -} diff --git a/tests/qa_gr_buffer.h b/tests/qa_gr_buffer.h deleted file mode 100644 index 2937c24..0000000 --- a/tests/qa_gr_buffer.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_BUFFER_H -#define INCLUDED_QA_GR_BUFFER_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_buffer : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_buffer); - CPPUNIT_TEST (t0); - CPPUNIT_TEST (t1); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST (t4); - CPPUNIT_TEST (t5); - CPPUNIT_TEST_SUITE_END (); - - - private: - - void t0 (); - void t1 (); - void t2 (); - void t3 (); - void t4 (); - void t5 (); -}; - - - -#endif /* INCLUDED_QA_GR_BUFFER_H */ diff --git a/tests/qa_gr_flowgraph.cc b/tests/qa_gr_flowgraph.cc deleted file mode 100644 index cce83cb..0000000 --- a/tests/qa_gr_flowgraph.cc +++ /dev/null @@ -1,245 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_gr_flowgraph.h> -#include <gr_flowgraph.h> -#include <gr_nop.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> - -void qa_gr_flowgraph::t0() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - CPPUNIT_ASSERT(fg); -} - -void qa_gr_flowgraph::t1_connect() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); -} - -void qa_gr_flowgraph::t2_connect_invalid_src_port_neg() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - CPPUNIT_ASSERT_THROW(fg->connect(nop1, -1, nop2, 0), std::invalid_argument); -} - -void qa_gr_flowgraph::t3_connect_src_port_exceeds() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - CPPUNIT_ASSERT_THROW(fg->connect(src, 1, dst, 0), std::invalid_argument); -} - -void qa_gr_flowgraph::t4_connect_invalid_dst_port_neg() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - CPPUNIT_ASSERT_THROW(fg->connect(nop1, 0, nop2, -1), std::invalid_argument); -} - -void qa_gr_flowgraph::t5_connect_dst_port_exceeds() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - CPPUNIT_ASSERT_THROW(fg->connect(src, 0, dst, 1), std::invalid_argument); -} - -void qa_gr_flowgraph::t6_connect_dst_in_use() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr src1 = gr_make_null_source(sizeof(int)); - gr_block_sptr src2 = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - fg->connect(src1, 0, dst, 0); - CPPUNIT_ASSERT_THROW(fg->connect(src2, 0, dst, 0), std::invalid_argument); -} - -void qa_gr_flowgraph::t7_connect_one_src_two_dst() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst1 = gr_make_null_sink(sizeof(int)); - gr_block_sptr dst2 = gr_make_null_sink(sizeof(int)); - - fg->connect(src, 0, dst1, 0); - fg->connect(src, 0, dst2, 0); -} - -void qa_gr_flowgraph::t8_connect_type_mismatch() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(char)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - CPPUNIT_ASSERT_THROW(fg->connect(nop1, 0, nop2, 0), std::invalid_argument); -} - -void qa_gr_flowgraph::t9_disconnect() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - fg->disconnect(nop1, 0, nop2, 0); -} - -void qa_gr_flowgraph::t10_disconnect_unconnected_block() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - gr_block_sptr nop3 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - CPPUNIT_ASSERT_THROW(fg->disconnect(nop1, 0, nop3, 0), std::invalid_argument); -} - -void qa_gr_flowgraph::t11_disconnect_unconnected_port() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - CPPUNIT_ASSERT_THROW(fg->disconnect(nop1, 0, nop2, 1), std::invalid_argument); -} - -void qa_gr_flowgraph::t12_validate() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - fg->validate(); -} - -void qa_gr_flowgraph::t13_validate_missing_input_assignment() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - fg->connect(nop1, 0, nop2, 2); - CPPUNIT_ASSERT_THROW(fg->validate(), std::runtime_error); -} - -void qa_gr_flowgraph::t14_validate_missing_output_assignment() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - fg->connect(nop1, 2, nop2, 1); - CPPUNIT_ASSERT_THROW(fg->validate(), std::runtime_error); -} - -void qa_gr_flowgraph::t15_clear() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop1 = gr_make_nop(sizeof(int)); - gr_block_sptr nop2 = gr_make_nop(sizeof(int)); - - fg->connect(nop1, 0, nop2, 0); - - CPPUNIT_ASSERT(fg->edges().size() == 1); - CPPUNIT_ASSERT(fg->calc_used_blocks().size() == 2); - - fg->clear(); - - CPPUNIT_ASSERT(fg->edges().size() == 0); - CPPUNIT_ASSERT(fg->calc_used_blocks().size() == 0); -} - -void qa_gr_flowgraph::t16_partition() -{ - gr_flowgraph_sptr fg = gr_make_flowgraph(); - - gr_block_sptr nop11 = gr_make_nop(sizeof(int)); - gr_block_sptr nop12 = gr_make_nop(sizeof(int)); - gr_block_sptr nop13 = gr_make_nop(sizeof(int)); - gr_block_sptr nop14 = gr_make_nop(sizeof(int)); - - gr_block_sptr nop21 = gr_make_nop(sizeof(int)); - gr_block_sptr nop22 = gr_make_nop(sizeof(int)); - gr_block_sptr nop23 = gr_make_nop(sizeof(int)); - - gr_block_sptr nop31 = gr_make_nop(sizeof(int)); - gr_block_sptr nop32 = gr_make_nop(sizeof(int)); - - // Build disjoint graph #1 - fg->connect(nop11, 0, nop12, 0); - fg->connect(nop12, 0, nop13, 0); - fg->connect(nop13, 0, nop14, 0); - - // Build disjoint graph #2 - fg->connect(nop21, 0, nop22, 0); - fg->connect(nop22, 0, nop23, 0); - - // Build disjoint graph #3 - fg->connect(nop31, 0, nop32, 0); - - std::vector<gr_basic_block_vector_t> graphs = fg->partition(); - - CPPUNIT_ASSERT(graphs.size() == 3); - CPPUNIT_ASSERT(graphs[0].size() == 4); - CPPUNIT_ASSERT(graphs[1].size() == 3); - CPPUNIT_ASSERT(graphs[2].size() == 2); -} diff --git a/tests/qa_gr_flowgraph.h b/tests/qa_gr_flowgraph.h deleted file mode 100644 index 2c2686f..0000000 --- a/tests/qa_gr_flowgraph.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_FLOWGRAPH_H -#define INCLUDED_QA_GR_FLOWGRAPH_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_gr_flowgraph : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_gr_flowgraph); - - CPPUNIT_TEST(t0); - CPPUNIT_TEST(t1_connect); - CPPUNIT_TEST(t2_connect_invalid_src_port_neg); - CPPUNIT_TEST(t3_connect_src_port_exceeds); - CPPUNIT_TEST(t4_connect_invalid_dst_port_neg); - CPPUNIT_TEST(t5_connect_dst_port_exceeds); - CPPUNIT_TEST(t6_connect_dst_in_use); - CPPUNIT_TEST(t7_connect_one_src_two_dst); - CPPUNIT_TEST(t8_connect_type_mismatch); - CPPUNIT_TEST(t9_disconnect); - CPPUNIT_TEST(t10_disconnect_unconnected_block); - CPPUNIT_TEST(t11_disconnect_unconnected_port); - CPPUNIT_TEST(t12_validate); - CPPUNIT_TEST(t13_validate_missing_input_assignment); - CPPUNIT_TEST(t14_validate_missing_output_assignment); - CPPUNIT_TEST(t15_clear); - CPPUNIT_TEST(t16_partition); - - CPPUNIT_TEST_SUITE_END(); - -private: - - void t0(); - void t1_connect(); - void t2_connect_invalid_src_port_neg(); - void t3_connect_src_port_exceeds(); - void t4_connect_invalid_dst_port_neg(); - void t5_connect_dst_port_exceeds(); - void t6_connect_dst_in_use(); - void t7_connect_one_src_two_dst(); - void t8_connect_type_mismatch(); - void t9_disconnect(); - void t10_disconnect_unconnected_block(); - void t11_disconnect_unconnected_port(); - void t12_validate(); - void t13_validate_missing_input_assignment(); - void t14_validate_missing_output_assignment(); - void t15_clear(); - void t16_partition(); -}; - -#endif /* INCLUDED_QA_GR_FLOWGRAPH_H */ diff --git a/tests/qa_gr_hier_block2.cc b/tests/qa_gr_hier_block2.cc deleted file mode 100644 index 9844d33..0000000 --- a/tests/qa_gr_hier_block2.cc +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_gr_hier_block2.h> -#include <gr_hier_block2.h> -#include <gr_io_signature.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> - -void qa_gr_hier_block2::test_make() -{ - gr_hier_block2_sptr src1(gr_make_hier_block2("test", - gr_make_io_signature(1, 1, 1 * sizeof(int)), - gr_make_io_signature(1, 1, 1 * sizeof(int)))); - - CPPUNIT_ASSERT(src1); - CPPUNIT_ASSERT_EQUAL(std::string("test"), src1->name()); - - CPPUNIT_ASSERT_EQUAL(1 * (int) sizeof(int), - src1->input_signature()->sizeof_stream_item(0)); - - CPPUNIT_ASSERT_EQUAL(1, src1->input_signature()->min_streams()); - CPPUNIT_ASSERT_EQUAL(1, src1->input_signature()->max_streams()); - - - CPPUNIT_ASSERT_EQUAL(1 * (int) sizeof(int), - src1->output_signature()->sizeof_stream_item(0)); - - CPPUNIT_ASSERT_EQUAL(1, src1->output_signature()->min_streams()); - CPPUNIT_ASSERT_EQUAL(1, src1->output_signature()->max_streams()); - -} - - diff --git a/tests/qa_gr_hier_block2.h b/tests/qa_gr_hier_block2.h deleted file mode 100644 index 653cd27..0000000 --- a/tests/qa_gr_hier_block2.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_HIER_BLOCK2_H -#define INCLUDED_QA_GR_HIER_BLOCK2_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_gr_hier_block2 : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_gr_hier_block2); - - CPPUNIT_TEST(test_make); - - CPPUNIT_TEST_SUITE_END(); - -private: - void test_make(); -}; - -#endif /* INCLUDED_QA_GR_HIER_BLOCK2_H */ diff --git a/tests/qa_gr_hier_block2_derived.cc b/tests/qa_gr_hier_block2_derived.cc deleted file mode 100644 index 060c4e2..0000000 --- a/tests/qa_gr_hier_block2_derived.cc +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_gr_hier_block2_derived.h> -#include <gr_top_block.h> -#include <gr_io_signature.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> -#include <gr_head.h> -#include <gr_kludge_copy.h> - -// Declare a test C++ hierarchical block - -class gr_derived_block; -typedef boost::shared_ptr<gr_derived_block> gr_derived_block_sptr; -gr_derived_block_sptr gr_make_derived_block(); - -class gr_derived_block : public gr_hier_block2 -{ -private: - friend gr_derived_block_sptr gr_make_derived_block(); - gr_derived_block(); - -public: - ~gr_derived_block(); -}; - - -gr_derived_block_sptr -gr_make_derived_block() -{ - return gnuradio::get_initial_sptr(new gr_derived_block()); -} - -gr_derived_block::gr_derived_block() - : gr_hier_block2("gr_derived_block", - gr_make_io_signature(1, 1, sizeof(int)), // Input signature - gr_make_io_signature(1, 1, sizeof(int))) // Output signature -{ - gr_block_sptr copy(gr_make_kludge_copy(sizeof(int))); - - connect(self(), 0, copy, 0); - connect(copy, 0, self(), 0); -} - -gr_derived_block::~gr_derived_block() -{ -} - -void qa_gr_hier_block2_derived::test_1() -{ - gr_top_block_sptr tb(gr_make_top_block("test")); - - gr_block_sptr src(gr_make_null_source(sizeof(int))); - gr_block_sptr head(gr_make_head(sizeof(int), 1000)); - gr_derived_block_sptr blk(gr_make_derived_block()); - gr_block_sptr dst(gr_make_null_sink(sizeof(int))); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, blk, 0); - tb->connect(blk, 0, dst, 0); - - tb->run(); -} diff --git a/tests/qa_gr_hier_block2_derived.h b/tests/qa_gr_hier_block2_derived.h deleted file mode 100644 index 8e0a188..0000000 --- a/tests/qa_gr_hier_block2_derived.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_HIER_BLOCK2_DERIVED_H -#define INCLUDED_QA_GR_HIER_BLOCK2_DERIVED_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -// Declare a QA test case -class qa_gr_hier_block2_derived : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_gr_hier_block2_derived); - CPPUNIT_TEST(test_1); - CPPUNIT_TEST_SUITE_END(); - -private: - void test_1(); -}; - -#endif /* INCLUDED_QA_GR_HIER_BLOCK2_DERIVED_H */ diff --git a/tests/qa_gr_io_signature.cc b/tests/qa_gr_io_signature.cc deleted file mode 100644 index c1737ff..0000000 --- a/tests/qa_gr_io_signature.cc +++ /dev/null @@ -1,64 +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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <qa_gr_io_signature.h> -#include <gr_io_signature.h> - -void -qa_gr_io_signature::t0 () -{ - gr_make_io_signature (1, 1, sizeof (int)); -} - -void -qa_gr_io_signature::t1 () -{ - gr_make_io_signature (3, 1, sizeof (int)); // throws std::invalid_argument -} - -void -qa_gr_io_signature::t2 () -{ - gr_io_signature_sptr p = - gr_make_io_signature (3, gr_io_signature::IO_INFINITE, sizeof (int)); - - CPPUNIT_ASSERT_EQUAL (p->min_streams (), 3); - CPPUNIT_ASSERT_EQUAL (p->sizeof_stream_item (0), (int) sizeof (int)); -} - -void -qa_gr_io_signature::t3 () -{ - gr_io_signature_sptr p = - gr_make_io_signature3 (0, 5, 1, 2, 3); - - CPPUNIT_ASSERT_EQUAL (p->min_streams (), 0); - CPPUNIT_ASSERT_EQUAL (p->max_streams (), 5); - CPPUNIT_ASSERT_EQUAL (p->sizeof_stream_item(0), 1); - CPPUNIT_ASSERT_EQUAL (p->sizeof_stream_item(1), 2); - CPPUNIT_ASSERT_EQUAL (p->sizeof_stream_item(2), 3); - CPPUNIT_ASSERT_EQUAL (p->sizeof_stream_item(3), 3); - CPPUNIT_ASSERT_EQUAL (p->sizeof_stream_item(4), 3); -} diff --git a/tests/qa_gr_io_signature.h b/tests/qa_gr_io_signature.h deleted file mode 100644 index 9cd6bb5..0000000 --- a/tests/qa_gr_io_signature.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_IO_SIGNATURE_H -#define INCLUDED_QA_GR_IO_SIGNATURE_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_gr_io_signature : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_io_signature); - CPPUNIT_TEST (t0); - CPPUNIT_TEST_EXCEPTION (t1, std::invalid_argument); - CPPUNIT_TEST (t2); - CPPUNIT_TEST (t3); - CPPUNIT_TEST_SUITE_END (); - - private: - void t0 (); - void t1 (); - void t2 (); - void t3 (); -}; - -#endif /* INCLUDED_QA_GR_IO_SIGNATURE_H */ diff --git a/tests/qa_gr_top_block.cc b/tests/qa_gr_top_block.cc deleted file mode 100644 index cc7b7c7..0000000 --- a/tests/qa_gr_top_block.cc +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_gr_top_block.h> -#include <gr_top_block.h> -#include <gr_head.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> -#include <iostream> - -#define VERBOSE 0 - -void qa_gr_top_block::t0() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t0()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - CPPUNIT_ASSERT(tb); -} - -void qa_gr_top_block::t1_run() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t1()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->run(); -} - -void qa_gr_top_block::t2_start_stop_wait() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t2()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - - tb->start(); - tb->stop(); - tb->wait(); -} - -void qa_gr_top_block::t3_lock_unlock() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t3()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - tb->connect(src, 0, dst, 0); - - tb->start(); - - tb->lock(); - tb->unlock(); - - tb->stop(); - tb->wait(); -} - -void qa_gr_top_block::t4_reconfigure() -{ - if (VERBOSE) std::cout << "qa_gr_top_block::t4()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_block_sptr head = gr_make_head(sizeof(int), 100000); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - // Start infinite flowgraph - tb->connect(src, 0, dst, 0); - tb->start(); - - // Reconfigure with gr_head in the middle - tb->lock(); - tb->disconnect(src, 0, dst, 0); - tb->connect(src, 0, head, 0); - tb->connect(head, 0, dst, 0); - tb->unlock(); - - // Wait for flowgraph to end on its own - tb->wait(); -} diff --git a/tests/qa_gr_top_block.h b/tests/qa_gr_top_block.h deleted file mode 100644 index b223633..0000000 --- a/tests/qa_gr_top_block.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_GR_TOP_BLOCK_H -#define INCLUDED_QA_GR_TOP_BLOCK_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_gr_top_block : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_gr_top_block); - - CPPUNIT_TEST(t0); - CPPUNIT_TEST(t1_run); - CPPUNIT_TEST(t2_start_stop_wait); - CPPUNIT_TEST(t3_lock_unlock); - CPPUNIT_TEST(t4_reconfigure); // triggers 'join never returns' bug - - CPPUNIT_TEST_SUITE_END(); - -private: - - void t0(); - void t1_run(); - void t2_start_stop_wait(); - void t3_lock_unlock(); - void t4_reconfigure(); -}; - -#endif /* INCLUDED_QA_GR_TOP_BLOCK_H */ diff --git a/tests/qa_gr_vmcircbuf.cc b/tests/qa_gr_vmcircbuf.cc deleted file mode 100644 index e3b36d8..0000000 --- a/tests/qa_gr_vmcircbuf.cc +++ /dev/null @@ -1,40 +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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_gr_vmcircbuf.h> -#include <cppunit/TestAssert.h> -#include <gr_vmcircbuf.h> -#include <stdio.h> - -void -qa_gr_vmcircbuf::test_all () -{ - int verbose = 1; // summary - - bool ok = gr_vmcircbuf_sysconfig::test_all_factories (verbose); - - CPPUNIT_ASSERT_EQUAL (true, ok); -} diff --git a/tests/qa_gr_vmcircbuf.h b/tests/qa_gr_vmcircbuf.h deleted file mode 100644 index 3576660..0000000 --- a/tests/qa_gr_vmcircbuf.h +++ /dev/null @@ -1,39 +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 _QA_GR_VMCIRCBUF_H_ -#define _QA_GR_VMCIRCBUF_H_ - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_gr_vmcircbuf : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE (qa_gr_vmcircbuf); - CPPUNIT_TEST (test_all); - CPPUNIT_TEST_SUITE_END (); - - private: - void test_all (); -}; - - -#endif /* _QA_GR_VMCIRCBUF_H_ */ diff --git a/tests/qa_runtime.h b/tests/qa_runtime.h deleted file mode 100644 index da71cbd..0000000 --- a/tests/qa_runtime.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef _QA_RUNTIME_H_ -#define _QA_RUNTIME_H_ - -#include <gruel/attributes.h> -#include <cppunit/TestSuite.h> - -//! collect all the tests for the runtime directory - -class __GR_ATTR_EXPORT qa_runtime { - public: - //! return suite of tests for all of runtime directory - static CppUnit::TestSuite *suite (); -}; - - -#endif /* _QA_RUNTIME_H_ */ diff --git a/tests/qa_set_msg_handler.cc b/tests/qa_set_msg_handler.cc deleted file mode 100644 index 25ae0b1..0000000 --- a/tests/qa_set_msg_handler.cc +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_set_msg_handler.h> -#include <gr_top_block.h> -#include <gr_head.h> -#include <gr_null_source.h> -#include <gr_null_sink.h> -#include <gr_nop.h> -#include <gruel/msg_passing.h> -#include <iostream> -#include <boost/thread/thread.hpp> - - -#define VERBOSE 0 - -using namespace pmt; - -/* - * The gr_nop block has been instrumented so that it counts - * the number of messages sent to it. We use this feature - * to confirm that gr_nop's call to set_msg_handler is working - * correctly. - */ - -void qa_set_msg_handler::t0() -{ - static const int NMSGS = 10; - - if (VERBOSE) std::cout << "qa_set_msg_handler::t0()\n"; - - gr_top_block_sptr tb = gr_make_top_block("top"); - - gr_block_sptr src = gr_make_null_source(sizeof(int)); - gr_nop_sptr nop = gr_make_nop(sizeof(int)); - gr_block_sptr dst = gr_make_null_sink(sizeof(int)); - - tb->connect(src, 0, nop, 0); - tb->connect(nop, 0, dst, 0); - - // Must start graph before sending messages - tb->start(); - - // Send them... - for (int i = 0; i < NMSGS; i++){ - send(nop, mp(mp("example-msg"), mp(i))); - } - - // And send a message to null_source to confirm that the default - // message handling action (which should be a nop) doesn't dump - // core. - send(src, mp(mp("example-msg"), mp(0))); - - // Give the messages a chance to be processed - boost::this_thread::sleep(boost::posix_time::milliseconds(100)); - - tb->stop(); - tb->wait(); - - // Confirm that the nop block received the right number of messages. - CPPUNIT_ASSERT_EQUAL(NMSGS, nop->nmsgs_received()); -} diff --git a/tests/qa_set_msg_handler.h b/tests/qa_set_msg_handler.h deleted file mode 100644 index 60277a1..0000000 --- a/tests/qa_set_msg_handler.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2011 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifndef INCLUDED_QA_SET_MSG_HANDLER_H -#define INCLUDED_QA_SET_MSG_HANDLER_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> -#include <stdexcept> - -class qa_set_msg_handler : public CppUnit::TestCase -{ - CPPUNIT_TEST_SUITE(qa_set_msg_handler); - - CPPUNIT_TEST(t0); - - CPPUNIT_TEST_SUITE_END(); - -private: - - void t0(); -}; - -#endif /* INCLUDED_QA_SET_MSG_HANDLER_H */ |