summaryrefslogtreecommitdiff
path: root/gr-blocks/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gr-blocks/lib')
-rw-r--r--gr-blocks/lib/CMakeLists.txt42
-rw-r--r--gr-blocks/lib/ConfigChecks.cmake7
-rw-r--r--gr-blocks/lib/annotator_1to1_impl.cc2
-rw-r--r--gr-blocks/lib/annotator_alltoall_impl.cc2
-rw-r--r--gr-blocks/lib/annotator_raw_impl.cc2
-rw-r--r--gr-blocks/lib/deinterleave_impl.cc2
-rw-r--r--gr-blocks/lib/float_array_to_int.cc9
-rw-r--r--gr-blocks/lib/interleave_impl.cc2
-rw-r--r--gr-blocks/lib/keep_m_in_n_impl.cc34
-rw-r--r--gr-blocks/lib/keep_one_in_n_impl.cc45
-rw-r--r--gr-blocks/lib/message_strobe_impl.cc9
-rw-r--r--gr-blocks/lib/message_strobe_impl.h1
-rw-r--r--gr-blocks/lib/message_strobe_random_impl.cc8
-rw-r--r--gr-blocks/lib/message_strobe_random_impl.h2
-rw-r--r--gr-blocks/lib/multiply_const_impl.cc34
-rw-r--r--gr-blocks/lib/multiply_const_impl.h3
-rw-r--r--gr-blocks/lib/packed_to_unpacked_impl.cc2
-rw-r--r--gr-blocks/lib/pdu.cc6
-rw-r--r--gr-blocks/lib/pdu_filter_impl.cc8
-rw-r--r--gr-blocks/lib/pdu_remove_impl.cc8
-rw-r--r--gr-blocks/lib/pdu_set_impl.cc10
-rw-r--r--gr-blocks/lib/pdu_to_tagged_stream_impl.cc4
-rw-r--r--gr-blocks/lib/plateau_detector_fb_impl.cc15
-rw-r--r--gr-blocks/lib/plateau_detector_fb_impl.h3
-rw-r--r--gr-blocks/lib/probe_rate_impl.cc15
-rw-r--r--gr-blocks/lib/probe_rate_impl.h3
-rw-r--r--gr-blocks/lib/qa_block_tags.cc77
-rw-r--r--gr-blocks/lib/qa_block_tags.h50
-rw-r--r--gr-blocks/lib/qa_blocks.cc46
-rw-r--r--gr-blocks/lib/qa_blocks.h38
-rw-r--r--gr-blocks/lib/qa_gr_block.cc66
-rw-r--r--gr-blocks/lib/qa_gr_block.h48
-rw-r--r--gr-blocks/lib/qa_gr_flowgraph.cc74
-rw-r--r--gr-blocks/lib/qa_gr_flowgraph.h75
-rw-r--r--gr-blocks/lib/qa_gr_hier_block2.cc22
-rw-r--r--gr-blocks/lib/qa_gr_hier_block2.h42
-rw-r--r--gr-blocks/lib/qa_gr_hier_block2_derived.cc6
-rw-r--r--gr-blocks/lib/qa_gr_hier_block2_derived.h41
-rw-r--r--gr-blocks/lib/qa_gr_top_block.cc30
-rw-r--r--gr-blocks/lib/qa_gr_top_block.h66
-rw-r--r--gr-blocks/lib/qa_rotator.cc27
-rw-r--r--gr-blocks/lib/qa_rotator.h41
-rw-r--r--gr-blocks/lib/qa_set_msg_handler.cc9
-rw-r--r--gr-blocks/lib/qa_set_msg_handler.h43
-rw-r--r--gr-blocks/lib/random_pdu_impl.cc4
-rw-r--r--gr-blocks/lib/repack_bits_bb_impl.cc4
-rw-r--r--gr-blocks/lib/skiphead_impl.cc14
-rw-r--r--gr-blocks/lib/skiphead_impl.h1
-rw-r--r--gr-blocks/lib/socket_pdu_impl.cc18
-rw-r--r--gr-blocks/lib/tagged_stream_multiply_length_impl.cc2
-rw-r--r--gr-blocks/lib/tagged_stream_mux_impl.cc2
-rw-r--r--gr-blocks/lib/tagged_stream_to_pdu_impl.cc4
-rw-r--r--gr-blocks/lib/tcp_connection.cc2
-rw-r--r--gr-blocks/lib/test_gr_blocks.cc48
-rw-r--r--gr-blocks/lib/test_tag_variable_rate_ff_impl.cc22
-rw-r--r--gr-blocks/lib/test_tag_variable_rate_ff_impl.h1
-rw-r--r--gr-blocks/lib/tuntap_pdu_impl.cc8
-rw-r--r--gr-blocks/lib/unpacked_to_packed_impl.cc2
-rw-r--r--gr-blocks/lib/vector_sink_impl.cc8
-rw-r--r--gr-blocks/lib/vector_sink_impl.h2
60 files changed, 342 insertions, 879 deletions
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt
index 49e7307658..cfb728ce22 100644
--- a/gr-blocks/lib/CMakeLists.txt
+++ b/gr-blocks/lib/CMakeLists.txt
@@ -281,33 +281,27 @@ if(ENABLE_TESTING)
include_directories(
${GR_BLOCKS_INCLUDE_DIRS}
${GNURADIO_RUNTIME_INCLUDE_DIRS}
- ${CPPUNIT_INCLUDE_DIRS})
- link_directories(${CPPUNIT_LIBRARY_DIRS})
+ )
list(APPEND test_gr_blocks_sources
- ${CMAKE_CURRENT_SOURCE_DIR}/test_gr_blocks.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_flowgraph.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_set_msg_handler.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_block.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_top_block.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_gr_hier_block2_derived.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_blocks.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_block_tags.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/qa_rotator.cc
- )
-
- add_executable(test-gr-blocks ${test_gr_blocks_sources})
-
- list(APPEND GR_TEST_TARGET_DEPS test-gr-blocks gnuradio-blocks)
-
- target_link_libraries(
- test-gr-blocks
- gnuradio-runtime
- gnuradio-blocks
+ qa_block_tags.cc
+ qa_gr_block.cc
+ qa_gr_flowgraph.cc
+ qa_gr_hier_block2.cc
+ qa_gr_hier_block2_derived.cc
+ qa_gr_top_block.cc
+ qa_rotator.cc
+ qa_set_msg_handler.cc
+ )
+ list(APPEND GR_TEST_TARGET_DEPS gnuradio-blocks
${Boost_LIBRARIES}
- ${CPPUNIT_LIBRARIES}
+ ${CMAKE_THREAD_LIBS_INIT}
)
- GR_ADD_TEST(test_gr_blocks test-gr-blocks)
+ foreach(qa_file ${test_gr_blocks_sources})
+ GR_ADD_CPP_TEST("blocks_${qa_file}"
+ ${CMAKE_CURRENT_SOURCE_DIR}/${qa_file}
+ )
+ endforeach(qa_file)
+
endif(ENABLE_TESTING)
diff --git a/gr-blocks/lib/ConfigChecks.cmake b/gr-blocks/lib/ConfigChecks.cmake
index 21e6abbe40..d359a54d95 100644
--- a/gr-blocks/lib/ConfigChecks.cmake
+++ b/gr-blocks/lib/ConfigChecks.cmake
@@ -76,10 +76,3 @@ CHECK_CXX_SOURCE_COMPILES("
" HAVE_COSF
)
GR_ADD_COND_DEF(HAVE_COSF)
-
-CHECK_CXX_SOURCE_COMPILES("
- #include <stdlib.h>
- int main(){srand48(0); drand48(); lrand48(); return 0;}
- " HAVE_RAND48
-)
-GR_ADD_COND_DEF(HAVE_RAND48)
diff --git a/gr-blocks/lib/annotator_1to1_impl.cc b/gr-blocks/lib/annotator_1to1_impl.cc
index 17ef134677..cf26728193 100644
--- a/gr-blocks/lib/annotator_1to1_impl.cc
+++ b/gr-blocks/lib/annotator_1to1_impl.cc
@@ -49,7 +49,7 @@ namespace gr {
set_tag_propagation_policy(TPP_ONE_TO_ONE);
d_tag_counter = 0;
- set_relative_rate(1.0);
+ set_relative_rate(1, 1);
}
annotator_1to1_impl::~annotator_1to1_impl()
diff --git a/gr-blocks/lib/annotator_alltoall_impl.cc b/gr-blocks/lib/annotator_alltoall_impl.cc
index a70e955f77..afc60d0acb 100644
--- a/gr-blocks/lib/annotator_alltoall_impl.cc
+++ b/gr-blocks/lib/annotator_alltoall_impl.cc
@@ -45,7 +45,7 @@ namespace gr {
: sync_block("annotator_alltoall",
io_signature::make(1, -1, sizeof_stream_item),
io_signature::make(1, -1, sizeof_stream_item)),
- d_when((uint64_t)when)
+ d_when((uint64_t)when)
{
set_tag_propagation_policy(TPP_ALL_TO_ALL);
diff --git a/gr-blocks/lib/annotator_raw_impl.cc b/gr-blocks/lib/annotator_raw_impl.cc
index ea763c7658..ce15103822 100644
--- a/gr-blocks/lib/annotator_raw_impl.cc
+++ b/gr-blocks/lib/annotator_raw_impl.cc
@@ -50,7 +50,7 @@ namespace gr {
d_itemsize(sizeof_stream_item)
{
set_tag_propagation_policy(TPP_ONE_TO_ONE);
- set_relative_rate(1.0);
+ set_relative_rate(1, 1);
}
annotator_raw_impl::~annotator_raw_impl()
diff --git a/gr-blocks/lib/deinterleave_impl.cc b/gr-blocks/lib/deinterleave_impl.cc
index 9e18c35e58..d7fdbb8f8f 100644
--- a/gr-blocks/lib/deinterleave_impl.cc
+++ b/gr-blocks/lib/deinterleave_impl.cc
@@ -54,7 +54,7 @@ namespace gr {
bool
deinterleave_impl::check_topology(int ninputs, int noutputs)
{
- set_relative_rate(1.0/(double)noutputs);
+ set_relative_rate(1, (uint64_t)noutputs);
d_noutputs = noutputs;
return true;
}
diff --git a/gr-blocks/lib/float_array_to_int.cc b/gr-blocks/lib/float_array_to_int.cc
index 66b112c066..46f78db19e 100644
--- a/gr-blocks/lib/float_array_to_int.cc
+++ b/gr-blocks/lib/float_array_to_int.cc
@@ -27,10 +27,15 @@
#define _ISOC9X_SOURCE
#include <float_array_to_int.h>
#include <math.h>
+#if __cplusplus >= 201103L
+#include <cstdint>
+using std::int64_t;
+#else
#include <stdint.h>
+#endif
-static const int64_t MAX_INT = 2147483647; // (2^31)-1
-static const int64_t MIN_INT = -2147483647; // -(2^31)-1
+static const int64_t MAX_INT = INT32_MAX;
+static const int64_t MIN_INT = INT32_MIN;
void
float_array_to_int(const float *in, int *out, float scale, int nsamples)
diff --git a/gr-blocks/lib/interleave_impl.cc b/gr-blocks/lib/interleave_impl.cc
index 3e5a8295bd..65a5cb69b7 100644
--- a/gr-blocks/lib/interleave_impl.cc
+++ b/gr-blocks/lib/interleave_impl.cc
@@ -48,7 +48,7 @@ namespace gr {
bool
interleave_impl::check_topology(int ninputs, int noutputs)
{
- set_relative_rate((double)ninputs);
+ set_relative_rate((uint64_t)ninputs, 1);
d_ninputs = ninputs;
set_output_multiple(d_blocksize * d_ninputs);
return true;
diff --git a/gr-blocks/lib/keep_m_in_n_impl.cc b/gr-blocks/lib/keep_m_in_n_impl.cc
index 11b3b27af7..4784d3c1a2 100644
--- a/gr-blocks/lib/keep_m_in_n_impl.cc
+++ b/gr-blocks/lib/keep_m_in_n_impl.cc
@@ -39,12 +39,12 @@ namespace gr {
keep_m_in_n_impl::keep_m_in_n_impl(size_t itemsize, int m, int n, int offset)
: block("keep_m_in_n",
- io_signature::make (1, 1, itemsize),
- io_signature::make (1, 1, itemsize)),
- d_m(m),
- d_n(n),
- d_offset(offset),
- d_itemsize(itemsize)
+ io_signature::make (1, 1, itemsize),
+ io_signature::make (1, 1, itemsize)),
+ d_m(m),
+ d_n(n),
+ d_offset(offset),
+ d_itemsize(itemsize)
{
// sanity checking
if(d_m <= 0) {
@@ -66,7 +66,7 @@ namespace gr {
}
set_output_multiple(m);
- set_relative_rate(static_cast<double>(d_m)/static_cast<double>(d_n));
+ set_relative_rate(static_cast<uint64_t>(d_m), static_cast<uint64_t>(d_n));
}
void
@@ -80,14 +80,14 @@ namespace gr {
{
d_m = m;
set_output_multiple(m);
- set_relative_rate(static_cast<double>(d_m)/static_cast<double>(d_n));
+ set_relative_rate(static_cast<uint64_t>(d_m), static_cast<uint64_t>(d_n));
}
void
keep_m_in_n_impl::set_n(int n)
{
d_n = n;
- set_relative_rate(static_cast<double>(d_m)/static_cast<double>(d_n));
+ set_relative_rate(static_cast<uint64_t>(d_m), static_cast<uint64_t>(d_n));
}
void
@@ -98,9 +98,9 @@ namespace gr {
int
keep_m_in_n_impl::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
uint8_t* out = (uint8_t*)output_items[0];
const uint8_t* in = (const uint8_t*)input_items[0];
@@ -109,11 +109,11 @@ namespace gr {
int blks = std::min(noutput_items/d_m, ninput_items[0]/d_n);
for(int i=0; i<blks; i++) {
- // set up copy pointers
- const uint8_t* iptr = &in[(i*d_n + d_offset)*d_itemsize];
- uint8_t* optr = &out[i*d_m*d_itemsize];
- // perform copy
- memcpy( optr, iptr, d_m*d_itemsize );
+ // set up copy pointers
+ const uint8_t* iptr = &in[(i*d_n + d_offset)*d_itemsize];
+ uint8_t* optr = &out[i*d_m*d_itemsize];
+ // perform copy
+ memcpy( optr, iptr, d_m*d_itemsize );
}
consume_each(blks*d_n);
diff --git a/gr-blocks/lib/keep_one_in_n_impl.cc b/gr-blocks/lib/keep_one_in_n_impl.cc
index e588655f7a..91c77da829 100644
--- a/gr-blocks/lib/keep_one_in_n_impl.cc
+++ b/gr-blocks/lib/keep_one_in_n_impl.cc
@@ -37,9 +37,9 @@ namespace gr {
keep_one_in_n_impl::keep_one_in_n_impl(size_t itemsize, int n)
: block("keep_one_in_n",
- io_signature::make (1, 1, itemsize),
- io_signature::make (1, 1, itemsize)),
- d_count(n)
+ io_signature::make (1, 1, itemsize),
+ io_signature::make (1, 1, itemsize)),
+ d_count(n)
{
// To avoid bad behavior with using set_relative_rate in this block with
// VERY large values of n, we will keep track of things ourselves. Using
@@ -53,8 +53,9 @@ namespace gr {
void
keep_one_in_n_impl::set_n(int n)
{
- if (n < 1)
- n = 1;
+ if (n < 1) {
+ throw std::invalid_argument("N must be at least 1.");
+ }
d_n = n;
d_count = n;
@@ -67,27 +68,27 @@ namespace gr {
int
keep_one_in_n_impl::general_work(int noutput_items,
- gr_vector_int &ninput_items,
- gr_vector_const_void_star &input_items,
- gr_vector_void_star &output_items)
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items)
{
const char *in = (const char *) input_items[0];
char *out = (char *) output_items[0];
size_t item_size = input_signature ()->sizeof_stream_item (0);
- int ni = 0;
- int no = 0;
+ int ni = 0;
+ int no = 0;
while (ni < ninput_items[0] && no < noutput_items){
- d_count--;
- if (d_count <= 0){
- memcpy (out, in, item_size); // copy 1 item
- out += item_size;
- no++;
- d_count = d_n;
- }
- in += item_size;
- ni++;
+ d_count--;
+ if (d_count <= 0){
+ memcpy (out, in, item_size); // copy 1 item
+ out += item_size;
+ no++;
+ d_count = d_n;
+ }
+ in += item_size;
+ ni++;
}
// Because we have set TPP_DONT, we have to propagate the tags here manually.
@@ -96,9 +97,9 @@ namespace gr {
std::vector<tag_t>::iterator t;
get_tags_in_range(tags, 0, nitems_read(0), nitems_read(0)+ni);
for(t = tags.begin(); t != tags.end(); t++) {
- tag_t new_tag = *t;
- new_tag.offset *= d_decim_rate;
- add_item_tag(0, new_tag);
+ tag_t new_tag = *t;
+ new_tag.offset *= d_decim_rate;
+ add_item_tag(0, new_tag);
}
consume_each (ni);
diff --git a/gr-blocks/lib/message_strobe_impl.cc b/gr-blocks/lib/message_strobe_impl.cc
index 5304faf165..bedec78a57 100644
--- a/gr-blocks/lib/message_strobe_impl.cc
+++ b/gr-blocks/lib/message_strobe_impl.cc
@@ -51,9 +51,10 @@ namespace gr {
io_signature::make(0, 0, 0)),
d_finished(false),
d_period_ms(period_ms),
- d_msg(msg)
+ d_msg(msg),
+ d_port(pmt::mp("strobe"))
{
- message_port_register_out(pmt::mp("strobe"));
+ message_port_register_out(d_port);
message_port_register_in(pmt::mp("set_msg"));
set_msg_handler(pmt::mp("set_msg"),
@@ -90,12 +91,12 @@ namespace gr {
void message_strobe_impl::run()
{
while(!d_finished) {
- boost::this_thread::sleep(boost::posix_time::milliseconds(d_period_ms));
+ boost::this_thread::sleep(boost::posix_time::milliseconds(static_cast<long>(d_period_ms)));
if(d_finished) {
return;
}
- message_port_pub(pmt::mp("strobe"), d_msg);
+ message_port_pub(d_port, d_msg);
}
}
diff --git a/gr-blocks/lib/message_strobe_impl.h b/gr-blocks/lib/message_strobe_impl.h
index 06a3fd3374..0ee1cf1f3d 100644
--- a/gr-blocks/lib/message_strobe_impl.h
+++ b/gr-blocks/lib/message_strobe_impl.h
@@ -35,6 +35,7 @@ namespace gr {
bool d_finished;
long d_period_ms;
pmt::pmt_t d_msg;
+ const pmt::pmt_t d_port;
void run();
diff --git a/gr-blocks/lib/message_strobe_random_impl.cc b/gr-blocks/lib/message_strobe_random_impl.cc
index a5c6693215..5c2055ddbd 100644
--- a/gr-blocks/lib/message_strobe_random_impl.cc
+++ b/gr-blocks/lib/message_strobe_random_impl.cc
@@ -45,6 +45,7 @@ namespace gr {
(new message_strobe_random_impl(msg, dist, mean_ms, std_ms));
}
+
message_strobe_random_impl::message_strobe_random_impl(pmt::pmt_t msg, message_strobe_random_distribution_t dist, float mean_ms, float std_ms)
: block("message_strobe_random",
io_signature::make(0, 0, 0),
@@ -54,13 +55,14 @@ namespace gr {
d_std_ms(std_ms),
d_dist(dist),
d_msg(msg),
- d_rng()
+ d_rng(),
+ d_port(pmt::mp("strobe"))
{
// allocate RNGs
update_dist();
// set up ports
- message_port_register_out(pmt::mp("strobe"));
+ message_port_register_out(d_port);
d_thread = boost::shared_ptr<gr::thread::thread>
(new gr::thread::thread(boost::bind(&message_strobe_random_impl::run, this)));
@@ -113,7 +115,7 @@ namespace gr {
return;
}
- message_port_pub(pmt::mp("strobe"), d_msg);
+ message_port_pub(d_port, d_msg);
}
}
diff --git a/gr-blocks/lib/message_strobe_random_impl.h b/gr-blocks/lib/message_strobe_random_impl.h
index 786f3288f6..08f966921c 100644
--- a/gr-blocks/lib/message_strobe_random_impl.h
+++ b/gr-blocks/lib/message_strobe_random_impl.h
@@ -50,6 +50,8 @@ namespace gr {
boost::shared_ptr< boost::variate_generator <boost::mt19937, boost::normal_distribution<> > > d_variate_normal;
boost::shared_ptr< boost::variate_generator <boost::mt19937, boost::uniform_real<> > > d_variate_uniform;
+ const pmt::pmt_t d_port;
+
void update_dist();
public:
diff --git a/gr-blocks/lib/multiply_const_impl.cc b/gr-blocks/lib/multiply_const_impl.cc
index bfdd88ed04..03ac054a0e 100644
--- a/gr-blocks/lib/multiply_const_impl.cc
+++ b/gr-blocks/lib/multiply_const_impl.cc
@@ -33,17 +33,17 @@ namespace gr {
namespace blocks {
template <class T>
- typename multiply_const<T>::sptr multiply_const<T>::make(T k)
+ typename multiply_const<T>::sptr multiply_const<T>::make(T k, size_t vlen)
{
- return gnuradio::get_initial_sptr(new multiply_const_impl<T> (k));
+ return gnuradio::get_initial_sptr(new multiply_const_impl<T> (k, vlen));
}
template <>
- multiply_const_impl<float>::multiply_const_impl(float k)
+ multiply_const_impl<float>::multiply_const_impl(float k, size_t vlen)
: sync_block ("multiply_const_ff",
- io_signature::make (1, 1, sizeof (float)),
- io_signature::make (1, 1, sizeof (float))),
- d_k(k)
+ io_signature::make (1, 1, sizeof (float)*vlen),
+ io_signature::make (1, 1, sizeof (float)*vlen)),
+ d_k(k), d_vlen(vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(float);
@@ -58,7 +58,7 @@ namespace gr {
{
const float *in = (const float *) input_items[0];
float *out = (float *) output_items[0];
- int noi = noutput_items;
+ int noi = noutput_items * d_vlen;
volk_32f_s32f_multiply_32f(out, in, d_k, noi);
@@ -66,11 +66,11 @@ namespace gr {
}
template <>
- multiply_const_impl<gr_complex>::multiply_const_impl(gr_complex k)
+ multiply_const_impl<gr_complex>::multiply_const_impl(gr_complex k, size_t vlen)
: sync_block ("multiply_const_cc",
- io_signature::make (1, 1, sizeof (gr_complex)),
- io_signature::make (1, 1, sizeof (gr_complex))),
- d_k(k)
+ io_signature::make (1, 1, sizeof (gr_complex)*vlen),
+ io_signature::make (1, 1, sizeof (gr_complex)*vlen)),
+ d_k(k), d_vlen(vlen)
{
const int alignment_multiple =
volk_get_alignment() / sizeof(gr_complex);
@@ -85,7 +85,7 @@ namespace gr {
{
const gr_complex *in = (const gr_complex *) input_items[0];
gr_complex *out = (gr_complex *) output_items[0];
- int noi = noutput_items;
+ int noi = noutput_items * d_vlen;
volk_32fc_s32fc_multiply_32fc(out, in, d_k, noi);
@@ -94,11 +94,11 @@ namespace gr {
template <class T>
- multiply_const_impl<T> ::multiply_const_impl(T k)
+ multiply_const_impl<T> ::multiply_const_impl(T k, size_t vlen)
: sync_block ("multiply_const",
- io_signature::make (1, 1, sizeof (T)),
- io_signature::make (1, 1, sizeof (T))),
- d_k(k)
+ io_signature::make (1, 1, sizeof (T)*vlen),
+ io_signature::make (1, 1, sizeof (T)*vlen)),
+ d_k(k), d_vlen(vlen)
{
}
@@ -111,7 +111,7 @@ namespace gr {
T *iptr = (T *) input_items[0];
T *optr = (T *) output_items[0];
- int size = noutput_items;
+ int size = noutput_items * d_vlen;
while (size >= 8){
*optr++ = *iptr++ * d_k;
diff --git a/gr-blocks/lib/multiply_const_impl.h b/gr-blocks/lib/multiply_const_impl.h
index c2cc388845..674fc66609 100644
--- a/gr-blocks/lib/multiply_const_impl.h
+++ b/gr-blocks/lib/multiply_const_impl.h
@@ -33,9 +33,10 @@ template<class T>
class BLOCKS_API multiply_const_impl : public multiply_const<T>
{
T d_k;
+ size_t d_vlen;
public:
- multiply_const_impl (T k);
+ multiply_const_impl (T k, size_t vlen);
T k() const { return d_k; }
void set_k(T k) { d_k = k; }
diff --git a/gr-blocks/lib/packed_to_unpacked_impl.cc b/gr-blocks/lib/packed_to_unpacked_impl.cc
index 54b6031238..ed84f7ecf0 100644
--- a/gr-blocks/lib/packed_to_unpacked_impl.cc
+++ b/gr-blocks/lib/packed_to_unpacked_impl.cc
@@ -52,7 +52,7 @@ namespace gr {
assert(bits_per_chunk <= this->d_bits_per_type);
assert(bits_per_chunk > 0);
- this->set_relative_rate((1.0 * this->d_bits_per_type) / bits_per_chunk);
+ this->set_relative_rate((uint64_t)BITS_PER_TYPE, (uint64_t)bits_per_chunk);
}
template <class T>
diff --git a/gr-blocks/lib/pdu.cc b/gr-blocks/lib/pdu.cc
index 54e0bad5d0..f0e610209f 100644
--- a/gr-blocks/lib/pdu.cc
+++ b/gr-blocks/lib/pdu.cc
@@ -30,6 +30,12 @@ namespace gr {
namespace blocks {
namespace pdu {
+ const
+ pmt::pmt_t pdu_port_id(){
+ static const pmt::pmt_t pdu_port_id = pmt::mp("pdus");
+ return pdu_port_id;
+ }
+
size_t
itemsize(vector_type type)
{
diff --git a/gr-blocks/lib/pdu_filter_impl.cc b/gr-blocks/lib/pdu_filter_impl.cc
index 507238d212..31c737af53 100644
--- a/gr-blocks/lib/pdu_filter_impl.cc
+++ b/gr-blocks/lib/pdu_filter_impl.cc
@@ -43,9 +43,9 @@ namespace gr {
io_signature::make (0, 0, 0)),
d_k(k), d_v(v), d_invert(invert)
{
- message_port_register_out(pmt::mp("pdus"));
- message_port_register_in(pmt::mp("pdus"));
- set_msg_handler(pmt::mp("pdus"), boost::bind(&pdu_filter_impl::handle_msg, this, _1));
+ message_port_register_out(pdu::pdu_port_id());
+ message_port_register_in(pdu::pdu_port_id());
+ set_msg_handler(pdu::pdu_port_id(), boost::bind(&pdu_filter_impl::handle_msg, this, _1));
}
void
@@ -63,7 +63,7 @@ namespace gr {
// if all tests pass, propagate the pdu
if(output){
- message_port_pub(pmt::mp("pdus"), pdu);
+ message_port_pub(pdu::pdu_port_id(), pdu);
}
}
diff --git a/gr-blocks/lib/pdu_remove_impl.cc b/gr-blocks/lib/pdu_remove_impl.cc
index c3a87ed69e..ab6dd4a4e7 100644
--- a/gr-blocks/lib/pdu_remove_impl.cc
+++ b/gr-blocks/lib/pdu_remove_impl.cc
@@ -43,9 +43,9 @@ namespace gr {
io_signature::make (0, 0, 0)),
d_k(k)
{
- message_port_register_out(pmt::mp("pdus"));
- message_port_register_in(pmt::mp("pdus"));
- set_msg_handler(pmt::mp("pdus"), boost::bind(&pdu_remove_impl::handle_msg, this, _1));
+ message_port_register_out(pdu::pdu_port_id());
+ message_port_register_in(pdu::pdu_port_id());
+ set_msg_handler(pdu::pdu_port_id(), boost::bind(&pdu_remove_impl::handle_msg, this, _1));
}
void
@@ -59,7 +59,7 @@ namespace gr {
throw std::runtime_error("pdu_remove received non PDU input");
}
meta = pmt::dict_delete(meta, d_k);
- message_port_pub(pmt::mp("pdus"), pmt::cons(meta, pmt::cdr(pdu)));
+ message_port_pub(pdu::pdu_port_id(), pmt::cons(meta, pmt::cdr(pdu)));
}
} /* namespace blocks */
diff --git a/gr-blocks/lib/pdu_set_impl.cc b/gr-blocks/lib/pdu_set_impl.cc
index dce4df09a3..df09e2e9f9 100644
--- a/gr-blocks/lib/pdu_set_impl.cc
+++ b/gr-blocks/lib/pdu_set_impl.cc
@@ -41,11 +41,11 @@ namespace gr {
: block("pdu_set",
io_signature::make (0, 0, 0),
io_signature::make (0, 0, 0)),
- d_k(k), d_v(v)
+ d_k(k), d_v(v)
{
- message_port_register_out(pmt::mp("pdus"));
- message_port_register_in(pmt::mp("pdus"));
- set_msg_handler(pmt::mp("pdus"), boost::bind(&pdu_set_impl::handle_msg, this, _1));
+ message_port_register_out(pdu::pdu_port_id());
+ message_port_register_in(pdu::pdu_port_id());
+ set_msg_handler(pdu::pdu_port_id(), boost::bind(&pdu_set_impl::handle_msg, this, _1));
}
void
@@ -59,7 +59,7 @@ namespace gr {
throw std::runtime_error("pdu_set received non PDU input");
}
meta = pmt::dict_add(meta, d_k, d_v);
- message_port_pub(pmt::mp("pdus"), pmt::cons(meta, pmt::cdr(pdu)));
+ message_port_pub(pdu::pdu_port_id(), pmt::cons(meta, pmt::cdr(pdu)));
}
} /* namespace blocks */
diff --git a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
index baf16aa599..10232cd970 100644
--- a/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
+++ b/gr-blocks/lib/pdu_to_tagged_stream_impl.cc
@@ -45,13 +45,13 @@ namespace gr {
d_itemsize(pdu::itemsize(type)),
d_curr_len(0)
{
- message_port_register_in(PDU_PORT_ID);
+ message_port_register_in(pdu::pdu_port_id());
}
int pdu_to_tagged_stream_impl::calculate_output_stream_length(const gr_vector_int &)
{
if (d_curr_len == 0) {
- pmt::pmt_t msg(delete_head_nowait(PDU_PORT_ID));
+ pmt::pmt_t msg(delete_head_nowait(pdu::pdu_port_id()));
if (msg.get() == NULL) {
return 0;
}
diff --git a/gr-blocks/lib/plateau_detector_fb_impl.cc b/gr-blocks/lib/plateau_detector_fb_impl.cc
index 14d52b392c..375c1a3070 100644
--- a/gr-blocks/lib/plateau_detector_fb_impl.cc
+++ b/gr-blocks/lib/plateau_detector_fb_impl.cc
@@ -61,6 +61,9 @@ namespace gr {
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
+ // thread-safe protection from ::set_threshold
+ gr::thread::scoped_lock l (d_setlock);
+
const float *in = (const float *) input_items[0];
unsigned char *out = (unsigned char *) output_items[0];
int flank_start;
@@ -86,6 +89,18 @@ namespace gr {
return i;
}
+ void plateau_detector_fb_impl::set_threshold(float threshold)
+ {
+ // thread-safe protection from ::set_threshold
+ gr::thread::scoped_lock l (d_setlock);
+ d_threshold = threshold;
+ }
+
+ float plateau_detector_fb_impl::threshold() const
+ {
+ return d_threshold;
+ }
+
} /* namespace blocks */
} /* namespace gr */
diff --git a/gr-blocks/lib/plateau_detector_fb_impl.h b/gr-blocks/lib/plateau_detector_fb_impl.h
index 906891d62b..1a99745104 100644
--- a/gr-blocks/lib/plateau_detector_fb_impl.h
+++ b/gr-blocks/lib/plateau_detector_fb_impl.h
@@ -44,6 +44,9 @@ class plateau_detector_fb_impl : public plateau_detector_fb
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items);
+
+ virtual void set_threshold(float threshold);
+ virtual float threshold() const;
};
} // namespace blocks
diff --git a/gr-blocks/lib/probe_rate_impl.cc b/gr-blocks/lib/probe_rate_impl.cc
index fb08b7dd99..24a736db4d 100644
--- a/gr-blocks/lib/probe_rate_impl.cc
+++ b/gr-blocks/lib/probe_rate_impl.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2005,2013 Free Software Foundation, Inc.
+ * Copyright 2005,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -45,9 +45,12 @@ namespace gr {
d_beta(1.0-alpha),
d_avg(0),
d_min_update_time(update_rate_ms),
- d_lastthru(0)
+ d_lastthru(0),
+ d_port(pmt::mp("rate")),
+ d_dict_avg(pmt::mp("rate_avg")),
+ d_dict_now(pmt::mp("rate_now"))
{
- message_port_register_out(pmt::mp("rate"));
+ message_port_register_out(d_port);
}
probe_rate_impl::~probe_rate_impl(){}
@@ -69,9 +72,9 @@ namespace gr {
d_avg = rate_this_update*d_alpha + d_avg*d_beta;
}
pmt::pmt_t d = pmt::make_dict();
- d = pmt::dict_add(d, pmt::mp("rate_avg"), pmt::mp(d_avg));
- d = pmt::dict_add(d, pmt::mp("rate_now"), pmt::mp(rate_this_update));
- message_port_pub(pmt::mp("rate"), pmt::cons(d, pmt::PMT_NIL));
+ d = pmt::dict_add(d, d_dict_avg, pmt::mp(d_avg));
+ d = pmt::dict_add(d, d_dict_now, pmt::mp(rate_this_update));
+ message_port_pub(d_port, pmt::cons(d, pmt::PMT_NIL));
}
return noutput_items;
}
diff --git a/gr-blocks/lib/probe_rate_impl.h b/gr-blocks/lib/probe_rate_impl.h
index ae4876dfa8..42c3b13fe2 100644
--- a/gr-blocks/lib/probe_rate_impl.h
+++ b/gr-blocks/lib/probe_rate_impl.h
@@ -37,6 +37,9 @@ namespace gr {
uint64_t d_lastthru;
void setup_rpc();
+ const pmt::pmt_t d_port;
+ const pmt::pmt_t d_dict_avg, d_dict_now;
+
public:
probe_rate_impl(size_t itemsize, double update_rate_ms, double alpha = 0.0001);
~probe_rate_impl();
diff --git a/gr-blocks/lib/qa_block_tags.cc b/gr-blocks/lib/qa_block_tags.cc
index d794f8edfe..fc61065e95 100644
--- a/gr-blocks/lib/qa_block_tags.cc
+++ b/gr-blocks/lib/qa_block_tags.cc
@@ -24,7 +24,6 @@
#include <config.h>
#endif
-#include <qa_block_tags.h>
#include <gnuradio/block.h>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/null_source.h>
@@ -33,6 +32,7 @@
#include <gnuradio/blocks/annotator_alltoall.h>
#include <gnuradio/blocks/annotator_1to1.h>
#include <gnuradio/blocks/keep_one_in_n.h>
+#include <boost/test/unit_test.hpp>
// ----------------------------------------------------------------
@@ -59,8 +59,8 @@ std::ostream&
operator << (std::ostream& os, const gr::tag_t &t) {
return os;
}
-void
-qa_block_tags::t0()
+
+BOOST_AUTO_TEST_CASE(t0)
{
unsigned int N = 1000;
gr::top_block_sptr tb = gr::make_top_block("top");
@@ -71,20 +71,19 @@ qa_block_tags::t0()
tb->connect(src, 0, head, 0);
tb->connect(head, 0, snk, 0);
- CPPUNIT_ASSERT_EQUAL(src->nitems_read(0), (uint64_t)0);
- CPPUNIT_ASSERT_EQUAL(src->nitems_written(0), (uint64_t)0);
+ BOOST_REQUIRE_EQUAL(src->nitems_read(0), (uint64_t)0);
+ BOOST_REQUIRE_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);
+ BOOST_REQUIRE_THROW(src->nitems_read(0), std::invalid_argument);
+ BOOST_REQUIRE(src->nitems_written(0) >= N);
+ BOOST_REQUIRE_EQUAL(snk->nitems_read(0), (uint64_t)1000);
+ BOOST_REQUIRE_THROW(snk->nitems_written(0), std::invalid_argument);
}
-void
-qa_block_tags::t1()
+BOOST_AUTO_TEST_CASE(t1)
{
int N = 40000;
gr::top_block_sptr tb = gr::make_top_block("top");
@@ -116,9 +115,9 @@ qa_block_tags::t1()
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);
+ BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
+ BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)8);
+ BOOST_REQUIRE_EQUAL(tags4.size(), (size_t)8);
#if QA_TAGS_DEBUG
// Kludge together the tags that we know should result from the above graph
@@ -152,20 +151,19 @@ qa_block_tags::t1()
// 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(tags3[i], expected_tags3[i]);
+ BOOST_REQUIRE_EQUAL(tags3[i], 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(tags4[i], expected_tags4[i]);
+ BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]);
}
#endif
}
-void
-qa_block_tags::t2 ()
+BOOST_AUTO_TEST_CASE(t2)
{
int N = 40000;
gr::top_block_sptr tb = gr::make_top_block("top");
@@ -202,13 +200,13 @@ qa_block_tags::t2 ()
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);
+ BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
+ BOOST_REQUIRE_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);
+ BOOST_REQUIRE_EQUAL(tags2.size(), (size_t)12);
+ BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)12);
+ BOOST_REQUIRE_EQUAL(tags4.size(), (size_t)12);
#if QA_TAGS_DEBUG
@@ -253,20 +251,19 @@ qa_block_tags::t2 ()
// 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(tags2[i], expected_tags2[i]);
+ BOOST_REQUIRE_EQUAL(tags2[i], 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(tags4[i], expected_tags4[i]);
+ BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]);
}
#endif
}
-void
-qa_block_tags::t3()
+BOOST_AUTO_TEST_CASE(t3)
{
int N = 40000;
gr::top_block_sptr tb = gr::make_top_block("top");
@@ -300,9 +297,9 @@ qa_block_tags::t3()
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);
+ BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
+ BOOST_REQUIRE_EQUAL(tags3.size(), (size_t)8);
+ BOOST_REQUIRE_EQUAL(tags4.size(), (size_t)8);
#if QA_TAGS_DEBUG
// Kludge together the tags that we know should result from the above graph
@@ -336,21 +333,20 @@ qa_block_tags::t3()
// 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(tags3[i], expected_tags3[i]);
+ BOOST_REQUIRE_EQUAL(tags3[i], 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(tags4[i], expected_tags4[i]);
+ BOOST_REQUIRE_EQUAL(tags4[i], expected_tags4[i]);
}
#endif
}
-void
-qa_block_tags::t4()
+BOOST_AUTO_TEST_CASE(t4)
{
int N = 40000;
gr::top_block_sptr tb = gr::make_top_block("top");
@@ -378,8 +374,7 @@ qa_block_tags::t4()
}
-void
-qa_block_tags::t5()
+BOOST_AUTO_TEST_CASE(t5)
{
int N = 40000;
gr::top_block_sptr tb = gr::make_top_block("top");
@@ -407,9 +402,9 @@ qa_block_tags::t5()
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);
+ BOOST_REQUIRE_EQUAL(tags0.size(), (size_t)0);
+ BOOST_REQUIRE_EQUAL(tags1.size(), (size_t)4);
+ BOOST_REQUIRE_EQUAL(tags2.size(), (size_t)8);
#if QA_TAGS_DEBUG
@@ -443,7 +438,7 @@ qa_block_tags::t5()
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(tags1[i], expected_tags1[i]);
+ BOOST_REQUIRE_EQUAL(tags1[i], expected_tags1[i]);
}
// annotator 2 gets tags from annotators 0 and 1
@@ -451,7 +446,7 @@ qa_block_tags::t5()
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(tags2[i], expected_tags2[i]);
+ BOOST_REQUIRE_EQUAL(tags2[i], expected_tags2[i]);
}
#endif
}
diff --git a/gr-blocks/lib/qa_block_tags.h b/gr-blocks/lib/qa_block_tags.h
deleted file mode 100644
index 83bebe23f6..0000000000
--- a/gr-blocks/lib/qa_block_tags.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2010,2013 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/gr-blocks/lib/qa_blocks.cc b/gr-blocks/lib/qa_blocks.cc
deleted file mode 100644
index c7d76ed3d7..0000000000
--- a/gr-blocks/lib/qa_blocks.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2012-2013 Free Software Foundation, Inc.
- *
- * This file is part of GNU Radio
- *
- * GNU Radio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3, or (at your option)
- * any later version.
- *
- * GNU Radio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GNU Radio; see the file COPYING. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street,
- * Boston, MA 02110-1301, USA.
- */
-
-/*
- * This class gathers together all the test cases for the gr-blocks
- * directory into a single test suite. As you create new test cases,
- * add them here.
- */
-
-#include <qa_blocks.h>
-#include <qa_block_tags.h>
-#include <qa_rotator.h>
-#include <qa_gr_block.h>
-#include <qa_gr_flowgraph.h>
-#include <qa_set_msg_handler.h>
-
-CppUnit::TestSuite *
-qa_blocks::suite()
-{
- CppUnit::TestSuite *s = new CppUnit::TestSuite("gr-blocks");
-
- s->addTest(qa_block_tags::suite());
- s->addTest(qa_rotator::suite());
- s->addTest(qa_gr_block::suite());
- s->addTest(qa_gr_flowgraph::suite());
- s->addTest(qa_set_msg_handler::suite());
- return s;
-}
diff --git a/gr-blocks/lib/qa_blocks.h b/gr-blocks/lib/qa_blocks.h
deleted file mode 100644
index 4d52878454..0000000000
--- a/gr-blocks/lib/qa_blocks.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012-2013 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_BLOCKS_H_
-#define _QA_GR_BLOCKS_H_
-
-#include <gnuradio/attributes.h>
-#include <cppunit/TestSuite.h>
-
-//! collect all the tests for the gr-blocks directory
-
-class __GR_ATTR_EXPORT qa_blocks
-{
- public:
- //! return suite of tests for all of gr-blocks directory
- static CppUnit::TestSuite *suite();
-};
-
-#endif /* _QA_GR_BLOCKS_H_ */
diff --git a/gr-blocks/lib/qa_gr_block.cc b/gr-blocks/lib/qa_gr_block.cc
index 36ec128b6e..46079165b0 100644
--- a/gr-blocks/lib/qa_gr_block.cc
+++ b/gr-blocks/lib/qa_gr_block.cc
@@ -24,56 +24,51 @@
#include <config.h>
#endif
-#include <qa_gr_block.h>
#include <gnuradio/block.h>
#include <gnuradio/blocks/null_sink.h>
#include <gnuradio/blocks/null_source.h>
+#include <boost/test/unit_test.hpp>
-// ----------------------------------------------------------------
-
-
-void
-qa_gr_block::t0 ()
+BOOST_AUTO_TEST_CASE(t0)
{
// test creation of sources
gr::block_sptr src1(gr::blocks::null_source::make(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),
+ BOOST_REQUIRE_EQUAL(std::string("null_source"), src1->name ());
+ BOOST_REQUIRE_EQUAL(0, src1->input_signature()->max_streams ());
+ BOOST_REQUIRE_EQUAL(1, src1->output_signature()->min_streams ());
+ BOOST_REQUIRE_EQUAL(-1, src1->output_signature()->max_streams ());
+ BOOST_REQUIRE_EQUAL((int) sizeof(int),
src1->output_signature()->sizeof_stream_item (0));
gr::block_sptr src2(gr::blocks::null_source::make(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),
+ BOOST_REQUIRE_EQUAL(std::string ("null_source"), src2->name ());
+ BOOST_REQUIRE_EQUAL(0, src2->input_signature()->max_streams ());
+ BOOST_REQUIRE_EQUAL(1, src2->output_signature()->min_streams ());
+ BOOST_REQUIRE_EQUAL(-1, src2->output_signature()->max_streams ());
+ BOOST_REQUIRE_EQUAL((int)sizeof (short),
src2->output_signature()->sizeof_stream_item (0));
}
-void
-qa_gr_block::t1 ()
+BOOST_AUTO_TEST_CASE(t1)
{
// test creation of sinks
gr::block_sptr dst1 (gr::blocks::null_sink::make (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),
+ BOOST_REQUIRE_EQUAL (std::string ("null_sink"), dst1->name ());
+ BOOST_REQUIRE_EQUAL (1, dst1->input_signature()->min_streams ());
+ BOOST_REQUIRE_EQUAL (-1, dst1->input_signature()->max_streams ());
+ BOOST_REQUIRE_EQUAL ((int) sizeof (int),
dst1->input_signature()->sizeof_stream_item (0));
- CPPUNIT_ASSERT_EQUAL (0, dst1->output_signature()->max_streams ());
+ BOOST_REQUIRE_EQUAL (0, dst1->output_signature()->max_streams ());
gr::block_sptr dst2 (gr::blocks::null_sink::make (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),
+ BOOST_REQUIRE_EQUAL (std::string ("null_sink"), dst2->name ());
+ BOOST_REQUIRE_EQUAL (1, dst2->input_signature()->min_streams ());
+ BOOST_REQUIRE_EQUAL (-1, dst2->input_signature()->max_streams ());
+ BOOST_REQUIRE_EQUAL ((int) sizeof (short),
dst2->input_signature()->sizeof_stream_item (0));
- CPPUNIT_ASSERT_EQUAL (0, dst2->output_signature()->max_streams ());
+ BOOST_REQUIRE_EQUAL (0, dst2->output_signature()->max_streams ());
}
#include <gnuradio/top_block.h>
@@ -81,8 +76,7 @@ qa_gr_block::t1 ()
#include <gnuradio/block_detail.h>
#include <gnuradio/blocks/nop.h>
-void
-qa_gr_block::t2 ()
+BOOST_AUTO_TEST_CASE(t2)
{
gr::block_sptr src1(gr::blocks::null_source::make(sizeof (int)));
gr::block_sptr nop(gr::blocks::nop::make(sizeof (int)));
@@ -98,16 +92,12 @@ qa_gr_block::t2 ()
const char *ibuf = nop->detail()->input(0)->buffer()->base();
int ibsize = nop->detail()->input(0)->buffer()->bufsize();
- CPPUNIT_ASSERT(obuf != NULL);
- CPPUNIT_ASSERT(ibuf != NULL);
- CPPUNIT_ASSERT(obsize > 0);
- CPPUNIT_ASSERT(ibsize > 0);
+ BOOST_REQUIRE(obuf != NULL);
+ BOOST_REQUIRE(ibuf != NULL);
+ BOOST_REQUIRE(obsize > 0);
+ BOOST_REQUIRE(ibsize > 0);
tb->stop();
tb->wait();
}
-void
-qa_gr_block::t3 ()
-{
-}
diff --git a/gr-blocks/lib/qa_gr_block.h b/gr-blocks/lib/qa_gr_block.h
deleted file mode 100644
index 14c7c40d1f..0000000000
--- a/gr-blocks/lib/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/gr-blocks/lib/qa_gr_flowgraph.cc b/gr-blocks/lib/qa_gr_flowgraph.cc
index 1933c8252d..2626b9bbda 100644
--- a/gr-blocks/lib/qa_gr_flowgraph.cc
+++ b/gr-blocks/lib/qa_gr_flowgraph.cc
@@ -24,11 +24,11 @@
#include <config.h>
#endif
-#include <qa_gr_flowgraph.h>
#include <gnuradio/flowgraph.h>
#include <gnuradio/blocks/nop.h>
#include <gnuradio/blocks/null_source.h>
#include <gnuradio/blocks/null_sink.h>
+#include <boost/test/unit_test.hpp>
namespace gr {
namespace blocks {
@@ -78,14 +78,14 @@ namespace gr {
} /* namespace blocks */
} /* namespace gr */
-void qa_gr_flowgraph::t0()
+BOOST_AUTO_TEST_CASE(t0)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
- CPPUNIT_ASSERT(fg);
+ BOOST_REQUIRE(fg);
}
-void qa_gr_flowgraph::t1_connect()
+BOOST_AUTO_TEST_CASE(t1_connect)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
@@ -95,47 +95,47 @@ void qa_gr_flowgraph::t1_connect()
fg->connect(nop1, 0, nop2, 0);
}
-void qa_gr_flowgraph::t2_connect_invalid_src_port_neg()
+BOOST_AUTO_TEST_CASE(t2_connect_invalid_src_port_neg)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- CPPUNIT_ASSERT_THROW(fg->connect(nop1, -1, nop2, 0), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->connect(nop1, -1, nop2, 0), std::invalid_argument);
}
-void qa_gr_flowgraph::t3_connect_src_port_exceeds()
+BOOST_AUTO_TEST_CASE(t3_connect_src_port_exceeds)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
gr::block_sptr src = gr::blocks::null_qa_source::make(sizeof(int));
gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
- CPPUNIT_ASSERT_THROW(fg->connect(src, 1, dst, 0), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->connect(src, 1, dst, 0), std::invalid_argument);
}
-void qa_gr_flowgraph::t4_connect_invalid_dst_port_neg()
+BOOST_AUTO_TEST_CASE(t4_connect_invalid_dst_port_neg)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(int));
gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- CPPUNIT_ASSERT_THROW(fg->connect(nop1, 0, nop2, -1), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->connect(nop1, 0, nop2, -1), std::invalid_argument);
}
-void qa_gr_flowgraph::t5_connect_dst_port_exceeds()
+BOOST_AUTO_TEST_CASE(t5_connect_dst_port_exceeds)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
gr::block_sptr src = gr::blocks::null_source::make(sizeof(int));
gr::block_sptr dst = gr::blocks::null_qa_sink::make(sizeof(int));
- CPPUNIT_ASSERT_THROW(fg->connect(src, 0, dst, 1), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->connect(src, 0, dst, 1), std::invalid_argument);
}
-void qa_gr_flowgraph::t6_connect_dst_in_use()
+BOOST_AUTO_TEST_CASE(t6_connect_dst_in_use)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
@@ -144,10 +144,10 @@ void qa_gr_flowgraph::t6_connect_dst_in_use()
gr::block_sptr dst = gr::blocks::null_sink::make(sizeof(int));
fg->connect(src1, 0, dst, 0);
- CPPUNIT_ASSERT_THROW(fg->connect(src2, 0, dst, 0), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->connect(src2, 0, dst, 0), std::invalid_argument);
}
-void qa_gr_flowgraph::t7_connect_one_src_two_dst()
+BOOST_AUTO_TEST_CASE(t7_connect_one_src_two_dst)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
@@ -159,17 +159,17 @@ void qa_gr_flowgraph::t7_connect_one_src_two_dst()
fg->connect(src, 0, dst2, 0);
}
-void qa_gr_flowgraph::t8_connect_type_mismatch()
+BOOST_AUTO_TEST_CASE(t8_connect_type_mismatch)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
gr::block_sptr nop1 = gr::blocks::nop::make(sizeof(char));
gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
- CPPUNIT_ASSERT_THROW(fg->connect(nop1, 0, nop2, 0), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->connect(nop1, 0, nop2, 0), std::invalid_argument);
}
-void qa_gr_flowgraph::t9_disconnect()
+BOOST_AUTO_TEST_CASE(t9_disconnect)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
@@ -180,7 +180,7 @@ void qa_gr_flowgraph::t9_disconnect()
fg->disconnect(nop1, 0, nop2, 0);
}
-void qa_gr_flowgraph::t10_disconnect_unconnected_block()
+BOOST_AUTO_TEST_CASE(t10_disconnect_unconnected_block)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
@@ -189,10 +189,10 @@ void qa_gr_flowgraph::t10_disconnect_unconnected_block()
gr::block_sptr nop3 = gr::blocks::nop::make(sizeof(int));
fg->connect(nop1, 0, nop2, 0);
- CPPUNIT_ASSERT_THROW(fg->disconnect(nop1, 0, nop3, 0), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->disconnect(nop1, 0, nop3, 0), std::invalid_argument);
}
-void qa_gr_flowgraph::t11_disconnect_unconnected_port()
+BOOST_AUTO_TEST_CASE(t11_disconnect_unconnected_port)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
@@ -200,10 +200,10 @@ void qa_gr_flowgraph::t11_disconnect_unconnected_port()
gr::block_sptr nop2 = gr::blocks::nop::make(sizeof(int));
fg->connect(nop1, 0, nop2, 0);
- CPPUNIT_ASSERT_THROW(fg->disconnect(nop1, 0, nop2, 1), std::invalid_argument);
+ BOOST_REQUIRE_THROW(fg->disconnect(nop1, 0, nop2, 1), std::invalid_argument);
}
-void qa_gr_flowgraph::t12_validate()
+BOOST_AUTO_TEST_CASE(t12_validate)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
@@ -214,7 +214,7 @@ void qa_gr_flowgraph::t12_validate()
fg->validate();
}
-void qa_gr_flowgraph::t13_validate_missing_input_assignment()
+BOOST_AUTO_TEST_CASE(t13_validate_missing_input_assignment)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
@@ -223,10 +223,10 @@ void qa_gr_flowgraph::t13_validate_missing_input_assignment()
fg->connect(nop1, 0, nop2, 0);
fg->connect(nop1, 0, nop2, 2);
- CPPUNIT_ASSERT_THROW(fg->validate(), std::runtime_error);
+ BOOST_REQUIRE_THROW(fg->validate(), std::runtime_error);
}
-void qa_gr_flowgraph::t14_validate_missing_output_assignment()
+BOOST_AUTO_TEST_CASE(t14_validate_missing_output_assignment)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
@@ -235,10 +235,10 @@ void qa_gr_flowgraph::t14_validate_missing_output_assignment()
fg->connect(nop1, 0, nop2, 0);
fg->connect(nop1, 2, nop2, 1);
- CPPUNIT_ASSERT_THROW(fg->validate(), std::runtime_error);
+ BOOST_REQUIRE_THROW(fg->validate(), std::runtime_error);
}
-void qa_gr_flowgraph::t15_clear()
+BOOST_AUTO_TEST_CASE(t15_clear)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
@@ -247,16 +247,16 @@ void qa_gr_flowgraph::t15_clear()
fg->connect(nop1, 0, nop2, 0);
- CPPUNIT_ASSERT(fg->edges().size() == 1);
- CPPUNIT_ASSERT(fg->calc_used_blocks().size() == 2);
+ BOOST_REQUIRE(fg->edges().size() == 1);
+ BOOST_REQUIRE(fg->calc_used_blocks().size() == 2);
fg->clear();
- CPPUNIT_ASSERT(fg->edges().size() == 0);
- CPPUNIT_ASSERT(fg->calc_used_blocks().size() == 0);
+ BOOST_REQUIRE(fg->edges().size() == 0);
+ BOOST_REQUIRE(fg->calc_used_blocks().size() == 0);
}
-void qa_gr_flowgraph::t16_partition()
+BOOST_AUTO_TEST_CASE(t16_partition)
{
gr::flowgraph_sptr fg = gr::make_flowgraph();
@@ -286,8 +286,8 @@ void qa_gr_flowgraph::t16_partition()
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);
+ BOOST_REQUIRE(graphs.size() == 3);
+ BOOST_REQUIRE(graphs[0].size() == 4);
+ BOOST_REQUIRE(graphs[1].size() == 3);
+ BOOST_REQUIRE(graphs[2].size() == 2);
}
diff --git a/gr-blocks/lib/qa_gr_flowgraph.h b/gr-blocks/lib/qa_gr_flowgraph.h
deleted file mode 100644
index 2c2686f71b..0000000000
--- a/gr-blocks/lib/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/gr-blocks/lib/qa_gr_hier_block2.cc b/gr-blocks/lib/qa_gr_hier_block2.cc
index bf9a167b14..fcc9e6fdc9 100644
--- a/gr-blocks/lib/qa_gr_hier_block2.cc
+++ b/gr-blocks/lib/qa_gr_hier_block2.cc
@@ -24,32 +24,30 @@
#include <config.h>
#endif
-#include <qa_gr_hier_block2.h>
#include <gnuradio/hier_block2.h>
#include <gnuradio/io_signature.h>
+#include <boost/test/unit_test.hpp>
-void qa_hier_block2::test_make()
+BOOST_AUTO_TEST_CASE(test_make)
{
gr::hier_block2_sptr src1(gr::make_hier_block2("test",
gr::io_signature::make(1, 1, 1 * sizeof(int)),
gr::io_signature::make(1, 1, 1 * sizeof(int))));
- CPPUNIT_ASSERT(src1);
- CPPUNIT_ASSERT_EQUAL(std::string("test"), src1->name());
+ BOOST_REQUIRE(src1);
+ BOOST_REQUIRE_EQUAL(std::string("test"), src1->name());
- CPPUNIT_ASSERT_EQUAL(1 * (int) sizeof(int),
+ BOOST_REQUIRE_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());
+ BOOST_REQUIRE_EQUAL(1, src1->input_signature()->min_streams());
+ BOOST_REQUIRE_EQUAL(1, src1->input_signature()->max_streams());
- CPPUNIT_ASSERT_EQUAL(1 * (int) sizeof(int),
+ BOOST_REQUIRE_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());
-
+ BOOST_REQUIRE_EQUAL(1, src1->output_signature()->min_streams());
+ BOOST_REQUIRE_EQUAL(1, src1->output_signature()->max_streams());
}
-
diff --git a/gr-blocks/lib/qa_gr_hier_block2.h b/gr-blocks/lib/qa_gr_hier_block2.h
deleted file mode 100644
index 34a77256c6..0000000000
--- a/gr-blocks/lib/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_hier_block2 : public CppUnit::TestCase
-{
- CPPUNIT_TEST_SUITE(qa_hier_block2);
-
- CPPUNIT_TEST(test_make);
-
- CPPUNIT_TEST_SUITE_END();
-
-private:
- void test_make();
-};
-
-#endif /* INCLUDED_QA_GR_HIER_BLOCK2_H */
diff --git a/gr-blocks/lib/qa_gr_hier_block2_derived.cc b/gr-blocks/lib/qa_gr_hier_block2_derived.cc
index 1d45c89233..519a23d97e 100644
--- a/gr-blocks/lib/qa_gr_hier_block2_derived.cc
+++ b/gr-blocks/lib/qa_gr_hier_block2_derived.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2008,2013 Free Software Foundation, Inc.
+ * Copyright 2006,2008,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -24,13 +24,13 @@
#include <config.h>
#endif
-#include <qa_gr_hier_block2_derived.h>
#include <gnuradio/top_block.h>
#include <gnuradio/io_signature.h>
#include <gnuradio/blocks/null_source.h>
#include <gnuradio/blocks/null_sink.h>
#include <gnuradio/blocks/head.h>
#include <gnuradio/blocks/copy.h>
+#include <boost/test/unit_test.hpp>
// Declare a test C++ hierarchical block
@@ -70,7 +70,7 @@ gr_derived_block::~gr_derived_block()
{
}
-void qa_hier_block2_derived::test_1()
+BOOST_AUTO_TEST_CASE(test_1)
{
gr::top_block_sptr tb(gr::make_top_block("test"));
diff --git a/gr-blocks/lib/qa_gr_hier_block2_derived.h b/gr-blocks/lib/qa_gr_hier_block2_derived.h
deleted file mode 100644
index 2c0a74356f..0000000000
--- a/gr-blocks/lib/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_hier_block2_derived : public CppUnit::TestCase
-{
- CPPUNIT_TEST_SUITE(qa_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/gr-blocks/lib/qa_gr_top_block.cc b/gr-blocks/lib/qa_gr_top_block.cc
index 39709d23d2..7c456e312a 100644
--- a/gr-blocks/lib/qa_gr_top_block.cc
+++ b/gr-blocks/lib/qa_gr_top_block.cc
@@ -24,26 +24,26 @@
#include <config.h>
#endif
-#include <qa_gr_top_block.h>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/head.h>
#include <gnuradio/blocks/nop.h>
#include <gnuradio/blocks/null_source.h>
#include <gnuradio/blocks/null_sink.h>
+#include <boost/test/unit_test.hpp>
#include <iostream>
#define VERBOSE 0
-void qa_top_block::t0()
+BOOST_AUTO_TEST_CASE(t0)
{
if (VERBOSE) std::cout << "qa_top_block::t0()\n";
gr::top_block_sptr tb = gr::make_top_block("top");
- CPPUNIT_ASSERT(tb);
+ BOOST_REQUIRE(tb);
}
-void qa_top_block::t1_run()
+BOOST_AUTO_TEST_CASE(t1_run)
{
if (VERBOSE) std::cout << "qa_top_block::t1()\n";
@@ -58,7 +58,7 @@ void qa_top_block::t1_run()
tb->run();
}
-void qa_top_block::t2_start_stop_wait()
+BOOST_AUTO_TEST_CASE(t2_start_stop_wait)
{
if(VERBOSE)
std::cout << "qa_top_block::t2()\n";
@@ -77,7 +77,7 @@ void qa_top_block::t2_start_stop_wait()
tb->wait();
}
-void qa_top_block::t3_lock_unlock()
+BOOST_AUTO_TEST_CASE(t3_lock_unlock)
{
if(VERBOSE)
std::cout << "qa_top_block::t3()\n";
@@ -98,7 +98,7 @@ void qa_top_block::t3_lock_unlock()
tb->wait();
}
-void qa_top_block::t4_reconfigure()
+BOOST_AUTO_TEST_CASE(t4_reconfigure)
{
if(VERBOSE)
std::cout << "qa_top_block::t4()\n";
@@ -125,7 +125,7 @@ void qa_top_block::t4_reconfigure()
}
-void qa_top_block::t5_max_noutputs()
+BOOST_AUTO_TEST_CASE(t5_max_noutputs)
{
if(VERBOSE)
std::cout << "qa_top_block::t5()\n";
@@ -143,7 +143,7 @@ void qa_top_block::t5_max_noutputs()
tb->wait();
}
-void qa_top_block::t6_reconfig_max_noutputs()
+BOOST_AUTO_TEST_CASE(t6_reconfig_max_noutputs)
{
if(VERBOSE)
std::cout << "qa_top_block::t6()\n";
@@ -171,7 +171,7 @@ void qa_top_block::t6_reconfig_max_noutputs()
tb->wait();
}
-void qa_top_block::t7_max_noutputs_per_block()
+BOOST_AUTO_TEST_CASE(t7_max_noutputs_per_block)
{
if(VERBOSE)
std::cout << "qa_top_block::t7()\n";
@@ -191,7 +191,7 @@ void qa_top_block::t7_max_noutputs_per_block()
tb->wait();
}
-void qa_top_block::t8_reconfig_max_noutputs_per_block()
+BOOST_AUTO_TEST_CASE(t8_reconfig_max_noutputs_per_block)
{
if(VERBOSE)
std::cout << "qa_top_block::t8()\n";
@@ -221,7 +221,7 @@ void qa_top_block::t8_reconfig_max_noutputs_per_block()
tb->wait();
}
-void qa_top_block::t9_max_output_buffer()
+BOOST_AUTO_TEST_CASE(t9_max_output_buffer)
{
if(VERBOSE)
std::cout << "qa_top_block::t9()\n";
@@ -241,7 +241,7 @@ void qa_top_block::t9_max_output_buffer()
tb->wait();
}
-void qa_top_block::t10_reconfig_max_output_buffer()
+BOOST_AUTO_TEST_CASE(t10_reconfig_max_output_buffer)
{
if(VERBOSE)
std::cout << "qa_top_block::t10()\n";
@@ -272,7 +272,7 @@ void qa_top_block::t10_reconfig_max_output_buffer()
tb->wait();
}
-void qa_top_block::t11_set_block_affinity()
+BOOST_AUTO_TEST_CASE(t11_set_block_affinity)
{
gr::top_block_sptr tb = gr::make_top_block("top");
gr::block_sptr src (gr::blocks::null_source::make(sizeof(float)));
@@ -290,5 +290,5 @@ void qa_top_block::t11_set_block_affinity()
// We only set the core affinity to 0 because we always know at
// least one thread core exists to use.
- CPPUNIT_ASSERT_EQUAL(set[0], ret[0]);
+ BOOST_CHECK_EQUAL(set[0], ret[0]);
}
diff --git a/gr-blocks/lib/qa_gr_top_block.h b/gr-blocks/lib/qa_gr_top_block.h
deleted file mode 100644
index e3ea3227e9..0000000000
--- a/gr-blocks/lib/qa_gr_top_block.h
+++ /dev/null
@@ -1,66 +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_top_block : public CppUnit::TestCase
-{
- CPPUNIT_TEST_SUITE(qa_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(t5_max_noutputs);
- CPPUNIT_TEST(t6_reconfig_max_noutputs);
- CPPUNIT_TEST(t7_max_noutputs_per_block);
- CPPUNIT_TEST(t8_reconfig_max_noutputs_per_block);
- CPPUNIT_TEST(t9_max_output_buffer);
- CPPUNIT_TEST(t10_reconfig_max_output_buffer);
- CPPUNIT_TEST(t11_set_block_affinity);
-
- CPPUNIT_TEST_SUITE_END();
-
-private:
-
- void t0();
- void t1_run();
- void t2_start_stop_wait();
- void t3_lock_unlock();
- void t4_reconfigure();
- void t5_max_noutputs();
- void t6_reconfig_max_noutputs();
- void t7_max_noutputs_per_block();
- void t8_reconfig_max_noutputs_per_block();
- void t9_max_output_buffer();
- void t10_reconfig_max_output_buffer();
- void t11_set_block_affinity();
-
-};
-
-#endif /* INCLUDED_QA_GR_TOP_BLOCK_H */
diff --git a/gr-blocks/lib/qa_rotator.cc b/gr-blocks/lib/qa_rotator.cc
index 829d6e26eb..a39a2bd0fa 100644
--- a/gr-blocks/lib/qa_rotator.cc
+++ b/gr-blocks/lib/qa_rotator.cc
@@ -24,15 +24,12 @@
#include <config.h>
#endif
-#include <qa_rotator.h>
-
+#include <boost/test/unit_test.hpp>
#include <gnuradio/attributes.h>
-#include <cppunit/TestAssert.h>
#include <gnuradio/blocks/rotator.h>
#include <gnuradio/expj.h>
#include <gnuradio/math.h>
-#include <cstdio>
#include <cmath>
// error vector magnitude
@@ -42,8 +39,7 @@ error_vector_mag(gr_complex a, gr_complex b)
return abs(a-b);
}
-void
-qa_rotator::t1()
+BOOST_AUTO_TEST_CASE(t1)
{
static const unsigned int N = 100000;
@@ -63,13 +59,7 @@ qa_rotator::t1()
gr_complex expected = gr_expj(phase);
gr_complex actual = r.rotate(gr_complex(1, 0));
-#if 0
- float evm = error_vector_mag(expected, actual);
- printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n",
- i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm);
-#endif
-
- CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001);
+ BOOST_CHECK(std::abs(expected - actual) <= 0.0001);
phase += phase_incr;
if(phase >= 2*GR_M_PI)
@@ -77,8 +67,7 @@ qa_rotator::t1()
}
}
-void
-qa_rotator::t2()
+BOOST_AUTO_TEST_CASE(t2)
{
static const unsigned int N = 100000;
@@ -104,13 +93,7 @@ qa_rotator::t2()
gr_complex expected = gr_expj(phase);
gr_complex actual = output[i];
-#if 0
- float evm = error_vector_mag(expected, actual);
- printf("[%6d] expected: (%8.6f, %8.6f) actual: (%8.6f, %8.6f) evm: %8.6f\n",
- i, expected.real(), expected.imag(), actual.real(), actual.imag(), evm);
-#endif
-
- CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected, actual, 0.0001);
+ BOOST_CHECK(std::abs(expected - actual) <= 0.0001);
phase += phase_incr;
if(phase >= 2*GR_M_PI)
diff --git a/gr-blocks/lib/qa_rotator.h b/gr-blocks/lib/qa_rotator.h
deleted file mode 100644
index 96fe9628b9..0000000000
--- a/gr-blocks/lib/qa_rotator.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2008,2013 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_ROTATOR_H_
-#define _QA_GR_ROTATOR_H_
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/TestCase.h>
-
-class qa_rotator : public CppUnit::TestCase
-{
- CPPUNIT_TEST_SUITE(qa_rotator);
- CPPUNIT_TEST(t1);
- CPPUNIT_TEST(t2);
- CPPUNIT_TEST_SUITE_END();
-
- private:
- void t1();
- void t2();
-};
-
-#endif /* _QA_GR_ROTATOR_H_ */
diff --git a/gr-blocks/lib/qa_set_msg_handler.cc b/gr-blocks/lib/qa_set_msg_handler.cc
index c5b463ca63..94bd6e4249 100644
--- a/gr-blocks/lib/qa_set_msg_handler.cc
+++ b/gr-blocks/lib/qa_set_msg_handler.cc
@@ -24,23 +24,22 @@
#include <config.h>
#endif
-#include <qa_set_msg_handler.h>
#include <gnuradio/top_block.h>
#include <gnuradio/blocks/head.h>
#include <gnuradio/blocks/null_source.h>
#include <gnuradio/blocks/null_sink.h>
#include <gnuradio/blocks/nop.h>
#include <gnuradio/messages/msg_passing.h>
-#include <iostream>
#include <boost/thread/thread.hpp>
+#include <boost/test/unit_test.hpp>
+#include <iostream>
/*
* The gr::block::nop block has been instrumented so that it counts
* the number of messages sent to it. We use this feature to confirm
* that gr::blocks::nop's call to set_msg_handler is working correctly.
*/
-
-void qa_set_msg_handler::t0()
+BOOST_AUTO_TEST_CASE(t0)
{
static const int NMSGS = 10;
@@ -68,5 +67,5 @@ void qa_set_msg_handler::t0()
tb->wait();
// Confirm that the nop block received the right number of messages.
- CPPUNIT_ASSERT_EQUAL(NMSGS, nop->nmsgs_received());
+ BOOST_CHECK_EQUAL(NMSGS, nop->nmsgs_received());
}
diff --git a/gr-blocks/lib/qa_set_msg_handler.h b/gr-blocks/lib/qa_set_msg_handler.h
deleted file mode 100644
index 60277a12cc..0000000000
--- a/gr-blocks/lib/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 */
diff --git a/gr-blocks/lib/random_pdu_impl.cc b/gr-blocks/lib/random_pdu_impl.cc
index 91a404c5dd..9dfc761a2b 100644
--- a/gr-blocks/lib/random_pdu_impl.cc
+++ b/gr-blocks/lib/random_pdu_impl.cc
@@ -48,7 +48,7 @@ namespace gr {
d_mask(byte_mask),
d_length_modulo(length_modulo)
{
- message_port_register_out(PDU_PORT_ID);
+ message_port_register_out(pdu::pdu_port_id());
message_port_register_in(pmt::mp("generate"));
set_msg_handler(pmt::mp("generate"), boost::bind(&random_pdu_impl::generate_pdu, this, _1));
if(length_modulo < 1)
@@ -80,7 +80,7 @@ namespace gr {
pmt::pmt_t vecpmt(pmt::make_blob(&vec[0], len));
pmt::pmt_t pdu(pmt::cons(pmt::PMT_NIL, vecpmt));
- message_port_pub(PDU_PORT_ID, pdu);
+ message_port_pub(pdu::pdu_port_id(), pdu);
}
} /* namespace blocks */
diff --git a/gr-blocks/lib/repack_bits_bb_impl.cc b/gr-blocks/lib/repack_bits_bb_impl.cc
index c20c99786a..a8185a95dc 100644
--- a/gr-blocks/lib/repack_bits_bb_impl.cc
+++ b/gr-blocks/lib/repack_bits_bb_impl.cc
@@ -55,7 +55,7 @@ namespace gr {
throw std::invalid_argument("k and l must be in [1, 8]");
}
- set_relative_rate((double) d_k / d_l);
+ set_relative_rate((uint64_t) d_k, (uint64_t) d_l);
}
void
@@ -64,7 +64,7 @@ namespace gr {
gr::thread::scoped_lock guard(d_setlock);
d_k = k;
d_l = l;
- set_relative_rate((double) d_k / d_l);
+ set_relative_rate((uint64_t) d_k, (uint64_t) d_l);
}
repack_bits_bb_impl::~repack_bits_bb_impl()
diff --git a/gr-blocks/lib/skiphead_impl.cc b/gr-blocks/lib/skiphead_impl.cc
index da9cb11280..0a1685b732 100644
--- a/gr-blocks/lib/skiphead_impl.cc
+++ b/gr-blocks/lib/skiphead_impl.cc
@@ -44,6 +44,12 @@ namespace gr {
io_signature::make(1, 1, itemsize)),
d_nitems_to_skip(nitems_to_skip), d_nitems(0)
{
+ // Reserve space for a few tags to avoid constant re-allocation
+ // in the call to get_tags_in_window
+ d_tags.reserve(8);
+
+ // We'll handle propagating tags our selves to handle shifting offsets of tags
+ set_tag_propagation_policy(TPP_DONT);
}
skiphead_impl::~skiphead_impl()
@@ -71,7 +77,13 @@ namespace gr {
ii += n_to_skip;
}
- else { // nothing left to skip. copy away
+ else { // nothing left to skip. copy away
+ // Grab all tags in the window and shift their offsets appropriately
+ get_tags_in_window(d_tags, 0, ii, ninput_items);
+ for(std::vector<tag_t>::iterator it = d_tags.begin(); it != d_tags.end(); it++) {
+ (*it).offset -= d_nitems_to_skip;
+ add_item_tag(0, *it);
+ }
int n_to_copy = ninput_items - ii;
if(n_to_copy > 0) {
size_t itemsize = output_signature()->sizeof_stream_item(0);
diff --git a/gr-blocks/lib/skiphead_impl.h b/gr-blocks/lib/skiphead_impl.h
index db4df50adb..738fa86a61 100644
--- a/gr-blocks/lib/skiphead_impl.h
+++ b/gr-blocks/lib/skiphead_impl.h
@@ -33,6 +33,7 @@ namespace gr {
private:
uint64_t d_nitems_to_skip;
uint64_t d_nitems; // total items seen
+ std::vector<tag_t> d_tags;
public:
skiphead_impl(size_t itemsize, uint64_t nitems_to_skip);
diff --git a/gr-blocks/lib/socket_pdu_impl.cc b/gr-blocks/lib/socket_pdu_impl.cc
index efb778f404..e20f1478f0 100644
--- a/gr-blocks/lib/socket_pdu_impl.cc
+++ b/gr-blocks/lib/socket_pdu_impl.cc
@@ -46,8 +46,8 @@ namespace gr {
{
d_rxbuf.resize(MTU);
- message_port_register_in(PDU_PORT_ID);
- message_port_register_out(PDU_PORT_ID);
+ message_port_register_in(pdu::pdu_port_id());
+ message_port_register_out(pdu::pdu_port_id());
if ((type == "TCP_SERVER") && ((addr.empty()) || (addr == "0.0.0.0"))) { // Bind on all interfaces
int port_num = atoi(port.c_str());
@@ -86,7 +86,7 @@ namespace gr {
start_tcp_accept();
- set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::tcp_server_send, this, _1));
+ set_msg_handler(pdu::pdu_port_id(), boost::bind(&socket_pdu_impl::tcp_server_send, this, _1));
}
else if (type =="TCP_CLIENT") {
boost::system::error_code error = boost::asio::error::host_not_found;
@@ -96,7 +96,7 @@ namespace gr {
throw boost::system::system_error(error);
d_tcp_socket->set_option(boost::asio::ip::tcp::no_delay(d_tcp_no_delay));
- set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::tcp_client_send, this, _1));
+ set_msg_handler(pdu::pdu_port_id(), boost::bind(&socket_pdu_impl::tcp_client_send, this, _1));
d_tcp_socket->async_read_some(boost::asio::buffer(d_rxbuf),
boost::bind(&socket_pdu_impl::handle_tcp_read, this,
@@ -110,7 +110,7 @@ namespace gr {
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
- set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::udp_send, this, _1));
+ set_msg_handler(pdu::pdu_port_id(), boost::bind(&socket_pdu_impl::udp_send, this, _1));
}
else if (type =="UDP_CLIENT") {
d_udp_socket.reset(new boost::asio::ip::udp::socket(d_io_service, d_udp_endpoint));
@@ -119,7 +119,7 @@ namespace gr {
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred));
- set_msg_handler(PDU_PORT_ID, boost::bind(&socket_pdu_impl::udp_send, this, _1));
+ set_msg_handler(pdu::pdu_port_id(), boost::bind(&socket_pdu_impl::udp_send, this, _1));
}
else
throw std::runtime_error("gr::blocks:socket_pdu: unknown socket type");
@@ -151,7 +151,7 @@ namespace gr {
if (!error) {
pmt::pmt_t vector = pmt::init_u8vector(bytes_transferred, (const uint8_t *)&d_rxbuf[0]);
pmt::pmt_t pdu = pmt::cons(pmt::PMT_NIL, vector);
- message_port_pub(PDU_PORT_ID, pdu);
+ message_port_pub(pdu::pdu_port_id(), pdu);
d_tcp_socket->async_read_some(boost::asio::buffer(d_rxbuf),
boost::bind(&socket_pdu_impl::handle_tcp_read, this,
@@ -231,7 +231,7 @@ namespace gr {
memcpy(&txbuf[0], pmt::uniform_vector_elements(vector, offset), send_len);
offset += send_len;
d_udp_socket->send_to(boost::asio::buffer(txbuf, send_len), d_udp_endpoint_other);
- }
+ }
}
void
@@ -241,7 +241,7 @@ namespace gr {
pmt::pmt_t vector = pmt::init_u8vector(bytes_transferred, (const uint8_t*)&d_rxbuf[0]);
pmt::pmt_t pdu = pmt::cons(pmt::PMT_NIL, vector);
- message_port_pub(PDU_PORT_ID, pdu);
+ message_port_pub(pdu::pdu_port_id(), pdu);
d_udp_socket->async_receive_from(boost::asio::buffer(d_rxbuf), d_udp_endpoint_other,
boost::bind(&socket_pdu_impl::handle_udp_read, this,
diff --git a/gr-blocks/lib/tagged_stream_multiply_length_impl.cc b/gr-blocks/lib/tagged_stream_multiply_length_impl.cc
index e9699d28f5..266b967e69 100644
--- a/gr-blocks/lib/tagged_stream_multiply_length_impl.cc
+++ b/gr-blocks/lib/tagged_stream_multiply_length_impl.cc
@@ -45,7 +45,7 @@ namespace gr {
d_itemsize(itemsize)
{
set_tag_propagation_policy(TPP_DONT);
- set_relative_rate(1);
+ set_relative_rate(1, 1);
message_port_register_in(pmt::intern("set_scalar"));
set_msg_handler(pmt::intern("set_scalar"),
boost::bind(&tagged_stream_multiply_length_impl::set_scalar_pmt, this, _1));
diff --git a/gr-blocks/lib/tagged_stream_mux_impl.cc b/gr-blocks/lib/tagged_stream_mux_impl.cc
index ac2d1c2203..90587639ce 100644
--- a/gr-blocks/lib/tagged_stream_mux_impl.cc
+++ b/gr-blocks/lib/tagged_stream_mux_impl.cc
@@ -74,7 +74,7 @@ namespace gr {
unsigned char *out = (unsigned char *) output_items[0];
int n_produced = 0;
- set_relative_rate(ninput_items.size());
+ set_relative_rate((uint64_t)ninput_items.size(), 1);
for (unsigned int i = 0; i < input_items.size(); i++) {
const unsigned char *in = (const unsigned char *) input_items[i];
diff --git a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc
index 04871aef8f..feada488c7 100644
--- a/gr-blocks/lib/tagged_stream_to_pdu_impl.cc
+++ b/gr-blocks/lib/tagged_stream_to_pdu_impl.cc
@@ -45,7 +45,7 @@ namespace gr {
d_pdu_meta(pmt::PMT_NIL),
d_pdu_vector(pmt::PMT_NIL)
{
- message_port_register_out(PDU_PORT_ID);
+ message_port_register_out(pdu::pdu_port_id());
}
int
@@ -71,7 +71,7 @@ namespace gr {
// Send msg
pmt::pmt_t msg = pmt::cons(d_pdu_meta, d_pdu_vector);
- message_port_pub(PDU_PORT_ID, msg);
+ message_port_pub(pdu::pdu_port_id(), msg);
return ninput_items[0];
}
diff --git a/gr-blocks/lib/tcp_connection.cc b/gr-blocks/lib/tcp_connection.cc
index 200e82b89f..4c0dfc27ac 100644
--- a/gr-blocks/lib/tcp_connection.cc
+++ b/gr-blocks/lib/tcp_connection.cc
@@ -94,7 +94,7 @@ namespace gr {
pmt::pmt_t vector = pmt::init_u8vector(bytes_transferred, (const uint8_t*)&d_buf[0]);
pmt::pmt_t pdu = pmt::cons(pmt::PMT_NIL, vector);
- d_block->message_port_pub(PDU_PORT_ID, pdu);
+ d_block->message_port_pub(pdu::pdu_port_id(), pdu);
}
d_socket.async_read_some(boost::asio::buffer(d_buf),
diff --git a/gr-blocks/lib/test_gr_blocks.cc b/gr-blocks/lib/test_gr_blocks.cc
deleted file mode 100644
index bc3901dac3..0000000000
--- a/gr-blocks/lib/test_gr_blocks.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-/* -*- c++ -*- */
-/*
- * Copyright 2012-2013 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 <cppunit/TextTestRunner.h>
-#include <cppunit/XmlOutputter.h>
-
-#include <gnuradio/unittests.h>
-#include <qa_blocks.h>
-#include <iostream>
-#include <fstream>
-
-int
-main(int argc, char **argv)
-{
- CppUnit::TextTestRunner runner;
- std::ofstream xmlfile(get_unittest_path("blocks.xml").c_str());
- CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile);
-
- runner.addTest(qa_blocks::suite());
- runner.setOutputter(xmlout);
-
- bool was_successful = runner.run("", false);
-
- return was_successful ? 0 : 1;
-}
diff --git a/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc b/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc
index ec239c9fa7..cc9e1eeab9 100644
--- a/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc
+++ b/gr-blocks/lib/test_tag_variable_rate_ff_impl.cc
@@ -26,10 +26,12 @@
#include "test_tag_variable_rate_ff_impl.h"
#include <gnuradio/io_signature.h>
+#include <gnuradio/xoroshiro128p.h>
#include <string.h>
#include <iostream>
#include <iomanip>
#include <stdexcept>
+#include <stdint.h>
using namespace pmt;
@@ -50,18 +52,14 @@ namespace gr {
d_update_once(update_once), d_update_step(update_step)
{
set_tag_propagation_policy(TPP_DONT);
- set_relative_rate(0.5);
+ set_relative_rate(1, 2);
d_accum = 0;
d_rrate = 0.5;
d_old_in = 0;
d_new_in = 0;
d_last_out = 0;
-#ifdef HAVE_RAND48
- srand48(time(NULL));
-#else
- srand(time(NULL));
-#endif
+ xoroshiro128p_seed(d_rng_state, 4 /* chosen by fair dice roll */);
}
test_tag_variable_rate_ff_impl::~test_tag_variable_rate_ff_impl()
@@ -82,11 +80,7 @@ namespace gr {
GR_LOG_DEBUG(d_logger, boost::format("noutput_items: %1%") % noutput_items);
if(d_update_once) {
-#ifdef HAVE_RAND48
- if(drand48() > 0.5) {
-#else
- if (rand() > RAND_MAX / 2) {
-#endif
+ if (xoroshiro128p_next(d_rng_state) > (UINT64_MAX / 2)){
d_rrate += d_update_step;
}
else {
@@ -103,11 +97,7 @@ namespace gr {
while(i < ninput_items[0]) {
if(!d_update_once) {
-#ifdef HAVE_RAND48
- if(drand48() > 0.5) {
-#else
- if (rand() > RAND_MAX / 2) {
-#endif
+ if (xoroshiro128p_next(d_rng_state) > (UINT64_MAX / 2)){
d_rrate += d_update_step;
}
else {
diff --git a/gr-blocks/lib/test_tag_variable_rate_ff_impl.h b/gr-blocks/lib/test_tag_variable_rate_ff_impl.h
index 0335ab6e66..a02bce1ccf 100644
--- a/gr-blocks/lib/test_tag_variable_rate_ff_impl.h
+++ b/gr-blocks/lib/test_tag_variable_rate_ff_impl.h
@@ -36,6 +36,7 @@ namespace gr {
double d_accum;
double d_rrate;
uint64_t d_old_in, d_new_in, d_last_out;
+ uint64_t d_rng_state[2];
public:
test_tag_variable_rate_ff_impl(bool update_once=false,
diff --git a/gr-blocks/lib/tuntap_pdu_impl.cc b/gr-blocks/lib/tuntap_pdu_impl.cc
index 7bd0889d5e..dd4ce90982 100644
--- a/gr-blocks/lib/tuntap_pdu_impl.cc
+++ b/gr-blocks/lib/tuntap_pdu_impl.cc
@@ -92,12 +92,12 @@ namespace gr {
) % dev % dev << std::endl;
// set up output message port
- message_port_register_out(PDU_PORT_ID);
- start_rxthread(this, PDU_PORT_ID);
+ message_port_register_out(pdu::pdu_port_id());
+ start_rxthread(this, pdu::pdu_port_id());
// set up input message port
- message_port_register_in(PDU_PORT_ID);
- set_msg_handler(PDU_PORT_ID, boost::bind(&tuntap_pdu_impl::send, this, _1));
+ message_port_register_in(pdu::pdu_port_id());
+ set_msg_handler(pdu::pdu_port_id(), boost::bind(&tuntap_pdu_impl::send, this, _1));
}
int
diff --git a/gr-blocks/lib/unpacked_to_packed_impl.cc b/gr-blocks/lib/unpacked_to_packed_impl.cc
index 92240c516a..54bcfd3c0b 100644
--- a/gr-blocks/lib/unpacked_to_packed_impl.cc
+++ b/gr-blocks/lib/unpacked_to_packed_impl.cc
@@ -53,7 +53,7 @@ namespace gr {
assert(bits_per_chunk <= d_bits_per_type);
assert(bits_per_chunk > 0);
- this->set_relative_rate(bits_per_chunk/(1.0 * d_bits_per_type));
+ this->set_relative_rate((uint64_t)bits_per_chunk, (uint64_t)BITS_PER_TYPE);
}
template <class T>
diff --git a/gr-blocks/lib/vector_sink_impl.cc b/gr-blocks/lib/vector_sink_impl.cc
index 8a99b32b6d..f27ebd1668 100644
--- a/gr-blocks/lib/vector_sink_impl.cc
+++ b/gr-blocks/lib/vector_sink_impl.cc
@@ -36,19 +36,21 @@ namespace gr {
template <class T>
typename vector_sink<T>::sptr
- vector_sink<T>::make(int vlen)
+ vector_sink<T>::make(int vlen, const int reserve_items)
{
return gnuradio::get_initial_sptr
- (new vector_sink_impl<T> (vlen));
+ (new vector_sink_impl<T> (vlen, reserve_items));
}
template <class T>
- vector_sink_impl<T> ::vector_sink_impl(int vlen)
+ vector_sink_impl<T> ::vector_sink_impl(int vlen, const int reserve_items)
: sync_block("vector_sink",
io_signature::make(1, 1, sizeof(T) * vlen),
io_signature::make(0, 0, 0)),
d_vlen(vlen)
{
+ gr::thread::scoped_lock guard(d_data_mutex);
+ d_data.reserve(d_vlen * reserve_items);
}
template <class T>
diff --git a/gr-blocks/lib/vector_sink_impl.h b/gr-blocks/lib/vector_sink_impl.h
index be083b2213..23d177eea5 100644
--- a/gr-blocks/lib/vector_sink_impl.h
+++ b/gr-blocks/lib/vector_sink_impl.h
@@ -40,7 +40,7 @@ template<class T>
int d_vlen;
public:
- vector_sink_impl (int vlen);
+ vector_sink_impl (int vlen, const int reserve_items);
~vector_sink_impl ();
void reset();