diff options
author | Josh Morman <jmorman@gnuradio.org> | 2021-11-01 17:28:12 -0400 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-11-11 14:06:01 -0500 |
commit | e1ce5154560b9e850df4a3c9ba256c601661de31 (patch) | |
tree | 5d240adb579dfba9ab49deb12570a42ecbe4015f | |
parent | 14d30f134cd402a35f46911342eb4d519e2ad7aa (diff) |
runtime: remove unused test.cc/h
Signed-off-by: Josh Morman <jmorman@gnuradio.org>
-rw-r--r-- | gnuradio-runtime/lib/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gnuradio-runtime/lib/test.cc | 186 | ||||
-rw-r--r-- | gnuradio-runtime/lib/test.h | 214 |
3 files changed, 0 insertions, 401 deletions
diff --git a/gnuradio-runtime/lib/CMakeLists.txt b/gnuradio-runtime/lib/CMakeLists.txt index f91900f5cc..0afa89e09f 100644 --- a/gnuradio-runtime/lib/CMakeLists.txt +++ b/gnuradio-runtime/lib/CMakeLists.txt @@ -86,7 +86,6 @@ add_library(gnuradio-runtime sys_paths.cc tagged_stream_block.cc terminate_handler.cc - test.cc top_block.cc top_block_impl.cc tpb_detail.cc diff --git a/gnuradio-runtime/lib/test.cc b/gnuradio-runtime/lib/test.cc deleted file mode 100644 index 297d1066ff..0000000000 --- a/gnuradio-runtime/lib/test.cc +++ /dev/null @@ -1,186 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,2010,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "test.h" -#include <gnuradio/io_signature.h> -#include <cstring> -#include <stdexcept> - -namespace gr { - -test_sptr make_test(const std::string& name, - int min_inputs, - int max_inputs, - unsigned int sizeof_input_item, - int min_outputs, - int max_outputs, - unsigned int sizeof_output_item, - unsigned int history, - unsigned int output_multiple, - double relative_rate, - bool fixed_rate, - consume_type_t cons_type, - produce_type_t prod_type) -{ - return gnuradio::make_block_sptr<test>(name, - min_inputs, - max_inputs, - sizeof_input_item, - min_outputs, - max_outputs, - sizeof_output_item, - history, - output_multiple, - relative_rate, - fixed_rate, - cons_type, - prod_type); -} - -test::test(const std::string& name, - int min_inputs, - int max_inputs, - unsigned int sizeof_input_item, - int min_outputs, - int max_outputs, - unsigned int sizeof_output_item, - unsigned int history, - unsigned int output_multiple, - double relative_rate, - bool fixed_rate, - consume_type_t cons_type, - produce_type_t prod_type) - : block(name, - io_signature::make(min_inputs, max_inputs, sizeof_input_item), - io_signature::make(min_outputs, max_outputs, sizeof_output_item)), - d_sizeof_input_item(sizeof_input_item), - d_sizeof_output_item(sizeof_output_item), - d_check_topology(true), - d_consume_type(cons_type), - d_min_consume(0), - d_max_consume(0), - d_produce_type(prod_type), - d_min_produce(0), - d_max_produce(0) -{ - set_history(history); - set_output_multiple(output_multiple); - set_relative_rate(relative_rate); - set_fixed_rate(fixed_rate); -} - -int test::general_work(int noutput_items, - gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) -{ - // touch all inputs and outputs to detect segfaults - unsigned ninputs = input_items.size(); - unsigned noutputs = output_items.size(); - for (unsigned i = 0; i < ninputs; i++) { - char* in = (char*)input_items[i]; - if (ninput_items[i] < (int)(noutput_items + history())) { - std::ostringstream msg; - msg << "ninput_items[" << i << "] < noutput_items+history()" - << "ninput_items[" << i << "] = " << ninput_items[i] - << "noutput_items+history() = " << (noutput_items + history()) - << "noutput_items = " << noutput_items << "history() = " << history(); - GR_LOG_ERROR(d_logger, msg.str()); - throw std::runtime_error("test"); - } else { - for (int j = 0; j < ninput_items[i]; j++) { - // Touch every available input_item - // We use a class variable to avoid the compiler to optimize this away - for (unsigned int k = 0; k < d_sizeof_input_item; k++) - d_temp = in[j * d_sizeof_input_item + k]; - } - switch (d_consume_type) { - case CONSUME_NOUTPUT_ITEMS: - consume(i, noutput_items); - break; - case CONSUME_NOUTPUT_ITEMS_LIMIT_MAX: - consume(i, std::min(noutput_items, d_max_consume)); - break; - case CONSUME_NOUTPUT_ITEMS_LIMIT_MIN: - consume( - i, std::min(std::max(noutput_items, d_min_consume), ninput_items[i])); - break; - case CONSUME_ALL_AVAILABLE: - consume(i, ninput_items[i]); - break; - case CONSUME_ALL_AVAILABLE_LIMIT_MAX: - consume(i, std::min(ninput_items[i], d_max_consume)); - break; - /* //This could result in segfault, uncomment if you want to test - this case CONSUME_ALL_AVAILABLE_LIMIT_MIN: - consume(i,std::max(ninput_items[i],d_max_consume)); - break;*/ - case CONSUME_ZERO: - consume(i, 0); - break; - case CONSUME_ONE: - consume(i, 1); - break; - case CONSUME_MINUS_ONE: - consume(i, -1); - break; - default: - consume(i, noutput_items); - } - } - } - for (unsigned i = 0; i < noutputs; i++) { - char* out = (char*)output_items[i]; - { - for (int j = 0; j < noutput_items; j++) { - // Touch every available output_item - for (unsigned int k = 0; k < d_sizeof_output_item; k++) - out[j * d_sizeof_input_item + k] = 0; - } - } - } - // Now copy input to output until max ninputs or max noutputs is reached - int common_nports = std::min(ninputs, noutputs); - if (d_sizeof_output_item == d_sizeof_input_item) - for (int i = 0; i < common_nports; i++) { - memcpy(output_items[i], input_items[i], noutput_items * d_sizeof_input_item); - } - int noutput_items_produced = 0; - switch (d_produce_type) { - case PRODUCE_NOUTPUT_ITEMS: - noutput_items_produced = noutput_items; - break; - case PRODUCE_NOUTPUT_ITEMS_LIMIT_MAX: - noutput_items_produced = std::min(noutput_items, d_max_produce); - break; - /* //This could result in segfault, uncomment if you want to test this - case PRODUCE_NOUTPUT_ITEMS_LIMIT_MIN: - noutput_items_produced=std::max(noutput_items,d_min_produce); - break;*/ - case PRODUCE_ZERO: - noutput_items_produced = 0; - break; - case PRODUCE_ONE: - noutput_items_produced = 1; - break; - case PRODUCE_MINUS_ONE: - noutput_items_produced = -1; - break; - default: - noutput_items_produced = noutput_items; - } - return noutput_items_produced; -} - -} /* namespace gr */ diff --git a/gnuradio-runtime/lib/test.h b/gnuradio-runtime/lib/test.h deleted file mode 100644 index 7c9842ad4a..0000000000 --- a/gnuradio-runtime/lib/test.h +++ /dev/null @@ -1,214 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2013 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * SPDX-License-Identifier: GPL-3.0-or-later - * - */ - -#ifndef INCLUDED_GR_TEST_H -#define INCLUDED_GR_TEST_H - -#include "test_types.h" -#include <gnuradio/api.h> -#include <gnuradio/block.h> -#include <string> - -namespace gr { - -class test; -typedef std::shared_ptr<test> test_sptr; - -// public constructor -GR_RUNTIME_API test_sptr make_test(const std::string& name = std::string("test"), - int min_inputs = 1, - int max_inputs = 1, - unsigned int sizeof_input_item = 1, - int min_outputs = 1, - int max_outputs = 1, - unsigned int sizeof_output_item = 1, - unsigned int history = 1, - unsigned int output_multiple = 1, - double relative_rate = 1.0, - bool fixed_rate = true, - consume_type_t cons_type = CONSUME_NOUTPUT_ITEMS, - produce_type_t prod_type = PRODUCE_NOUTPUT_ITEMS); - -/*! - * \brief Test class for testing runtime system (setting up buffers and such.) - * \ingroup misc - * - * This block does not do any useful actual data processing. It - * just exposes setting all standard block parameters using the - * constructor or public methods. - * - * This block can be useful when testing the runtime system. - * You can force this block to have a large history, decimation - * factor and/or large output_multiple. - * The runtime system should detect this and create large enough buffers - * all through the signal chain. - */ -class GR_RUNTIME_API test : public block -{ -public: - ~test() override {} - - int general_work(int noutput_items, - gr_vector_int& ninput_items, - gr_vector_const_void_star& input_items, - gr_vector_void_star& output_items) override; - - // ---------------------------------------------------------------- - // override these to define your behavior - // ---------------------------------------------------------------- - - /*! - * \brief Estimate input requirements given output request - * - * \param noutput_items number of output items to produce - * \param ninput_items_required number of input items required on each input stream - * - * Given a request to product \p noutput_items, estimate the - * number of data items required on each input stream. The - * estimate doesn't have to be exact, but should be close. - */ - void forecast(int noutput_items, gr_vector_int& ninput_items_required) override - { - unsigned ninputs = ninput_items_required.size(); - for (unsigned i = 0; i < ninputs; i++) - ninput_items_required[i] = - (int)((double)noutput_items / relative_rate()) + (int)history(); - } - - /*! - * \brief Force check topology to return true or false. - * - * \param check_topology value to return when check_topology is - * called (true or false) default check_topology returns true - */ - void set_check_topology(bool check_topology) { d_check_topology = check_topology; } - - /*! - * \brief Confirm that ninputs and noutputs is an acceptable combination. - * - * \param ninputs number of input streams connected - * \param noutputs number of output streams connected - * - * \returns true if this is a valid configuration for this block. - * - * This function is called by the runtime system whenever the - * topology changes. Most classes do not need to override this. - * This check is in addition to the constraints specified by the - * input and output gr::io_signatures. - */ - bool check_topology(int ninputs, int noutputs) override { return d_check_topology; } - - // ---------------------------------------------------------------- - /* - * The following two methods provide special case info to the - * scheduler in the event that a block has a fixed input to output - * ratio. gr::sync_block, gr::sync_decimator and - * gr::sync_interpolator override these. If you're fixed rate, - * subclass one of those. - */ - /*! - * \brief Given ninput samples, return number of output samples - * that will be produced. N.B. this is only defined if fixed_rate - * returns true. Generally speaking, you don't need to override - * this. - */ - int fixed_rate_ninput_to_noutput(int ninput) override - { - return (int)((double)ninput / relative_rate()); - } - - /*! - * \brief Given noutput samples, return number of input samples - * required to produce noutput. N.B. this is only defined if - * fixed_rate returns true. - */ - int fixed_rate_noutput_to_ninput(int noutput) override - { - return (int)((double)noutput * relative_rate()); - } - - /*! - * \brief Set if fixed rate should return true. - * N.B. This is normally a private method but we make it available here as public. - */ - void set_fixed_rate_public(bool fixed_rate) { set_fixed_rate(fixed_rate); } - - /*! - * \brief Set the consume pattern. - * - * \param cons_type which consume pattern to use - */ - void set_consume_type(consume_type_t cons_type) { d_consume_type = cons_type; } - - /*! - * \brief Set the consume limit. - * - * \param limit min or maximum items to consume (depending on - * consume_type) - */ - void set_consume_limit(unsigned int limit) - { - d_min_consume = limit; - d_max_consume = limit; - } - - /*! - * \brief Set the produce pattern. - * - * \param prod_type which produce pattern to use - */ - void set_produce_type(produce_type_t prod_type) { d_produce_type = prod_type; } - - /*! - * \brief Set the produce limit. - * - * \param limit min or maximum items to produce (depending on - * produce_type) - */ - void set_produce_limit(unsigned int limit) - { - d_min_produce = limit; - d_max_produce = limit; - } - - // ---------------------------------------------------------------------------- - -protected: - unsigned int d_sizeof_input_item; - unsigned int d_sizeof_output_item; - bool d_check_topology; - char d_temp; - consume_type_t d_consume_type; - int d_min_consume; - int d_max_consume; - produce_type_t d_produce_type; - int d_min_produce; - int d_max_produce; - test(const std::string& name, - int min_inputs, - int max_inputs, - unsigned int sizeof_input_item, - int min_outputs, - int max_outputs, - unsigned int sizeof_output_item, - unsigned int history, - unsigned int output_multiple, - double relative_rate, - bool fixed_rate, - consume_type_t cons_type, - produce_type_t prod_type); - - template <typename T, typename... Args> - friend std::shared_ptr<T> gnuradio::make_block_sptr(Args&&... args); -}; - -} /* namespace gr */ - -#endif /* INCLUDED_TEST_H */ |