diff options
author | Josh Blum <josh@joshknows.com> | 2011-11-07 18:47:29 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-11-07 18:47:29 -0800 |
commit | e219ad10a6e86cd4edc748f2218e01a9890e108c (patch) | |
tree | 372f2e426781de9885889bec6aa98697006268ec /host/tests | |
parent | 8ff8f206d317e8d9c026fef9228a80edc241f9d4 (diff) | |
parent | 11f1390bbde65c60f45962acb128cac1ce21e474 (diff) | |
download | uhd-e219ad10a6e86cd4edc748f2218e01a9890e108c.tar.gz uhd-e219ad10a6e86cd4edc748f2218e01a9890e108c.tar.bz2 uhd-e219ad10a6e86cd4edc748f2218e01a9890e108c.zip |
Merge branch 'uhd_next'
Diffstat (limited to 'host/tests')
-rw-r--r-- | host/tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/tests/convert_test.cpp | 148 | ||||
-rw-r--r-- | host/tests/ranges_test.cpp | 13 | ||||
-rw-r--r-- | host/tests/sph_recv_test.cpp | 165 | ||||
-rw-r--r-- | host/tests/sph_send_test.cpp | 44 | ||||
-rw-r--r-- | host/tests/wax_test.cpp | 104 |
6 files changed, 182 insertions, 293 deletions
diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt index c97116233..28cc1c5da 100644 --- a/host/tests/CMakeLists.txt +++ b/host/tests/CMakeLists.txt @@ -34,7 +34,6 @@ SET(test_sources subdev_spec_test.cpp time_spec_test.cpp vrt_test.cpp - wax_test.cpp ) #turn each test cpp file into an executable with an int main() function diff --git a/host/tests/convert_test.cpp b/host/tests/convert_test.cpp index d828ed64a..b63ff6752 100644 --- a/host/tests/convert_test.cpp +++ b/host/tests/convert_test.cpp @@ -41,8 +41,8 @@ typedef std::complex<double> fc64_t; **********************************************************************/ template <typename Range> static void loopback( size_t nsamps, - const io_type_t &io_type, - const otw_type_t &otw_type, + convert::id_type &in_id, + convert::id_type &out_id, const Range &input, Range &output ){ @@ -53,23 +53,17 @@ template <typename Range> static void loopback( std::vector<void *> output0(1, &interm[0]), output1(1, &output[0]); //convert to intermediate type - convert::get_converter_cpu_to_otw( - io_type, otw_type, input0.size(), output0.size() - )(input0, output0, nsamps, 32767.); + convert::get_converter(in_id)(input0, output0, nsamps, 32767.); //convert back to host type - convert::get_converter_otw_to_cpu( - io_type, otw_type, input1.size(), output1.size() - )(input1, output1, nsamps, 1/32767.); + convert::get_converter(out_id)(input1, output1, nsamps, 1/32767.); } /*********************************************************************** * Test short conversion **********************************************************************/ static void test_convert_types_sc16( - size_t nsamps, - const io_type_t &io_type, - const otw_type_t &otw_type + size_t nsamps, convert::id_type &id ){ //fill the input samples std::vector<sc16_t> input(nsamps), output(nsamps); @@ -79,31 +73,37 @@ static void test_convert_types_sc16( ); //run the loopback and test - loopback(nsamps, io_type, otw_type, input, output); + convert::id_type in_id = id; + convert::id_type out_id = id; + std::swap(out_id.input_format, out_id.output_format); + std::swap(out_id.num_inputs, out_id.num_outputs); + loopback(nsamps, in_id, out_id, input, output); BOOST_CHECK_EQUAL_COLLECTIONS(input.begin(), input.end(), output.begin(), output.end()); } BOOST_AUTO_TEST_CASE(test_convert_types_be_sc16){ - io_type_t io_type(io_type_t::COMPLEX_INT16); - otw_type_t otw_type; - otw_type.byteorder = otw_type_t::BO_BIG_ENDIAN; - otw_type.width = 16; + convert::id_type id; + id.input_format = "sc16"; + id.num_inputs = 1; + id.output_format = "sc16_item32_be"; + id.num_outputs = 1; //try various lengths to test edge cases for (size_t nsamps = 1; nsamps < 16; nsamps++){ - test_convert_types_sc16(nsamps, io_type, otw_type); + test_convert_types_sc16(nsamps, id); } } BOOST_AUTO_TEST_CASE(test_convert_types_le_sc16){ - io_type_t io_type(io_type_t::COMPLEX_INT16); - otw_type_t otw_type; - otw_type.byteorder = otw_type_t::BO_LITTLE_ENDIAN; - otw_type.width = 16; + convert::id_type id; + id.input_format = "sc16"; + id.num_inputs = 1; + id.output_format = "sc16_item32_le"; + id.num_outputs = 1; //try various lengths to test edge cases for (size_t nsamps = 1; nsamps < 16; nsamps++){ - test_convert_types_sc16(nsamps, io_type, otw_type); + test_convert_types_sc16(nsamps, id); } } @@ -112,9 +112,7 @@ BOOST_AUTO_TEST_CASE(test_convert_types_le_sc16){ **********************************************************************/ template <typename data_type> static void test_convert_types_for_floats( - size_t nsamps, - const io_type_t &io_type, - const otw_type_t &otw_type + size_t nsamps, convert::id_type &id ){ typedef typename data_type::value_type value_type; @@ -126,7 +124,11 @@ static void test_convert_types_for_floats( ); //run the loopback and test - loopback(nsamps, io_type, otw_type, input, output); + convert::id_type in_id = id; + convert::id_type out_id = id; + std::swap(out_id.input_format, out_id.output_format); + std::swap(out_id.num_inputs, out_id.num_outputs); + loopback(nsamps, in_id, out_id, input, output); for (size_t i = 0; i < nsamps; i++){ MY_CHECK_CLOSE(input[i].real(), output[i].real(), value_type(0.01)); MY_CHECK_CLOSE(input[i].imag(), output[i].imag(), value_type(0.01)); @@ -134,50 +136,54 @@ static void test_convert_types_for_floats( } BOOST_AUTO_TEST_CASE(test_convert_types_be_fc32){ - io_type_t io_type(io_type_t::COMPLEX_FLOAT32); - otw_type_t otw_type; - otw_type.byteorder = otw_type_t::BO_BIG_ENDIAN; - otw_type.width = 16; + convert::id_type id; + id.input_format = "fc32"; + id.num_inputs = 1; + id.output_format = "sc16_item32_be"; + id.num_outputs = 1; //try various lengths to test edge cases for (size_t nsamps = 1; nsamps < 16; nsamps++){ - test_convert_types_for_floats<fc32_t>(nsamps, io_type, otw_type); + test_convert_types_for_floats<fc32_t>(nsamps, id); } } BOOST_AUTO_TEST_CASE(test_convert_types_le_fc32){ - io_type_t io_type(io_type_t::COMPLEX_FLOAT32); - otw_type_t otw_type; - otw_type.byteorder = otw_type_t::BO_LITTLE_ENDIAN; - otw_type.width = 16; + convert::id_type id; + id.input_format = "fc32"; + id.num_inputs = 1; + id.output_format = "sc16_item32_le"; + id.num_outputs = 1; //try various lengths to test edge cases for (size_t nsamps = 1; nsamps < 16; nsamps++){ - test_convert_types_for_floats<fc32_t>(nsamps, io_type, otw_type); + test_convert_types_for_floats<fc32_t>(nsamps, id); } } BOOST_AUTO_TEST_CASE(test_convert_types_be_fc64){ - io_type_t io_type(io_type_t::COMPLEX_FLOAT64); - otw_type_t otw_type; - otw_type.byteorder = otw_type_t::BO_BIG_ENDIAN; - otw_type.width = 16; + convert::id_type id; + id.input_format = "fc64"; + id.num_inputs = 1; + id.output_format = "sc16_item32_be"; + id.num_outputs = 1; //try various lengths to test edge cases for (size_t nsamps = 1; nsamps < 16; nsamps++){ - test_convert_types_for_floats<fc64_t>(nsamps, io_type, otw_type); + test_convert_types_for_floats<fc64_t>(nsamps, id); } } BOOST_AUTO_TEST_CASE(test_convert_types_le_fc64){ - io_type_t io_type(io_type_t::COMPLEX_FLOAT64); - otw_type_t otw_type; - otw_type.byteorder = otw_type_t::BO_LITTLE_ENDIAN; - otw_type.width = 16; + convert::id_type id; + id.input_format = "fc64"; + id.num_inputs = 1; + id.output_format = "sc16_item32_le"; + id.num_outputs = 1; //try various lengths to test edge cases for (size_t nsamps = 1; nsamps < 16; nsamps++){ - test_convert_types_for_floats<fc64_t>(nsamps, io_type, otw_type); + test_convert_types_for_floats<fc64_t>(nsamps, id); } } @@ -185,12 +191,17 @@ BOOST_AUTO_TEST_CASE(test_convert_types_le_fc64){ * Test float to short conversion loopback **********************************************************************/ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){ - io_type_t io_type_in(io_type_t::COMPLEX_FLOAT32); - io_type_t io_type_out(io_type_t::COMPLEX_INT16); - - otw_type_t otw_type; - otw_type.byteorder = otw_type_t::BO_NATIVE; - otw_type.width = 16; + convert::id_type in_id; + in_id.input_format = "fc32"; + in_id.num_inputs = 1; + in_id.output_format = "sc16_item32_le"; + in_id.num_outputs = 1; + + convert::id_type out_id; + out_id.input_format = "sc16_item32_le"; + out_id.num_inputs = 1; + out_id.output_format = "sc16"; + out_id.num_outputs = 1; const size_t nsamps = 13; std::vector<fc32_t> input(nsamps); @@ -205,14 +216,10 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){ std::vector<void *> output0(1, &interm[0]), output1(1, &output[0]); //convert float to intermediate - convert::get_converter_cpu_to_otw( - io_type_in, otw_type, input0.size(), output0.size() - )(input0, output0, nsamps, 32767.); + convert::get_converter(in_id)(input0, output0, nsamps, 32767.); //convert intermediate to short - convert::get_converter_otw_to_cpu( - io_type_out, otw_type, input1.size(), output1.size() - )(input1, output1, nsamps, 1/32767.); + convert::get_converter(out_id)(input1, output1, nsamps, 1/32767.); //test that the inputs and outputs match for (size_t i = 0; i < nsamps; i++){ @@ -225,12 +232,17 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){ * Test short to float conversion loopback **********************************************************************/ BOOST_AUTO_TEST_CASE(test_convert_types_sc16_to_fc32){ - io_type_t io_type_in(io_type_t::COMPLEX_INT16); - io_type_t io_type_out(io_type_t::COMPLEX_FLOAT32); - - otw_type_t otw_type; - otw_type.byteorder = otw_type_t::BO_NATIVE; - otw_type.width = 16; + convert::id_type in_id; + in_id.input_format = "sc16"; + in_id.num_inputs = 1; + in_id.output_format = "sc16_item32_le"; + in_id.num_outputs = 1; + + convert::id_type out_id; + out_id.input_format = "sc16_item32_le"; + out_id.num_inputs = 1; + out_id.output_format = "fc32"; + out_id.num_outputs = 1; const size_t nsamps = 13; std::vector<sc16_t> input(nsamps); @@ -245,14 +257,10 @@ BOOST_AUTO_TEST_CASE(test_convert_types_sc16_to_fc32){ std::vector<void *> output0(1, &interm[0]), output1(1, &output[0]); //convert short to intermediate - convert::get_converter_cpu_to_otw( - io_type_in, otw_type, input0.size(), output0.size() - )(input0, output0, nsamps, 32767.); + convert::get_converter(in_id)(input0, output0, nsamps, 32767.); //convert intermediate to float - convert::get_converter_otw_to_cpu( - io_type_out, otw_type, input1.size(), output1.size() - )(input1, output1, nsamps, 1/32767.); + convert::get_converter(out_id)(input1, output1, nsamps, 1/32767.); //test that the inputs and outputs match for (size_t i = 0; i < nsamps; i++){ diff --git a/host/tests/ranges_test.cpp b/host/tests/ranges_test.cpp index 5f6de4645..85bb4c3c4 100644 --- a/host/tests/ranges_test.cpp +++ b/host/tests/ranges_test.cpp @@ -55,3 +55,16 @@ BOOST_AUTO_TEST_CASE(test_ranges_clip){ BOOST_CHECK_CLOSE(mr.clip(50.9, false), 50.9, tolerance); BOOST_CHECK_CLOSE(mr.clip(50.9, true), 51.0, tolerance); } + +BOOST_AUTO_TEST_CASE(test_ranges_clip2){ + meta_range_t mr; + mr.push_back(range_t(1.)); + mr.push_back(range_t(2.)); + mr.push_back(range_t(3.)); + + BOOST_CHECK_CLOSE(mr.clip(2., true), 2., tolerance); + BOOST_CHECK_CLOSE(mr.clip(0., true), 1., tolerance); + BOOST_CHECK_CLOSE(mr.clip(1.2, true), 1., tolerance); + BOOST_CHECK_CLOSE(mr.clip(3.1, true), 3., tolerance); + BOOST_CHECK_CLOSE(mr.clip(4., true), 3., tolerance); +} diff --git a/host/tests/sph_recv_test.cpp b/host/tests/sph_recv_test.cpp index 1387e3b66..85d06aa0d 100644 --- a/host/tests/sph_recv_test.cpp +++ b/host/tests/sph_recv_test.cpp @@ -67,8 +67,8 @@ private: **********************************************************************/ class dummy_recv_xport_class{ public: - dummy_recv_xport_class(const uhd::otw_type_t &otw_type){ - _otw_type = otw_type; + dummy_recv_xport_class(const std::string &end){ + _end = end; } void push_back_packet( @@ -77,10 +77,10 @@ public: ){ const size_t max_pkt_len = (ifpi.num_payload_words32 + uhd::transport::vrt::max_if_hdr_words32 + 1/*tlr*/)*sizeof(boost::uint32_t); _mems.push_back(boost::shared_array<char>(new char[max_pkt_len])); - if (_otw_type.byteorder == uhd::otw_type_t::BO_BIG_ENDIAN){ + if (_end == "big"){ uhd::transport::vrt::if_hdr_pack_be(reinterpret_cast<boost::uint32_t *>(_mems.back().get()), ifpi); } - if (_otw_type.byteorder == uhd::otw_type_t::BO_LITTLE_ENDIAN){ + if (_end == "little"){ uhd::transport::vrt::if_hdr_pack_le(reinterpret_cast<boost::uint32_t *>(_mems.back().get()), ifpi); } (reinterpret_cast<boost::uint32_t *>(_mems.back().get()) + ifpi.num_header_words32)[0] = optional_msg_word | uhd::byteswap(optional_msg_word); @@ -100,18 +100,19 @@ private: std::list<boost::shared_array<char> > _mems; std::list<size_t> _lens; std::list<dummy_mrb> _mrbs; //list means no-realloc - uhd::otw_type_t _otw_type; + std::string _end; }; //////////////////////////////////////////////////////////////////////// BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_normal){ //////////////////////////////////////////////////////////////////////// - uhd::otw_type_t otw_type; - otw_type.width = 16; - otw_type.shift = 0; - otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN; + uhd::convert::id_type id; + id.input_format = "sc16_item32_be"; + id.num_inputs = 1; + id.output_format = "fc32"; + id.num_outputs = 1; - dummy_recv_xport_class dummy_recv_xport(otw_type); + dummy_recv_xport_class dummy_recv_xport("big"); uhd::transport::vrt::if_packet_info_t ifpi; ifpi.packet_type = uhd::transport::vrt::if_packet_info_t::PACKET_TYPE_DATA; ifpi.num_payload_words32 = 0; @@ -144,7 +145,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_normal){ handler.set_tick_rate(TICK_RATE); handler.set_samp_rate(SAMP_RATE); handler.set_xport_chan_get_buff(0, boost::bind(&dummy_recv_xport_class::get_recv_buff, &dummy_recv_xport, _1)); - handler.set_converter(otw_type); + handler.set_converter(id); //check the received packets size_t num_accum_samps = 0; @@ -153,9 +154,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_normal){ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){ std::cout << "data check " << i << std::endl; size_t num_samps_ret = handler.recv( - &buff.front(), buff.size(), metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + &buff.front(), buff.size(), metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_NONE); BOOST_CHECK(not metadata.more_fragments); @@ -169,9 +168,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_normal){ for (size_t i = 0; i < 3; i++){ std::cout << "timeout check " << i << std::endl; handler.recv( - &buff.front(), buff.size(), metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + &buff.front(), buff.size(), metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT); } @@ -180,12 +177,13 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_normal){ //////////////////////////////////////////////////////////////////////// BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_sequence_error){ //////////////////////////////////////////////////////////////////////// - uhd::otw_type_t otw_type; - otw_type.width = 16; - otw_type.shift = 0; - otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN; + uhd::convert::id_type id; + id.input_format = "sc16_item32_be"; + id.num_inputs = 1; + id.output_format = "fc32"; + id.num_outputs = 1; - dummy_recv_xport_class dummy_recv_xport(otw_type); + dummy_recv_xport_class dummy_recv_xport("big"); uhd::transport::vrt::if_packet_info_t ifpi; ifpi.packet_type = uhd::transport::vrt::if_packet_info_t::PACKET_TYPE_DATA; ifpi.num_payload_words32 = 0; @@ -220,7 +218,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_sequence_error){ handler.set_tick_rate(TICK_RATE); handler.set_samp_rate(SAMP_RATE); handler.set_xport_chan_get_buff(0, boost::bind(&dummy_recv_xport_class::get_recv_buff, &dummy_recv_xport, _1)); - handler.set_converter(otw_type); + handler.set_converter(id); //check the received packets size_t num_accum_samps = 0; @@ -229,9 +227,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_sequence_error){ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){ std::cout << "data check " << i << std::endl; size_t num_samps_ret = handler.recv( - &buff.front(), buff.size(), metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + &buff.front(), buff.size(), metadata, 1.0, true ); if (i == NUM_PKTS_TO_TEST/2){ //must get the soft overflow here @@ -253,9 +249,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_sequence_error){ for (size_t i = 0; i < 3; i++){ std::cout << "timeout check " << i << std::endl; handler.recv( - &buff.front(), buff.size(), metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + &buff.front(), buff.size(), metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT); } @@ -264,12 +258,13 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_sequence_error){ //////////////////////////////////////////////////////////////////////// BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_inline_message){ //////////////////////////////////////////////////////////////////////// - uhd::otw_type_t otw_type; - otw_type.width = 16; - otw_type.shift = 0; - otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN; + uhd::convert::id_type id; + id.input_format = "sc16_item32_be"; + id.num_inputs = 1; + id.output_format = "fc32"; + id.num_outputs = 1; - dummy_recv_xport_class dummy_recv_xport(otw_type); + dummy_recv_xport_class dummy_recv_xport("big"); uhd::transport::vrt::if_packet_info_t ifpi; ifpi.packet_type = uhd::transport::vrt::if_packet_info_t::PACKET_TYPE_DATA; ifpi.num_payload_words32 = 0; @@ -310,7 +305,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_inline_message){ handler.set_tick_rate(TICK_RATE); handler.set_samp_rate(SAMP_RATE); handler.set_xport_chan_get_buff(0, boost::bind(&dummy_recv_xport_class::get_recv_buff, &dummy_recv_xport, _1)); - handler.set_converter(otw_type); + handler.set_converter(id); //create an overflow handler overflow_handler_type overflow_handler; @@ -323,9 +318,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_inline_message){ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){ std::cout << "data check " << i << std::endl; size_t num_samps_ret = handler.recv( - &buff.front(), buff.size(), metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + &buff.front(), buff.size(), metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_NONE); BOOST_CHECK(not metadata.more_fragments); @@ -335,9 +328,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_inline_message){ num_accum_samps += num_samps_ret; if (i == NUM_PKTS_TO_TEST/2){ handler.recv( - &buff.front(), buff.size(), metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + &buff.front(), buff.size(), metadata, 1.0, true ); std::cout << "metadata.error_code " << metadata.error_code << std::endl; BOOST_REQUIRE(metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_OVERFLOW); @@ -350,9 +341,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_inline_message){ for (size_t i = 0; i < 3; i++){ std::cout << "timeout check " << i << std::endl; handler.recv( - &buff.front(), buff.size(), metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + &buff.front(), buff.size(), metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT); } @@ -361,10 +350,11 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_inline_message){ //////////////////////////////////////////////////////////////////////// BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_normal){ //////////////////////////////////////////////////////////////////////// - uhd::otw_type_t otw_type; - otw_type.width = 16; - otw_type.shift = 0; - otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN; + uhd::convert::id_type id; + id.input_format = "sc16_item32_be"; + id.num_inputs = 1; + id.output_format = "fc32"; + id.num_outputs = 1; uhd::transport::vrt::if_packet_info_t ifpi; ifpi.packet_type = uhd::transport::vrt::if_packet_info_t::PACKET_TYPE_DATA; @@ -386,7 +376,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_normal){ static const size_t NUM_SAMPS_PER_BUFF = 20; static const size_t NCHANNELS = 4; - std::vector<dummy_recv_xport_class> dummy_recv_xports(NCHANNELS, dummy_recv_xport_class(otw_type)); + std::vector<dummy_recv_xport_class> dummy_recv_xports(NCHANNELS, dummy_recv_xport_class("big")); //generate a bunch of packets for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){ @@ -406,7 +396,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_normal){ for (size_t ch = 0; ch < NCHANNELS; ch++){ handler.set_xport_chan_get_buff(ch, boost::bind(&dummy_recv_xport_class::get_recv_buff, &dummy_recv_xports[ch], _1)); } - handler.set_converter(otw_type); + handler.set_converter(id); //check the received packets size_t num_accum_samps = 0; @@ -419,9 +409,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_normal){ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){ std::cout << "data check " << i << std::endl; size_t num_samps_ret = handler.recv( - buffs, NUM_SAMPS_PER_BUFF, metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_NONE); BOOST_CHECK(not metadata.more_fragments); @@ -435,9 +423,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_normal){ for (size_t i = 0; i < 3; i++){ std::cout << "timeout check " << i << std::endl; handler.recv( - buffs, NUM_SAMPS_PER_BUFF, metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT); } @@ -447,10 +433,11 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_normal){ //////////////////////////////////////////////////////////////////////// BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_sequence_error){ //////////////////////////////////////////////////////////////////////// - uhd::otw_type_t otw_type; - otw_type.width = 16; - otw_type.shift = 0; - otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN; + uhd::convert::id_type id; + id.input_format = "sc16_item32_be"; + id.num_inputs = 1; + id.output_format = "fc32"; + id.num_outputs = 1; uhd::transport::vrt::if_packet_info_t ifpi; ifpi.packet_type = uhd::transport::vrt::if_packet_info_t::PACKET_TYPE_DATA; @@ -472,7 +459,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_sequence_error){ static const size_t NUM_SAMPS_PER_BUFF = 20; static const size_t NCHANNELS = 4; - std::vector<dummy_recv_xport_class> dummy_recv_xports(NCHANNELS, dummy_recv_xport_class(otw_type)); + std::vector<dummy_recv_xport_class> dummy_recv_xports(NCHANNELS, dummy_recv_xport_class("big")); //generate a bunch of packets for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){ @@ -495,7 +482,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_sequence_error){ for (size_t ch = 0; ch < NCHANNELS; ch++){ handler.set_xport_chan_get_buff(ch, boost::bind(&dummy_recv_xport_class::get_recv_buff, &dummy_recv_xports[ch], _1)); } - handler.set_converter(otw_type); + handler.set_converter(id); //check the received packets size_t num_accum_samps = 0; @@ -508,9 +495,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_sequence_error){ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){ std::cout << "data check " << i << std::endl; size_t num_samps_ret = handler.recv( - buffs, NUM_SAMPS_PER_BUFF, metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true ); if (i == NUM_PKTS_TO_TEST/2){ //must get the soft overflow here @@ -532,9 +517,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_sequence_error){ for (size_t i = 0; i < 3; i++){ std::cout << "timeout check " << i << std::endl; handler.recv( - buffs, NUM_SAMPS_PER_BUFF, metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT); } @@ -543,10 +526,11 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_sequence_error){ //////////////////////////////////////////////////////////////////////// BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_time_error){ //////////////////////////////////////////////////////////////////////// - uhd::otw_type_t otw_type; - otw_type.width = 16; - otw_type.shift = 0; - otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN; + uhd::convert::id_type id; + id.input_format = "sc16_item32_be"; + id.num_inputs = 1; + id.output_format = "fc32"; + id.num_outputs = 1; uhd::transport::vrt::if_packet_info_t ifpi; ifpi.packet_type = uhd::transport::vrt::if_packet_info_t::PACKET_TYPE_DATA; @@ -568,7 +552,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_time_error){ static const size_t NUM_SAMPS_PER_BUFF = 20; static const size_t NCHANNELS = 4; - std::vector<dummy_recv_xport_class> dummy_recv_xports(NCHANNELS, dummy_recv_xport_class(otw_type)); + std::vector<dummy_recv_xport_class> dummy_recv_xports(NCHANNELS, dummy_recv_xport_class("big")); //generate a bunch of packets for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){ @@ -591,7 +575,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_time_error){ for (size_t ch = 0; ch < NCHANNELS; ch++){ handler.set_xport_chan_get_buff(ch, boost::bind(&dummy_recv_xport_class::get_recv_buff, &dummy_recv_xports[ch], _1)); } - handler.set_converter(otw_type); + handler.set_converter(id); //check the received packets size_t num_accum_samps = 0; @@ -604,9 +588,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_time_error){ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){ std::cout << "data check " << i << std::endl; size_t num_samps_ret = handler.recv( - buffs, NUM_SAMPS_PER_BUFF, metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_NONE); BOOST_CHECK(not metadata.more_fragments); @@ -623,9 +605,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_time_error){ for (size_t i = 0; i < 3; i++){ std::cout << "timeout check " << i << std::endl; handler.recv( - buffs, NUM_SAMPS_PER_BUFF, metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT); } @@ -634,10 +614,11 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_time_error){ //////////////////////////////////////////////////////////////////////// BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_fragment){ //////////////////////////////////////////////////////////////////////// - uhd::otw_type_t otw_type; - otw_type.width = 16; - otw_type.shift = 0; - otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN; + uhd::convert::id_type id; + id.input_format = "sc16_item32_be"; + id.num_inputs = 1; + id.output_format = "fc32"; + id.num_outputs = 1; uhd::transport::vrt::if_packet_info_t ifpi; ifpi.packet_type = uhd::transport::vrt::if_packet_info_t::PACKET_TYPE_DATA; @@ -659,7 +640,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_fragment){ static const size_t NUM_SAMPS_PER_BUFF = 10; static const size_t NCHANNELS = 4; - std::vector<dummy_recv_xport_class> dummy_recv_xports(NCHANNELS, dummy_recv_xport_class(otw_type)); + std::vector<dummy_recv_xport_class> dummy_recv_xports(NCHANNELS, dummy_recv_xport_class("big")); //generate a bunch of packets for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){ @@ -679,7 +660,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_fragment){ for (size_t ch = 0; ch < NCHANNELS; ch++){ handler.set_xport_chan_get_buff(ch, boost::bind(&dummy_recv_xport_class::get_recv_buff, &dummy_recv_xports[ch], _1)); } - handler.set_converter(otw_type); + handler.set_converter(id); //check the received packets size_t num_accum_samps = 0; @@ -692,9 +673,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_fragment){ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){ std::cout << "data check " << i << std::endl; size_t num_samps_ret = handler.recv( - buffs, NUM_SAMPS_PER_BUFF, metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_NONE); BOOST_CHECK(metadata.has_time_spec); @@ -705,9 +684,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_fragment){ if (not metadata.more_fragments) continue; num_samps_ret = handler.recv( - buffs, NUM_SAMPS_PER_BUFF, metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_NONE); BOOST_CHECK(not metadata.more_fragments); @@ -722,9 +699,7 @@ BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_fragment){ for (size_t i = 0; i < 3; i++){ std::cout << "timeout check " << i << std::endl; handler.recv( - buffs, NUM_SAMPS_PER_BUFF, metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::RECV_MODE_ONE_PACKET, 1.0 + buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true ); BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT); } diff --git a/host/tests/sph_send_test.cpp b/host/tests/sph_send_test.cpp index ed2f54371..25a3f97ee 100644 --- a/host/tests/sph_send_test.cpp +++ b/host/tests/sph_send_test.cpp @@ -55,18 +55,18 @@ private: **********************************************************************/ class dummy_send_xport_class{ public: - dummy_send_xport_class(const uhd::otw_type_t &otw_type){ - _otw_type = otw_type; + dummy_send_xport_class(const std::string &end){ + _end = end; } void pop_front_packet( uhd::transport::vrt::if_packet_info_t &ifpi ){ ifpi.num_packet_words32 = _lens.front()/sizeof(boost::uint32_t); - if (_otw_type.byteorder == uhd::otw_type_t::BO_BIG_ENDIAN){ + if (_end == "big"){ uhd::transport::vrt::if_hdr_unpack_be(reinterpret_cast<boost::uint32_t *>(_mems.front().get()), ifpi); } - if (_otw_type.byteorder == uhd::otw_type_t::BO_LITTLE_ENDIAN){ + if (_end == "little"){ uhd::transport::vrt::if_hdr_unpack_le(reinterpret_cast<boost::uint32_t *>(_mems.front().get()), ifpi); } _mems.pop_front(); @@ -85,18 +85,19 @@ private: std::list<boost::shared_array<char> > _mems; std::list<size_t> _lens; std::list<dummy_msb> _msbs; //list means no-realloc - uhd::otw_type_t _otw_type; + std::string _end; }; //////////////////////////////////////////////////////////////////////// BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_one_packet_mode){ //////////////////////////////////////////////////////////////////////// - uhd::otw_type_t otw_type; - otw_type.width = 16; - otw_type.shift = 0; - otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN; + uhd::convert::id_type id; + id.input_format = "fc32"; + id.num_inputs = 1; + id.output_format = "sc16_item32_be"; + id.num_outputs = 1; - dummy_send_xport_class dummy_send_xport(otw_type); + dummy_send_xport_class dummy_send_xport("big"); static const double TICK_RATE = 100e6; static const double SAMP_RATE = 10e6; @@ -108,7 +109,7 @@ BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_one_packet_mode){ handler.set_tick_rate(TICK_RATE); handler.set_samp_rate(SAMP_RATE); handler.set_xport_chan_get_buff(0, boost::bind(&dummy_send_xport_class::get_send_buff, &dummy_send_xport, _1)); - handler.set_converter(otw_type); + handler.set_converter(id); handler.set_max_samples_per_packet(20); //allocate metadata and buffer @@ -122,9 +123,7 @@ BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_one_packet_mode){ metadata.start_of_burst = (i == 0); metadata.end_of_burst = (i == NUM_PKTS_TO_TEST-1); const size_t num_sent = handler.send( - &buff.front(), 10 + i%10, metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_ONE_PACKET, 1.0 + &buff.front(), 10 + i%10, metadata, 1.0 ); BOOST_CHECK_EQUAL(num_sent, 10 + i%10); metadata.time_spec += uhd::time_spec_t(0, num_sent, SAMP_RATE); @@ -150,12 +149,13 @@ BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_one_packet_mode){ //////////////////////////////////////////////////////////////////////// BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_full_buffer_mode){ //////////////////////////////////////////////////////////////////////// - uhd::otw_type_t otw_type; - otw_type.width = 16; - otw_type.shift = 0; - otw_type.byteorder = uhd::otw_type_t::BO_BIG_ENDIAN; + uhd::convert::id_type id; + id.input_format = "fc32"; + id.num_inputs = 1; + id.output_format = "sc16_item32_be"; + id.num_outputs = 1; - dummy_send_xport_class dummy_send_xport(otw_type); + dummy_send_xport_class dummy_send_xport("big"); static const double TICK_RATE = 100e6; static const double SAMP_RATE = 10e6; @@ -167,7 +167,7 @@ BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_full_buffer_mode){ handler.set_tick_rate(TICK_RATE); handler.set_samp_rate(SAMP_RATE); handler.set_xport_chan_get_buff(0, boost::bind(&dummy_send_xport_class::get_send_buff, &dummy_send_xport, _1)); - handler.set_converter(otw_type); + handler.set_converter(id); handler.set_max_samples_per_packet(20); //allocate metadata and buffer @@ -180,9 +180,7 @@ BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_full_buffer_mode){ //generate the test data const size_t num_sent = handler.send( - &buff.front(), buff.size(), metadata, - uhd::io_type_t::COMPLEX_FLOAT32, - uhd::device::SEND_MODE_FULL_BUFF, 1.0 + &buff.front(), buff.size(), metadata, 1.0 ); BOOST_CHECK_EQUAL(num_sent, buff.size()); diff --git a/host/tests/wax_test.cpp b/host/tests/wax_test.cpp deleted file mode 100644 index 18730e0c2..000000000 --- a/host/tests/wax_test.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// -// Copyright 2010-2011 Ettus Research LLC -// -// This program 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 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#include <boost/test/unit_test.hpp> -#include <boost/shared_ptr.hpp> -#include <uhd/wax.hpp> -#include <iostream> - -enum opt_a_t{OPTION_A_0, OPTION_A_1}; -enum opt_b_t{OPTION_B_0, OPTION_B_1}; - -BOOST_AUTO_TEST_CASE(test_enums){ - wax::obj opta = OPTION_A_0; - BOOST_CHECK_THROW(opta.as<opt_b_t>(), std::exception); - BOOST_CHECK_EQUAL(opta.as<opt_a_t>(), OPTION_A_0); -} - -/*********************************************************************** - * demo class for wax framework - **********************************************************************/ -class wax_demo : public wax::obj{ -public: - typedef boost::shared_ptr<wax_demo> sptr; - - wax_demo(size_t sub_demos, size_t len){ - d_nums = std::vector<float>(len); - if (sub_demos != 0){ - for (size_t i = 0; i < len; i++){ - d_subs.push_back(sptr(new wax_demo(sub_demos-1, len))); - } - } - } - ~wax_demo(void){ - /* NOP */ - } -private: - std::vector<float> d_nums; - std::vector<sptr> d_subs; - - void get(const wax::obj &key, wax::obj &value){ - if (d_subs.size() == 0){ - value = d_nums[key.as<size_t>()]; - }else{ - value = d_subs[key.as<size_t>()]->get_link(); - } - } - void set(const wax::obj &key, const wax::obj &value){ - if (d_subs.size() == 0){ - d_nums[key.as<size_t>()] = value.as<float>(); - }else{ - throw std::runtime_error("cant set to a wax demo with sub demos"); - } - } -}; - -BOOST_AUTO_TEST_CASE(test_chaining){ - wax_demo wd(2, 1); - std::cout << "chain 1" << std::endl; - wd[size_t(0)]; - std::cout << "chain 2" << std::endl; - wd[size_t(0)][size_t(0)]; - std::cout << "chain 3" << std::endl; - wd[size_t(0)][size_t(0)][size_t(0)]; -} - -BOOST_AUTO_TEST_CASE(test_set_get){ - wax_demo wd(2, 10); - std::cout << "set and get all" << std::endl; - for (size_t i = 0; i < 10; i++){ - for (size_t j = 0; j < 10; j++){ - for (size_t k = 0; k < 10; k++){ - float val = float(i * j * k + i + j + k); - //std::cout << i << " " << j << " " << k << std::endl; - wd[i][j][k] = val; - BOOST_CHECK_EQUAL(val, wd[i][j][k].as<float>()); - } - } - } -} - -BOOST_AUTO_TEST_CASE(test_proxy){ - wax_demo wd(2, 1); - std::cout << "store proxy" << std::endl; - wax::obj p = wd[size_t(0)][size_t(0)]; - p[size_t(0)] = float(5); - - std::cout << "assign proxy" << std::endl; - wax::obj a = p[size_t(0)]; - BOOST_CHECK_EQUAL(a.as<float>(), float(5)); -} |