aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests
diff options
context:
space:
mode:
authorBrent Stapleton <brent.stapleton@ettus.com>2019-01-14 10:35:25 -0800
committerBrent Stapleton <brent.stapleton@ettus.com>2019-01-16 11:40:23 -0800
commit967be2a4e82b1a125b26bb72a60318a4fb2b50c4 (patch)
tree8a24954b54d1546dc8049a17e485adb0a605f74f /host/tests
parentaafe4e8b742a0e21d3818f21f34e3c8613132530 (diff)
downloaduhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.gz
uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.tar.bz2
uhd-967be2a4e82b1a125b26bb72a60318a4fb2b50c4.zip
uhd: mpm: apply clang-format to all files
Applying formatting changes to all .cpp and .hpp files in the following directories: ``` find host/examples/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/tests/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/neon/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/dboard/magnesium/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/device3/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/mpmd/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/lib/usrp/x300/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find host/utils/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file find mpm/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Also formatted host/include/, except Cpp03 was used as a the language standard instead of Cpp11. ``` sed -i 's/ Cpp11/ Cpp03/g' .clang-format find host/include/ -iname *.hpp -o -iname *.cpp | \ xargs clang-format -i -style=file ``` Formatting style was designated by the .clang-format file.
Diffstat (limited to 'host/tests')
-rw-r--r--host/tests/addr_test.cpp42
-rw-r--r--host/tests/block_id_test.cpp18
-rw-r--r--host/tests/blockdef_test.cpp38
-rw-r--r--host/tests/buffer_test.cpp18
-rw-r--r--host/tests/byteswap_test.cpp14
-rw-r--r--host/tests/cal_container_test.cpp33
-rw-r--r--host/tests/cast_test.cpp21
-rw-r--r--host/tests/chdr_test.cpp141
-rw-r--r--host/tests/common/mock_ctrl_iface_impl.cpp23
-rw-r--r--host/tests/common/mock_ctrl_iface_impl.hpp17
-rw-r--r--host/tests/common/mock_zero_copy.cpp29
-rw-r--r--host/tests/common/mock_zero_copy.hpp159
-rw-r--r--host/tests/config_parser_test.cpp109
-rw-r--r--host/tests/constrained_device_args_test.cpp146
-rw-r--r--host/tests/convert_test.cpp569
-rw-r--r--host/tests/device3_test.cpp95
-rw-r--r--host/tests/dict_test.cpp58
-rw-r--r--host/tests/dpdk_test.cpp216
-rw-r--r--host/tests/eeprom_utils_test.cpp46
-rw-r--r--host/tests/error_c_test.cpp129
-rw-r--r--host/tests/error_test.cpp57
-rw-r--r--host/tests/expert_test.cpp165
-rw-r--r--host/tests/fe_conn_test.cpp40
-rw-r--r--host/tests/fp_compare_delta_test.cpp134
-rw-r--r--host/tests/fp_compare_epsilon_test.cpp125
-rw-r--r--host/tests/gain_group_test.cpp53
-rw-r--r--host/tests/graph.hpp15
-rw-r--r--host/tests/graph_search_test.cpp30
-rw-r--r--host/tests/log_test.cpp29
-rw-r--r--host/tests/math_test.cpp8
-rw-r--r--host/tests/module_test.cpp3
-rw-r--r--host/tests/narrow_cast_test.cpp7
-rw-r--r--host/tests/nocscript_common.hpp19
-rw-r--r--host/tests/nocscript_expr_test.cpp189
-rw-r--r--host/tests/nocscript_ftable_test.cpp75
-rw-r--r--host/tests/nocscript_parser_test.cpp37
-rw-r--r--host/tests/node_connect_test.cpp30
-rw-r--r--host/tests/packet_handler_benchmark.cpp229
-rw-r--r--host/tests/paths_test.cpp34
-rw-r--r--host/tests/property_test.cpp91
-rw-r--r--host/tests/ranges_test.cpp17
-rw-r--r--host/tests/rate_node_test.cpp19
-rw-r--r--host/tests/sensors_test.cpp41
-rw-r--r--host/tests/sid_t_test.cpp21
-rw-r--r--host/tests/soft_reg_test.cpp9
-rw-r--r--host/tests/sph_recv_test.cpp836
-rw-r--r--host/tests/sph_send_test.cpp106
-rw-r--r--host/tests/stream_sig_test.cpp15
-rw-r--r--host/tests/subdev_spec_test.cpp17
-rw-r--r--host/tests/system_time_test.cpp22
-rw-r--r--host/tests/tasks_test.cpp12
-rw-r--r--host/tests/tick_node_test.cpp13
-rw-r--r--host/tests/time_spec_test.cpp28
-rw-r--r--host/tests/vrt_test.cpp185
54 files changed, 2313 insertions, 2319 deletions
diff --git a/host/tests/addr_test.cpp b/host/tests/addr_test.cpp
index 9819df1a5..03608d723 100644
--- a/host/tests/addr_test.cpp
+++ b/host/tests/addr_test.cpp
@@ -5,15 +5,16 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
-#include <uhd/types/mac_addr.hpp>
#include <uhd/types/device_addr.hpp>
+#include <uhd/types/mac_addr.hpp>
#include <uhd/usrp/dboard_id.hpp>
#include <boost/assign/list_of.hpp>
+#include <boost/test/unit_test.hpp>
#include <algorithm>
#include <iostream>
-BOOST_AUTO_TEST_CASE(test_mac_addr){
+BOOST_AUTO_TEST_CASE(test_mac_addr)
+{
std::cout << "Testing mac addr..." << std::endl;
const std::string mac_addr_str("00:01:23:45:67:89");
uhd::mac_addr_t mac_addr = uhd::mac_addr_t::from_string(mac_addr_str);
@@ -22,39 +23,40 @@ BOOST_AUTO_TEST_CASE(test_mac_addr){
BOOST_CHECK_EQUAL(mac_addr_str, mac_addr.to_string());
}
-BOOST_AUTO_TEST_CASE(test_device_addr){
+BOOST_AUTO_TEST_CASE(test_device_addr)
+{
std::cout << "Testing device addr..." << std::endl;
- //load the device address with something
+ // load the device address with something
uhd::device_addr_t dev_addr;
dev_addr["key1"] = "val1";
dev_addr["key1"] = "val1";
dev_addr["key3"] = "";
- //convert to and from args string
+ // convert to and from args string
std::cout << "Pretty Print: " << std::endl << dev_addr.to_pp_string();
std::string args_str = dev_addr.to_string();
std::cout << "Args String: " << args_str << std::endl;
uhd::device_addr_t new_dev_addr(args_str);
- //they should be the same size
+ // they should be the same size
BOOST_REQUIRE_EQUAL(dev_addr.size(), new_dev_addr.size());
- //the keys should match
+ // the keys should match
std::vector<std::string> old_dev_addr_keys = dev_addr.keys();
std::vector<std::string> new_dev_addr_keys = new_dev_addr.keys();
- BOOST_CHECK_EQUAL_COLLECTIONS(
- old_dev_addr_keys.begin(), old_dev_addr_keys.end(),
- new_dev_addr_keys.begin(), new_dev_addr_keys.end()
- );
+ BOOST_CHECK_EQUAL_COLLECTIONS(old_dev_addr_keys.begin(),
+ old_dev_addr_keys.end(),
+ new_dev_addr_keys.begin(),
+ new_dev_addr_keys.end());
- //the vals should match
+ // the vals should match
std::vector<std::string> old_dev_addr_vals = dev_addr.vals();
std::vector<std::string> new_dev_addr_vals = new_dev_addr.vals();
- BOOST_CHECK_EQUAL_COLLECTIONS(
- old_dev_addr_vals.begin(), old_dev_addr_vals.end(),
- new_dev_addr_vals.begin(), new_dev_addr_vals.end()
- );
+ BOOST_CHECK_EQUAL_COLLECTIONS(old_dev_addr_vals.begin(),
+ old_dev_addr_vals.end(),
+ new_dev_addr_vals.begin(),
+ new_dev_addr_vals.end());
uhd::device_addr_t dev_addr_lhs1("key1=val1,key2=val2");
dev_addr_lhs1.update(uhd::device_addr_t("key2=val2x,key3=val3"), false);
@@ -64,7 +66,8 @@ BOOST_AUTO_TEST_CASE(test_device_addr){
std::cout << "Merged: " << dev_addr_lhs1.to_string() << std::endl;
}
-BOOST_AUTO_TEST_CASE(test_dboard_id){
+BOOST_AUTO_TEST_CASE(test_dboard_id)
+{
std::cout << "Testing dboard id..." << std::endl;
using namespace uhd::usrp;
@@ -76,7 +79,8 @@ BOOST_AUTO_TEST_CASE(test_dboard_id){
std::cout << "Pretty Print: " << std::endl << dboard_id_t::none().to_pp_string();
}
-BOOST_AUTO_TEST_CASE(test_map_device_addr){
+BOOST_AUTO_TEST_CASE(test_map_device_addr)
+{
std::map<std::string, std::string> dev_addr_map;
dev_addr_map["key1"] = "val1";
dev_addr_map["key2"] = "val2";
diff --git a/host/tests/block_id_test.cpp b/host/tests/block_id_test.cpp
index 51be3a2a2..7c068e4d2 100644
--- a/host/tests/block_id_test.cpp
+++ b/host/tests/block_id_test.cpp
@@ -5,14 +5,15 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <iostream>
-#include <boost/test/unit_test.hpp>
#include <uhd/exception.hpp>
#include <uhd/rfnoc/block_id.hpp>
+#include <boost/test/unit_test.hpp>
+#include <iostream>
using namespace uhd::rfnoc;
-BOOST_AUTO_TEST_CASE(test_block_id) {
+BOOST_AUTO_TEST_CASE(test_block_id)
+{
BOOST_CHECK(block_id_t::is_valid_block_id("00/Filter_1"));
BOOST_CHECK(not block_id_t::is_valid_block_id("0/MAG_SQUARE"));
BOOST_CHECK(block_id_t::is_valid_blockname("FilterFoo"));
@@ -45,7 +46,8 @@ BOOST_AUTO_TEST_CASE(test_block_id) {
BOOST_CHECK(not block_id.set_block_name("Foo_Bar"));
BOOST_CHECK_EQUAL(block_id.get_device_no(), 17);
- BOOST_CHECK_EQUAL(block_id.get_block_name(), "FooBar"); // Is unchanged because invalid
+ BOOST_CHECK_EQUAL(
+ block_id.get_block_name(), "FooBar"); // Is unchanged because invalid
BOOST_CHECK_EQUAL(block_id.get_block_count(), 11);
block_id++;
@@ -82,7 +84,8 @@ BOOST_AUTO_TEST_CASE(test_block_id) {
BOOST_CHECK(not other_block_id.match("2093ksdjfflsdkjf"));
}
-BOOST_AUTO_TEST_CASE(test_block_id_set) {
+BOOST_AUTO_TEST_CASE(test_block_id_set)
+{
// test set()
block_id_t block_id_for_set(5, "Blockname", 9);
block_id_for_set.set("FirFilter");
@@ -99,9 +102,10 @@ BOOST_AUTO_TEST_CASE(test_block_id_set) {
BOOST_CHECK_EQUAL(block_id_for_set.get_block_count(), 3);
}
-BOOST_AUTO_TEST_CASE(test_block_id_cmp) {
+BOOST_AUTO_TEST_CASE(test_block_id_cmp)
+{
BOOST_CHECK(block_id_t("0/FFT_1") == block_id_t("0/FFT_1"));
BOOST_CHECK(block_id_t("0/FFT_1") != block_id_t("1/FFT_1"));
BOOST_CHECK(block_id_t("0/FFT_1") < block_id_t("1/aaaaaaaaa_0"));
- BOOST_CHECK(not (block_id_t("0/FFT_1") > block_id_t("1/aaaaaaaaa_0")));
+ BOOST_CHECK(not(block_id_t("0/FFT_1") > block_id_t("1/aaaaaaaaa_0")));
}
diff --git a/host/tests/blockdef_test.cpp b/host/tests/blockdef_test.cpp
index bc513bebd..7a663f514 100644
--- a/host/tests/blockdef_test.cpp
+++ b/host/tests/blockdef_test.cpp
@@ -5,30 +5,28 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <iostream>
-#include <map>
+#include <uhd/rfnoc/blockdef.hpp>
#include <stdint.h>
-#include <boost/test/unit_test.hpp>
#include <boost/format.hpp>
-#include <uhd/rfnoc/blockdef.hpp>
+#include <boost/test/unit_test.hpp>
+#include <iostream>
+#include <map>
using namespace uhd::rfnoc;
-BOOST_AUTO_TEST_CASE(test_lookup) {
- const std::map<uint64_t, std::string> blocknames{
- {0, "NullSrcSink"},
+BOOST_AUTO_TEST_CASE(test_lookup)
+{
+ const std::map<uint64_t, std::string> blocknames{{0, "NullSrcSink"},
{0xFF70000000000000, "FFT"},
{0xF112000000000001, "FIR"},
{0xF1F0000000000000, "FIFO"},
{0xD053000000000000, "Window"},
- {0x5CC0000000000000, "SchmidlCox"}
- };
+ {0x5CC0000000000000, "SchmidlCox"}};
std::cout << blocknames.size() << std::endl;
for (const auto block : blocknames) {
- std::cout << "Testing " << block.second
- << " => " << str(boost::format("%016X") % block.first)
- << std::endl;
+ std::cout << "Testing " << block.second << " => "
+ << str(boost::format("%016X") % block.first) << std::endl;
auto block_definition = blockdef::make_from_noc_id(block.first);
// If the previous function fails, it'll return a NULL pointer
BOOST_REQUIRE(block_definition);
@@ -37,10 +35,11 @@ BOOST_AUTO_TEST_CASE(test_lookup) {
}
}
-BOOST_AUTO_TEST_CASE(test_ports) {
+BOOST_AUTO_TEST_CASE(test_ports)
+{
// Create an FFT:
blockdef::sptr block_definition = blockdef::make_from_noc_id(0xFF70000000000000);
- blockdef::ports_t in_ports = block_definition->get_input_ports();
+ blockdef::ports_t in_ports = block_definition->get_input_ports();
BOOST_REQUIRE_EQUAL(in_ports.size(), 1);
BOOST_CHECK_EQUAL(in_ports[0]["name"], "in");
BOOST_CHECK_EQUAL(in_ports[0]["type"], "sc16");
@@ -57,20 +56,22 @@ BOOST_AUTO_TEST_CASE(test_ports) {
BOOST_CHECK_EQUAL(block_definition->get_all_port_numbers()[0], 0);
}
-BOOST_AUTO_TEST_CASE(test_args) {
+BOOST_AUTO_TEST_CASE(test_args)
+{
// Create an FFT:
blockdef::sptr block_definition = blockdef::make_from_noc_id(0xFF70000000000000);
- blockdef::args_t args = block_definition->get_args();
+ blockdef::args_t args = block_definition->get_args();
BOOST_REQUIRE_EQUAL(args.size(), 7);
BOOST_CHECK_EQUAL(args[0]["name"], "spp");
BOOST_CHECK_EQUAL(args[0]["type"], "int");
BOOST_CHECK_EQUAL(args[0]["value"], "256");
}
-BOOST_AUTO_TEST_CASE(test_regs) {
+BOOST_AUTO_TEST_CASE(test_regs)
+{
// Create an FFT:
blockdef::sptr block_definition = blockdef::make_from_noc_id(0xFF70000000000000);
- blockdef::registers_t sregs = block_definition->get_settings_registers();
+ blockdef::registers_t sregs = block_definition->get_settings_registers();
BOOST_REQUIRE_EQUAL(sregs.size(), 6);
BOOST_CHECK_EQUAL(sregs["FFT_RESET"], 131);
BOOST_CHECK_EQUAL(sregs["FFT_SIZE_LOG2"], 132);
@@ -80,4 +81,3 @@ BOOST_AUTO_TEST_CASE(test_regs) {
BOOST_CHECK_EQUAL(user_regs["RB_FFT_RESET"], 0);
BOOST_CHECK_EQUAL(user_regs["RB_MAGNITUDE_OUT"], 1);
}
-
diff --git a/host/tests/buffer_test.cpp b/host/tests/buffer_test.cpp
index b2659a86b..ef4c68ff2 100644
--- a/host/tests/buffer_test.cpp
+++ b/host/tests/buffer_test.cpp
@@ -5,26 +5,27 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/transport/bounded_buffer.hpp>
#include <boost/assign/list_of.hpp>
+#include <boost/test/unit_test.hpp>
using namespace boost::assign;
using namespace uhd::transport;
-static const double timeout = 0.01/*secs*/;
+static const double timeout = 0.01 /*secs*/;
-BOOST_AUTO_TEST_CASE(test_bounded_buffer_with_timed_wait){
+BOOST_AUTO_TEST_CASE(test_bounded_buffer_with_timed_wait)
+{
bounded_buffer<int> bb(3);
- //push elements, check for timeout
+ // push elements, check for timeout
BOOST_CHECK(bb.push_with_timed_wait(0, timeout));
BOOST_CHECK(bb.push_with_timed_wait(1, timeout));
BOOST_CHECK(bb.push_with_timed_wait(2, timeout));
BOOST_CHECK(not bb.push_with_timed_wait(3, timeout));
int val;
- //pop elements, check for timeout and check values
+ // pop elements, check for timeout and check values
BOOST_CHECK(bb.pop_with_timed_wait(val, timeout));
BOOST_CHECK_EQUAL(val, 0);
BOOST_CHECK(bb.pop_with_timed_wait(val, timeout));
@@ -34,17 +35,18 @@ BOOST_AUTO_TEST_CASE(test_bounded_buffer_with_timed_wait){
BOOST_CHECK(not bb.pop_with_timed_wait(val, timeout));
}
-BOOST_AUTO_TEST_CASE(test_bounded_buffer_with_pop_on_full){
+BOOST_AUTO_TEST_CASE(test_bounded_buffer_with_pop_on_full)
+{
bounded_buffer<int> bb(3);
- //push elements, check for timeout
+ // push elements, check for timeout
BOOST_CHECK(bb.push_with_pop_on_full(0));
BOOST_CHECK(bb.push_with_pop_on_full(1));
BOOST_CHECK(bb.push_with_pop_on_full(2));
BOOST_CHECK(not bb.push_with_pop_on_full(3));
int val;
- //pop elements, check for timeout and check values
+ // pop elements, check for timeout and check values
BOOST_CHECK(bb.pop_with_timed_wait(val, timeout));
BOOST_CHECK_EQUAL(val, 1);
BOOST_CHECK(bb.pop_with_timed_wait(val, timeout));
diff --git a/host/tests/byteswap_test.cpp b/host/tests/byteswap_test.cpp
index c006de169..4cc04f484 100644
--- a/host/tests/byteswap_test.cpp
+++ b/host/tests/byteswap_test.cpp
@@ -5,25 +5,27 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/utils/byteswap.hpp>
+#include <boost/test/unit_test.hpp>
-BOOST_AUTO_TEST_CASE(test_byteswap16){
+BOOST_AUTO_TEST_CASE(test_byteswap16)
+{
uint16_t x = 0x0123;
uint16_t y = 0x2301;
BOOST_CHECK_EQUAL(uhd::byteswap(x), y);
}
-BOOST_AUTO_TEST_CASE(test_byteswap32){
+BOOST_AUTO_TEST_CASE(test_byteswap32)
+{
uint32_t x = 0x01234567;
uint32_t y = 0x67452301;
BOOST_CHECK_EQUAL(uhd::byteswap(x), y);
}
-BOOST_AUTO_TEST_CASE(test_byteswap64){
- //split up 64 bit constants to avoid long-long compiler warnings
+BOOST_AUTO_TEST_CASE(test_byteswap64)
+{
+ // split up 64 bit constants to avoid long-long compiler warnings
uint64_t x = 0x01234567 | (uint64_t(0x89abcdef) << 32);
uint64_t y = 0xefcdab89 | (uint64_t(0x67452301) << 32);
BOOST_CHECK_EQUAL(uhd::byteswap(x), y);
}
-
diff --git a/host/tests/cal_container_test.cpp b/host/tests/cal_container_test.cpp
index 559a674c1..4957b0b0d 100644
--- a/host/tests/cal_container_test.cpp
+++ b/host/tests/cal_container_test.cpp
@@ -7,10 +7,10 @@
#include <uhd/cal/power_container.hpp>
#include <uhd/exception.hpp>
-#include <boost/test/unit_test.hpp>
#include <boost/shared_ptr.hpp>
-#include <vector>
+#include <boost/test/unit_test.hpp>
#include <fstream>
+#include <vector>
using namespace uhd;
using namespace uhd::cal;
@@ -18,8 +18,9 @@ using namespace uhd::cal;
static const double eps = 1e-8;
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_power_container_bilinear){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_power_container_bilinear)
+{
+ ////////////////////////////////////////////////////////////////////////
// Create the data container
power_container::sptr container = power_container::make();
@@ -51,8 +52,9 @@ BOOST_AUTO_TEST_CASE(test_power_container_bilinear){
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_power_temp_container){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_power_temp_container)
+{
+ ////////////////////////////////////////////////////////////////////////
// Create the data container
power_container::sptr container = power_container::make();
@@ -80,8 +82,9 @@ BOOST_AUTO_TEST_CASE(test_power_temp_container){
}
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_power_container_metadata){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_power_container_metadata)
+{
+ ////////////////////////////////////////////////////////////////////////
// Create the data container
power_container::sptr container = power_container::make();
@@ -90,7 +93,7 @@ BOOST_AUTO_TEST_CASE(test_power_container_metadata){
base_container::metadata_t data;
std::string fake_serial = "F2A432";
- data["x300"] = fake_serial;
+ data["x300"] = fake_serial;
// Add some metadata
container->add_metadata(data);
@@ -102,8 +105,9 @@ BOOST_AUTO_TEST_CASE(test_power_container_metadata){
}
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_power_serialization){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_power_serialization)
+{
+ ////////////////////////////////////////////////////////////////////////
// Create the data container
power_container::sptr container = power_container::make();
@@ -112,7 +116,7 @@ BOOST_AUTO_TEST_CASE(test_power_serialization){
base_container::metadata_t data;
std::string fake_serial = "F2A432";
- data["x300"] = fake_serial;
+ data["x300"] = fake_serial;
// Add some metadata
container->add_metadata(data);
@@ -167,8 +171,9 @@ BOOST_AUTO_TEST_CASE(test_power_serialization){
}
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_interp_singular){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_interp_singular)
+{
+ ////////////////////////////////////////////////////////////////////////
// Create the data container
power_container::sptr container = power_container::make();
diff --git a/host/tests/cast_test.cpp b/host/tests/cast_test.cpp
index d1357459e..296574b48 100644
--- a/host/tests/cast_test.cpp
+++ b/host/tests/cast_test.cpp
@@ -5,19 +5,18 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <iostream>
-#include <boost/test/unit_test.hpp>
-#include <stdint.h>
#include <uhd/utils/cast.hpp>
+#include <stdint.h>
+#include <boost/test/unit_test.hpp>
+#include <iostream>
-BOOST_AUTO_TEST_CASE(test_mac_addr){
- std::string in = "0x0100";
+BOOST_AUTO_TEST_CASE(test_mac_addr)
+{
+ std::string in = "0x0100";
uint16_t correct_result = 256;
- uint16_t x = uhd::cast::hexstr_cast<uint16_t>(in);
- //uint16_t x = uhd::cast::hexstr_cast(in);
- std::cout
- << "Testing hex -> uint16_t conversion. "
- << in << " == " << std::hex << x << "?" << std::endl;
+ uint16_t x = uhd::cast::hexstr_cast<uint16_t>(in);
+ // uint16_t x = uhd::cast::hexstr_cast(in);
+ std::cout << "Testing hex -> uint16_t conversion. " << in << " == " << std::hex << x
+ << "?" << std::endl;
BOOST_CHECK_EQUAL(x, correct_result);
}
-
diff --git a/host/tests/chdr_test.cpp b/host/tests/chdr_test.cpp
index 11daca521..595d7011a 100644
--- a/host/tests/chdr_test.cpp
+++ b/host/tests/chdr_test.cpp
@@ -7,128 +7,131 @@
#include <uhd/transport/chdr.hpp>
#include <uhd/utils/byteswap.hpp>
-#include <boost/test/unit_test.hpp>
#include <boost/format.hpp>
+#include <boost/test/unit_test.hpp>
#include <cstdlib>
#include <iostream>
using namespace uhd::transport::vrt;
-static void pack_and_unpack(
- if_packet_info_t &if_packet_info_in
-){
+static void pack_and_unpack(if_packet_info_t& if_packet_info_in)
+{
// Temp buffer for packed packet
uint32_t packet_buff[2048] = {0};
// Check input (must not be lazy)
- BOOST_REQUIRE(
- (if_packet_info_in.num_payload_words32 == 0 and if_packet_info_in.num_payload_bytes == 0)
- or
- (if_packet_info_in.num_payload_words32 != 0 and if_packet_info_in.num_payload_bytes != 0)
- );
+ BOOST_REQUIRE((if_packet_info_in.num_payload_words32 == 0
+ and if_packet_info_in.num_payload_bytes == 0)
+ or (if_packet_info_in.num_payload_words32 != 0
+ and if_packet_info_in.num_payload_bytes != 0));
if (if_packet_info_in.num_payload_words32) {
- BOOST_REQUIRE(if_packet_info_in.num_payload_bytes <= 4 * if_packet_info_in.num_payload_words32);
- BOOST_REQUIRE(if_packet_info_in.num_payload_bytes > 4*(if_packet_info_in.num_payload_words32-1));
+ BOOST_REQUIRE(if_packet_info_in.num_payload_bytes
+ <= 4 * if_packet_info_in.num_payload_words32);
+ BOOST_REQUIRE(if_packet_info_in.num_payload_bytes
+ > 4 * (if_packet_info_in.num_payload_words32 - 1));
}
- //pack metadata into a vrt header
- chdr::if_hdr_pack_be(
- packet_buff, if_packet_info_in
- );
+ // pack metadata into a vrt header
+ chdr::if_hdr_pack_be(packet_buff, if_packet_info_in);
std::cout << std::endl;
uint32_t header_bits = (uhd::ntohx(packet_buff[0]) >> 28);
std::cout << boost::format("header bits = 0b%d%d%d%d") % ((header_bits & 8) > 0)
- % ((header_bits & 4) > 0)
- % ((header_bits & 2) > 0)
- % ((header_bits & 1) > 0) << std::endl;
- for (size_t i = 0; i < 5; i++)
- {
- std::cout << boost::format("packet_buff[%u] = 0x%08x") % i % uhd::ntohx(packet_buff[i]) << std::endl;
+ % ((header_bits & 4) > 0) % ((header_bits & 2) > 0)
+ % ((header_bits & 1) > 0)
+ << std::endl;
+ for (size_t i = 0; i < 5; i++) {
+ std::cout << boost::format("packet_buff[%u] = 0x%08x") % i
+ % uhd::ntohx(packet_buff[i])
+ << std::endl;
}
if_packet_info_t if_packet_info_out;
// Must be set a-priori as per contract
if_packet_info_out.num_packet_words32 = if_packet_info_in.num_packet_words32;
- //unpack the vrt header back into metadata
- chdr::if_hdr_unpack_be(
- packet_buff, if_packet_info_out
- );
+ // unpack the vrt header back into metadata
+ chdr::if_hdr_unpack_be(packet_buff, if_packet_info_out);
- //check the the unpacked metadata is the same
+ // check the the unpacked metadata is the same
BOOST_CHECK_EQUAL(if_packet_info_in.packet_count, if_packet_info_out.packet_count);
- BOOST_CHECK_EQUAL(if_packet_info_in.num_header_words32, if_packet_info_out.num_header_words32);
- BOOST_CHECK_EQUAL(if_packet_info_in.num_payload_words32, if_packet_info_out.num_payload_words32);
+ BOOST_CHECK_EQUAL(
+ if_packet_info_in.num_header_words32, if_packet_info_out.num_header_words32);
+ BOOST_CHECK_EQUAL(
+ if_packet_info_in.num_payload_words32, if_packet_info_out.num_payload_words32);
BOOST_CHECK(if_packet_info_out.has_sid);
BOOST_CHECK_EQUAL(if_packet_info_in.sid, if_packet_info_out.sid);
BOOST_CHECK(if_packet_info_out.has_sid);
BOOST_CHECK_EQUAL(if_packet_info_in.has_tsf, if_packet_info_out.has_tsf);
- if (if_packet_info_in.has_tsf and if_packet_info_out.has_tsf){
+ if (if_packet_info_in.has_tsf and if_packet_info_out.has_tsf) {
BOOST_CHECK_EQUAL(if_packet_info_in.tsf, if_packet_info_out.tsf);
}
}
-BOOST_AUTO_TEST_CASE(test_with_chdr){
+BOOST_AUTO_TEST_CASE(test_with_chdr)
+{
if_packet_info_t if_packet_info;
- if_packet_info.packet_type = if_packet_info_t::PACKET_TYPE_DATA;
- if_packet_info.eob = false;
- if_packet_info.packet_count = 7;
- if_packet_info.has_tsf = true;
- if_packet_info.tsf = 0x1234567890ABCDEFull;
- if_packet_info.sid = 0xAABBCCDD;
+ if_packet_info.packet_type = if_packet_info_t::PACKET_TYPE_DATA;
+ if_packet_info.eob = false;
+ if_packet_info.packet_count = 7;
+ if_packet_info.has_tsf = true;
+ if_packet_info.tsf = 0x1234567890ABCDEFull;
+ if_packet_info.sid = 0xAABBCCDD;
if_packet_info.num_payload_words32 = 24;
- if_packet_info.num_payload_bytes = 95;
+ if_packet_info.num_payload_bytes = 95;
pack_and_unpack(if_packet_info);
}
-BOOST_AUTO_TEST_CASE(test_with_chdr_fc){
+BOOST_AUTO_TEST_CASE(test_with_chdr_fc)
+{
if_packet_info_t if_packet_info;
- if_packet_info.packet_type = if_packet_info_t::PACKET_TYPE_FC;
- if_packet_info.eob = false;
- if_packet_info.packet_count = 19;
- if_packet_info.has_tsf = false;
- if_packet_info.tsf = 0x1234567890ABCDEFull;
- if_packet_info.sid = 0xAABBCCDD;
+ if_packet_info.packet_type = if_packet_info_t::PACKET_TYPE_FC;
+ if_packet_info.eob = false;
+ if_packet_info.packet_count = 19;
+ if_packet_info.has_tsf = false;
+ if_packet_info.tsf = 0x1234567890ABCDEFull;
+ if_packet_info.sid = 0xAABBCCDD;
if_packet_info.num_payload_words32 = 4;
- if_packet_info.num_payload_bytes = 16;
+ if_packet_info.num_payload_bytes = 16;
pack_and_unpack(if_packet_info);
}
-BOOST_AUTO_TEST_CASE(test_with_chdr_cmd){
+BOOST_AUTO_TEST_CASE(test_with_chdr_cmd)
+{
if_packet_info_t if_packet_info;
- if_packet_info.packet_type = if_packet_info_t::PACKET_TYPE_CMD;
- if_packet_info.packet_count = 19;
- if_packet_info.has_tsf = true;
- if_packet_info.tsf = 0x1234567890ABCDEFull;
- if_packet_info.sid = 0xAABBCCDD;
+ if_packet_info.packet_type = if_packet_info_t::PACKET_TYPE_CMD;
+ if_packet_info.packet_count = 19;
+ if_packet_info.has_tsf = true;
+ if_packet_info.tsf = 0x1234567890ABCDEFull;
+ if_packet_info.sid = 0xAABBCCDD;
if_packet_info.num_payload_words32 = 4;
- if_packet_info.num_payload_bytes = 16;
+ if_packet_info.num_payload_bytes = 16;
pack_and_unpack(if_packet_info);
}
-BOOST_AUTO_TEST_CASE(test_with_chdr_resp){
+BOOST_AUTO_TEST_CASE(test_with_chdr_resp)
+{
if_packet_info_t if_packet_info;
- if_packet_info.packet_type = if_packet_info_t::PACKET_TYPE_RESP;
- if_packet_info.packet_count = 123;
- if_packet_info.has_tsf = false;
- if_packet_info.tsf = 0x1234567890ABCDEFull;
- if_packet_info.sid = 0xAABBCCDD;
+ if_packet_info.packet_type = if_packet_info_t::PACKET_TYPE_RESP;
+ if_packet_info.packet_count = 123;
+ if_packet_info.has_tsf = false;
+ if_packet_info.tsf = 0x1234567890ABCDEFull;
+ if_packet_info.sid = 0xAABBCCDD;
if_packet_info.num_payload_words32 = 4;
- if_packet_info.num_payload_bytes = 16;
+ if_packet_info.num_payload_bytes = 16;
pack_and_unpack(if_packet_info);
}
-BOOST_AUTO_TEST_CASE(test_with_chdr_err){
+BOOST_AUTO_TEST_CASE(test_with_chdr_err)
+{
if_packet_info_t if_packet_info;
- if_packet_info.packet_type = if_packet_info_t::PACKET_TYPE_ERROR;
- if_packet_info.packet_count = 1928;
- if_packet_info.eob = false;
- if_packet_info.error = false; // Needs to be set explicitly
- if_packet_info.has_tsf = false;
- if_packet_info.tsf = 0x1234567890ABCDEFull;
- if_packet_info.sid = 0xAABBCCDD;
+ if_packet_info.packet_type = if_packet_info_t::PACKET_TYPE_ERROR;
+ if_packet_info.packet_count = 1928;
+ if_packet_info.eob = false;
+ if_packet_info.error = false; // Needs to be set explicitly
+ if_packet_info.has_tsf = false;
+ if_packet_info.tsf = 0x1234567890ABCDEFull;
+ if_packet_info.sid = 0xAABBCCDD;
if_packet_info.num_payload_words32 = 4;
- if_packet_info.num_payload_bytes = 16;
+ if_packet_info.num_payload_bytes = 16;
pack_and_unpack(if_packet_info);
}
-
diff --git a/host/tests/common/mock_ctrl_iface_impl.cpp b/host/tests/common/mock_ctrl_iface_impl.cpp
index 0e80ef9a0..e8560ad9e 100644
--- a/host/tests/common/mock_ctrl_iface_impl.cpp
+++ b/host/tests/common/mock_ctrl_iface_impl.cpp
@@ -7,16 +7,19 @@
#include "mock_ctrl_iface_impl.hpp"
static const uint64_t TEST_NOC_ID = 0xAAAABBBBCCCCDDDD;
-uint64_t mock_ctrl_iface_impl::send_cmd_pkt(
- const size_t addr,
- const size_t data,
- const bool readback,
- const uint64_t /* timestamp */
-) {
+uint64_t mock_ctrl_iface_impl::send_cmd_pkt(const size_t addr,
+ const size_t data,
+ const bool readback,
+ const uint64_t /* timestamp */
+)
+{
if (not readback) {
- std::cout << str(boost::format("[MOCK] poke to addr: %016X, data == %016X") % addr % data) << std::endl;
+ std::cout << str(boost::format("[MOCK] poke to addr: %016X, data == %016X") % addr
+ % data)
+ << std::endl;
} else {
- std::cout << str(boost::format("[MOCK] peek64 to addr: %016X") % data) << std::endl;
+ std::cout << str(boost::format("[MOCK] peek64 to addr: %016X") % data)
+ << std::endl;
switch (data) {
case uhd::rfnoc::SR_READBACK_REG_ID:
return TEST_NOC_ID;
@@ -25,8 +28,8 @@ uint64_t mock_ctrl_iface_impl::send_cmd_pkt(
case uhd::rfnoc::SR_READBACK_REG_USER:
return 0x0123456789ABCDEF;
case uhd::rfnoc::SR_READBACK_COMPAT:
- return uhd::rfnoc::NOC_SHELL_COMPAT_MAJOR << 32 |
- uhd::rfnoc::NOC_SHELL_COMPAT_MINOR;
+ return uhd::rfnoc::NOC_SHELL_COMPAT_MAJOR << 32
+ | uhd::rfnoc::NOC_SHELL_COMPAT_MINOR;
default:
return 0;
}
diff --git a/host/tests/common/mock_ctrl_iface_impl.hpp b/host/tests/common/mock_ctrl_iface_impl.hpp
index 8d2aafed6..ad60d32ef 100644
--- a/host/tests/common/mock_ctrl_iface_impl.hpp
+++ b/host/tests/common/mock_ctrl_iface_impl.hpp
@@ -10,21 +10,18 @@
#include <uhd/rfnoc/constants.hpp>
#include <uhdlib/rfnoc/ctrl_iface.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/thread.hpp>
-#include <boost/format.hpp>
#include <boost/bind.hpp>
+#include <boost/format.hpp>
#include <boost/make_shared.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
#include <queue>
class mock_ctrl_iface_impl : public uhd::rfnoc::ctrl_iface
{
-
- uint64_t send_cmd_pkt(
- const size_t addr,
- const size_t data,
- const bool readback=false,
- const uint64_t timestamp=0
- );
+ uint64_t send_cmd_pkt(const size_t addr,
+ const size_t data,
+ const bool readback = false,
+ const uint64_t timestamp = 0);
};
#endif /* INCLUDED_MOCK_CTRL_IFACE_IMPL_HPP */ \ No newline at end of file
diff --git a/host/tests/common/mock_zero_copy.cpp b/host/tests/common/mock_zero_copy.cpp
index bc49c3f10..0843a0274 100644
--- a/host/tests/common/mock_zero_copy.cpp
+++ b/host/tests/common/mock_zero_copy.cpp
@@ -10,18 +10,19 @@
using namespace uhd::transport;
-mock_zero_copy::mock_zero_copy(
- vrt::if_packet_info_t::link_type_t link_type,
+mock_zero_copy::mock_zero_copy(vrt::if_packet_info_t::link_type_t link_type,
size_t recv_frame_size,
- size_t send_frame_size
-) : _link_type(link_type)
- , _recv_frame_size(recv_frame_size)
- , _send_frame_size(send_frame_size) {
+ size_t send_frame_size)
+ : _link_type(link_type)
+ , _recv_frame_size(recv_frame_size)
+ , _send_frame_size(send_frame_size)
+{
}
-uhd::transport::managed_recv_buffer::sptr mock_zero_copy::get_recv_buff(double) {
+uhd::transport::managed_recv_buffer::sptr mock_zero_copy::get_recv_buff(double)
+{
if (_simulate_io_error) {
- throw uhd::io_error("IO error exception"); //simulate an IO error
+ throw uhd::io_error("IO error exception"); // simulate an IO error
}
if (_rx_mems.empty()) {
return uhd::transport::managed_recv_buffer::sptr(); // timeout
@@ -38,20 +39,22 @@ uhd::transport::managed_recv_buffer::sptr mock_zero_copy::get_recv_buff(double)
return mrb;
}
-uhd::transport::managed_send_buffer::sptr mock_zero_copy::get_send_buff(double) {
+uhd::transport::managed_send_buffer::sptr mock_zero_copy::get_send_buff(double)
+{
if (not _reuse_send_memory or _tx_mems.size() == 0) {
- _tx_mems.push_back(
- boost::shared_array<uint8_t>(new uint8_t[_send_frame_size]));
+ _tx_mems.push_back(boost::shared_array<uint8_t>(new uint8_t[_send_frame_size]));
_tx_lens.push_back(_send_frame_size);
}
return _msb.get_new(_tx_mems.back(), &_tx_lens.back());
}
-void mock_zero_copy::set_reuse_recv_memory(bool reuse_recv) {
+void mock_zero_copy::set_reuse_recv_memory(bool reuse_recv)
+{
_reuse_recv_memory = reuse_recv;
}
-void mock_zero_copy::set_reuse_send_memory(bool reuse_send) {
+void mock_zero_copy::set_reuse_send_memory(bool reuse_send)
+{
_reuse_send_memory = reuse_send;
}
diff --git a/host/tests/common/mock_zero_copy.hpp b/host/tests/common/mock_zero_copy.hpp
index 8d27c9b46..60e5f4659 100644
--- a/host/tests/common/mock_zero_copy.hpp
+++ b/host/tests/common/mock_zero_copy.hpp
@@ -7,18 +7,17 @@
#ifndef INCLUDED_MOCK_XPORT_HPP
#define INCLUDED_MOCK_XPORT_HPP
-#include <uhdlib/rfnoc/xports.hpp>
+#include <uhd/exception.hpp>
#include <uhd/transport/chdr.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
#include <uhd/transport/zero_copy.hpp>
#include <uhd/types/endianness.hpp>
#include <uhd/types/sid.hpp>
-#include <uhd/exception.hpp>
#include <uhd/utils/byteswap.hpp>
-#include <uhd/exception.hpp>
+#include <uhdlib/rfnoc/xports.hpp>
#include <boost/make_shared.hpp>
-#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
+#include <boost/shared_ptr.hpp>
#include <list>
#include <vector>
@@ -36,89 +35,101 @@ static constexpr size_t DEFAULT_RECV_FRAME_SIZE = 1024;
/***********************************************************************
* Dummy managed buffers for testing
**********************************************************************/
-class mock_msb : public uhd::transport::managed_send_buffer {
- public:
- void release(void) { /* nop */
+class mock_msb : public uhd::transport::managed_send_buffer
+{
+public:
+ void release(void)
+ { /* nop */
}
- sptr get_new(boost::shared_array<uint8_t> mem, size_t* len) {
+ sptr get_new(boost::shared_array<uint8_t> mem, size_t* len)
+ {
_mem = mem;
return make(this, mem.get(), *len);
}
- private:
+private:
boost::shared_array<uint8_t> _mem;
};
-class mock_mrb : public uhd::transport::managed_recv_buffer {
- public:
- void release(void) { /* nop */
+class mock_mrb : public uhd::transport::managed_recv_buffer
+{
+public:
+ void release(void)
+ { /* nop */
}
- sptr get_new(boost::shared_array<uint8_t> mem, size_t len) {
+ sptr get_new(boost::shared_array<uint8_t> mem, size_t len)
+ {
_mem = mem;
return make(this, _mem.get(), len);
}
- private:
+private:
boost::shared_array<uint8_t> _mem;
};
-class mock_zero_copy : public uhd::transport::zero_copy_if {
- public:
+class mock_zero_copy : public uhd::transport::zero_copy_if
+{
+public:
typedef boost::shared_ptr<mock_zero_copy> sptr;
- mock_zero_copy(
- uhd::transport::vrt::if_packet_info_t::link_type_t type,
+ mock_zero_copy(uhd::transport::vrt::if_packet_info_t::link_type_t type,
size_t recv_frame_size = DEFAULT_RECV_FRAME_SIZE,
- size_t send_frame_size = DEFAULT_SEND_FRAME_SIZE
- );
+ size_t send_frame_size = DEFAULT_SEND_FRAME_SIZE);
uhd::transport::managed_recv_buffer::sptr get_recv_buff(double);
uhd::transport::managed_send_buffer::sptr get_send_buff(double);
- size_t get_num_recv_frames(void) const { return 1; }
- size_t get_num_send_frames(void) const { return 1; }
- size_t get_recv_frame_size(void) const { return _recv_frame_size; }
- size_t get_send_frame_size(void) const { return _send_frame_size; }
+ size_t get_num_recv_frames(void) const
+ {
+ return 1;
+ }
+ size_t get_num_send_frames(void) const
+ {
+ return 1;
+ }
+ size_t get_recv_frame_size(void) const
+ {
+ return _recv_frame_size;
+ }
+ size_t get_send_frame_size(void) const
+ {
+ return _send_frame_size;
+ }
template <typename T>
- void push_back_packet(
- uhd::transport::vrt::if_packet_info_t& ifpi,
+ void push_back_packet(uhd::transport::vrt::if_packet_info_t& ifpi,
const std::vector<T>& otw_data = std::vector<T>(),
- uhd::endianness_t endianness = uhd::ENDIANNESS_BIG);
+ uhd::endianness_t endianness = uhd::ENDIANNESS_BIG);
void set_reuse_recv_memory(bool reuse_recv);
void set_reuse_send_memory(bool reuse_send);
- void set_simulate_io_error(bool status) { _simulate_io_error = status; }
+ void set_simulate_io_error(bool status)
+ {
+ _simulate_io_error = status;
+ }
template <typename T, uhd::endianness_t endianness = uhd::ENDIANNESS_BIG>
void push_back_recv_packet(
- uhd::transport::vrt::if_packet_info_t& ifpi,
- const std::vector<T>& otw_data
- );
+ uhd::transport::vrt::if_packet_info_t& ifpi, const std::vector<T>& otw_data);
template <uhd::endianness_t endianness = uhd::ENDIANNESS_BIG>
void push_back_inline_message_packet(
- uhd::transport::vrt::if_packet_info_t& ifpi,
- const uint32_t message
- );
+ uhd::transport::vrt::if_packet_info_t& ifpi, const uint32_t message);
template <uhd::endianness_t endianness = uhd::ENDIANNESS_BIG>
void push_back_flow_ctrl_packet(
uhd::transport::vrt::if_packet_info_t::packet_type_t type,
uint32_t packet_count,
- uint32_t byte_count
- );
+ uint32_t byte_count);
template <uhd::endianness_t endianness = uhd::ENDIANNESS_BIG>
- void pop_send_packet(
- uhd::transport::vrt::if_packet_info_t &ifpi
- );
+ void pop_send_packet(uhd::transport::vrt::if_packet_info_t& ifpi);
- private:
+private:
std::list<boost::shared_array<uint8_t>> _tx_mems;
std::list<size_t> _tx_lens;
@@ -136,27 +147,23 @@ class mock_zero_copy : public uhd::transport::zero_copy_if {
bool _reuse_recv_memory = false;
bool _reuse_send_memory = false;
-
};
template <typename T, uhd::endianness_t endianness>
void mock_zero_copy::push_back_recv_packet(
- uhd::transport::vrt::if_packet_info_t& ifpi,
- const std::vector<T>& otw_data
-) {
+ uhd::transport::vrt::if_packet_info_t& ifpi, const std::vector<T>& otw_data)
+{
using namespace uhd::transport;
UHD_ASSERT_THROW(
- ifpi.num_payload_words32 * sizeof(uint32_t)
- == otw_data.size() * sizeof(T));
+ ifpi.num_payload_words32 * sizeof(uint32_t) == otw_data.size() * sizeof(T));
const size_t max_hdr_len =
- _link_type == vrt::if_packet_info_t::LINK_TYPE_CHDR ?
- vrt::chdr::max_if_hdr_words64*sizeof(uint64_t) :
- (vrt::max_if_hdr_words32 + 1/*tlr*/)*sizeof(uint32_t);
+ _link_type == vrt::if_packet_info_t::LINK_TYPE_CHDR
+ ? vrt::chdr::max_if_hdr_words64 * sizeof(uint64_t)
+ : (vrt::max_if_hdr_words32 + 1 /*tlr*/) * sizeof(uint32_t);
- const size_t max_pkt_len =
- ifpi.num_payload_words32*sizeof(uint32_t)+max_hdr_len;
+ const size_t max_pkt_len = ifpi.num_payload_words32 * sizeof(uint32_t) + max_hdr_len;
UHD_ASSERT_THROW(max_pkt_len <= _recv_frame_size);
@@ -168,15 +175,13 @@ void mock_zero_copy::push_back_recv_packet(
if (endianness == uhd::ENDIANNESS_BIG) {
if (_link_type == vrt::if_packet_info_t::LINK_TYPE_CHDR) {
uhd::transport::vrt::chdr::if_hdr_pack_be(rx_buff_ptr, ifpi);
- }
- else {
+ } else {
uhd::transport::vrt::if_hdr_pack_be(rx_buff_ptr, ifpi);
}
} else {
if (_link_type == vrt::if_packet_info_t::LINK_TYPE_CHDR) {
uhd::transport::vrt::chdr::if_hdr_pack_le(rx_buff_ptr, ifpi);
- }
- else {
+ } else {
uhd::transport::vrt::if_hdr_pack_le(rx_buff_ptr, ifpi);
}
}
@@ -184,42 +189,37 @@ void mock_zero_copy::push_back_recv_packet(
// Copy data
uint32_t* data_ptr = (rx_buff_ptr + ifpi.num_header_words32);
std::copy(otw_data.begin(), otw_data.end(), reinterpret_cast<T*>(data_ptr));
- _rx_lens.push_back(ifpi.num_packet_words32*sizeof(uint32_t));
+ _rx_lens.push_back(ifpi.num_packet_words32 * sizeof(uint32_t));
}
template <uhd::endianness_t endianness>
void mock_zero_copy::push_back_inline_message_packet(
- uhd::transport::vrt::if_packet_info_t& ifpi,
- const uint32_t message
-) {
- const std::vector<uint32_t> data { message | uhd::byteswap(message) };
+ uhd::transport::vrt::if_packet_info_t& ifpi, const uint32_t message)
+{
+ const std::vector<uint32_t> data{message | uhd::byteswap(message)};
push_back_recv_packet<uint32_t, endianness>(ifpi, data);
}
template <uhd::endianness_t endianness>
-void mock_zero_copy::pop_send_packet(
- uhd::transport::vrt::if_packet_info_t &ifpi
-) {
+void mock_zero_copy::pop_send_packet(uhd::transport::vrt::if_packet_info_t& ifpi)
+{
using namespace uhd::transport;
- ifpi.num_packet_words32 = _tx_lens.front()/sizeof(uint32_t);
+ ifpi.num_packet_words32 = _tx_lens.front() / sizeof(uint32_t);
- uint32_t* tx_buff_ptr = reinterpret_cast<uint32_t *>(_tx_mems.front().get());
+ uint32_t* tx_buff_ptr = reinterpret_cast<uint32_t*>(_tx_mems.front().get());
if (endianness == uhd::ENDIANNESS_BIG) {
if (_link_type == vrt::if_packet_info_t::LINK_TYPE_CHDR) {
uhd::transport::vrt::chdr::if_hdr_unpack_be(tx_buff_ptr, ifpi);
- }
- else {
+ } else {
uhd::transport::vrt::if_hdr_unpack_be(tx_buff_ptr, ifpi);
}
- }
- else {
+ } else {
if (_link_type == vrt::if_packet_info_t::LINK_TYPE_CHDR) {
uhd::transport::vrt::chdr::if_hdr_unpack_le(tx_buff_ptr, ifpi);
- }
- else {
+ } else {
uhd::transport::vrt::if_hdr_unpack_le(tx_buff_ptr, ifpi);
}
}
@@ -231,14 +231,12 @@ template <uhd::endianness_t endianness>
void mock_zero_copy::push_back_flow_ctrl_packet(
uhd::transport::vrt::if_packet_info_t::packet_type_t type,
uint32_t packet_count,
- uint32_t byte_count
-)
+ uint32_t byte_count)
{
using namespace uhd::transport;
- UHD_ASSERT_THROW(
- type == vrt::if_packet_info_t::PACKET_TYPE_FC or
- type == vrt::if_packet_info_t::PACKET_TYPE_ACK);
+ UHD_ASSERT_THROW(type == vrt::if_packet_info_t::PACKET_TYPE_FC
+ or type == vrt::if_packet_info_t::PACKET_TYPE_ACK);
// Only implemented for chdr packets currently
UHD_ASSERT_THROW(_link_type == vrt::if_packet_info_t::LINK_TYPE_CHDR);
@@ -246,18 +244,17 @@ void mock_zero_copy::push_back_flow_ctrl_packet(
const size_t packet_len_in_words32 = 2;
vrt::if_packet_info_t ifpi;
- ifpi.packet_type = type;
+ ifpi.packet_type = type;
ifpi.num_payload_words32 = packet_len_in_words32;
- ifpi.num_payload_bytes = ifpi.num_payload_words32*sizeof(uint32_t);
- ifpi.has_tsf = false;
+ ifpi.num_payload_bytes = ifpi.num_payload_words32 * sizeof(uint32_t);
+ ifpi.has_tsf = false;
std::vector<uint32_t> data(packet_len_in_words32, 0);
if (endianness == uhd::ENDIANNESS_BIG) {
data[0] = uhd::ntohx(packet_count);
data[1] = uhd::ntohx(byte_count);
- }
- else {
+ } else {
data[0] = uhd::wtohx(packet_count);
data[1] = uhd::wtohx(byte_count);
}
diff --git a/host/tests/config_parser_test.cpp b/host/tests/config_parser_test.cpp
index ef1686a11..2016776a7 100644
--- a/host/tests/config_parser_test.cpp
+++ b/host/tests/config_parser_test.cpp
@@ -5,93 +5,68 @@
//
#include <uhdlib/utils/config_parser.hpp>
-#include <boost/test/unit_test.hpp>
#include <boost/assign/list_of.hpp>
-#include <fstream>
+#include <boost/test/unit_test.hpp>
#include <cstdio>
+#include <fstream>
const std::string INI1_FILENAME = "test1.ini";
-const std::string INI1 =
- "[section1]\n"
- "key1=value1\n"
- "key2=4\n"
- "\n"
- "; This is a comment\n"
- "[section2]\n"
- "key3=value with spaces\n"
- "key4= leading and trailing spaces \n"
-;
+const std::string INI1 = "[section1]\n"
+ "key1=value1\n"
+ "key2=4\n"
+ "\n"
+ "; This is a comment\n"
+ "[section2]\n"
+ "key3=value with spaces\n"
+ "key4= leading and trailing spaces \n";
const std::string INI2_FILENAME = "test2.ini";
-const std::string INI2 =
- "[section2]\n"
- "key3=value with even more spaces\n"
- "\n"
- "[section3]\n"
- "key4=\"with quotes\"\n";
+const std::string INI2 = "[section2]\n"
+ "key3=value with even more spaces\n"
+ "\n"
+ "[section3]\n"
+ "key4=\"with quotes\"\n";
namespace {
- //! Create files that can be read by the CUT
- void make_config_parsers()
- {
- std::ofstream ini1(INI1_FILENAME);
- ini1 << INI1 << std::endl;
- ini1.close();
- std::ofstream ini2(INI2_FILENAME);
- ini2 << INI2 << std::endl;
- ini2.close();
- }
+//! Create files that can be read by the CUT
+void make_config_parsers()
+{
+ std::ofstream ini1(INI1_FILENAME);
+ ini1 << INI1 << std::endl;
+ ini1.close();
+ std::ofstream ini2(INI2_FILENAME);
+ ini2 << INI2 << std::endl;
+ ini2.close();
+}
- //! Tidy up after us
- void cleanup_config_parsers()
- {
- std::remove(INI1_FILENAME.c_str());
- std::remove(INI2_FILENAME.c_str());
- }
+//! Tidy up after us
+void cleanup_config_parsers()
+{
+ std::remove(INI1_FILENAME.c_str());
+ std::remove(INI2_FILENAME.c_str());
}
+} // namespace
-BOOST_AUTO_TEST_CASE(test_config_parser){
+BOOST_AUTO_TEST_CASE(test_config_parser)
+{
make_config_parsers();
uhd::config_parser I(INI1_FILENAME);
BOOST_CHECK_EQUAL(I.sections().size(), 2);
BOOST_CHECK_EQUAL(I.options("section1").size(), 2);
+ BOOST_CHECK_EQUAL(I.get<std::string>("section1", "key1"), "value1");
+ BOOST_CHECK_EQUAL(I.get<int>("section1", "key2"), 4);
+ BOOST_CHECK_EQUAL(I.get<std::string>("section2", "key3"), "value with spaces");
BOOST_CHECK_EQUAL(
- I.get<std::string>("section1", "key1"),
- "value1"
- );
+ I.get<std::string>("section2", "key4"), "leading and trailing spaces");
BOOST_CHECK_EQUAL(
- I.get<int>("section1", "key2"),
- 4
- );
- BOOST_CHECK_EQUAL(
- I.get<std::string>("section2", "key3"),
- "value with spaces"
- );
- BOOST_CHECK_EQUAL(
- I.get<std::string>("section2", "key4"),
- "leading and trailing spaces"
- );
- BOOST_CHECK_EQUAL(
- I.get<std::string>("section2", "non_existent_key", "default"),
- "default"
- );
+ I.get<std::string>("section2", "non_existent_key", "default"), "default");
BOOST_REQUIRE_THROW(
- I.get<std::string>("section2", "non_existent_key"),
- uhd::key_error
- );
+ I.get<std::string>("section2", "non_existent_key"), uhd::key_error);
I.read_file(INI2_FILENAME);
BOOST_CHECK_EQUAL(
- I.get<std::string>("section2", "key3"),
- "value with even more spaces"
- );
- BOOST_CHECK_EQUAL(
- I.get<std::string>("section1", "key1"),
- "value1"
- );
- BOOST_CHECK_EQUAL(
- I.get<std::string>("section3", "key4"),
- "\"with quotes\""
- );
+ I.get<std::string>("section2", "key3"), "value with even more spaces");
+ BOOST_CHECK_EQUAL(I.get<std::string>("section1", "key1"), "value1");
+ BOOST_CHECK_EQUAL(I.get<std::string>("section3", "key4"), "\"with quotes\"");
cleanup_config_parsers();
}
diff --git a/host/tests/constrained_device_args_test.cpp b/host/tests/constrained_device_args_test.cpp
index 318315739..2fe7e5c16 100644
--- a/host/tests/constrained_device_args_test.cpp
+++ b/host/tests/constrained_device_args_test.cpp
@@ -4,101 +4,93 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhdlib/usrp/constrained_device_args.hpp>
+#include <boost/test/unit_test.hpp>
#include <iostream>
using uhd::usrp::constrained_device_args_t;
namespace {
- enum test_enum_t { VALUE1, VALUE2, VALUE3=4 };
+enum test_enum_t { VALUE1, VALUE2, VALUE3 = 4 };
- static constexpr double MAX_DOUBLE_ARG = 1e6;
- static constexpr double MIN_DOUBLE_ARG = 0.125;
+static constexpr double MAX_DOUBLE_ARG = 1e6;
+static constexpr double MIN_DOUBLE_ARG = 0.125;
- static constexpr double DEFAULT_DOUBLE_ARG = 2.25;
- static constexpr size_t DEFAULT_SIZE_T_ARG = 42;
- static constexpr bool DEFAULT_BOOL_ARG = true;
- static constexpr test_enum_t DEFAULT_ENUM_ARG = VALUE1;
+static constexpr double DEFAULT_DOUBLE_ARG = 2.25;
+static constexpr size_t DEFAULT_SIZE_T_ARG = 42;
+static constexpr bool DEFAULT_BOOL_ARG = true;
+static constexpr test_enum_t DEFAULT_ENUM_ARG = VALUE1;
- class test_device_args_t : public constrained_device_args_t
+class test_device_args_t : public constrained_device_args_t
+{
+public:
+ test_device_args_t() {}
+ test_device_args_t(const std::string& dev_args)
{
- public:
- test_device_args_t() {}
- test_device_args_t(const std::string& dev_args) { parse(dev_args); }
+ parse(dev_args);
+ }
- double get_double_arg() const {
- return _double_arg.get();
- }
- size_t get_size_t_arg() const {
- return _size_t_arg.get();
- }
- bool get_bool_arg() const {
- return _bool_arg.get();
- }
- test_enum_t get_enum_arg() const {
- return _enum_arg.get();
- }
+ double get_double_arg() const
+ {
+ return _double_arg.get();
+ }
+ size_t get_size_t_arg() const
+ {
+ return _size_t_arg.get();
+ }
+ bool get_bool_arg() const
+ {
+ return _bool_arg.get();
+ }
+ test_enum_t get_enum_arg() const
+ {
+ return _enum_arg.get();
+ }
- inline virtual std::string to_string() const {
- return _double_arg.to_string() + ", " +
- _size_t_arg.to_string() + ", " +
- _bool_arg.to_string() + ", " +
- _enum_arg.to_string();
- }
- private:
- virtual void _parse(const uhd::device_addr_t& dev_args) {
- if (dev_args.has_key(_double_arg.key()))
- _double_arg.parse(dev_args[_double_arg.key()]);
- if (dev_args.has_key(_size_t_arg.key()))
- _size_t_arg.parse(dev_args[_size_t_arg.key()]);
- if (dev_args.has_key(_bool_arg.key()))
- _bool_arg.parse(dev_args[_bool_arg.key()]);
- if (dev_args.has_key(_enum_arg.key()))
- _enum_arg.parse(dev_args[_enum_arg.key()]);
- _enforce_range(_double_arg, MIN_DOUBLE_ARG, MAX_DOUBLE_ARG);
- }
+ inline virtual std::string to_string() const
+ {
+ return _double_arg.to_string() + ", " + _size_t_arg.to_string() + ", "
+ + _bool_arg.to_string() + ", " + _enum_arg.to_string();
+ }
- constrained_device_args_t::num_arg<double> _double_arg
- {"double_arg", DEFAULT_DOUBLE_ARG};
- constrained_device_args_t::num_arg<size_t> _size_t_arg
- {"size_t_arg", DEFAULT_SIZE_T_ARG};
- constrained_device_args_t::bool_arg _bool_arg
- {"bool_arg", DEFAULT_BOOL_ARG};
- constrained_device_args_t::enum_arg<test_enum_t> _enum_arg
- {"enum_arg", DEFAULT_ENUM_ARG,
- {{"value1", VALUE1}, {"value2", VALUE2}, {"VALUE3", VALUE3}}};
- };
+private:
+ virtual void _parse(const uhd::device_addr_t& dev_args)
+ {
+ if (dev_args.has_key(_double_arg.key()))
+ _double_arg.parse(dev_args[_double_arg.key()]);
+ if (dev_args.has_key(_size_t_arg.key()))
+ _size_t_arg.parse(dev_args[_size_t_arg.key()]);
+ if (dev_args.has_key(_bool_arg.key()))
+ _bool_arg.parse(dev_args[_bool_arg.key()]);
+ if (dev_args.has_key(_enum_arg.key()))
+ _enum_arg.parse(dev_args[_enum_arg.key()]);
+ _enforce_range(_double_arg, MIN_DOUBLE_ARG, MAX_DOUBLE_ARG);
+ }
-}
+ constrained_device_args_t::num_arg<double> _double_arg{
+ "double_arg", DEFAULT_DOUBLE_ARG};
+ constrained_device_args_t::num_arg<size_t> _size_t_arg{
+ "size_t_arg", DEFAULT_SIZE_T_ARG};
+ constrained_device_args_t::bool_arg _bool_arg{"bool_arg", DEFAULT_BOOL_ARG};
+ constrained_device_args_t::enum_arg<test_enum_t> _enum_arg{"enum_arg",
+ DEFAULT_ENUM_ARG,
+ {{"value1", VALUE1}, {"value2", VALUE2}, {"VALUE3", VALUE3}}};
+};
-BOOST_AUTO_TEST_CASE(test_constrained_device_args) {
+} // namespace
+
+BOOST_AUTO_TEST_CASE(test_constrained_device_args)
+{
test_device_args_t test_dev_args("double_arg=3.5,bool_arg=0,foo=bar");
BOOST_CHECK_EQUAL(test_dev_args.get_double_arg(), 3.5);
- BOOST_CHECK_EQUAL(
- test_dev_args.get_size_t_arg(),
- DEFAULT_SIZE_T_ARG
- );
+ BOOST_CHECK_EQUAL(test_dev_args.get_size_t_arg(), DEFAULT_SIZE_T_ARG);
BOOST_CHECK_EQUAL(test_dev_args.get_bool_arg(), false);
- BOOST_CHECK_EQUAL(
- test_dev_args.get_enum_arg(),
- DEFAULT_ENUM_ARG
- );
- BOOST_REQUIRE_THROW(
- test_dev_args.parse("double_arg=2e6"),
- uhd::value_error
- ); // Note: test_dev_args is now in a bad state until we fix it!
- test_dev_args.parse("double_arg=2.6"),
- test_dev_args.parse("enum_arg=vaLue2");
- BOOST_CHECK_EQUAL(
- test_dev_args.get_enum_arg(),
- VALUE2
- );
+ BOOST_CHECK_EQUAL(test_dev_args.get_enum_arg(), DEFAULT_ENUM_ARG);
+ BOOST_REQUIRE_THROW(test_dev_args.parse("double_arg=2e6"),
+ uhd::value_error); // Note: test_dev_args is now in a bad state until we fix it!
+ test_dev_args.parse("double_arg=2.6"), test_dev_args.parse("enum_arg=vaLue2");
+ BOOST_CHECK_EQUAL(test_dev_args.get_enum_arg(), VALUE2);
test_dev_args.parse("enum_arg=VALUE3");
- BOOST_CHECK_EQUAL(
- test_dev_args.get_enum_arg(),
- VALUE3
- );
+ BOOST_CHECK_EQUAL(test_dev_args.get_enum_arg(), VALUE3);
}
-
diff --git a/host/tests/convert_test.cpp b/host/tests/convert_test.cpp
index 862e02073..67409e310 100644
--- a/host/tests/convert_test.cpp
+++ b/host/tests/convert_test.cpp
@@ -6,52 +6,54 @@
//
#include <uhd/convert.hpp>
-#include <boost/test/unit_test.hpp>
#include <stdint.h>
+#include <boost/test/unit_test.hpp>
#include <complex>
-#include <vector>
#include <cstdlib>
#include <iostream>
+#include <vector>
using namespace uhd;
-//typedefs for complex types
+// typedefs for complex types
typedef std::complex<int16_t> sc16_t;
typedef std::complex<float> fc32_t;
typedef std::complex<double> fc64_t;
-#define MY_CHECK_CLOSE(a, b, f) { \
- BOOST_CHECK_MESSAGE(std::abs((a)-(b)) < f, "\n\t" << #a << " (" << (a) << ") error " << #b << " (" << (b) << ")"); \
-}
+#define MY_CHECK_CLOSE(a, b, f) \
+ { \
+ BOOST_CHECK_MESSAGE(std::abs((a) - (b)) < f, \
+ "\n\t" << #a << " (" << (a) << ") error " << #b << " (" << (b) << ")"); \
+ }
/***********************************************************************
* Loopback runner:
* convert input buffer into intermediate buffer
* convert intermediate buffer into output buffer
**********************************************************************/
-template <typename Range> static void loopback(
- size_t nsamps,
- convert::id_type &in_id,
- convert::id_type &out_id,
- const Range &input,
- Range &output,
- const int prio_in = -1,
- const int prio_out = -1
-){
- //make this buffer large enough for all test types
+template <typename Range>
+static void loopback(size_t nsamps,
+ convert::id_type& in_id,
+ convert::id_type& out_id,
+ const Range& input,
+ Range& output,
+ const int prio_in = -1,
+ const int prio_out = -1)
+{
+ // make this buffer large enough for all test types
std::vector<uint64_t> interm(nsamps);
- std::vector<const void *> input0(1, &input[0]), input1(1, &interm[0]);
- std::vector<void *> output0(1, &interm[0]), output1(1, &output[0]);
+ std::vector<const void*> input0(1, &input[0]), input1(1, &interm[0]);
+ std::vector<void*> output0(1, &interm[0]), output1(1, &output[0]);
- //convert to intermediate type
+ // convert to intermediate type
convert::converter::sptr c0 = convert::get_converter(in_id, prio_in)();
c0->set_scalar(32767.);
c0->conv(input0, output0, nsamps);
- //convert back to host type
+ // convert back to host type
convert::converter::sptr c1 = convert::get_converter(out_id, prio_out)();
- c1->set_scalar(1/32767.);
+ c1->set_scalar(1 / 32767.);
c1->conv(input1, output1, nsamps);
}
@@ -59,46 +61,51 @@ template <typename Range> static void loopback(
* Test short conversion
**********************************************************************/
static void test_convert_types_sc16(
- size_t nsamps, convert::id_type &id, const int extra_div = 1, int mask = 0xffff
-){
- //fill the input samples
+ size_t nsamps, convert::id_type& id, const int extra_div = 1, int mask = 0xffff)
+{
+ // fill the input samples
std::vector<sc16_t> input(nsamps), output(nsamps);
- for(sc16_t &in: input) in = sc16_t(
- short((float((std::rand())/(double(RAND_MAX)/2)) - 1)*32767/extra_div) & mask,
- short((float((std::rand())/(double(RAND_MAX)/2)) - 1)*32767/extra_div) & mask
- );
-
- //run the loopback and test
- convert::id_type in_id = id;
+ for (sc16_t& in : input)
+ in = sc16_t(
+ short((float((std::rand()) / (double(RAND_MAX) / 2)) - 1) * 32767 / extra_div)
+ & mask,
+ short((float((std::rand()) / (double(RAND_MAX) / 2)) - 1) * 32767 / extra_div)
+ & mask);
+
+ // run the loopback and test
+ 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_CHECK_EQUAL_COLLECTIONS(
+ input.begin(), input.end(), output.begin(), output.end());
}
-BOOST_AUTO_TEST_CASE(test_convert_types_be_sc16){
+BOOST_AUTO_TEST_CASE(test_convert_types_be_sc16)
+{
convert::id_type id;
- id.input_format = "sc16";
- id.num_inputs = 1;
+ id.input_format = "sc16";
+ id.num_inputs = 1;
id.output_format = "sc16_item32_be";
- id.num_outputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ // try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_sc16(nsamps, id);
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_le_sc16){
+BOOST_AUTO_TEST_CASE(test_convert_types_le_sc16)
+{
convert::id_type id;
- id.input_format = "sc16";
- id.num_inputs = 1;
+ id.input_format = "sc16";
+ id.num_inputs = 1;
id.output_format = "sc16_item32_le";
- id.num_outputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ // try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_sc16(nsamps, id);
}
}
@@ -108,90 +115,90 @@ BOOST_AUTO_TEST_CASE(test_convert_types_le_sc16){
**********************************************************************/
template <typename data_type>
static void test_convert_types_for_floats(
- size_t nsamps, convert::id_type &id, const double extra_scale = 1.0
-){
+ size_t nsamps, convert::id_type& id, const double extra_scale = 1.0)
+{
typedef typename data_type::value_type value_type;
- //fill the input samples
+ // fill the input samples
std::vector<data_type> input(nsamps), output(nsamps);
- for(data_type &in: input) in = data_type(
- ((std::rand()/(value_type(RAND_MAX)/2)) - 1)*float(extra_scale),
- ((std::rand()/(value_type(RAND_MAX)/2)) - 1)*float(extra_scale)
- );
+ for (data_type& in : input)
+ in = data_type(
+ ((std::rand() / (value_type(RAND_MAX) / 2)) - 1) * float(extra_scale),
+ ((std::rand() / (value_type(RAND_MAX) / 2)) - 1) * float(extra_scale));
- //run the loopback and test
- convert::id_type in_id = id;
+ // run the loopback and test
+ 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);
- //make a list of all prio: best/generic combos
+ // make a list of all prio: best/generic combos
typedef std::pair<int, int> int_pair_t;
const std::vector<int_pair_t> prios{
- int_pair_t(0, 0),
- int_pair_t(-1, 0),
- int_pair_t(0, -1),
- int_pair_t(-1, -1)
- };
-
- //loopback foreach prio combo (generic vs best)
- for (const auto &prio : prios) {
+ int_pair_t(0, 0), int_pair_t(-1, 0), int_pair_t(0, -1), int_pair_t(-1, -1)};
+
+ // loopback foreach prio combo (generic vs best)
+ for (const auto& prio : prios) {
loopback(nsamps, in_id, out_id, input, output, prio.first, prio.second);
- for (size_t i = 0; i < nsamps; i++){
- MY_CHECK_CLOSE(input[i].real(), output[i].real(), value_type(1./(1 << 14)));
- MY_CHECK_CLOSE(input[i].imag(), output[i].imag(), value_type(1./(1 << 14)));
+ for (size_t i = 0; i < nsamps; i++) {
+ MY_CHECK_CLOSE(input[i].real(), output[i].real(), value_type(1. / (1 << 14)));
+ MY_CHECK_CLOSE(input[i].imag(), output[i].imag(), value_type(1. / (1 << 14)));
}
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_be_fc32){
+BOOST_AUTO_TEST_CASE(test_convert_types_be_fc32)
+{
convert::id_type id;
- id.input_format = "fc32";
- id.num_inputs = 1;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
id.output_format = "sc16_item32_be";
- id.num_outputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ // try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_for_floats<fc32_t>(nsamps, id);
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_le_fc32){
+BOOST_AUTO_TEST_CASE(test_convert_types_le_fc32)
+{
convert::id_type id;
- id.input_format = "fc32";
- id.num_inputs = 1;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
id.output_format = "sc16_item32_le";
- id.num_outputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ // try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_for_floats<fc32_t>(nsamps, id);
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_be_fc64){
+BOOST_AUTO_TEST_CASE(test_convert_types_be_fc64)
+{
convert::id_type id;
- id.input_format = "fc64";
- id.num_inputs = 1;
+ id.input_format = "fc64";
+ id.num_inputs = 1;
id.output_format = "sc16_item32_be";
- id.num_outputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ // try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_for_floats<fc64_t>(nsamps, id);
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_le_fc64){
+BOOST_AUTO_TEST_CASE(test_convert_types_le_fc64)
+{
convert::id_type id;
- id.input_format = "fc64";
- id.num_inputs = 1;
+ id.input_format = "fc64";
+ id.num_inputs = 1;
id.output_format = "sc16_item32_le";
- id.num_outputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ // try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_for_floats<fc64_t>(nsamps, id);
}
}
@@ -200,53 +207,57 @@ BOOST_AUTO_TEST_CASE(test_convert_types_le_fc64){
* Test float to/from sc12 conversion loopback
**********************************************************************/
-BOOST_AUTO_TEST_CASE(test_convert_types_le_sc12_with_fc32){
+BOOST_AUTO_TEST_CASE(test_convert_types_le_sc12_with_fc32)
+{
convert::id_type id;
- id.input_format = "fc32";
- id.num_inputs = 1;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
id.output_format = "sc12_item32_le";
- id.num_outputs = 1;
+ 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, id, 1./16);
+ // try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
+ test_convert_types_for_floats<fc32_t>(nsamps, id, 1. / 16);
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_be_sc12_with_fc32){
+BOOST_AUTO_TEST_CASE(test_convert_types_be_sc12_with_fc32)
+{
convert::id_type id;
- id.input_format = "fc32";
- id.num_inputs = 1;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
id.output_format = "sc12_item32_be";
- id.num_outputs = 1;
+ 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, id, 1./16);
+ // try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
+ test_convert_types_for_floats<fc32_t>(nsamps, id, 1. / 16);
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_le_sc16_and_sc12){
+BOOST_AUTO_TEST_CASE(test_convert_types_le_sc16_and_sc12)
+{
convert::id_type id;
id.input_format = "sc16";
- id.num_inputs = 1;
- id.num_outputs = 1;
+ id.num_inputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "sc12_item32_le";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_sc16(nsamps, id, 1, 0xfff0);
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_be_sc16_and_sc12){
+BOOST_AUTO_TEST_CASE(test_convert_types_be_sc16_and_sc12)
+{
convert::id_type id;
id.input_format = "sc16";
- id.num_inputs = 1;
- id.num_outputs = 1;
+ id.num_inputs = 1;
+ id.num_outputs = 1;
id.output_format = "sc12_item32_be";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_sc16(nsamps, id, 1, 0xfff0);
}
}
@@ -255,28 +266,30 @@ BOOST_AUTO_TEST_CASE(test_convert_types_be_sc16_and_sc12){
* Test float to/from fc32 conversion loopback
**********************************************************************/
-BOOST_AUTO_TEST_CASE(test_convert_types_le_fc32_with_fc32){
+BOOST_AUTO_TEST_CASE(test_convert_types_le_fc32_with_fc32)
+{
convert::id_type id;
- id.input_format = "fc32";
- id.num_inputs = 1;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
id.output_format = "fc32_item32_le";
- id.num_outputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ // try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_for_floats<fc32_t>(nsamps, id);
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_be_fc32_with_fc32){
+BOOST_AUTO_TEST_CASE(test_convert_types_be_fc32_with_fc32)
+{
convert::id_type id;
- id.input_format = "fc32";
- id.num_inputs = 1;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
id.output_format = "fc32_item32_be";
- id.num_outputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ // try various lengths to test edge cases
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_for_floats<fc32_t>(nsamps, id);
}
}
@@ -284,149 +297,151 @@ BOOST_AUTO_TEST_CASE(test_convert_types_be_fc32_with_fc32){
/***********************************************************************
* Test float to short conversion loopback
**********************************************************************/
-BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16){
+BOOST_AUTO_TEST_CASE(test_convert_types_fc32_to_sc16)
+{
convert::id_type in_id;
- in_id.input_format = "fc32";
- in_id.num_inputs = 1;
+ in_id.input_format = "fc32";
+ in_id.num_inputs = 1;
in_id.output_format = "sc16_item32_le";
- in_id.num_outputs = 1;
+ in_id.num_outputs = 1;
convert::id_type out_id;
- out_id.input_format = "sc16_item32_le";
- out_id.num_inputs = 1;
+ out_id.input_format = "sc16_item32_le";
+ out_id.num_inputs = 1;
out_id.output_format = "sc16";
- out_id.num_outputs = 1;
+ out_id.num_outputs = 1;
const size_t nsamps = 13;
std::vector<fc32_t> input(nsamps);
- for(fc32_t &in: input) in = fc32_t(
- (std::rand()/(RAND_MAX/2.0)) - 1,
- (std::rand()/(RAND_MAX/2.0)) - 1
- );
+ for (fc32_t& in : input)
+ in = fc32_t(
+ (std::rand() / (RAND_MAX / 2.0)) - 1, (std::rand() / (RAND_MAX / 2.0)) - 1);
std::vector<uint32_t> interm(nsamps);
std::vector<sc16_t> output(nsamps);
- std::vector<const void *> input0(1, &input[0]), input1(1, &interm[0]);
- std::vector<void *> output0(1, &interm[0]), output1(1, &output[0]);
+ std::vector<const void*> input0(1, &input[0]), input1(1, &interm[0]);
+ std::vector<void*> output0(1, &interm[0]), output1(1, &output[0]);
- //convert float to intermediate
+ // convert float to intermediate
convert::converter::sptr c0 = convert::get_converter(in_id)();
c0->set_scalar(32767.);
c0->conv(input0, output0, nsamps);
- //convert intermediate to short
+ // convert intermediate to short
convert::converter::sptr c1 = convert::get_converter(out_id)();
- c1->set_scalar(1/32767.);
+ c1->set_scalar(1 / 32767.);
c1->conv(input1, output1, nsamps);
- //test that the inputs and outputs match
- for (size_t i = 0; i < nsamps; i++){
- MY_CHECK_CLOSE(input[i].real(), output[i].real()/float(32767), float(0.01));
- MY_CHECK_CLOSE(input[i].imag(), output[i].imag()/float(32767), float(0.01));
+ // test that the inputs and outputs match
+ for (size_t i = 0; i < nsamps; i++) {
+ MY_CHECK_CLOSE(input[i].real(), output[i].real() / float(32767), float(0.01));
+ MY_CHECK_CLOSE(input[i].imag(), output[i].imag() / float(32767), float(0.01));
}
}
/***********************************************************************
* Test short to float conversion loopback
**********************************************************************/
-BOOST_AUTO_TEST_CASE(test_convert_types_sc16_to_fc32){
+BOOST_AUTO_TEST_CASE(test_convert_types_sc16_to_fc32)
+{
convert::id_type in_id;
- in_id.input_format = "sc16";
- in_id.num_inputs = 1;
+ in_id.input_format = "sc16";
+ in_id.num_inputs = 1;
in_id.output_format = "sc16_item32_le";
- in_id.num_outputs = 1;
+ in_id.num_outputs = 1;
convert::id_type out_id;
- out_id.input_format = "sc16_item32_le";
- out_id.num_inputs = 1;
+ out_id.input_format = "sc16_item32_le";
+ out_id.num_inputs = 1;
out_id.output_format = "fc32";
- out_id.num_outputs = 1;
+ out_id.num_outputs = 1;
const size_t nsamps = 13;
std::vector<sc16_t> input(nsamps);
- for(sc16_t &in: input) in = sc16_t(
- std::rand()-(RAND_MAX/2),
- std::rand()-(RAND_MAX/2)
- );
+ for (sc16_t& in : input)
+ in = sc16_t(std::rand() - (RAND_MAX / 2), std::rand() - (RAND_MAX / 2));
std::vector<uint32_t> interm(nsamps);
std::vector<fc32_t> output(nsamps);
- std::vector<const void *> input0(1, &input[0]), input1(1, &interm[0]);
- std::vector<void *> output0(1, &interm[0]), output1(1, &output[0]);
+ std::vector<const void*> input0(1, &input[0]), input1(1, &interm[0]);
+ std::vector<void*> output0(1, &interm[0]), output1(1, &output[0]);
- //convert short to intermediate
+ // convert short to intermediate
convert::converter::sptr c0 = convert::get_converter(in_id)();
c0->set_scalar(32767.);
c0->conv(input0, output0, nsamps);
- //convert intermediate to float
+ // convert intermediate to float
convert::converter::sptr c1 = convert::get_converter(out_id)();
- c1->set_scalar(1/32767.);
+ c1->set_scalar(1 / 32767.);
c1->conv(input1, output1, nsamps);
- //test that the inputs and outputs match
- for (size_t i = 0; i < nsamps; i++){
- MY_CHECK_CLOSE(input[i].real()/float(32767), output[i].real(), float(0.01));
- MY_CHECK_CLOSE(input[i].imag()/float(32767), output[i].imag(), float(0.01));
+ // test that the inputs and outputs match
+ for (size_t i = 0; i < nsamps; i++) {
+ MY_CHECK_CLOSE(input[i].real() / float(32767), output[i].real(), float(0.01));
+ MY_CHECK_CLOSE(input[i].imag() / float(32767), output[i].imag(), float(0.01));
}
}
/***********************************************************************
* Test sc8 conversions
**********************************************************************/
-BOOST_AUTO_TEST_CASE(test_convert_types_fc64_and_sc8){
+BOOST_AUTO_TEST_CASE(test_convert_types_fc64_and_sc8)
+{
convert::id_type id;
id.input_format = "fc64";
- id.num_inputs = 1;
- id.num_outputs = 1;
+ id.num_inputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "sc8_item32_le";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
- test_convert_types_for_floats<fc64_t>(nsamps, id, 1./256);
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
+ test_convert_types_for_floats<fc64_t>(nsamps, id, 1. / 256);
}
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "sc8_item32_be";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
- test_convert_types_for_floats<fc64_t>(nsamps, id, 1./256);
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
+ test_convert_types_for_floats<fc64_t>(nsamps, id, 1. / 256);
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_fc32_and_sc8){
+BOOST_AUTO_TEST_CASE(test_convert_types_fc32_and_sc8)
+{
convert::id_type id;
id.input_format = "fc32";
- id.num_inputs = 1;
- id.num_outputs = 1;
+ id.num_inputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "sc8_item32_le";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
- test_convert_types_for_floats<fc32_t>(nsamps, id, 1./256);
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
+ test_convert_types_for_floats<fc32_t>(nsamps, id, 1. / 256);
}
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "sc8_item32_be";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
- test_convert_types_for_floats<fc32_t>(nsamps, id, 1./256);
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
+ test_convert_types_for_floats<fc32_t>(nsamps, id, 1. / 256);
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_sc16_and_sc8){
+BOOST_AUTO_TEST_CASE(test_convert_types_sc16_and_sc8)
+{
convert::id_type id;
id.input_format = "sc16";
- id.num_inputs = 1;
- id.num_outputs = 1;
+ id.num_inputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "sc8_item32_le";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_sc16(nsamps, id, 256);
}
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "sc8_item32_be";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_sc16(nsamps, id, 256);
}
}
@@ -434,39 +449,41 @@ BOOST_AUTO_TEST_CASE(test_convert_types_sc16_and_sc8){
/***********************************************************************
* Test u8 conversion
**********************************************************************/
-static void test_convert_types_u8(
- size_t nsamps, convert::id_type &id
-){
- //fill the input samples
+static void test_convert_types_u8(size_t nsamps, convert::id_type& id)
+{
+ // fill the input samples
std::vector<uint8_t> input(nsamps), output(nsamps);
- for(uint8_t &in: input) in = uint8_t(std::rand() & 0xFF);
- //uint32_t d = 48;
- //for(uint8_t &in: input) in = d++;
+ for (uint8_t& in : input)
+ in = uint8_t(std::rand() & 0xFF);
+ // uint32_t d = 48;
+ // for(uint8_t &in: input) in = d++;
- //run the loopback and test
- convert::id_type in_id = id;
+ // run the loopback and test
+ 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_CHECK_EQUAL_COLLECTIONS(
+ input.begin(), input.end(), output.begin(), output.end());
}
-BOOST_AUTO_TEST_CASE(test_convert_types_u8_and_u8){
+BOOST_AUTO_TEST_CASE(test_convert_types_u8_and_u8)
+{
convert::id_type id;
id.input_format = "u8";
- id.num_inputs = 1;
- id.num_outputs = 1;
+ id.num_inputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "u8_item32_le";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_u8(nsamps, id);
}
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "u8_item32_be";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_u8(nsamps, id);
}
}
@@ -474,37 +491,39 @@ BOOST_AUTO_TEST_CASE(test_convert_types_u8_and_u8){
/***********************************************************************
* Test s8 conversion
**********************************************************************/
-static void test_convert_types_s8(
- size_t nsamps, convert::id_type &id
-){
- //fill the input samples
+static void test_convert_types_s8(size_t nsamps, convert::id_type& id)
+{
+ // fill the input samples
std::vector<int8_t> input(nsamps), output(nsamps);
- for(int8_t &in: input) in = int8_t(std::rand() & 0xFF);
+ for (int8_t& in : input)
+ in = int8_t(std::rand() & 0xFF);
- //run the loopback and test
- convert::id_type in_id = id;
+ // run the loopback and test
+ 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_CHECK_EQUAL_COLLECTIONS(
+ input.begin(), input.end(), output.begin(), output.end());
}
-BOOST_AUTO_TEST_CASE(test_convert_types_s8_and_s8){
+BOOST_AUTO_TEST_CASE(test_convert_types_s8_and_s8)
+{
convert::id_type id;
id.input_format = "s8";
- id.num_inputs = 1;
- id.num_outputs = 1;
+ id.num_inputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "s8_item32_le";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_s8(nsamps, id);
}
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "s8_item32_be";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_s8(nsamps, id);
}
}
@@ -512,37 +531,39 @@ BOOST_AUTO_TEST_CASE(test_convert_types_s8_and_s8){
/***********************************************************************
* Test s16 conversion
**********************************************************************/
-static void test_convert_types_s16(
- size_t nsamps, convert::id_type &id
-){
- //fill the input samples
+static void test_convert_types_s16(size_t nsamps, convert::id_type& id)
+{
+ // fill the input samples
std::vector<int16_t> input(nsamps), output(nsamps);
- for(int16_t &in: input) in = int16_t(std::rand() & 0xFFFF);
+ for (int16_t& in : input)
+ in = int16_t(std::rand() & 0xFFFF);
- //run the loopback and test
- convert::id_type in_id = id;
+ // run the loopback and test
+ 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_CHECK_EQUAL_COLLECTIONS(
+ input.begin(), input.end(), output.begin(), output.end());
}
-BOOST_AUTO_TEST_CASE(test_convert_types_s16_and_s16){
+BOOST_AUTO_TEST_CASE(test_convert_types_s16_and_s16)
+{
convert::id_type id;
id.input_format = "s16";
- id.num_inputs = 1;
- id.num_outputs = 1;
+ id.num_inputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "s16_item32_le";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_s16(nsamps, id);
}
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "s16_item32_be";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_s16(nsamps, id);
}
}
@@ -550,43 +571,42 @@ BOOST_AUTO_TEST_CASE(test_convert_types_s16_and_s16){
/***********************************************************************
* Test fc32 -> fc32 conversion
**********************************************************************/
-static void test_convert_types_fc32(
- size_t nsamps, convert::id_type &id
-){
- //fill the input samples
- std::vector< std::complex<float> > input(nsamps), output(nsamps);
- for(fc32_t &in: input) in = fc32_t(
- (std::rand()/float(RAND_MAX/2)) - 1,
- (std::rand()/float(RAND_MAX/2)) - 1
- );
-
- //run the loopback and test
- convert::id_type in_id = id;
+static void test_convert_types_fc32(size_t nsamps, convert::id_type& id)
+{
+ // fill the input samples
+ std::vector<std::complex<float>> input(nsamps), output(nsamps);
+ for (fc32_t& in : input)
+ in = fc32_t((std::rand() / float(RAND_MAX / 2)) - 1,
+ (std::rand() / float(RAND_MAX / 2)) - 1);
+
+ // run the loopback and test
+ 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(), float(1./(1 << 16)));
- MY_CHECK_CLOSE(input[i].imag(), output[i].imag(), float(1./(1 << 16)));
+ for (size_t i = 0; i < nsamps; i++) {
+ MY_CHECK_CLOSE(input[i].real(), output[i].real(), float(1. / (1 << 16)));
+ MY_CHECK_CLOSE(input[i].imag(), output[i].imag(), float(1. / (1 << 16)));
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_fc32_and_fc32){
+BOOST_AUTO_TEST_CASE(test_convert_types_fc32_and_fc32)
+{
convert::id_type id;
id.input_format = "fc32";
- id.num_inputs = 1;
- id.num_outputs = 1;
+ id.num_inputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "fc32_item32_le";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_fc32(nsamps, id);
}
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "fc32_item32_be";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_fc32(nsamps, id);
}
}
@@ -594,39 +614,40 @@ BOOST_AUTO_TEST_CASE(test_convert_types_fc32_and_fc32){
/***********************************************************************
* Test f32 -> f32 conversion
**********************************************************************/
-static void test_convert_types_f32(
- size_t nsamps, convert::id_type &id
-){
- //fill the input samples
+static void test_convert_types_f32(size_t nsamps, convert::id_type& id)
+{
+ // fill the input samples
std::vector<float> input(nsamps), output(nsamps);
- for(float &in: input) in = float((float(std::rand())/float(RAND_MAX/2)) - 1);
+ for (float& in : input)
+ in = float((float(std::rand()) / float(RAND_MAX / 2)) - 1);
- //run the loopback and test
- convert::id_type in_id = id;
+ // run the loopback and test
+ 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], output[i], float(1./(1 << 16)));
+ for (size_t i = 0; i < nsamps; i++) {
+ MY_CHECK_CLOSE(input[i], output[i], float(1. / (1 << 16)));
}
}
-BOOST_AUTO_TEST_CASE(test_convert_types_f32_and_f32){
+BOOST_AUTO_TEST_CASE(test_convert_types_f32_and_f32)
+{
convert::id_type id;
id.input_format = "f32";
- id.num_inputs = 1;
- id.num_outputs = 1;
+ id.num_inputs = 1;
+ id.num_outputs = 1;
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "f32_item32_le";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_f32(nsamps, id);
}
- //try various lengths to test edge cases
+ // try various lengths to test edge cases
id.output_format = "f32_item32_be";
- for (size_t nsamps = 1; nsamps < 16; nsamps++){
+ for (size_t nsamps = 1; nsamps < 16; nsamps++) {
test_convert_types_f32(nsamps, id);
}
}
diff --git a/host/tests/device3_test.cpp b/host/tests/device3_test.cpp
index 71b3225e1..43f5fe45b 100644
--- a/host/tests/device3_test.cpp
+++ b/host/tests/device3_test.cpp
@@ -6,8 +6,8 @@
//
-#include "mock_zero_copy.hpp"
#include "mock_ctrl_iface_impl.hpp"
+#include "mock_zero_copy.hpp"
#include <uhd/device3.hpp>
#include <uhd/property_tree.hpp>
#include <uhd/rfnoc/block_ctrl.hpp>
@@ -20,17 +20,17 @@
#include <iostream>
-
using namespace uhd;
using namespace uhd::rfnoc;
using namespace uhd::transport::vrt;
-using uhd::transport::managed_send_buffer;
using uhd::transport::managed_recv_buffer;
+using uhd::transport::managed_send_buffer;
static const sid_t TEST_SID0 = 0x00000200; // 0.0.2.0
static const sid_t TEST_SID1 = 0x00000210; // 0.0.2.F
-uhd::both_xports_t make_mock_transport(const uhd::sid_t& tx_sid) {
+uhd::both_xports_t make_mock_transport(const uhd::sid_t& tx_sid)
+{
uhd::both_xports_t xports;
xports.send_sid = tx_sid;
xports.recv_sid = tx_sid.reversed();
@@ -42,60 +42,59 @@ uhd::both_xports_t make_mock_transport(const uhd::sid_t& tx_sid) {
}
// Mock-device
-class mock_device3_impl : public uhd::device3, public boost::enable_shared_from_this<mock_device3_impl>
+class mock_device3_impl : public uhd::device3,
+ public boost::enable_shared_from_this<mock_device3_impl>
{
- public:
+public:
mock_device3_impl()
{
_tree = uhd::property_tree::make();
_tree->create<std::string>("/name").set("Test Mock-Device3");
// We can re-use this:
std::map<size_t, ctrl_iface::sptr> ctrl_ifaces{
- {0, ctrl_iface::sptr(new mock_ctrl_iface_impl())}
- };
+ {0, ctrl_iface::sptr(new mock_ctrl_iface_impl())}};
// Add two block controls:
uhd::rfnoc::make_args_t make_args;
- make_args.ctrl_ifaces = ctrl_ifaces;
+ make_args.ctrl_ifaces = ctrl_ifaces;
make_args.base_address = TEST_SID0.get_dst();
make_args.device_index = 0;
- make_args.tree = _tree;
+ make_args.tree = _tree;
std::cout << "[MOCK] Generating block controls 1/2:" << std::endl;
- _rfnoc_block_ctrl.push_back( block_ctrl_base::make(make_args) );
+ _rfnoc_block_ctrl.push_back(block_ctrl_base::make(make_args));
std::cout << "[MOCK] Generating block controls 2/2:" << std::endl;
make_args.base_address = TEST_SID1.get_dst();
- _rfnoc_block_ctrl.push_back( block_ctrl::make(make_args) );
+ _rfnoc_block_ctrl.push_back(block_ctrl::make(make_args));
}
- rx_streamer::sptr get_rx_stream(const stream_args_t &args) {
+ rx_streamer::sptr get_rx_stream(const stream_args_t& args)
+ {
throw uhd::not_implemented_error(args.args.to_string());
}
- tx_streamer::sptr get_tx_stream(const stream_args_t &args) {
+ tx_streamer::sptr get_tx_stream(const stream_args_t& args)
+ {
throw uhd::not_implemented_error(args.args.to_string());
}
- bool recv_async_msg(async_metadata_t &async_metadata, double timeout) {
- throw uhd::not_implemented_error(str(boost::format("%d %f") % async_metadata.channel % timeout));
+ bool recv_async_msg(async_metadata_t& async_metadata, double timeout)
+ {
+ throw uhd::not_implemented_error(
+ str(boost::format("%d %f") % async_metadata.channel % timeout));
}
- rfnoc::graph::sptr create_graph(const std::string &name)
+ rfnoc::graph::sptr create_graph(const std::string& name)
{
sid_t async_sid(0);
async_sid.set_dst_addr(2);
auto async_xports = make_mock_transport(async_sid);
- auto async_msg_handler = uhd::rfnoc::async_msg_handler::make(
- async_xports.recv,
+ auto async_msg_handler = uhd::rfnoc::async_msg_handler::make(async_xports.recv,
async_xports.send,
async_xports.send_sid,
- async_xports.endianness
- );
- auto graph = boost::make_shared<uhd::rfnoc::graph_impl>(
- name,
- shared_from_this(),
- async_msg_handler
- );
+ async_xports.endianness);
+ auto graph = boost::make_shared<uhd::rfnoc::graph_impl>(
+ name, shared_from_this(), async_msg_handler);
return graph;
}
};
@@ -105,18 +104,21 @@ device3::sptr make_mock_device()
return device3::sptr(new mock_device3_impl());
}
-class mock_block_ctrl : public block_ctrl {
+class mock_block_ctrl : public block_ctrl
+{
int foo;
};
-BOOST_AUTO_TEST_CASE(test_device3) {
+BOOST_AUTO_TEST_CASE(test_device3)
+{
device3::sptr my_device = make_mock_device();
std::cout << "Checking block 0..." << std::endl;
BOOST_REQUIRE(my_device->find_blocks("Block").size());
std::cout << "Getting block 0..." << std::endl;
- block_ctrl_base::sptr block0 = my_device->get_block_ctrl(my_device->find_blocks("Block")[0]);
+ block_ctrl_base::sptr block0 =
+ my_device->get_block_ctrl(my_device->find_blocks("Block")[0]);
BOOST_REQUIRE(block0);
BOOST_CHECK_EQUAL(block0->get_block_id(), "0/Block_0");
@@ -130,7 +132,8 @@ BOOST_AUTO_TEST_CASE(test_device3) {
}
-BOOST_AUTO_TEST_CASE(test_device3_graph) {
+BOOST_AUTO_TEST_CASE(test_device3_graph)
+{
auto my_device = make_mock_device();
std::cout << "Start device3 test graph.." << std::endl;
std::cout << "Checking block 0..." << std::endl;
@@ -153,28 +156,33 @@ BOOST_AUTO_TEST_CASE(test_device3_graph) {
std::cout << "Connecting block_0 to block_1 ..." << std::endl;
graph->connect(block_id_t("0/Block_0"), 0, block_id_t("0/Block_1"), 0);
- BOOST_CHECK_EQUAL(block0->list_upstream_nodes().size(),0);
- BOOST_CHECK_EQUAL(block0->list_downstream_nodes().size(),1);
- BOOST_CHECK_EQUAL(block0->list_downstream_nodes()[0].lock()->unique_id(),"0/Block_1");
- BOOST_CHECK_EQUAL(block1->list_upstream_nodes().size(),1);
- BOOST_CHECK_EQUAL(block1->list_downstream_nodes().size(),0);
- BOOST_CHECK_EQUAL(block1->list_upstream_nodes()[0].lock()->unique_id(),"0/Block_0");
+ BOOST_CHECK_EQUAL(block0->list_upstream_nodes().size(), 0);
+ BOOST_CHECK_EQUAL(block0->list_downstream_nodes().size(), 1);
+ BOOST_CHECK_EQUAL(
+ block0->list_downstream_nodes()[0].lock()->unique_id(), "0/Block_1");
+ BOOST_CHECK_EQUAL(block1->list_upstream_nodes().size(), 1);
+ BOOST_CHECK_EQUAL(block1->list_downstream_nodes().size(), 0);
+ BOOST_CHECK_EQUAL(block1->list_upstream_nodes()[0].lock()->unique_id(), "0/Block_0");
}
-BOOST_AUTO_TEST_CASE(test_device3_cast) {
+BOOST_AUTO_TEST_CASE(test_device3_cast)
+{
device3::sptr my_device = make_mock_device();
std::cout << "Getting block 0..." << std::endl;
- block_ctrl::sptr block0 = my_device->get_block_ctrl<block_ctrl>(block_id_t("0/Block_0"));
+ block_ctrl::sptr block0 =
+ my_device->get_block_ctrl<block_ctrl>(block_id_t("0/Block_0"));
BOOST_REQUIRE(block0);
BOOST_CHECK_EQUAL(block0->get_block_id(), "0/Block_0");
std::cout << "Getting block 1..." << std::endl;
- block_ctrl_base::sptr block1 = my_device->get_block_ctrl<block_ctrl>(block_id_t("0/Block_1"));
+ block_ctrl_base::sptr block1 =
+ my_device->get_block_ctrl<block_ctrl>(block_id_t("0/Block_1"));
BOOST_CHECK_EQUAL(block1->get_block_id(), "0/Block_1");
}
-BOOST_AUTO_TEST_CASE(test_device3_fail) {
+BOOST_AUTO_TEST_CASE(test_device3_fail)
+{
device3::sptr my_device = make_mock_device();
BOOST_CHECK(not my_device->has_block(block_id_t("0/FooBarBlock_0")));
@@ -184,13 +192,10 @@ BOOST_AUTO_TEST_CASE(test_device3_fail) {
BOOST_CHECK(my_device->find_blocks<block_ctrl>("FooBarBlock").size() == 0);
BOOST_REQUIRE_THROW(
- my_device->get_block_ctrl(block_id_t("0/FooBarBlock_17")),
- uhd::lookup_error
- );
+ my_device->get_block_ctrl(block_id_t("0/FooBarBlock_17")), uhd::lookup_error);
BOOST_REQUIRE_THROW(
my_device->get_block_ctrl<mock_block_ctrl>(block_id_t("0/Block_1")),
- uhd::lookup_error
- );
+ uhd::lookup_error);
}
// vim: sw=4 et:
diff --git a/host/tests/dict_test.cpp b/host/tests/dict_test.cpp
index 53432d533..99fc2366c 100644
--- a/host/tests/dict_test.cpp
+++ b/host/tests/dict_test.cpp
@@ -5,15 +5,16 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/types/dict.hpp>
#include <boost/assign/list_of.hpp>
+#include <boost/test/unit_test.hpp>
-BOOST_AUTO_TEST_CASE(test_dict_init){
+BOOST_AUTO_TEST_CASE(test_dict_init)
+{
uhd::dict<int, int> d;
d[-1] = 3;
- d[0] = 4;
- d[1] = 5;
+ d[0] = 4;
+ d[1] = 5;
BOOST_CHECK(d.has_key(0));
BOOST_CHECK(not d.has_key(2));
BOOST_CHECK(d.keys()[1] == 0);
@@ -21,12 +22,9 @@ BOOST_AUTO_TEST_CASE(test_dict_init){
BOOST_CHECK_EQUAL(d[-1], 3);
}
-BOOST_AUTO_TEST_CASE(test_dict_assign){
- uhd::dict<int, int> d = boost::assign::map_list_of
- (-1, 3)
- (0, 4)
- (1, 5)
- ;
+BOOST_AUTO_TEST_CASE(test_dict_assign)
+{
+ uhd::dict<int, int> d = boost::assign::map_list_of(-1, 3)(0, 4)(1, 5);
BOOST_CHECK(d.has_key(0));
BOOST_CHECK(not d.has_key(2));
BOOST_CHECK(d.keys()[1] == 0);
@@ -34,12 +32,9 @@ BOOST_AUTO_TEST_CASE(test_dict_assign){
BOOST_CHECK_EQUAL(d[-1], 3);
}
-BOOST_AUTO_TEST_CASE(test_const_dict){
- const uhd::dict<int, int> d = boost::assign::map_list_of
- (-1, 3)
- (0, 4)
- (1, 5)
- ;
+BOOST_AUTO_TEST_CASE(test_const_dict)
+{
+ const uhd::dict<int, int> d = boost::assign::map_list_of(-1, 3)(0, 4)(1, 5);
BOOST_CHECK(d.has_key(0));
BOOST_CHECK(not d.has_key(2));
BOOST_CHECK(d.keys()[1] == 0);
@@ -48,12 +43,9 @@ BOOST_AUTO_TEST_CASE(test_const_dict){
BOOST_CHECK_THROW(d[2], std::exception);
}
-BOOST_AUTO_TEST_CASE(test_dict_pop){
- uhd::dict<int, int> d = boost::assign::map_list_of
- (-1, 3)
- (0, 4)
- (1, 5)
- ;
+BOOST_AUTO_TEST_CASE(test_dict_pop)
+{
+ uhd::dict<int, int> d = boost::assign::map_list_of(-1, 3)(0, 4)(1, 5);
BOOST_CHECK(d.has_key(0));
BOOST_CHECK_EQUAL(d.pop(0), 4);
BOOST_CHECK(not d.has_key(0));
@@ -63,24 +55,18 @@ BOOST_AUTO_TEST_CASE(test_dict_pop){
BOOST_AUTO_TEST_CASE(test_dict_update)
{
- uhd::dict<std::string, std::string> d1 = boost::assign::map_list_of
- ("key1", "val1")
- ("key2", "val2")
- ;
- uhd::dict<std::string, std::string> d2 = boost::assign::map_list_of
- ("key2", "val2x")
- ("key3", "val3")
- ;
+ uhd::dict<std::string, std::string> d1 =
+ boost::assign::map_list_of("key1", "val1")("key2", "val2");
+ uhd::dict<std::string, std::string> d2 =
+ boost::assign::map_list_of("key2", "val2x")("key3", "val3");
d1.update(d2, false /* don't throw cause of conflict */);
BOOST_CHECK_EQUAL(d1["key1"], "val1");
BOOST_CHECK_EQUAL(d1["key2"], "val2x");
BOOST_CHECK_EQUAL(d1["key3"], "val3");
- uhd::dict<std::string, std::string> d3 = boost::assign::map_list_of
- ("key1", "val1")
- ("key2", "val2")
- ;
+ uhd::dict<std::string, std::string> d3 =
+ boost::assign::map_list_of("key1", "val1")("key2", "val2");
BOOST_CHECK_THROW(d3.update(d2), uhd::value_error);
}
@@ -121,6 +107,6 @@ BOOST_AUTO_TEST_CASE(test_dict_equals)
BOOST_CHECK(d0 != d4);
BOOST_CHECK(d0 != d5);
// Redundant, but just to be sure
- BOOST_CHECK(not (d0 == d2));
- BOOST_CHECK(not (d0 == d3));
+ BOOST_CHECK(not(d0 == d2));
+ BOOST_CHECK(not(d0 == d3));
}
diff --git a/host/tests/dpdk_test.cpp b/host/tests/dpdk_test.cpp
index 8a4e51af7..43ef3d388 100644
--- a/host/tests/dpdk_test.cpp
+++ b/host/tests/dpdk_test.cpp
@@ -8,18 +8,18 @@
*/
-#include <cstdio>
-#include <cstdbool>
-#include <cstring>
-#include <unistd.h>
-#include <sys/time.h>
-#include <errno.h>
+#include "../transport/dpdk_zero_copy.hpp"
#include <arpa/inet.h>
+#include <errno.h>
#include <sched.h>
#include <sys/syscall.h>
-#include "../transport/dpdk_zero_copy.hpp"
+#include <sys/time.h>
+#include <unistd.h>
#include <boost/program_options.hpp>
#include <boost/regex.hpp>
+#include <cstdbool>
+#include <cstdio>
+#include <cstring>
#include <iostream>
static const boost::regex colons(":");
@@ -27,28 +27,30 @@ static const boost::regex colons(":");
namespace po = boost::program_options;
namespace {
- constexpr unsigned int NUM_MBUFS = 4095; /* Total number of mbufs in pool */
- constexpr unsigned int MBUF_CACHE_SIZE = 315; /* Size of cpu-local mbuf cache */
- constexpr unsigned int BURST_SIZE = 64; /* Maximum burst size for RX */
-
- constexpr unsigned int NUM_PORTS = 2; /* Number of NIC ports */
- constexpr unsigned int TX_CREDITS = 28; /* Number of TX credits */
- constexpr unsigned int RX_CREDITS = 64; /* Number of RX credits */
- constexpr unsigned int BENCH_SPP = 700; /* "Samples" per packet */
-}
+constexpr unsigned int NUM_MBUFS = 4095; /* Total number of mbufs in pool */
+constexpr unsigned int MBUF_CACHE_SIZE = 315; /* Size of cpu-local mbuf cache */
+constexpr unsigned int BURST_SIZE = 64; /* Maximum burst size for RX */
+
+constexpr unsigned int NUM_PORTS = 2; /* Number of NIC ports */
+constexpr unsigned int TX_CREDITS = 28; /* Number of TX credits */
+constexpr unsigned int RX_CREDITS = 64; /* Number of RX credits */
+constexpr unsigned int BENCH_SPP = 700; /* "Samples" per packet */
+} // namespace
-struct dpdk_test_args {
+struct dpdk_test_args
+{
unsigned int portid;
std::string src_port;
std::string dst_ip;
std::string dst_port;
- pthread_cond_t *cond;
+ pthread_cond_t* cond;
pthread_mutex_t mutex;
bool started;
int cpu;
};
-struct dpdk_test_stats {
+struct dpdk_test_stats
+{
uint32_t last_seqno;
uint32_t dropped_packets;
uint32_t lasts[16];
@@ -59,7 +61,7 @@ struct dpdk_test_stats {
};
-static void process_udp(int id, uint32_t *udp_data, struct dpdk_test_stats *stats)
+static void process_udp(int id, uint32_t* udp_data, struct dpdk_test_stats* stats)
{
if (udp_data[0] != stats[id].last_seqno + 1) {
stats[id].lasts[stats[id].dropped_packets & 0xf] = stats[id].last_seqno;
@@ -71,22 +73,24 @@ static void process_udp(int id, uint32_t *udp_data, struct dpdk_test_stats *stat
stats[id].last_ackno = udp_data[1];
}
-static void send_udp(uhd::transport::dpdk_zero_copy::sptr &stream, int id,
- bool fc_only, struct dpdk_test_stats *stats)
+static void send_udp(uhd::transport::dpdk_zero_copy::sptr& stream,
+ int id,
+ bool fc_only,
+ struct dpdk_test_stats* stats)
{
uhd::transport::managed_send_buffer::sptr mbuf = stream->get_send_buff(0);
if (mbuf.get() == nullptr) {
printf("Could not get TX buffer!\n");
return;
}
- auto *tx_data = mbuf->cast<uint32_t *>();
- tx_data[0] = fc_only ? stats[id].tx_seqno - 1 : stats[id].tx_seqno;
- tx_data[1] = stats[id].last_seqno;
+ auto* tx_data = mbuf->cast<uint32_t*>();
+ tx_data[0] = fc_only ? stats[id].tx_seqno - 1 : stats[id].tx_seqno;
+ tx_data[1] = stats[id].last_seqno;
if (!fc_only) {
- memset(&tx_data[2], stats[id].last_seqno, 8*BENCH_SPP);
- stats[id].tx_xfer += 8*BENCH_SPP;
+ memset(&tx_data[2], stats[id].last_seqno, 8 * BENCH_SPP);
+ stats[id].tx_xfer += 8 * BENCH_SPP;
}
- size_t num_bytes = 8 + (fc_only ? 0 : 8*BENCH_SPP);
+ size_t num_bytes = 8 + (fc_only ? 0 : 8 * BENCH_SPP);
mbuf->commit(num_bytes);
mbuf.reset();
@@ -95,18 +99,20 @@ static void send_udp(uhd::transport::dpdk_zero_copy::sptr &stream, int id,
}
}
-static void bench(uhd::transport::dpdk_zero_copy::sptr *stream, uint32_t nb_ports, double timeout)
+static void bench(
+ uhd::transport::dpdk_zero_copy::sptr* stream, uint32_t nb_ports, double timeout)
{
uint64_t total_xfer[NUM_PORTS];
uint32_t id;
- struct dpdk_test_stats *stats = (struct dpdk_test_stats *) malloc(sizeof(*stats)*nb_ports);
+ struct dpdk_test_stats* stats =
+ (struct dpdk_test_stats*)malloc(sizeof(*stats) * nb_ports);
for (id = 0; id < nb_ports; id++) {
- stats[id].tx_seqno = 1;
- stats[id].tx_xfer = 0;
- stats[id].last_ackno = 0;
- stats[id].last_seqno = 0;
+ stats[id].tx_seqno = 1;
+ stats[id].tx_xfer = 0;
+ stats[id].last_ackno = 0;
+ stats[id].last_seqno = 0;
stats[id].dropped_packets = 0;
- total_xfer[id] = 0;
+ total_xfer[id] = 0;
}
sleep(1);
struct timeval bench_start, bench_end;
@@ -115,8 +121,8 @@ static void bench(uhd::transport::dpdk_zero_copy::sptr *stream, uint32_t nb_port
* The test...
*/
uint64_t total_received = 0;
- uint32_t consec_no_rx = 0;
- while ((total_received / nb_ports) < 1000000 ) { //&& consec_no_rx < 10000) {
+ uint32_t consec_no_rx = 0;
+ while ((total_received / nb_ports) < 1000000) { //&& consec_no_rx < 10000) {
for (id = 0; id < nb_ports; id++) {
unsigned int nb_rx = 0;
uhd::transport::managed_recv_buffer::sptr bufs[BURST_SIZE];
@@ -132,7 +138,9 @@ static void bench(uhd::transport::dpdk_zero_copy::sptr *stream, uint32_t nb_port
consec_no_rx++;
if (consec_no_rx >= 100000) {
uint32_t skt_drops = stream[id]->get_drop_count();
- //printf("TX seq %d, TX ack %d, RX seq %d, %d drops!\n", stats[id].tx_seqno, stats[id].last_ackno, stats[id].last_seqno, skt_drops);
+ // printf("TX seq %d, TX ack %d, RX seq %d, %d drops!\n",
+ // stats[id].tx_seqno, stats[id].last_ackno, stats[id].last_seqno,
+ // skt_drops);
consec_no_rx = 0;
break;
}
@@ -143,7 +151,7 @@ static void bench(uhd::transport::dpdk_zero_copy::sptr *stream, uint32_t nb_port
for (unsigned int buf = 0; buf < nb_rx; buf++) {
total_xfer[id] += bufs[buf]->size();
- auto data = bufs[buf]->cast<uint32_t *>();
+ auto data = bufs[buf]->cast<uint32_t*>();
process_udp(id, data, stats);
}
@@ -153,15 +161,17 @@ static void bench(uhd::transport::dpdk_zero_copy::sptr *stream, uint32_t nb_port
for (id = 0; id < nb_ports; id++) {
/* TX portion */
uint32_t window_end = stats[id].last_ackno + TX_CREDITS;
- //uint32_t window_end = last_seqno[port] + TX_CREDITS;
+ // uint32_t window_end = last_seqno[port] + TX_CREDITS;
if (window_end <= stats[id].tx_seqno) {
if (consec_no_rx == 9999) {
send_udp(stream[id], id, true, stats);
}
- //send_udp(tx[id], id, true);
+ // send_udp(tx[id], id, true);
;
} else {
- for (unsigned int pktno = 0; (pktno < BURST_SIZE) && (stats[id].tx_seqno < window_end); pktno++) {
+ for (unsigned int pktno = 0;
+ (pktno < BURST_SIZE) && (stats[id].tx_seqno < window_end);
+ pktno++) {
send_udp(stream[id], id, false, stats);
}
}
@@ -174,13 +184,16 @@ static void bench(uhd::transport::dpdk_zero_copy::sptr *stream, uint32_t nb_port
printf("\n");
printf("Bytes received = %ld\n", total_xfer[id]);
printf("Bytes sent = %ld\n", stats[id].tx_xfer);
- printf("Time taken = %ld us\n", (bench_end.tv_sec - bench_start.tv_sec)*1000000 + (bench_end.tv_usec - bench_start.tv_usec));
- double elapsed_time = (bench_end.tv_sec - bench_start.tv_sec)*1000000 + (bench_end.tv_usec - bench_start.tv_usec);
+ printf("Time taken = %ld us\n",
+ (bench_end.tv_sec - bench_start.tv_sec) * 1000000
+ + (bench_end.tv_usec - bench_start.tv_usec));
+ double elapsed_time = (bench_end.tv_sec - bench_start.tv_sec) * 1000000
+ + (bench_end.tv_usec - bench_start.tv_usec);
elapsed_time *= 1.0e-6;
double elapsed_bytes = total_xfer[id];
- printf("RX Performance = %e Gbps\n", elapsed_bytes*8.0/1.0e9/elapsed_time);
+ printf("RX Performance = %e Gbps\n", elapsed_bytes * 8.0 / 1.0e9 / elapsed_time);
elapsed_bytes = stats[id].tx_xfer;
- printf("TX Performance = %e Gbps\n", elapsed_bytes*8.0/1.0e9/elapsed_time);
+ printf("TX Performance = %e Gbps\n", elapsed_bytes * 8.0 / 1.0e9 / elapsed_time);
uint32_t skt_drops = stream[id]->get_drop_count();
printf("Dropped %d packets\n", stats[id].dropped_packets);
printf("Socket reports dropped %d packets\n", skt_drops);
@@ -189,11 +202,10 @@ static void bench(uhd::transport::dpdk_zero_copy::sptr *stream, uint32_t nb_port
break;
printf("Last(%u), Recv(%u)\n", stats[id].lasts[i], stats[id].drops[i]);
}
- //printf("%d missed/dropped packets\n", errors);
+ // printf("%d missed/dropped packets\n", errors);
printf("\n");
}
free(stats);
-
}
static inline void set_cpu(pthread_t t, int cpu)
@@ -209,31 +221,29 @@ static inline void set_cpu(pthread_t t, int cpu)
}
}
-void *prepare_and_bench_blocking(void *arg)
+void* prepare_and_bench_blocking(void* arg)
{
- struct dpdk_test_args *args = (struct dpdk_test_args *) arg;
+ struct dpdk_test_args* args = (struct dpdk_test_args*)arg;
pthread_mutex_lock(&args->mutex);
pthread_t t = pthread_self();
set_cpu(t, args->cpu);
args->started = true;
pthread_cond_wait(args->cond, &args->mutex);
- auto &ctx = uhd::transport::uhd_dpdk_ctx::get();
+ auto& ctx = uhd::transport::uhd_dpdk_ctx::get();
uhd::transport::dpdk_zero_copy::sptr eth_data[1];
uhd::transport::zero_copy_xport_params buff_args;
buff_args.recv_frame_size = 8000;
buff_args.send_frame_size = 8000;
buff_args.num_send_frames = 8;
buff_args.num_recv_frames = 8;
- auto dev_addr = uhd::device_addr_t();
- eth_data[0] = uhd::transport::dpdk_zero_copy::make(
- ctx,
+ auto dev_addr = uhd::device_addr_t();
+ eth_data[0] = uhd::transport::dpdk_zero_copy::make(ctx,
args->portid,
args->dst_ip,
args->src_port,
args->dst_port,
buff_args,
- dev_addr
- );
+ dev_addr);
bench(eth_data, 1, 0.1);
return 0;
@@ -241,19 +251,19 @@ void *prepare_and_bench_blocking(void *arg)
void prepare_and_bench_polling(void)
{
- auto &ctx = uhd::transport::uhd_dpdk_ctx::get();
+ auto& ctx = uhd::transport::uhd_dpdk_ctx::get();
struct dpdk_test_args bench_args[2];
- bench_args[0].cond = NULL;
- bench_args[0].started = true;
- bench_args[0].portid = 0;
+ bench_args[0].cond = NULL;
+ bench_args[0].started = true;
+ bench_args[0].portid = 0;
bench_args[0].src_port = "0xBEE7";
- bench_args[0].dst_ip = "192.168.0.4";
+ bench_args[0].dst_ip = "192.168.0.4";
bench_args[0].dst_port = "0xBEE7";
- bench_args[1].cond = NULL;
- bench_args[1].started = true;
- bench_args[1].portid = 1;
+ bench_args[1].cond = NULL;
+ bench_args[1].started = true;
+ bench_args[1].portid = 1;
bench_args[1].src_port = "0xBEE7";
- bench_args[1].dst_ip = "192.168.0.3";
+ bench_args[1].dst_ip = "192.168.0.3";
bench_args[1].dst_port = "0xBEE7";
uhd::transport::dpdk_zero_copy::sptr eth_data[NUM_PORTS];
@@ -262,45 +272,43 @@ void prepare_and_bench_polling(void)
buff_args.send_frame_size = 8000;
buff_args.num_send_frames = 8;
buff_args.num_recv_frames = 8;
- auto dev_addr = uhd::device_addr_t();
+ auto dev_addr = uhd::device_addr_t();
for (unsigned int i = 0; i < NUM_PORTS; i++) {
- eth_data[i] = uhd::transport::dpdk_zero_copy::make(
- ctx,
+ eth_data[i] = uhd::transport::dpdk_zero_copy::make(ctx,
bench_args[i].portid,
bench_args[i].dst_ip,
bench_args[i].src_port,
bench_args[i].dst_port,
buff_args,
- dev_addr
- );
+ dev_addr);
}
bench(eth_data, NUM_PORTS, 0.0);
}
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
int retval, io0_cpu = 1, io1_cpu = 1, user0_cpu = 0, user1_cpu = 2;
std::string args, cpusets;
po::options_description desc("Allowed options");
- desc.add_options()
- ("help", "help message")
- ("args", po::value<std::string>(&args)->default_value(""), "UHD-DPDK args")
- ("polling-mode", "Use polling mode (single thread on own core)")
- ("cpusets", po::value<std::string>(&cpusets)->default_value(""), "which core(s) to use for a given thread (specify something like \"io0=1,io1=1,user0=0,user1=2\")")
- ;
+ desc.add_options()("help", "help message")(
+ "args", po::value<std::string>(&args)->default_value(""), "UHD-DPDK args")(
+ "polling-mode", "Use polling mode (single thread on own core)")("cpusets",
+ po::value<std::string>(&cpusets)->default_value(""),
+ "which core(s) to use for a given thread (specify something like "
+ "\"io0=1,io1=1,user0=0,user1=2\")");
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help")) {
- std::cout << desc << std::endl;
- return 0;
+ std::cout << desc << std::endl;
+ return 0;
}
auto dpdk_args = uhd::device_addr_t(args);
- for (std::string &key : dpdk_args.keys()) {
+ for (std::string& key : dpdk_args.keys()) {
/* device_addr_t splits on commas, so we use colons and replace */
if (key == "corelist" || key == "coremap") {
dpdk_args[key] = boost::regex_replace(dpdk_args[key], colons, ",");
@@ -308,7 +316,7 @@ int main(int argc, char **argv)
}
auto cpuset_map = uhd::device_addr_t(cpusets);
- for (std::string &key : cpuset_map.keys()) {
+ for (std::string& key : cpuset_map.keys()) {
if (key == "io0") {
io0_cpu = std::stoi(cpuset_map[key], NULL, 0);
} else if (key == "io1") {
@@ -321,12 +329,12 @@ int main(int argc, char **argv)
}
int port_thread_mapping[2] = {io0_cpu, io1_cpu};
- auto &ctx = uhd::transport::uhd_dpdk_ctx::get();
+ auto& ctx = uhd::transport::uhd_dpdk_ctx::get();
ctx.init(dpdk_args, 2, &port_thread_mapping[0], NUM_MBUFS, MBUF_CACHE_SIZE, 9000);
- uint32_t eth_ip = htonl(0xc0a80003);
+ uint32_t eth_ip = htonl(0xc0a80003);
uint32_t eth_mask = htonl(0xffffff00);
- int status = ctx.set_ipv4_addr(0, eth_ip, eth_mask);
+ int status = ctx.set_ipv4_addr(0, eth_ip, eth_mask);
if (status) {
printf("Error while setting IP0: %d\n", status);
return status;
@@ -346,19 +354,19 @@ int main(int argc, char **argv)
struct dpdk_test_args bench_args[2];
pthread_mutex_init(&bench_args[0].mutex, NULL);
pthread_mutex_init(&bench_args[1].mutex, NULL);
- bench_args[0].cpu = user0_cpu;
- bench_args[0].cond = &cond;
- bench_args[0].started = false;
- bench_args[0].portid = 0;
+ bench_args[0].cpu = user0_cpu;
+ bench_args[0].cond = &cond;
+ bench_args[0].started = false;
+ bench_args[0].portid = 0;
bench_args[0].src_port = "0xBEE7";
- bench_args[0].dst_ip = "192.168.0.4";
+ bench_args[0].dst_ip = "192.168.0.4";
bench_args[0].dst_port = "0xBEE7";
- bench_args[1].cpu = user1_cpu;
- bench_args[1].cond = &cond;
- bench_args[1].started = false;
- bench_args[1].portid = 1;
+ bench_args[1].cpu = user1_cpu;
+ bench_args[1].cond = &cond;
+ bench_args[1].started = false;
+ bench_args[1].portid = 1;
bench_args[1].src_port = "0xBEE7";
- bench_args[1].dst_ip = "192.168.0.3";
+ bench_args[1].dst_ip = "192.168.0.3";
bench_args[1].dst_port = "0xBEE7";
pthread_t threads[2];
@@ -366,29 +374,29 @@ int main(int argc, char **argv)
pthread_create(&threads[1], NULL, prepare_and_bench_blocking, &bench_args[1]);
do {
- pthread_mutex_lock(&bench_args[0].mutex);
- if (bench_args[0].started)
- break;
- pthread_mutex_unlock(&bench_args[0].mutex);
+ pthread_mutex_lock(&bench_args[0].mutex);
+ if (bench_args[0].started)
+ break;
+ pthread_mutex_unlock(&bench_args[0].mutex);
} while (true);
pthread_mutex_unlock(&bench_args[0].mutex);
do {
- pthread_mutex_lock(&bench_args[1].mutex);
- if (bench_args[1].started)
- break;
- pthread_mutex_unlock(&bench_args[1].mutex);
+ pthread_mutex_lock(&bench_args[1].mutex);
+ if (bench_args[1].started)
+ break;
+ pthread_mutex_unlock(&bench_args[1].mutex);
} while (true);
pthread_mutex_unlock(&bench_args[1].mutex);
pthread_cond_broadcast(&cond);
- status = pthread_join(threads[0], (void **) &retval);
+ status = pthread_join(threads[0], (void**)&retval);
if (status) {
perror("Error while joining thread");
return status;
}
- status = pthread_join(threads[1], (void **) &retval);
+ status = pthread_join(threads[1], (void**)&retval);
if (status) {
perror("Error while joining thread");
return status;
diff --git a/host/tests/eeprom_utils_test.cpp b/host/tests/eeprom_utils_test.cpp
index 4407ad4e4..728b4b8b6 100644
--- a/host/tests/eeprom_utils_test.cpp
+++ b/host/tests/eeprom_utils_test.cpp
@@ -4,15 +4,19 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhdlib/utils/eeprom_utils.hpp>
#include <boost/assign/list_of.hpp>
+#include <boost/test/unit_test.hpp>
using namespace boost::assign;
-class upper_case_char {
+class upper_case_char
+{
public:
- upper_case_char(char ch) {value = ch;}
+ upper_case_char(char ch)
+ {
+ value = ch;
+ }
static upper_case_char from_string(std::string str)
{
return upper_case_char(toupper(str[0]));
@@ -21,36 +25,28 @@ public:
{
return std::string(1, value);
}
+
private:
char value;
};
BOOST_AUTO_TEST_CASE(test_eeprom_duplicate_check)
{
- const uhd::dict<std::string,std::string> curr_eeprom = map_list_of
- ("0","A")
- ("1","B")
- ("2","C")
- ;
- const uhd::dict<std::string,std::string> new_eeprom_no_dups = map_list_of
- ("0","d")
- ("1","e")
- ;
- const uhd::dict<std::string,std::string> new_eeprom_dups_in_curr = map_list_of
- ("0","b")
- ;
- const uhd::dict<std::string,std::string> new_eeprom_dups_in_new = map_list_of
- ("0","c")
- ("1","c")
- ;
- const uhd::dict<std::string,std::string> new_eeprom_dups_in_both = map_list_of
- ("0","b")
- ("1","B")
- ;
- const std::vector<std::string> keys = {"0","1","2"};
+ const uhd::dict<std::string, std::string> curr_eeprom =
+ map_list_of("0", "A")("1", "B")("2", "C");
+ const uhd::dict<std::string, std::string> new_eeprom_no_dups =
+ map_list_of("0", "d")("1", "e");
+ const uhd::dict<std::string, std::string> new_eeprom_dups_in_curr =
+ map_list_of("0", "b");
+ const uhd::dict<std::string, std::string> new_eeprom_dups_in_new =
+ map_list_of("0", "c")("1", "c");
+ const uhd::dict<std::string, std::string> new_eeprom_dups_in_both =
+ map_list_of("0", "b")("1", "B");
+ const std::vector<std::string> keys = {"0", "1", "2"};
BOOST_CHECK_EQUAL(check_for_duplicates<upper_case_char>(
- "TEST", new_eeprom_no_dups, curr_eeprom, "Test Value", keys), false);
+ "TEST", new_eeprom_no_dups, curr_eeprom, "Test Value", keys),
+ false);
BOOST_CHECK(check_for_duplicates<upper_case_char>(
"TEST", new_eeprom_dups_in_curr, curr_eeprom, "Test Value", keys));
BOOST_CHECK(check_for_duplicates<upper_case_char>(
diff --git a/host/tests/error_c_test.cpp b/host/tests/error_c_test.cpp
index a60abe289..c697ebac7 100644
--- a/host/tests/error_c_test.cpp
+++ b/host/tests/error_c_test.cpp
@@ -7,11 +7,10 @@
#include <uhd/error.h>
#include <uhd/types/dict.hpp>
-
-#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/assign.hpp>
#include <boost/format.hpp>
+#include <boost/test/unit_test.hpp>
/*
* Test our conversions from exceptions to C-level UHD error codes.
@@ -19,97 +18,93 @@
* to test our C++ macro, which returns the error code.
*/
-typedef struct {
+typedef struct
+{
std::string last_error;
} dummy_handle_t;
template <typename error_type>
-UHD_INLINE uhd_error throw_uhd_exception(dummy_handle_t *handle, const uhd::exception* except){
- UHD_SAFE_C_SAVE_ERROR(handle,
- throw *dynamic_cast<const error_type*>(except);
- )
+UHD_INLINE uhd_error throw_uhd_exception(
+ dummy_handle_t* handle, const uhd::exception* except)
+{
+ UHD_SAFE_C_SAVE_ERROR(handle, throw *dynamic_cast<const error_type*>(except);)
}
-UHD_INLINE uhd_error throw_boost_exception(dummy_handle_t *handle){
- UHD_SAFE_C_SAVE_ERROR(handle,
+UHD_INLINE uhd_error throw_boost_exception(dummy_handle_t* handle)
+{
+ UHD_SAFE_C_SAVE_ERROR(
+ handle,
std::runtime_error except("This is a std::runtime_error, thrown by Boost.");
- BOOST_THROW_EXCEPTION(except);
- )
+ BOOST_THROW_EXCEPTION(except);)
}
-UHD_INLINE uhd_error throw_std_exception(dummy_handle_t *handle){
- UHD_SAFE_C_SAVE_ERROR(handle,
- throw std::runtime_error("This is a std::runtime_error.");
- )
+UHD_INLINE uhd_error throw_std_exception(dummy_handle_t* handle)
+{
+ UHD_SAFE_C_SAVE_ERROR(
+ handle, throw std::runtime_error("This is a std::runtime_error.");)
}
-UHD_INLINE uhd_error throw_unknown_exception(dummy_handle_t *handle){
- UHD_SAFE_C_SAVE_ERROR(handle,
- throw 1;
- )
+UHD_INLINE uhd_error throw_unknown_exception(dummy_handle_t* handle)
+{
+ UHD_SAFE_C_SAVE_ERROR(handle, throw 1;)
}
// There are enough non-standard names that we can't just use a conversion function
static const uhd::dict<std::string, std::string> pretty_exception_names =
- boost::assign::map_list_of
- ("assertion_error", "AssertionError")
- ("lookup_error", "LookupError")
- ("index_error", "LookupError: IndexError")
- ("key_error", "LookupError: KeyError")
- ("type_error", "TypeError")
- ("value_error", "ValueError")
- ("runtime_error", "RuntimeError")
- ("not_implemented_error", "RuntimeError: NotImplementedError")
- ("usb_error", "RuntimeError: USBError 1")
- ("environment_error", "EnvironmentError")
- ("io_error", "EnvironmentError: IOError")
- ("os_error", "EnvironmentError: OSError")
- ("system_error", "SystemError")
- ;
-
-#define UHD_TEST_CHECK_ERROR_CODE(cpp_exception_type, c_error_code) \
- expected_msg = str(boost::format("This is a uhd::%s.") % BOOST_STRINGIZE(cpp_exception_type)); \
- uhd::cpp_exception_type cpp_exception_type ## _foo(expected_msg); \
- error_code = throw_uhd_exception<uhd::cpp_exception_type>(&handle, &cpp_exception_type ## _foo); \
- BOOST_CHECK_EQUAL(error_code, c_error_code); \
- expected_msg = str(boost::format("%s: %s") \
+ boost::assign::map_list_of("assertion_error", "AssertionError")(
+ "lookup_error", "LookupError")("index_error", "LookupError: IndexError")(
+ "key_error", "LookupError: KeyError")("type_error", "TypeError")("value_error",
+ "ValueError")("runtime_error", "RuntimeError")("not_implemented_error",
+ "RuntimeError: NotImplementedError")("usb_error", "RuntimeError: USBError 1")(
+ "environment_error", "EnvironmentError")("io_error", "EnvironmentError: IOError")(
+ "os_error", "EnvironmentError: OSError")("system_error", "SystemError");
+
+#define UHD_TEST_CHECK_ERROR_CODE(cpp_exception_type, c_error_code) \
+ expected_msg = \
+ str(boost::format("This is a uhd::%s.") % BOOST_STRINGIZE(cpp_exception_type)); \
+ uhd::cpp_exception_type cpp_exception_type##_foo(expected_msg); \
+ error_code = throw_uhd_exception<uhd::cpp_exception_type>( \
+ &handle, &cpp_exception_type##_foo); \
+ BOOST_CHECK_EQUAL(error_code, c_error_code); \
+ expected_msg = str(boost::format("%s: %s") \
% pretty_exception_names.get(BOOST_STRINGIZE(cpp_exception_type)) \
- % expected_msg); \
- BOOST_CHECK_EQUAL(handle.last_error, expected_msg); \
+ % expected_msg); \
+ BOOST_CHECK_EQUAL(handle.last_error, expected_msg); \
BOOST_CHECK_EQUAL(get_c_global_error_string(), expected_msg);
// uhd::usb_error has a different constructor
-#define UHD_TEST_CHECK_USB_ERROR_CODE() \
- expected_msg = "This is a uhd::usb_error."; \
- uhd::usb_error usb_error_foo(1, expected_msg); \
- error_code = throw_uhd_exception<uhd::usb_error>(&handle, &usb_error_foo); \
- BOOST_CHECK_EQUAL(error_code, UHD_ERROR_USB); \
- expected_msg = str(boost::format("%s: %s") \
- % pretty_exception_names.get("usb_error") \
- % expected_msg); \
- BOOST_CHECK_EQUAL(handle.last_error, expected_msg); \
+#define UHD_TEST_CHECK_USB_ERROR_CODE() \
+ expected_msg = "This is a uhd::usb_error."; \
+ uhd::usb_error usb_error_foo(1, expected_msg); \
+ error_code = throw_uhd_exception<uhd::usb_error>(&handle, &usb_error_foo); \
+ BOOST_CHECK_EQUAL(error_code, UHD_ERROR_USB); \
+ expected_msg = str(boost::format("%s: %s") % pretty_exception_names.get("usb_error") \
+ % expected_msg); \
+ BOOST_CHECK_EQUAL(handle.last_error, expected_msg); \
BOOST_CHECK_EQUAL(get_c_global_error_string(), expected_msg);
-BOOST_AUTO_TEST_CASE(test_uhd_exception){
+BOOST_AUTO_TEST_CASE(test_uhd_exception)
+{
dummy_handle_t handle;
std::string expected_msg;
uhd_error error_code;
- UHD_TEST_CHECK_ERROR_CODE(assertion_error, UHD_ERROR_ASSERTION);
- UHD_TEST_CHECK_ERROR_CODE(lookup_error, UHD_ERROR_LOOKUP);
- UHD_TEST_CHECK_ERROR_CODE(index_error, UHD_ERROR_INDEX);
- UHD_TEST_CHECK_ERROR_CODE(key_error, UHD_ERROR_KEY);
- UHD_TEST_CHECK_ERROR_CODE(type_error, UHD_ERROR_TYPE);
- UHD_TEST_CHECK_ERROR_CODE(value_error, UHD_ERROR_VALUE);
- UHD_TEST_CHECK_ERROR_CODE(runtime_error, UHD_ERROR_RUNTIME);
+ UHD_TEST_CHECK_ERROR_CODE(assertion_error, UHD_ERROR_ASSERTION);
+ UHD_TEST_CHECK_ERROR_CODE(lookup_error, UHD_ERROR_LOOKUP);
+ UHD_TEST_CHECK_ERROR_CODE(index_error, UHD_ERROR_INDEX);
+ UHD_TEST_CHECK_ERROR_CODE(key_error, UHD_ERROR_KEY);
+ UHD_TEST_CHECK_ERROR_CODE(type_error, UHD_ERROR_TYPE);
+ UHD_TEST_CHECK_ERROR_CODE(value_error, UHD_ERROR_VALUE);
+ UHD_TEST_CHECK_ERROR_CODE(runtime_error, UHD_ERROR_RUNTIME);
UHD_TEST_CHECK_ERROR_CODE(not_implemented_error, UHD_ERROR_NOT_IMPLEMENTED);
- UHD_TEST_CHECK_ERROR_CODE(io_error, UHD_ERROR_IO);
- UHD_TEST_CHECK_ERROR_CODE(os_error, UHD_ERROR_OS);
- UHD_TEST_CHECK_ERROR_CODE(system_error, UHD_ERROR_SYSTEM);
+ UHD_TEST_CHECK_ERROR_CODE(io_error, UHD_ERROR_IO);
+ UHD_TEST_CHECK_ERROR_CODE(os_error, UHD_ERROR_OS);
+ UHD_TEST_CHECK_ERROR_CODE(system_error, UHD_ERROR_SYSTEM);
UHD_TEST_CHECK_USB_ERROR_CODE();
}
-BOOST_AUTO_TEST_CASE(test_boost_exception){
+BOOST_AUTO_TEST_CASE(test_boost_exception)
+{
dummy_handle_t handle;
uhd_error error_code = throw_boost_exception(&handle);
@@ -117,7 +112,8 @@ BOOST_AUTO_TEST_CASE(test_boost_exception){
BOOST_CHECK_EQUAL(error_code, UHD_ERROR_BOOSTEXCEPT);
}
-BOOST_AUTO_TEST_CASE(test_std_exception){
+BOOST_AUTO_TEST_CASE(test_std_exception)
+{
dummy_handle_t handle;
uhd_error error_code = throw_std_exception(&handle);
@@ -125,7 +121,8 @@ BOOST_AUTO_TEST_CASE(test_std_exception){
BOOST_CHECK_EQUAL(handle.last_error, "This is a std::runtime_error.");
}
-BOOST_AUTO_TEST_CASE(test_unknown_exception){
+BOOST_AUTO_TEST_CASE(test_unknown_exception)
+{
dummy_handle_t handle;
uhd_error error_code = throw_unknown_exception(&handle);
diff --git a/host/tests/error_test.cpp b/host/tests/error_test.cpp
index b749ca6f4..62411e06d 100644
--- a/host/tests/error_test.cpp
+++ b/host/tests/error_test.cpp
@@ -5,79 +5,76 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/exception.hpp>
#include <uhd/utils/assert_has.hpp>
-#include <vector>
+#include <boost/test/unit_test.hpp>
#include <iostream>
+#include <vector>
-BOOST_AUTO_TEST_CASE(test_exception_methods){
- try{
+BOOST_AUTO_TEST_CASE(test_exception_methods)
+{
+ try {
throw uhd::assertion_error("your assertion failed: 1 != 2");
- }
- catch(const uhd::exception &e){
+ } catch (const uhd::exception& e) {
std::cout << "what: " << e.what() << std::endl;
std::cout << "code: " << e.code() << std::endl;
}
}
-BOOST_AUTO_TEST_CASE(test_assert_has){
+BOOST_AUTO_TEST_CASE(test_assert_has)
+{
std::vector<int> vec;
vec.push_back(2);
vec.push_back(3);
vec.push_back(5);
- //verify the uhd::has utility
+ // verify the uhd::has utility
BOOST_CHECK(uhd::has(vec, 2));
BOOST_CHECK(not uhd::has(vec, 1));
std::cout << "The output of the assert_has error:" << std::endl;
- try{
+ try {
uhd::assert_has(vec, 1, "prime");
- }
- catch(const std::exception &e){
+ } catch (const std::exception& e) {
std::cout << e.what() << std::endl;
}
}
-BOOST_AUTO_TEST_CASE(test_assert_throw){
+BOOST_AUTO_TEST_CASE(test_assert_throw)
+{
std::cout << "The output of the assert throw error:" << std::endl;
- try{
+ try {
UHD_ASSERT_THROW(2 + 2 == 5);
- }
- catch(const std::exception &e){
+ } catch (const std::exception& e) {
std::cout << e.what() << std::endl;
}
}
-BOOST_AUTO_TEST_CASE(test_exception_dynamic){
- uhd::exception *exception_clone;
+BOOST_AUTO_TEST_CASE(test_exception_dynamic)
+{
+ uhd::exception* exception_clone;
- //throw an exception and dynamically clone it
- try{
+ // throw an exception and dynamically clone it
+ try {
throw uhd::runtime_error("noooooo");
- }
- catch(const uhd::exception &e){
+ } catch (const uhd::exception& e) {
std::cout << e.what() << std::endl;
exception_clone = e.dynamic_clone();
}
- //now we dynamically re-throw the exception
- try{
+ // now we dynamically re-throw the exception
+ try {
exception_clone->dynamic_throw();
- }
- catch(const uhd::assertion_error &e){
+ } catch (const uhd::assertion_error& e) {
std::cout << e.what() << std::endl;
BOOST_CHECK(false);
- }
- catch(const uhd::runtime_error &e){
+ } catch (const uhd::runtime_error& e) {
std::cout << e.what() << std::endl;
BOOST_CHECK(true);
- }
- catch(const uhd::exception &e){
+ } catch (const uhd::exception& e) {
std::cout << e.what() << std::endl;
BOOST_CHECK(false);
}
- delete exception_clone; //manual cleanup
+ delete exception_clone; // manual cleanup
}
diff --git a/host/tests/expert_test.cpp b/host/tests/expert_test.cpp
index efd4f1d08..36a9ef03b 100644
--- a/host/tests/expert_test.cpp
+++ b/host/tests/expert_test.cpp
@@ -5,20 +5,21 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
-#include <boost/format.hpp>
-#include <boost/make_shared.hpp>
#include <uhd/property_tree.hpp>
#include <uhdlib/experts/expert_container.hpp>
#include <uhdlib/experts/expert_factory.hpp>
+#include <boost/format.hpp>
+#include <boost/make_shared.hpp>
+#include <boost/test/unit_test.hpp>
#include <fstream>
using namespace uhd::experts;
-class worker1_t : public worker_node_t {
+class worker1_t : public worker_node_t
+{
public:
worker1_t(const node_retriever_t& db)
- : worker_node_t("A+B=C"), _a(db, "A/desired"), _b(db, "B"), _c(db, "C")
+ : worker_node_t("A+B=C"), _a(db, "A/desired"), _b(db, "B"), _c(db, "C")
{
bind_accessor(_a);
bind_accessor(_b);
@@ -26,7 +27,8 @@ public:
}
private:
- void resolve() {
+ void resolve()
+ {
_c = _a + _b;
}
@@ -37,10 +39,11 @@ private:
//=============================================================================
-class worker2_t : public worker_node_t {
+class worker2_t : public worker_node_t
+{
public:
worker2_t(const node_retriever_t& db)
- : worker_node_t("C*D=E"), _c(db, "C"), _d(db, "D"), _e(db, "E")
+ : worker_node_t("C*D=E"), _c(db, "C"), _d(db, "D"), _e(db, "E")
{
bind_accessor(_c);
bind_accessor(_d);
@@ -48,7 +51,8 @@ public:
}
private:
- void resolve() {
+ void resolve()
+ {
_e.set(_c.get() * _d.get());
}
@@ -59,17 +63,19 @@ private:
//=============================================================================
-class worker3_t : public worker_node_t {
+class worker3_t : public worker_node_t
+{
public:
worker3_t(const node_retriever_t& db)
- : worker_node_t("-B=F"), _b(db, "B"), _f(db, "F")
+ : worker_node_t("-B=F"), _b(db, "B"), _f(db, "F")
{
bind_accessor(_b);
bind_accessor(_f);
}
private:
- void resolve() {
+ void resolve()
+ {
_f.set(-_b.get());
}
@@ -79,10 +85,11 @@ private:
//=============================================================================
-class worker4_t : public worker_node_t {
+class worker4_t : public worker_node_t
+{
public:
worker4_t(const node_retriever_t& db)
- : worker_node_t("E-F=G"), _e(db, "E"), _f(db, "F"), _g(db, "G")
+ : worker_node_t("E-F=G"), _e(db, "E"), _f(db, "F"), _g(db, "G")
{
bind_accessor(_e);
bind_accessor(_f);
@@ -90,7 +97,8 @@ public:
}
private:
- void resolve() {
+ void resolve()
+ {
_g.set(_e.get() - _f.get());
}
@@ -101,17 +109,19 @@ private:
//=============================================================================
-class worker5_t : public worker_node_t {
+class worker5_t : public worker_node_t
+{
public:
worker5_t(const node_retriever_t& db, boost::shared_ptr<int> output)
- : worker_node_t("Consume_G"), _g(db, "G"), _c(db, "C"), _output(output)
+ : worker_node_t("Consume_G"), _g(db, "G"), _c(db, "C"), _output(output)
{
bind_accessor(_g);
-// bind_accessor(_c);
+ // bind_accessor(_c);
}
private:
- void resolve() {
+ void resolve()
+ {
*_output = _g;
}
@@ -121,82 +131,92 @@ private:
boost::shared_ptr<int> _output;
};
-class worker6_t : public worker_node_t {
+class worker6_t : public worker_node_t
+{
public:
- worker6_t() : worker_node_t("null_worker")
- {
- }
+ worker6_t() : worker_node_t("null_worker") {}
private:
- void resolve() {
- }
+ void resolve() {}
};
//=============================================================================
-#define DUMP_VARS \
- BOOST_TEST_MESSAGE( str(boost::format("### State = {A=%d%s, B=%d%s, C=%d%s, D=%d%s, E=%d%s, F=%d%s, G=%d%s}\n") % \
- nodeA.get() % (nodeA.is_dirty()?"*":"") % \
- nodeB.get() % (nodeB.is_dirty()?"*":"") % \
- nodeC.get() % (nodeC.is_dirty()?"*":"") % \
- nodeD.get() % (nodeD.is_dirty()?"*":"") % \
- nodeE.get() % (nodeE.is_dirty()?"*":"") % \
- nodeF.get() % (nodeF.is_dirty()?"*":"") % \
- nodeG.get() % (nodeG.is_dirty()?"*":"")) );
-
-#define VALIDATE_ALL_DEPENDENCIES \
- BOOST_CHECK(!nodeA.is_dirty()); \
- BOOST_CHECK(!nodeB.is_dirty()); \
- BOOST_CHECK(!nodeC.is_dirty()); \
- BOOST_CHECK(!nodeD.is_dirty()); \
- BOOST_CHECK(!nodeE.is_dirty()); \
- BOOST_CHECK(!nodeF.is_dirty()); \
- BOOST_CHECK(!nodeG.is_dirty()); \
+#define DUMP_VARS \
+ BOOST_TEST_MESSAGE(str( \
+ boost::format( \
+ "### State = {A=%d%s, B=%d%s, C=%d%s, D=%d%s, E=%d%s, F=%d%s, G=%d%s}\n") \
+ % nodeA.get() % (nodeA.is_dirty() ? "*" : "") % nodeB.get() \
+ % (nodeB.is_dirty() ? "*" : "") % nodeC.get() % (nodeC.is_dirty() ? "*" : "") \
+ % nodeD.get() % (nodeD.is_dirty() ? "*" : "") % nodeE.get() \
+ % (nodeE.is_dirty() ? "*" : "") % nodeF.get() % (nodeF.is_dirty() ? "*" : "") \
+ % nodeG.get() % (nodeG.is_dirty() ? "*" : "")));
+
+#define VALIDATE_ALL_DEPENDENCIES \
+ BOOST_CHECK(!nodeA.is_dirty()); \
+ BOOST_CHECK(!nodeB.is_dirty()); \
+ BOOST_CHECK(!nodeC.is_dirty()); \
+ BOOST_CHECK(!nodeD.is_dirty()); \
+ BOOST_CHECK(!nodeE.is_dirty()); \
+ BOOST_CHECK(!nodeF.is_dirty()); \
+ BOOST_CHECK(!nodeG.is_dirty()); \
BOOST_CHECK(nodeC.get() == nodeA.get() + nodeB.get()); \
BOOST_CHECK(nodeE.get() == nodeC.get() * nodeD.get()); \
- BOOST_CHECK(nodeF.get() == - nodeB.get()); \
+ BOOST_CHECK(nodeF.get() == -nodeB.get()); \
BOOST_CHECK(nodeG.get() == nodeE.get() - nodeF.get()); \
BOOST_CHECK(nodeG.get() == *final_output);
-BOOST_AUTO_TEST_CASE(test_experts){
- //Initialize container object
+BOOST_AUTO_TEST_CASE(test_experts)
+{
+ // Initialize container object
expert_container::sptr container = expert_factory::create_container("example");
- uhd::property_tree::sptr tree = uhd::property_tree::make();
+ uhd::property_tree::sptr tree = uhd::property_tree::make();
- //Output of expert tree
+ // Output of expert tree
boost::shared_ptr<int> final_output = boost::make_shared<int>();
- //Add data nodes to container
- expert_factory::add_dual_prop_node<int>(container, tree, "A", 0, uhd::experts::AUTO_RESOLVE_ON_WRITE);
+ // Add data nodes to container
+ expert_factory::add_dual_prop_node<int>(
+ container, tree, "A", 0, uhd::experts::AUTO_RESOLVE_ON_WRITE);
expert_factory::add_prop_node<int>(container, tree, "B", 0);
expert_factory::add_data_node<int>(container, "C", 0);
expert_factory::add_data_node<int>(container, "D", 1);
- expert_factory::add_prop_node<int>(container, tree, "E", 0, uhd::experts::AUTO_RESOLVE_ON_READ);
+ expert_factory::add_prop_node<int>(
+ container, tree, "E", 0, uhd::experts::AUTO_RESOLVE_ON_READ);
expert_factory::add_data_node<int>(container, "F", 0);
expert_factory::add_data_node<int>(container, "G", 0);
- //Add worker nodes to container
+ // Add worker nodes to container
expert_factory::add_worker_node<worker1_t>(container, container->node_retriever());
expert_factory::add_worker_node<worker2_t>(container, container->node_retriever());
expert_factory::add_worker_node<worker3_t>(container, container->node_retriever());
expert_factory::add_worker_node<worker4_t>(container, container->node_retriever());
- expert_factory::add_worker_node<worker5_t>(container, container->node_retriever(), final_output);
+ expert_factory::add_worker_node<worker5_t>(
+ container, container->node_retriever(), final_output);
expert_factory::add_worker_node<worker6_t>(container);
- //Once initialized, getting modify access to graph nodes is possible (by design) but extremely red-flaggy!
- //But we do it here to monitor things
- data_node_t<int>& nodeA = *(const_cast< data_node_t<int>* >(dynamic_cast< const data_node_t<int>* >(&container->node_retriever().lookup("A/desired"))));
- data_node_t<int>& nodeB = *(const_cast< data_node_t<int>* >(dynamic_cast< const data_node_t<int>* >(&container->node_retriever().lookup("B"))));
- data_node_t<int>& nodeC = *(const_cast< data_node_t<int>* >(dynamic_cast< const data_node_t<int>* >(&container->node_retriever().lookup("C"))));
- data_node_t<int>& nodeD = *(const_cast< data_node_t<int>* >(dynamic_cast< const data_node_t<int>* >(&container->node_retriever().lookup("D"))));
- data_node_t<int>& nodeE = *(const_cast< data_node_t<int>* >(dynamic_cast< const data_node_t<int>* >(&container->node_retriever().lookup("E"))));
- data_node_t<int>& nodeF = *(const_cast< data_node_t<int>* >(dynamic_cast< const data_node_t<int>* >(&container->node_retriever().lookup("F"))));
- data_node_t<int>& nodeG = *(const_cast< data_node_t<int>* >(dynamic_cast< const data_node_t<int>* >(&container->node_retriever().lookup("G"))));
+ // Once initialized, getting modify access to graph nodes is possible (by design) but
+ // extremely red-flaggy! But we do it here to monitor things
+ data_node_t<int>& nodeA =
+ *(const_cast<data_node_t<int>*>(dynamic_cast<const data_node_t<int>*>(
+ &container->node_retriever().lookup("A/desired"))));
+ data_node_t<int>& nodeB = *(const_cast<data_node_t<int>*>(
+ dynamic_cast<const data_node_t<int>*>(&container->node_retriever().lookup("B"))));
+ data_node_t<int>& nodeC = *(const_cast<data_node_t<int>*>(
+ dynamic_cast<const data_node_t<int>*>(&container->node_retriever().lookup("C"))));
+ data_node_t<int>& nodeD = *(const_cast<data_node_t<int>*>(
+ dynamic_cast<const data_node_t<int>*>(&container->node_retriever().lookup("D"))));
+ data_node_t<int>& nodeE = *(const_cast<data_node_t<int>*>(
+ dynamic_cast<const data_node_t<int>*>(&container->node_retriever().lookup("E"))));
+ data_node_t<int>& nodeF = *(const_cast<data_node_t<int>*>(
+ dynamic_cast<const data_node_t<int>*>(&container->node_retriever().lookup("F"))));
+ data_node_t<int>& nodeG = *(const_cast<data_node_t<int>*>(
+ dynamic_cast<const data_node_t<int>*>(&container->node_retriever().lookup("G"))));
DUMP_VARS
- //Ensure init behavior
+ // Ensure init behavior
BOOST_CHECK(nodeA.is_dirty());
BOOST_CHECK(nodeB.is_dirty());
BOOST_CHECK(nodeC.is_dirty());
@@ -205,18 +225,19 @@ BOOST_AUTO_TEST_CASE(test_experts){
BOOST_CHECK(nodeF.is_dirty());
BOOST_CHECK(nodeG.is_dirty());
container->resolve_all();
- VALIDATE_ALL_DEPENDENCIES //Ensure a default resolve
+ VALIDATE_ALL_DEPENDENCIES // Ensure a default resolve
- //Ensure basic node value propagation
- tree->access<int>("B").set(3);
- BOOST_CHECK(nodeB.get() == 3); //Ensure value propagated
- BOOST_CHECK(nodeB.is_dirty()); //Ensure that nothing got resolved...
+ // Ensure basic node value propagation
+ tree->access<int>("B")
+ .set(3);
+ BOOST_CHECK(nodeB.get() == 3); // Ensure value propagated
+ BOOST_CHECK(nodeB.is_dirty()); // Ensure that nothing got resolved...
container->resolve_all();
VALIDATE_ALL_DEPENDENCIES
- nodeD.set(2); //Hack for testing
+ nodeD.set(2); // Hack for testing
- //Ensure auto-resolve on write
+ // Ensure auto-resolve on write
tree->access<int>("A").set(200);
BOOST_CHECK(nodeC.get() == nodeA.get() + nodeB.get());
BOOST_CHECK(nodeE.get() == nodeC.get() * nodeD.get());
@@ -227,7 +248,7 @@ BOOST_AUTO_TEST_CASE(test_experts){
container->resolve_all();
VALIDATE_ALL_DEPENDENCIES
- //Ensure auto-resolve on read
+ // Ensure auto-resolve on read
tree->access<int>("E").get();
BOOST_CHECK(nodeC.get() == nodeA.get() + nodeB.get());
BOOST_CHECK(nodeE.get() == nodeC.get() * nodeD.get());
@@ -236,7 +257,7 @@ BOOST_AUTO_TEST_CASE(test_experts){
container->resolve_all(true);
VALIDATE_ALL_DEPENDENCIES
- //Resolve to/from
+ // Resolve to/from
tree->access<int>("A").set(-1);
container->resolve_to("C");
BOOST_CHECK(nodeC.get() == nodeA.get() + nodeB.get());
diff --git a/host/tests/fe_conn_test.cpp b/host/tests/fe_conn_test.cpp
index 34ebb7b33..bbf79835f 100644
--- a/host/tests/fe_conn_test.cpp
+++ b/host/tests/fe_conn_test.cpp
@@ -5,19 +5,20 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <uhd/usrp/fe_connection.hpp>
#include <uhd/exception.hpp>
+#include <uhd/usrp/fe_connection.hpp>
#include <boost/test/unit_test.hpp>
using namespace uhd::usrp;
-BOOST_AUTO_TEST_CASE(test_quardrature){
+BOOST_AUTO_TEST_CASE(test_quardrature)
+{
fe_connection_t IQ("IQ"), QI("QI"), IbQ("IbQ"), QbI("QbI"), QbIb("QbIb");
- BOOST_CHECK(IQ.get_sampling_mode()==fe_connection_t::QUADRATURE);
- BOOST_CHECK(QI.get_sampling_mode()==fe_connection_t::QUADRATURE);
- BOOST_CHECK(IbQ.get_sampling_mode()==fe_connection_t::QUADRATURE);
- BOOST_CHECK(QbI.get_sampling_mode()==fe_connection_t::QUADRATURE);
- BOOST_CHECK(QbIb.get_sampling_mode()==fe_connection_t::QUADRATURE);
+ BOOST_CHECK(IQ.get_sampling_mode() == fe_connection_t::QUADRATURE);
+ BOOST_CHECK(QI.get_sampling_mode() == fe_connection_t::QUADRATURE);
+ BOOST_CHECK(IbQ.get_sampling_mode() == fe_connection_t::QUADRATURE);
+ BOOST_CHECK(QbI.get_sampling_mode() == fe_connection_t::QUADRATURE);
+ BOOST_CHECK(QbIb.get_sampling_mode() == fe_connection_t::QUADRATURE);
BOOST_CHECK(not IQ.is_iq_swapped());
BOOST_CHECK(QI.is_iq_swapped());
@@ -38,12 +39,13 @@ BOOST_AUTO_TEST_CASE(test_quardrature){
BOOST_CHECK(QbIb.is_q_inverted());
}
-BOOST_AUTO_TEST_CASE(test_heterodyne){
+BOOST_AUTO_TEST_CASE(test_heterodyne)
+{
fe_connection_t II("II"), QQ("QQ"), IbIb("IbIb"), QbQb("QbQb");
- BOOST_CHECK(II.get_sampling_mode()==fe_connection_t::HETERODYNE);
- BOOST_CHECK(QQ.get_sampling_mode()==fe_connection_t::HETERODYNE);
- BOOST_CHECK(IbIb.get_sampling_mode()==fe_connection_t::HETERODYNE);
- BOOST_CHECK(QbQb.get_sampling_mode()==fe_connection_t::HETERODYNE);
+ BOOST_CHECK(II.get_sampling_mode() == fe_connection_t::HETERODYNE);
+ BOOST_CHECK(QQ.get_sampling_mode() == fe_connection_t::HETERODYNE);
+ BOOST_CHECK(IbIb.get_sampling_mode() == fe_connection_t::HETERODYNE);
+ BOOST_CHECK(QbQb.get_sampling_mode() == fe_connection_t::HETERODYNE);
BOOST_CHECK(not II.is_iq_swapped());
BOOST_CHECK(QQ.is_iq_swapped());
@@ -66,12 +68,13 @@ BOOST_AUTO_TEST_CASE(test_heterodyne){
BOOST_CHECK_THROW(fe_connection_t dummy("QbQ"), uhd::value_error);
}
-BOOST_AUTO_TEST_CASE(test_real){
+BOOST_AUTO_TEST_CASE(test_real)
+{
fe_connection_t I("I"), Q("Q"), Ib("Ib"), Qb("Qb");
- BOOST_CHECK(I.get_sampling_mode()==fe_connection_t::REAL);
- BOOST_CHECK(Q.get_sampling_mode()==fe_connection_t::REAL);
- BOOST_CHECK(Ib.get_sampling_mode()==fe_connection_t::REAL);
- BOOST_CHECK(Qb.get_sampling_mode()==fe_connection_t::REAL);
+ BOOST_CHECK(I.get_sampling_mode() == fe_connection_t::REAL);
+ BOOST_CHECK(Q.get_sampling_mode() == fe_connection_t::REAL);
+ BOOST_CHECK(Ib.get_sampling_mode() == fe_connection_t::REAL);
+ BOOST_CHECK(Qb.get_sampling_mode() == fe_connection_t::REAL);
BOOST_CHECK(not I.is_iq_swapped());
BOOST_CHECK(Q.is_iq_swapped());
@@ -89,7 +92,8 @@ BOOST_AUTO_TEST_CASE(test_real){
BOOST_CHECK(not Qb.is_q_inverted());
}
-BOOST_AUTO_TEST_CASE(test_invalid){
+BOOST_AUTO_TEST_CASE(test_invalid)
+{
BOOST_CHECK_THROW(fe_connection_t dummy("blah"), uhd::value_error);
BOOST_CHECK_THROW(fe_connection_t dummy("123456"), uhd::value_error);
BOOST_CHECK_THROW(fe_connection_t dummy("ii"), uhd::value_error);
diff --git a/host/tests/fp_compare_delta_test.cpp b/host/tests/fp_compare_delta_test.cpp
index 5023d660a..ae1f14281 100644
--- a/host/tests/fp_compare_delta_test.cpp
+++ b/host/tests/fp_compare_delta_test.cpp
@@ -10,20 +10,21 @@
using namespace uhd::math::fp_compare;
-BOOST_AUTO_TEST_CASE(fp_compare_delta_constructors) {
+BOOST_AUTO_TEST_CASE(fp_compare_delta_constructors)
+{
// Test default constructor
fp_compare_delta<float> alpha = fp_compare_delta<float>(7457392.0);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
BOOST_CHECK_EQUAL(alpha._value, beta._value);
BOOST_CHECK_EQUAL(alpha._delta, beta._delta);
// Test constructor with specified delta
- fp_compare_delta<float> foxtrot = fp_compare_delta<float>(alpha._value,
- uhd::math::SINGLE_PRECISION_DELTA);
- fp_compare_delta<float> gamma = fp_compare_delta<float>(alpha._value,
- 2 * uhd::math::SINGLE_PRECISION_DELTA);
+ fp_compare_delta<float> foxtrot =
+ fp_compare_delta<float>(alpha._value, uhd::math::SINGLE_PRECISION_DELTA);
+ fp_compare_delta<float> gamma =
+ fp_compare_delta<float>(alpha._value, 2 * uhd::math::SINGLE_PRECISION_DELTA);
BOOST_CHECK_EQUAL(alpha._delta, foxtrot._delta);
- BOOST_CHECK(not (alpha._delta == gamma._delta));
+ BOOST_CHECK(not(alpha._delta == gamma._delta));
// Test copy-constructor
fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha);
@@ -36,19 +37,20 @@ BOOST_AUTO_TEST_CASE(fp_compare_delta_constructors) {
BOOST_CHECK_EQUAL(alpha._delta, delta._delta);
}
-BOOST_AUTO_TEST_CASE(double_compare_constructors) {
+BOOST_AUTO_TEST_CASE(double_compare_constructors)
+{
// Test default constructor
fp_compare_delta<double> alpha = fp_compare_delta<double>(45739210286.0101);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
BOOST_CHECK_EQUAL(alpha._value, beta._value);
BOOST_CHECK_EQUAL(alpha._delta, beta._delta);
// Test constructor with specified delta
- fp_compare_delta<double> foxtrot = fp_compare_delta<double>(alpha._value,
- uhd::math::DOUBLE_PRECISION_DELTA);
+ fp_compare_delta<double> foxtrot =
+ fp_compare_delta<double>(alpha._value, uhd::math::DOUBLE_PRECISION_DELTA);
fp_compare_delta<double> gamma = fp_compare_delta<double>(alpha._value, 2.0e-6);
BOOST_CHECK_EQUAL(alpha._delta, foxtrot._delta);
- BOOST_CHECK(not (alpha._delta == gamma._delta));
+ BOOST_CHECK(not(alpha._delta == gamma._delta));
// Test copy-constructor
fp_compare_delta<double> charlie = fp_compare_delta<double>(alpha);
@@ -61,56 +63,61 @@ BOOST_AUTO_TEST_CASE(double_compare_constructors) {
BOOST_CHECK_EQUAL(alpha._delta, delta._delta);
}
-BOOST_AUTO_TEST_CASE(float_equality_operators) {
+BOOST_AUTO_TEST_CASE(float_equality_operators)
+{
// Test basic equality operator
fp_compare_delta<float> alpha = fp_compare_delta<float>(1.0);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
BOOST_CHECK(alpha == beta);
BOOST_CHECK(alpha == float(alpha._value));
// Test equality edge case at difference = delta
- fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value
- + uhd::math::SINGLE_PRECISION_DELTA);
- BOOST_CHECK(not (alpha == charlie));
- BOOST_CHECK(not (alpha == float(alpha._value + uhd::math::SINGLE_PRECISION_DELTA)));
+ fp_compare_delta<float> charlie =
+ fp_compare_delta<float>(alpha._value + uhd::math::SINGLE_PRECISION_DELTA);
+ BOOST_CHECK(not(alpha == charlie));
+ BOOST_CHECK(not(alpha == float(alpha._value + uhd::math::SINGLE_PRECISION_DELTA)));
}
-BOOST_AUTO_TEST_CASE(double_equality_operators) {
+BOOST_AUTO_TEST_CASE(double_equality_operators)
+{
// Test basic equality operator
fp_compare_delta<double> alpha = fp_compare_delta<double>(1.0);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
BOOST_CHECK(alpha == beta);
BOOST_CHECK(alpha == double(beta._value));
// Test equality edge case at delta = delta
- fp_compare_delta<double> charlie = fp_compare_delta<double>(alpha._value
- + uhd::math::DOUBLE_PRECISION_DELTA);
- BOOST_CHECK(not (alpha == charlie));
- BOOST_CHECK(not (alpha == double(alpha._value + uhd::math::DOUBLE_PRECISION_DELTA)));
+ fp_compare_delta<double> charlie =
+ fp_compare_delta<double>(alpha._value + uhd::math::DOUBLE_PRECISION_DELTA);
+ BOOST_CHECK(not(alpha == charlie));
+ BOOST_CHECK(not(alpha == double(alpha._value + uhd::math::DOUBLE_PRECISION_DELTA)));
}
-BOOST_AUTO_TEST_CASE(float_inequality_operators) {
+BOOST_AUTO_TEST_CASE(float_inequality_operators)
+{
// Test inequality operator, which is based on equality operator
fp_compare_delta<float> alpha = fp_compare_delta<float>(127.0f);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 1.19e-3f);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 1.19e-3f);
BOOST_CHECK(alpha != beta);
BOOST_CHECK(alpha != float(alpha._value + 1.19e-3));
}
-BOOST_AUTO_TEST_CASE(double_inequality_operators) {
+BOOST_AUTO_TEST_CASE(double_inequality_operators)
+{
// Test inequality operator, which is based on equality operator
fp_compare_delta<double> alpha = fp_compare_delta<double>(1.0);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value + 1.19e-5);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value + 1.19e-5);
BOOST_CHECK(alpha != beta);
BOOST_CHECK(alpha != double(alpha._value + 1.19e-5));
}
-BOOST_AUTO_TEST_CASE(float_lessthan_operators) {
+BOOST_AUTO_TEST_CASE(float_lessthan_operators)
+{
// Test less-than operator
fp_compare_delta<float> alpha = fp_compare_delta<float>(274192.7f);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value - 0.2f);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value - 0.2f);
BOOST_CHECK(beta < alpha);
BOOST_CHECK(float(alpha._value - 0.2) < alpha);
@@ -118,14 +125,15 @@ BOOST_AUTO_TEST_CASE(float_lessthan_operators) {
// Confirm false less-than case
fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value - 1.2f);
- BOOST_CHECK(not (alpha < charlie));
- BOOST_CHECK(not (alpha < float(alpha._value - 1.2f)));
+ BOOST_CHECK(not(alpha < charlie));
+ BOOST_CHECK(not(alpha < float(alpha._value - 1.2f)));
}
-BOOST_AUTO_TEST_CASE(double_lessthan_operators) {
+BOOST_AUTO_TEST_CASE(double_lessthan_operators)
+{
// Test less-than operator
fp_compare_delta<double> alpha = fp_compare_delta<double>(274192856.762312);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value - 0.0002);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value - 0.0002);
BOOST_CHECK(beta < alpha);
BOOST_CHECK(double(alpha._value - 0.0002) < alpha);
@@ -133,14 +141,15 @@ BOOST_AUTO_TEST_CASE(double_lessthan_operators) {
// Confirm false less-than case
fp_compare_delta<double> charlie = fp_compare_delta<double>(alpha._value - 1.0012);
- BOOST_CHECK(not (alpha < charlie));
- BOOST_CHECK(not (alpha < double(alpha._value - 1.0012)));
+ BOOST_CHECK(not(alpha < charlie));
+ BOOST_CHECK(not(alpha < double(alpha._value - 1.0012)));
}
-BOOST_AUTO_TEST_CASE(float_lessthanequals_operators) {
+BOOST_AUTO_TEST_CASE(float_lessthanequals_operators)
+{
// Test that <= correctly reports for equal values
fp_compare_delta<float> alpha = fp_compare_delta<float>(827.3f);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
BOOST_CHECK(alpha <= beta);
BOOST_CHECK(alpha <= float(alpha._value));
@@ -152,10 +161,11 @@ BOOST_AUTO_TEST_CASE(float_lessthanequals_operators) {
BOOST_CHECK(float(alpha._value - 1.2) <= alpha);
}
-BOOST_AUTO_TEST_CASE(double_lessthanequals_operators) {
+BOOST_AUTO_TEST_CASE(double_lessthanequals_operators)
+{
// Test that <= correctly reports for equal values
fp_compare_delta<double> alpha = fp_compare_delta<double>(837652123.383764);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
BOOST_CHECK(alpha <= beta);
BOOST_CHECK(alpha <= double(alpha._value));
@@ -167,10 +177,11 @@ BOOST_AUTO_TEST_CASE(double_lessthanequals_operators) {
BOOST_CHECK(double(alpha._value - 0.0012) <= alpha);
}
-BOOST_AUTO_TEST_CASE(float_greaterthan_operators) {
+BOOST_AUTO_TEST_CASE(float_greaterthan_operators)
+{
// Test basic greater-than functionality
fp_compare_delta<float> alpha = fp_compare_delta<float>(98325.4f);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 0.15f);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value + 0.15f);
BOOST_CHECK(beta > alpha);
BOOST_CHECK(float(alpha._value + 0.15) > alpha);
@@ -178,14 +189,15 @@ BOOST_AUTO_TEST_CASE(float_greaterthan_operators) {
// Test false greater-than case
fp_compare_delta<float> charlie = fp_compare_delta<float>(alpha._value + 1.2f);
- BOOST_CHECK(not (alpha > charlie));
- BOOST_CHECK(not (alpha > float(alpha._value + 1.2)));
+ BOOST_CHECK(not(alpha > charlie));
+ BOOST_CHECK(not(alpha > float(alpha._value + 1.2)));
}
-BOOST_AUTO_TEST_CASE(double_greaterthan_operators) {
+BOOST_AUTO_TEST_CASE(double_greaterthan_operators)
+{
// Test basic greater-than functionality
fp_compare_delta<double> alpha = fp_compare_delta<double>(643907213.428475);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value + 0.0002);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value + 0.0002);
BOOST_CHECK(beta > alpha);
BOOST_CHECK(double(alpha._value + 0.0002) > alpha);
@@ -193,14 +205,15 @@ BOOST_AUTO_TEST_CASE(double_greaterthan_operators) {
// Test false greater-than case
fp_compare_delta<double> charlie = fp_compare_delta<double>(alpha._value + 0.0012);
- BOOST_CHECK(not (alpha > charlie));
- BOOST_CHECK(not (alpha > double(alpha._value + 0.0012)));
+ BOOST_CHECK(not(alpha > charlie));
+ BOOST_CHECK(not(alpha > double(alpha._value + 0.0012)));
}
-BOOST_AUTO_TEST_CASE(float_greaterthanequals_operators) {
+BOOST_AUTO_TEST_CASE(float_greaterthanequals_operators)
+{
// Test that >= correctly reports for equal values
fp_compare_delta<float> alpha = fp_compare_delta<float>(7834.89f);
- fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
+ fp_compare_delta<float> beta = fp_compare_delta<float>(alpha._value);
BOOST_CHECK(alpha >= beta);
BOOST_CHECK(alpha >= float(alpha._value));
@@ -212,10 +225,11 @@ BOOST_AUTO_TEST_CASE(float_greaterthanequals_operators) {
BOOST_CHECK(float(alpha._value + 4.8) >= alpha);
}
-BOOST_AUTO_TEST_CASE(double_greaterthanequals_operators) {
+BOOST_AUTO_TEST_CASE(double_greaterthanequals_operators)
+{
// Test that >= correctly reports for equal values
fp_compare_delta<double> alpha = fp_compare_delta<double>(737623834.89843);
- fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
+ fp_compare_delta<double> beta = fp_compare_delta<double>(alpha._value);
BOOST_CHECK(alpha >= beta);
BOOST_CHECK(alpha >= double(alpha._value));
@@ -227,16 +241,20 @@ BOOST_AUTO_TEST_CASE(double_greaterthanequals_operators) {
BOOST_CHECK(double(alpha._value + 3.0008) >= alpha);
}
-BOOST_AUTO_TEST_CASE(fp_compare_large_delta) {
- BOOST_CHECK(fp_compare_delta<double>(61440000.047870710492, 0.1) == 61440000.000000000000);
- BOOST_CHECK(fp_compare_delta<double>(61440000.047870710492, 0.1) <= 61440000.000000000000);
- BOOST_CHECK(fp_compare_delta<double>(61440000.047870710492, 0.1) >= 61440000.000000000000);
+BOOST_AUTO_TEST_CASE(fp_compare_large_delta)
+{
+ BOOST_CHECK(
+ fp_compare_delta<double>(61440000.047870710492, 0.1) == 61440000.000000000000);
+ BOOST_CHECK(
+ fp_compare_delta<double>(61440000.047870710492, 0.1) <= 61440000.000000000000);
+ BOOST_CHECK(
+ fp_compare_delta<double>(61440000.047870710492, 0.1) >= 61440000.000000000000);
BOOST_CHECK(fp_compare_delta<double>(1.0, 10.0) == 2.0);
}
-BOOST_AUTO_TEST_CASE(frequency_compare_function) {
-
+BOOST_AUTO_TEST_CASE(frequency_compare_function)
+{
BOOST_CHECK(uhd::math::frequencies_are_equal(6817333232.0, 6817333232.0));
BOOST_CHECK(!uhd::math::frequencies_are_equal(6817333233.0, 6817333232.0));
BOOST_CHECK(uhd::math::frequencies_are_equal(6817333232.1, 6817333232.1));
diff --git a/host/tests/fp_compare_epsilon_test.cpp b/host/tests/fp_compare_epsilon_test.cpp
index 5e5971586..0c2a7f1cb 100644
--- a/host/tests/fp_compare_epsilon_test.cpp
+++ b/host/tests/fp_compare_epsilon_test.cpp
@@ -10,19 +10,20 @@
using namespace uhd::math::fp_compare;
-BOOST_AUTO_TEST_CASE(fp_compare_epsilon_constructors) {
+BOOST_AUTO_TEST_CASE(fp_compare_epsilon_constructors)
+{
// Test default constructor
fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(7457392.0);
- fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value);
+ fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value);
BOOST_CHECK_EQUAL(alpha._value, beta._value);
BOOST_CHECK_EQUAL(alpha._epsilon, beta._epsilon);
// Test constructor with specified epsilon
- fp_compare_epsilon<float> foxtrot = fp_compare_epsilon<float>(alpha._value,
- uhd::math::SINGLE_PRECISION_EPSILON);
+ fp_compare_epsilon<float> foxtrot =
+ fp_compare_epsilon<float>(alpha._value, uhd::math::SINGLE_PRECISION_EPSILON);
fp_compare_epsilon<float> gamma = fp_compare_epsilon<float>(alpha._value, 2.0e-1f);
BOOST_CHECK_EQUAL(alpha._epsilon, foxtrot._epsilon);
- BOOST_CHECK(not (alpha._epsilon == gamma._epsilon));
+ BOOST_CHECK(not(alpha._epsilon == gamma._epsilon));
// Test copy-constructor
fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha);
@@ -35,19 +36,20 @@ BOOST_AUTO_TEST_CASE(fp_compare_epsilon_constructors) {
BOOST_CHECK_EQUAL(alpha._epsilon, delta._epsilon);
}
-BOOST_AUTO_TEST_CASE(double_compare_constructors) {
+BOOST_AUTO_TEST_CASE(double_compare_constructors)
+{
// Test default constructor
fp_compare_epsilon<double> alpha = fp_compare_epsilon<double>(45739210286.0101);
- fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value);
+ fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value);
BOOST_CHECK_EQUAL(alpha._value, beta._value);
BOOST_CHECK_EQUAL(alpha._epsilon, beta._epsilon);
// Test constructor with specified epsilon
- fp_compare_epsilon<double> foxtrot = fp_compare_epsilon<double>(alpha._value,
- uhd::math::DOUBLE_PRECISION_EPSILON);
+ fp_compare_epsilon<double> foxtrot =
+ fp_compare_epsilon<double>(alpha._value, uhd::math::DOUBLE_PRECISION_EPSILON);
fp_compare_epsilon<double> gamma = fp_compare_epsilon<double>(alpha._value, 2.0e-6);
BOOST_CHECK_EQUAL(alpha._epsilon, foxtrot._epsilon);
- BOOST_CHECK(not (alpha._epsilon == gamma._epsilon));
+ BOOST_CHECK(not(alpha._epsilon == gamma._epsilon));
// Test copy-constructor
fp_compare_epsilon<double> charlie = fp_compare_epsilon<double>(alpha);
@@ -60,45 +62,48 @@ BOOST_AUTO_TEST_CASE(double_compare_constructors) {
BOOST_CHECK_EQUAL(alpha._epsilon, delta._epsilon);
}
-BOOST_AUTO_TEST_CASE(float_equality_operators) {
+BOOST_AUTO_TEST_CASE(float_equality_operators)
+{
// Test basic equality operator
fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(1.0);
- fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value);
+ fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value);
BOOST_CHECK(alpha == beta);
BOOST_CHECK(alpha == float(alpha._value));
// Test equality edge case at delta = epsilon
- fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha._value
- + uhd::math::SINGLE_PRECISION_EPSILON);
- BOOST_CHECK(not (alpha == charlie));
- BOOST_CHECK(not (alpha == float(alpha._value + uhd::math::SINGLE_PRECISION_EPSILON)));
+ fp_compare_epsilon<float> charlie =
+ fp_compare_epsilon<float>(alpha._value + uhd::math::SINGLE_PRECISION_EPSILON);
+ BOOST_CHECK(not(alpha == charlie));
+ BOOST_CHECK(not(alpha == float(alpha._value + uhd::math::SINGLE_PRECISION_EPSILON)));
}
-BOOST_AUTO_TEST_CASE(double_equality_operators) {
+BOOST_AUTO_TEST_CASE(double_equality_operators)
+{
// Test basic equality operator
fp_compare_epsilon<double> alpha = fp_compare_epsilon<double>(1.0);
- fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value);
+ fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value);
BOOST_CHECK(alpha == beta);
BOOST_CHECK(alpha == double(beta._value));
// Test equality edge case at delta = epsilon
- fp_compare_epsilon<double> charlie = fp_compare_epsilon<double>(alpha._value
- + uhd::math::DOUBLE_PRECISION_EPSILON);
- BOOST_CHECK(not (alpha == charlie));
- BOOST_CHECK(not (alpha == double(alpha._value
- + uhd::math::DOUBLE_PRECISION_EPSILON)));
+ fp_compare_epsilon<double> charlie =
+ fp_compare_epsilon<double>(alpha._value + uhd::math::DOUBLE_PRECISION_EPSILON);
+ BOOST_CHECK(not(alpha == charlie));
+ BOOST_CHECK(not(alpha == double(alpha._value + uhd::math::DOUBLE_PRECISION_EPSILON)));
}
-BOOST_AUTO_TEST_CASE(float_inequality_operators) {
+BOOST_AUTO_TEST_CASE(float_inequality_operators)
+{
// Test inequality operator, which is based on equality operator
fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(127.0);
- fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value + 1.19e-5f);
+ fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value + 1.19e-5f);
BOOST_CHECK(alpha != beta);
BOOST_CHECK(alpha != float(alpha._value + 1.19e-5f));
}
-BOOST_AUTO_TEST_CASE(double_inequality_operators) {
+BOOST_AUTO_TEST_CASE(double_inequality_operators)
+{
// Test inequality operator, which is based on equality operator
fp_compare_epsilon<double> alpha = fp_compare_epsilon<double>(1.0);
fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value + 1.19e-10);
@@ -107,10 +112,11 @@ BOOST_AUTO_TEST_CASE(double_inequality_operators) {
BOOST_CHECK(alpha != double(alpha._value + 1.19e-10));
}
-BOOST_AUTO_TEST_CASE(float_lessthan_operators) {
+BOOST_AUTO_TEST_CASE(float_lessthan_operators)
+{
// Test less-than operator
fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(274192.7f);
- fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value - 0.15f);
+ fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value - 0.15f);
BOOST_CHECK(beta < alpha);
BOOST_CHECK(float(alpha._value - 0.15) < alpha);
@@ -118,29 +124,32 @@ BOOST_AUTO_TEST_CASE(float_lessthan_operators) {
// Confirm false less-than case
fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha._value - 1.2f);
- BOOST_CHECK(not (alpha < charlie));
- BOOST_CHECK(not (alpha < float(alpha._value - 1.2f)));
+ BOOST_CHECK(not(alpha < charlie));
+ BOOST_CHECK(not(alpha < float(alpha._value - 1.2f)));
}
-BOOST_AUTO_TEST_CASE(double_lessthan_operators) {
+BOOST_AUTO_TEST_CASE(double_lessthan_operators)
+{
// Test less-than operator
fp_compare_epsilon<double> alpha = fp_compare_epsilon<double>(274192856.762312);
- fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value - 0.0002);
+ fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value - 0.0002);
BOOST_CHECK(beta < alpha);
BOOST_CHECK(double(alpha._value - 0.0002) < alpha);
// Confirm false less-than case
- fp_compare_epsilon<double> charlie = fp_compare_epsilon<double>(alpha._value - 1.0012);
+ fp_compare_epsilon<double> charlie =
+ fp_compare_epsilon<double>(alpha._value - 1.0012);
- BOOST_CHECK(not (alpha < charlie));
- BOOST_CHECK(not (alpha < double(alpha._value - 1.0012)));
+ BOOST_CHECK(not(alpha < charlie));
+ BOOST_CHECK(not(alpha < double(alpha._value - 1.0012)));
}
-BOOST_AUTO_TEST_CASE(float_lessthanequals_operators) {
+BOOST_AUTO_TEST_CASE(float_lessthanequals_operators)
+{
// Test that <= correctly reports for equal values
fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(827.3f);
- fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value);
+ fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value);
BOOST_CHECK(alpha <= beta);
BOOST_CHECK(alpha <= float(alpha._value));
@@ -152,25 +161,28 @@ BOOST_AUTO_TEST_CASE(float_lessthanequals_operators) {
BOOST_CHECK(float(alpha._value - 1.2) <= alpha);
}
-BOOST_AUTO_TEST_CASE(double_lessthanequals_operators) {
+BOOST_AUTO_TEST_CASE(double_lessthanequals_operators)
+{
// Test that <= correctly reports for equal values
fp_compare_epsilon<double> alpha = fp_compare_epsilon<double>(837652123.383764);
- fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value);
+ fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value);
BOOST_CHECK(alpha <= beta);
BOOST_CHECK(alpha <= double(alpha._value));
// Test that <= correctly reports for less-than values
- fp_compare_epsilon<double> charlie = fp_compare_epsilon<double>(alpha._value - 0.0012);
+ fp_compare_epsilon<double> charlie =
+ fp_compare_epsilon<double>(alpha._value - 0.0012);
BOOST_CHECK(charlie <= alpha);
BOOST_CHECK(double(alpha._value - 0.0012) <= alpha);
}
-BOOST_AUTO_TEST_CASE(float_greaterthan_operators) {
+BOOST_AUTO_TEST_CASE(float_greaterthan_operators)
+{
// Test basic greater-than functionality
fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(98325.4f);
- fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value + 0.15f);
+ fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value + 0.15f);
BOOST_CHECK(beta > alpha);
BOOST_CHECK(float(alpha._value + 0.15) > alpha);
@@ -178,29 +190,32 @@ BOOST_AUTO_TEST_CASE(float_greaterthan_operators) {
// Test false greater-than case
fp_compare_epsilon<float> charlie = fp_compare_epsilon<float>(alpha._value + 1.2f);
- BOOST_CHECK(not (alpha > charlie));
- BOOST_CHECK(not (alpha > float(alpha._value + 1.2f)));
+ BOOST_CHECK(not(alpha > charlie));
+ BOOST_CHECK(not(alpha > float(alpha._value + 1.2f)));
}
-BOOST_AUTO_TEST_CASE(double_greaterthan_operators) {
+BOOST_AUTO_TEST_CASE(double_greaterthan_operators)
+{
// Test basic greater-than functionality
fp_compare_epsilon<double> alpha = fp_compare_epsilon<double>(643907213.428475);
- fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value + 0.0002);
+ fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value + 0.0002);
BOOST_CHECK(beta > alpha);
BOOST_CHECK(double(alpha._value + 0.0002) > alpha);
// Test false greater-than case
- fp_compare_epsilon<double> charlie = fp_compare_epsilon<double>(alpha._value + 0.0012);
+ fp_compare_epsilon<double> charlie =
+ fp_compare_epsilon<double>(alpha._value + 0.0012);
- BOOST_CHECK(not (alpha > charlie));
- BOOST_CHECK(not (alpha > double(alpha._value + 0.0012)));
+ BOOST_CHECK(not(alpha > charlie));
+ BOOST_CHECK(not(alpha > double(alpha._value + 0.0012)));
}
-BOOST_AUTO_TEST_CASE(float_greaterthanequals_operators) {
+BOOST_AUTO_TEST_CASE(float_greaterthanequals_operators)
+{
// Test that >= correctly reports for equal values
fp_compare_epsilon<float> alpha = fp_compare_epsilon<float>(7834.89f);
- fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value);
+ fp_compare_epsilon<float> beta = fp_compare_epsilon<float>(alpha._value);
BOOST_CHECK(alpha >= beta);
BOOST_CHECK(alpha >= float(alpha._value));
@@ -212,16 +227,18 @@ BOOST_AUTO_TEST_CASE(float_greaterthanequals_operators) {
BOOST_CHECK(float(alpha._value + 4.8f) >= alpha);
}
-BOOST_AUTO_TEST_CASE(double_greaterthanequals_operators) {
+BOOST_AUTO_TEST_CASE(double_greaterthanequals_operators)
+{
// Test that >= correctly reports for equal values
fp_compare_epsilon<double> alpha = fp_compare_epsilon<double>(737623834.89843);
- fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value);
+ fp_compare_epsilon<double> beta = fp_compare_epsilon<double>(alpha._value);
BOOST_CHECK(alpha >= beta);
BOOST_CHECK(alpha >= double(alpha._value));
// Test that >= correctly reports for greater-than values
- fp_compare_epsilon<double> charlie = fp_compare_epsilon<double>(alpha._value + 3.0008);
+ fp_compare_epsilon<double> charlie =
+ fp_compare_epsilon<double>(alpha._value + 3.0008);
BOOST_CHECK(charlie >= alpha);
BOOST_CHECK(double(alpha._value + 3.0008) >= alpha);
diff --git a/host/tests/gain_group_test.cpp b/host/tests/gain_group_test.cpp
index b8c15b479..2608f292d 100644
--- a/host/tests/gain_group_test.cpp
+++ b/host/tests/gain_group_test.cpp
@@ -5,10 +5,10 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/utils/gain_group.hpp>
#include <boost/bind.hpp>
#include <boost/math/special_functions/round.hpp>
+#include <boost/test/unit_test.hpp>
#include <iostream>
#define rint(x) boost::math::iround(x)
@@ -18,56 +18,63 @@ using namespace uhd;
/***********************************************************************
* Define gain element classes with needed functions
**********************************************************************/
-class gain_element1{
+class gain_element1
+{
public:
-
- gain_range_t get_range(void){
+ gain_range_t get_range(void)
+ {
return gain_range_t(0, 90, 1);
}
- double get_value(void){
+ double get_value(void)
+ {
return _gain;
}
- void set_value(double gain){
+ void set_value(double gain)
+ {
double step = get_range().step();
- _gain = step*rint(gain/step);
+ _gain = step * rint(gain / step);
}
private:
double _gain;
};
-class gain_element2{
+class gain_element2
+{
public:
-
- gain_range_t get_range(void){
+ gain_range_t get_range(void)
+ {
return gain_range_t(-20, 10, 0.1);
}
- double get_value(void){
+ double get_value(void)
+ {
return _gain;
}
- void set_value(double gain){
+ void set_value(double gain)
+ {
double step = get_range().step();
- _gain = step*rint(gain/step);
+ _gain = step * rint(gain / step);
}
private:
double _gain;
};
-//create static instances of gain elements to be shared by the tests
+// create static instances of gain elements to be shared by the tests
static gain_element1 g1;
static gain_element2 g2;
-static gain_group::sptr get_gain_group(size_t pri1 = 0, size_t pri2 = 0){
- //create instance of gain group
+static gain_group::sptr get_gain_group(size_t pri1 = 0, size_t pri2 = 0)
+{
+ // create instance of gain group
gain_fcns_t gain_fcns;
gain_group::sptr gg(gain_group::make());
- //load gain group with function sets
+ // load gain group with function sets
gain_fcns.get_range = boost::bind(&gain_element1::get_range, &g1);
gain_fcns.get_value = boost::bind(&gain_element1::get_value, &g1);
gain_fcns.set_value = boost::bind(&gain_element1::set_value, &g1, _1);
@@ -86,10 +93,11 @@ static gain_group::sptr get_gain_group(size_t pri1 = 0, size_t pri2 = 0){
**********************************************************************/
static const double tolerance = 0.001;
-BOOST_AUTO_TEST_CASE(test_gain_group_overall){
+BOOST_AUTO_TEST_CASE(test_gain_group_overall)
+{
gain_group::sptr gg = get_gain_group();
- //test the overall stuff
+ // test the overall stuff
gg->set_value(80);
BOOST_CHECK_CLOSE(gg->get_value(), 80.0, tolerance);
BOOST_CHECK_CLOSE(gg->get_range().start(), -20.0, tolerance);
@@ -97,16 +105,17 @@ BOOST_AUTO_TEST_CASE(test_gain_group_overall){
BOOST_CHECK_CLOSE(gg->get_range().step(), 0.1, tolerance);
}
-BOOST_AUTO_TEST_CASE(test_gain_group_priority){
+BOOST_AUTO_TEST_CASE(test_gain_group_priority)
+{
gain_group::sptr gg = get_gain_group(0, 1);
- //test the overall stuff
+ // test the overall stuff
gg->set_value(80);
BOOST_CHECK_CLOSE(gg->get_value(), 80.0, tolerance);
BOOST_CHECK_CLOSE(gg->get_range().start(), -20.0, tolerance);
BOOST_CHECK_CLOSE(gg->get_range().stop(), 100.0, tolerance);
BOOST_CHECK_CLOSE(gg->get_range().step(), 0.1, tolerance);
- //test the the higher priority gain got filled first (gain 2)
+ // test the the higher priority gain got filled first (gain 2)
BOOST_CHECK_CLOSE(g2.get_value(), g2.get_range().stop(), tolerance);
}
diff --git a/host/tests/graph.hpp b/host/tests/graph.hpp
index 50a87d307..fb36ae510 100644
--- a/host/tests/graph.hpp
+++ b/host/tests/graph.hpp
@@ -15,23 +15,28 @@
#define MAKE_NODE(name) test_node::sptr name(new test_node(#name));
// Smallest possible test class
-class test_node : virtual public uhd::rfnoc::sink_node_ctrl, virtual public uhd::rfnoc::source_node_ctrl
+class test_node : virtual public uhd::rfnoc::sink_node_ctrl,
+ virtual public uhd::rfnoc::source_node_ctrl
{
public:
typedef boost::shared_ptr<test_node> sptr;
- test_node(const std::string &test_id) : _test_id(test_id) {};
+ test_node(const std::string& test_id) : _test_id(test_id){};
- void issue_stream_cmd(const uhd::stream_cmd_t &, const size_t) {/* nop */};
+ void issue_stream_cmd(const uhd::stream_cmd_t&, const size_t){/* nop */};
- std::string get_test_id() const { return _test_id; };
+ std::string get_test_id() const
+ {
+ return _test_id;
+ };
private:
const std::string _test_id;
}; /* class test_node */
-void connect_nodes(uhd::rfnoc::source_node_ctrl::sptr A, uhd::rfnoc::sink_node_ctrl::sptr B)
+void connect_nodes(
+ uhd::rfnoc::source_node_ctrl::sptr A, uhd::rfnoc::sink_node_ctrl::sptr B)
{
const size_t actual_src_port = A->connect_downstream(B);
const size_t actual_dst_port = B->connect_upstream(A);
diff --git a/host/tests/graph_search_test.cpp b/host/tests/graph_search_test.cpp
index 8d35b3b1a..932647d98 100644
--- a/host/tests/graph_search_test.cpp
+++ b/host/tests/graph_search_test.cpp
@@ -17,7 +17,7 @@ class result_node : public test_node
public:
typedef boost::shared_ptr<result_node> sptr;
- result_node(const std::string &test_id) : test_node(test_id) {};
+ result_node(const std::string& test_id) : test_node(test_id){};
}; /* class result_node */
@@ -49,12 +49,12 @@ BOOST_AUTO_TEST_CASE(test_simple_downstream_search)
connect_nodes(node_A, node_B1);
// We're still searching for test_node, so any downstream block will match
- std::vector< test_node::sptr > result = node_A->find_downstream_node<test_node>();
+ std::vector<test_node::sptr> result = node_A->find_downstream_node<test_node>();
BOOST_REQUIRE(result.size() == 2);
BOOST_CHECK(
- (result[0]->get_test_id() == "node_B0" and result[1]->get_test_id() == "node_B1") or
- (result[1]->get_test_id() == "node_B0" and result[0]->get_test_id() == "node_B1")
- );
+ (result[0]->get_test_id() == "node_B0" and result[1]->get_test_id() == "node_B1")
+ or (result[1]->get_test_id() == "node_B0"
+ and result[0]->get_test_id() == "node_B1"));
BOOST_CHECK(result[0] == node_B0 or result[0] == node_B1);
}
@@ -69,11 +69,11 @@ BOOST_AUTO_TEST_CASE(test_linear_downstream_search)
connect_nodes(node_B, node_C);
// This time, we search for result_node
- std::vector< result_node::sptr > result = node_A->find_downstream_node<result_node>();
+ std::vector<result_node::sptr> result = node_A->find_downstream_node<result_node>();
std::cout << "size: " << result.size() << std::endl;
BOOST_CHECK_EQUAL(result.size(), 1);
BOOST_CHECK_EQUAL(result[0]->get_test_id(), "node_B");
- for(const result_node::sptr &node: result) {
+ for (const result_node::sptr& node : result) {
std::cout << node->get_test_id() << std::endl;
}
}
@@ -99,9 +99,9 @@ BOOST_AUTO_TEST_CASE(test_multi_iter_downstream_search)
connect_nodes(node_C0, node_D0);
// This time, we search for result_node
- std::vector< result_node::sptr > result = node_A->find_downstream_node<result_node>();
+ std::vector<result_node::sptr> result = node_A->find_downstream_node<result_node>();
BOOST_REQUIRE(result.size() == 4);
- for(const result_node::sptr &node: result) {
+ for (const result_node::sptr& node : result) {
std::cout << node->get_test_id() << std::endl;
}
}
@@ -120,7 +120,8 @@ BOOST_AUTO_TEST_CASE(test_multi_iter_cycle_downstream_search)
// Slightly more complex graph:
connect_nodes(node_A, node_B0);
// This connection goes both ways, causing a cycle
- connect_nodes(node_A, node_B1); connect_nodes(node_B1, node_A);
+ connect_nodes(node_A, node_B1);
+ connect_nodes(node_B1, node_A);
connect_nodes(node_B0, node_C0);
connect_nodes(node_B0, node_C1);
connect_nodes(node_B1, node_C2);
@@ -128,9 +129,9 @@ BOOST_AUTO_TEST_CASE(test_multi_iter_cycle_downstream_search)
connect_nodes(node_C0, node_D0);
// This time, we search for result_node
- std::vector< result_node::sptr > result = node_A->find_downstream_node<result_node>();
+ std::vector<result_node::sptr> result = node_A->find_downstream_node<result_node>();
BOOST_REQUIRE(result.size() == 4);
- for(const result_node::sptr &node: result) {
+ for (const result_node::sptr& node : result) {
std::cout << node->get_test_id() << std::endl;
}
}
@@ -141,9 +142,10 @@ BOOST_AUTO_TEST_CASE(test_mini_cycle_downstream_and_upstream)
MAKE_NODE(node_B);
// Connect them in a loop
- connect_nodes(node_A, node_B); connect_nodes(node_B, node_A);
+ connect_nodes(node_A, node_B);
+ connect_nodes(node_B, node_A);
- std::vector< test_node::sptr > result;
+ std::vector<test_node::sptr> result;
result = node_A->find_downstream_node<test_node>();
BOOST_REQUIRE_EQUAL(result.size(), 1);
BOOST_REQUIRE(result[0] == node_B);
diff --git a/host/tests/log_test.cpp b/host/tests/log_test.cpp
index 5e3ce0199..d9eae09f1 100644
--- a/host/tests/log_test.cpp
+++ b/host/tests/log_test.cpp
@@ -5,34 +5,25 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/utils/log.hpp>
#include <uhd/utils/log_add.hpp>
+#include <boost/test/unit_test.hpp>
#include <iostream>
-BOOST_AUTO_TEST_CASE(test_messages){
+BOOST_AUTO_TEST_CASE(test_messages)
+{
UHD_LOG_FASTPATH("foo");
UHD_LOG_FASTPATH("bar");
uhd::log::set_log_level(uhd::log::debug);
uhd::log::set_console_level(uhd::log::info);
- uhd::log::add_logger("test",
- [](const uhd::log::logging_info &I){
- std::cout << "<TEST> " << I.message << std::endl;
- }
- );
+ uhd::log::add_logger("test", [](const uhd::log::logging_info& I) {
+ std::cout << "<TEST> " << I.message << std::endl;
+ });
uhd::log::set_logger_level("test", uhd::log::debug);
- UHD_LOGGER_DEBUG("logger_test") <<
- "This is a test print for a debug log."
- ;
- UHD_LOGGER_INFO("logger_test") <<
- "This is a test print for a info log."
- ;
- UHD_LOGGER_WARNING("logger_test") <<
- "This is a test print for a warning log."
- ;
- UHD_LOGGER_ERROR("logger_test") <<
- "This is a test print for an error log."
- ;
+ UHD_LOGGER_DEBUG("logger_test") << "This is a test print for a debug log.";
+ UHD_LOGGER_INFO("logger_test") << "This is a test print for a info log.";
+ UHD_LOGGER_WARNING("logger_test") << "This is a test print for a warning log.";
+ UHD_LOGGER_ERROR("logger_test") << "This is a test print for an error log.";
UHD_HERE();
const int x = 42;
UHD_VAR(x);
diff --git a/host/tests/math_test.cpp b/host/tests/math_test.cpp
index 131016091..ffdcbb086 100644
--- a/host/tests/math_test.cpp
+++ b/host/tests/math_test.cpp
@@ -5,15 +5,15 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
-#include <stdint.h>
#include <uhd/utils/math.hpp>
+#include <stdint.h>
+#include <boost/test/unit_test.hpp>
// NOTE: This is not the only math test case, see e.g. special tests
// for fp comparison.
-BOOST_AUTO_TEST_CASE(test_log2){
+BOOST_AUTO_TEST_CASE(test_log2)
+{
double y = uhd::math::log2(16.0);
BOOST_CHECK_EQUAL(y, 4.0);
}
-
diff --git a/host/tests/module_test.cpp b/host/tests/module_test.cpp
index 8914c56a1..c81d8563f 100644
--- a/host/tests/module_test.cpp
+++ b/host/tests/module_test.cpp
@@ -8,7 +8,8 @@
#include <uhd/utils/static.hpp>
#include <iostream>
-UHD_STATIC_BLOCK(module_test){
+UHD_STATIC_BLOCK(module_test)
+{
std::cout << "---------------------------------------" << std::endl;
std::cout << "-- Good news, everyone!" << std::endl;
std::cout << "-- The test module has been loaded." << std::endl;
diff --git a/host/tests/narrow_cast_test.cpp b/host/tests/narrow_cast_test.cpp
index c108c310e..3ea7db1bf 100644
--- a/host/tests/narrow_cast_test.cpp
+++ b/host/tests/narrow_cast_test.cpp
@@ -11,11 +11,12 @@
using namespace uhd;
-BOOST_AUTO_TEST_CASE(test_narrow){
+BOOST_AUTO_TEST_CASE(test_narrow)
+{
uint16_t x = 5;
- uint8_t y = narrow_cast<uint8_t>(x);
+ uint8_t y = narrow_cast<uint8_t>(x);
BOOST_CHECK_EQUAL(x, y);
- BOOST_CHECK_THROW(narrow<uint8_t>(uint16_t(1<<10)), narrowing_error);
+ BOOST_CHECK_THROW(narrow<uint8_t>(uint16_t(1 << 10)), narrowing_error);
BOOST_CHECK_THROW(narrow<uint8_t>(int8_t(-1)), narrowing_error);
}
diff --git a/host/tests/nocscript_common.hpp b/host/tests/nocscript_common.hpp
index 4176fec6f..ad254fa0e 100644
--- a/host/tests/nocscript_common.hpp
+++ b/host/tests/nocscript_common.hpp
@@ -11,15 +11,20 @@
using namespace uhd::rfnoc::nocscript;
// Some global defs to make tests easier to write
-expression_function::argtype_list_type one_int_arg = boost::assign::list_of(expression::TYPE_INT);
-expression_function::argtype_list_type two_int_args = boost::assign::list_of(expression::TYPE_INT)(expression::TYPE_INT);
-expression_function::argtype_list_type one_double_arg = boost::assign::list_of(expression::TYPE_DOUBLE);
-expression_function::argtype_list_type two_double_args = boost::assign::list_of(expression::TYPE_DOUBLE)(expression::TYPE_DOUBLE);
-expression_function::argtype_list_type one_bool_arg = boost::assign::list_of(expression::TYPE_BOOL);
-expression_function::argtype_list_type two_bool_args = boost::assign::list_of(expression::TYPE_BOOL)(expression::TYPE_BOOL);
+expression_function::argtype_list_type one_int_arg =
+ boost::assign::list_of(expression::TYPE_INT);
+expression_function::argtype_list_type two_int_args =
+ boost::assign::list_of(expression::TYPE_INT)(expression::TYPE_INT);
+expression_function::argtype_list_type one_double_arg =
+ boost::assign::list_of(expression::TYPE_DOUBLE);
+expression_function::argtype_list_type two_double_args =
+ boost::assign::list_of(expression::TYPE_DOUBLE)(expression::TYPE_DOUBLE);
+expression_function::argtype_list_type one_bool_arg =
+ boost::assign::list_of(expression::TYPE_BOOL);
+expression_function::argtype_list_type two_bool_args =
+ boost::assign::list_of(expression::TYPE_BOOL)(expression::TYPE_BOOL);
expression_function::argtype_list_type no_args;
expression_container::expr_list_type empty_arg_list;
#define E(x) expression_literal::make(x)
-
diff --git a/host/tests/nocscript_expr_test.cpp b/host/tests/nocscript_expr_test.cpp
index 19b4345c2..ed5f6598d 100644
--- a/host/tests/nocscript_expr_test.cpp
+++ b/host/tests/nocscript_expr_test.cpp
@@ -6,16 +6,15 @@
//
#include "../lib/rfnoc/nocscript/function_table.hpp"
-#include <boost/test/unit_test.hpp>
-#include <boost/test/floating_point_comparison.hpp>
+#include "nocscript_common.hpp"
#include <boost/bind.hpp>
-#include <boost/make_shared.hpp>
#include <boost/format.hpp>
+#include <boost/make_shared.hpp>
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/unit_test.hpp>
#include <algorithm>
#include <iostream>
-#include "nocscript_common.hpp"
-
// We need this global variable for one of the later tests
int and_counter = 0;
@@ -65,15 +64,15 @@ BOOST_AUTO_TEST_CASE(test_literals)
BOOST_CHECK_EQUAL(literal_int_vec.infer_type(), expression::TYPE_INT_VECTOR);
std::vector<int> test_data{1, 2, 3};
std::vector<int> result = literal_int_vec.get_int_vector();
- BOOST_CHECK_EQUAL_COLLECTIONS(test_data.begin(), test_data.end(),
- result.begin(), result.end());
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ test_data.begin(), test_data.end(), result.begin(), result.end());
BOOST_REQUIRE_THROW(literal_int_vec.get_bool(), uhd::type_error);
BOOST_REQUIRE_THROW(literal_int_vec.get_int(), uhd::type_error);
}
// Need those for the variable testing:
-expression::type_t variable_get_type(const std::string &var_name)
+expression::type_t variable_get_type(const std::string& var_name)
{
if (var_name == "spp") {
std::cout << "Returning type for $spp..." << std::endl;
@@ -87,7 +86,7 @@ expression::type_t variable_get_type(const std::string &var_name)
throw uhd::syntax_error("Cannot infer type (unknown variable)");
}
-expression_literal variable_get_value(const std::string &var_name)
+expression_literal variable_get_value(const std::string& var_name)
{
if (var_name == "spp") {
std::cout << "Returning value for $spp..." << std::endl;
@@ -103,18 +102,14 @@ expression_literal variable_get_value(const std::string &var_name)
BOOST_AUTO_TEST_CASE(test_variables)
{
- BOOST_REQUIRE_THROW(
- expression_variable v_fail(
- "foo", // Invalid token
- boost::bind(&variable_get_type, _1), boost::bind(&variable_get_value, _1)
- ),
- uhd::assertion_error
- );
-
- expression_variable v(
- "$spp", // The token
- boost::bind(&variable_get_type, _1), // type-getter
- boost::bind(&variable_get_value, _1) // value-getter
+ BOOST_REQUIRE_THROW(expression_variable v_fail("foo", // Invalid token
+ boost::bind(&variable_get_type, _1),
+ boost::bind(&variable_get_value, _1)),
+ uhd::assertion_error);
+
+ expression_variable v("$spp", // The token
+ boost::bind(&variable_get_type, _1), // type-getter
+ boost::bind(&variable_get_value, _1) // value-getter
);
BOOST_CHECK_EQUAL(v.infer_type(), expression::TYPE_INT);
BOOST_CHECK_EQUAL(v.eval().get_int(), 5);
@@ -123,23 +118,21 @@ BOOST_AUTO_TEST_CASE(test_variables)
BOOST_AUTO_TEST_CASE(test_container)
{
// Create some sub-expressions:
- expression_literal::sptr l_true = E(true);
+ expression_literal::sptr l_true = E(true);
expression_literal::sptr l_false = E(false);
- expression_literal::sptr l_int = E(5);
+ expression_literal::sptr l_int = E(5);
BOOST_REQUIRE_EQUAL(l_false->get_bool(), false);
BOOST_REQUIRE_EQUAL(l_false->to_bool(), false);
- expression_variable::sptr l_boolvar = boost::make_shared<expression_variable>(
- "$is_true",
- boost::bind(&variable_get_type, _1),
- boost::bind(&variable_get_value, _1)
- );
+ expression_variable::sptr l_boolvar =
+ boost::make_shared<expression_variable>("$is_true",
+ boost::bind(&variable_get_type, _1),
+ boost::bind(&variable_get_value, _1));
// This will throw anytime it's evaluated:
- expression_variable::sptr l_failvar = boost::make_shared<expression_variable>(
- "$does_not_exist",
- boost::bind(&variable_get_type, _1),
- boost::bind(&variable_get_value, _1)
- );
+ expression_variable::sptr l_failvar =
+ boost::make_shared<expression_variable>("$does_not_exist",
+ boost::bind(&variable_get_type, _1),
+ boost::bind(&variable_get_value, _1));
expression_container c;
std::cout << "One true, OR: " << std::endl;
@@ -196,38 +189,32 @@ BOOST_AUTO_TEST_CASE(test_container)
// be defined for INT and DOUBLE
class functable_mockup_impl : public function_table
{
- public:
- functable_mockup_impl(void) {};
+public:
+ functable_mockup_impl(void){};
- bool function_exists(const std::string &name) const {
+ bool function_exists(const std::string& name) const
+ {
return name == "ADD" or name == "XOR" or name == "AND";
}
- bool function_exists(
- const std::string &name,
- const expression_function::argtype_list_type &arg_types
- ) const {
+ bool function_exists(const std::string& name,
+ const expression_function::argtype_list_type& arg_types) const
+ {
if (name == "ADD") {
- if (arg_types.size() == 2
- and arg_types[0] == expression::TYPE_DOUBLE
- and arg_types[1] == expression::TYPE_DOUBLE
- ) {
+ if (arg_types.size() == 2 and arg_types[0] == expression::TYPE_DOUBLE
+ and arg_types[1] == expression::TYPE_DOUBLE) {
return true;
}
- if (arg_types.size() == 2
- and arg_types[0] == expression::TYPE_INT
- and arg_types[1] == expression::TYPE_INT
- ) {
+ if (arg_types.size() == 2 and arg_types[0] == expression::TYPE_INT
+ and arg_types[1] == expression::TYPE_INT) {
return true;
}
return false;
}
if (name == "XOR" or name == "AND") {
- if (arg_types.size() == 2
- and arg_types[0] == expression::TYPE_BOOL
- and arg_types[1] == expression::TYPE_BOOL
- ) {
+ if (arg_types.size() == 2 and arg_types[0] == expression::TYPE_BOOL
+ and arg_types[1] == expression::TYPE_BOOL) {
return true;
}
return false;
@@ -236,15 +223,14 @@ class functable_mockup_impl : public function_table
return false;
}
- expression::type_t get_type(
- const std::string &name,
- const expression_function::argtype_list_type &arg_types
- ) const {
+ expression::type_t get_type(const std::string& name,
+ const expression_function::argtype_list_type& arg_types) const
+ {
if (not function_exists(name, arg_types)) {
- throw uhd::syntax_error(str(
- boost::format("[EXPR_TEXT] get_type(): Unknown function: %s, %d arguments")
- % name % arg_types.size()
- ));
+ throw uhd::syntax_error(
+ str(boost::format(
+ "[EXPR_TEXT] get_type(): Unknown function: %s, %d arguments")
+ % name % arg_types.size()));
}
if (name == "XOR" or name == "AND") {
@@ -256,58 +242,48 @@ class functable_mockup_impl : public function_table
UHD_THROW_INVALID_CODE_PATH();
}
- expression_literal eval(
- const std::string &name,
- const expression_function::argtype_list_type &arg_types,
- expression_container::expr_list_type &args
- ) {
+ expression_literal eval(const std::string& name,
+ const expression_function::argtype_list_type& arg_types,
+ expression_container::expr_list_type& args)
+ {
if (name == "XOR") {
- if (arg_types.size() != 2
- or args.size() != 2
+ if (arg_types.size() != 2 or args.size() != 2
or arg_types[0] != expression::TYPE_BOOL
or arg_types[1] != expression::TYPE_BOOL
or args[0]->infer_type() != expression::TYPE_BOOL
- or args[1]->infer_type() != expression::TYPE_BOOL
- ) {
+ or args[1]->infer_type() != expression::TYPE_BOOL) {
throw uhd::syntax_error("eval(): XOR type mismatch");
}
- return expression_literal(bool(
- args[0]->eval().get_bool() xor args[1]->eval().get_bool()
- ));
+ return expression_literal(
+ bool(args[0]->eval().get_bool() xor args[1]->eval().get_bool()));
}
if (name == "AND") {
- if (arg_types.size() != 2
- or args.size() != 2
+ if (arg_types.size() != 2 or args.size() != 2
or arg_types[0] != expression::TYPE_BOOL
or arg_types[1] != expression::TYPE_BOOL
or args[0]->infer_type() != expression::TYPE_BOOL
- or args[1]->infer_type() != expression::TYPE_BOOL
- ) {
+ or args[1]->infer_type() != expression::TYPE_BOOL) {
throw uhd::syntax_error("eval(): AND type mismatch");
}
std::cout << "Calling AND" << std::endl;
and_counter++;
- return expression_literal(bool(
- args[0]->eval().get_bool() and args[1]->eval().get_bool()
- ));
+ return expression_literal(
+ bool(args[0]->eval().get_bool() and args[1]->eval().get_bool()));
}
if (name == "ADD") {
if (args.size() != 2) {
throw uhd::syntax_error("eval(): ADD type mismatch");
}
- if ((args[0]->infer_type() == expression::TYPE_INT) and
- (args[1]->infer_type() == expression::TYPE_INT)) {
- return expression_literal(int(
- args[0]->eval().get_int() + args[1]->eval().get_int()
- ));
- }
- else if ((args[0]->infer_type() == expression::TYPE_DOUBLE) and
- (args[1]->infer_type() == expression::TYPE_DOUBLE)) {
- return expression_literal(double(
- args[0]->eval().get_double() + args[1]->eval().get_double()
- ));
+ if ((args[0]->infer_type() == expression::TYPE_INT)
+ and (args[1]->infer_type() == expression::TYPE_INT)) {
+ return expression_literal(
+ int(args[0]->eval().get_int() + args[1]->eval().get_int()));
+ } else if ((args[0]->infer_type() == expression::TYPE_DOUBLE)
+ and (args[1]->infer_type() == expression::TYPE_DOUBLE)) {
+ return expression_literal(
+ double(args[0]->eval().get_double() + args[1]->eval().get_double()));
}
throw uhd::syntax_error("eval(): ADD type mismatch");
}
@@ -315,13 +291,10 @@ class functable_mockup_impl : public function_table
}
// We don't actually need this
- void register_function(
- const std::string &,
- const function_table::function_ptr &,
- const expression::type_t,
- const expression_function::argtype_list_type &
- ) {};
-
+ void register_function(const std::string&,
+ const function_table::function_ptr&,
+ const expression::type_t,
+ const expression_function::argtype_list_type&){};
};
@@ -342,16 +315,20 @@ BOOST_AUTO_TEST_CASE(test_functable_mockup)
BOOST_CHECK(not functable.function_exists("XOR", no_args));
BOOST_CHECK_EQUAL(functable.get_type("ADD", two_int_args), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(functable.get_type("ADD", two_double_args), expression::TYPE_DOUBLE);
+ BOOST_CHECK_EQUAL(
+ functable.get_type("ADD", two_double_args), expression::TYPE_DOUBLE);
BOOST_CHECK_EQUAL(functable.get_type("XOR", two_bool_args), expression::TYPE_BOOL);
expression_container::expr_list_type add_args_int{E(2), E(3)};
expression_container::expr_list_type add_args_dbl{E(2.25), E(5.0)};
expression_container::expr_list_type xor_args_bool{E(true), E(false)};
- BOOST_CHECK_EQUAL(functable.eval("ADD", two_int_args, add_args_int), expression_literal(5));
- BOOST_CHECK_EQUAL(functable.eval("ADD", two_double_args, add_args_dbl), expression_literal(7.25));
- BOOST_CHECK_EQUAL(functable.eval("XOR", two_bool_args, xor_args_bool), expression_literal(true));
+ BOOST_CHECK_EQUAL(
+ functable.eval("ADD", two_int_args, add_args_int), expression_literal(5));
+ BOOST_CHECK_EQUAL(
+ functable.eval("ADD", two_double_args, add_args_dbl), expression_literal(7.25));
+ BOOST_CHECK_EQUAL(
+ functable.eval("XOR", two_bool_args, xor_args_bool), expression_literal(true));
}
BOOST_AUTO_TEST_CASE(test_function_expression)
@@ -402,7 +379,7 @@ BOOST_AUTO_TEST_CASE(test_function_expression_laziness)
f3->add(E(false));
BOOST_CHECK(not f3->eval().get_bool());
- and_counter = 0;
+ and_counter = 0;
expression_function::sptr f1 = boost::make_shared<expression_function>("AND", ft);
f1->add(f2);
f1->add(f3);
@@ -417,14 +394,12 @@ BOOST_AUTO_TEST_CASE(test_sptrs)
BOOST_CHECK_EQUAL(c->infer_type(), expression::TYPE_BOOL);
BOOST_CHECK(c->eval().get_bool());
- expression_variable::sptr v = expression_variable::make(
- "$spp",
- boost::bind(&variable_get_type, _1), // type-getter
- boost::bind(&variable_get_value, _1) // value-getter
+ expression_variable::sptr v = expression_variable::make("$spp",
+ boost::bind(&variable_get_type, _1), // type-getter
+ boost::bind(&variable_get_value, _1) // value-getter
);
c->add(v);
BOOST_REQUIRE_EQUAL(c->infer_type(), expression::TYPE_INT);
BOOST_CHECK_EQUAL(c->eval().get_int(), 5);
}
-
diff --git a/host/tests/nocscript_ftable_test.cpp b/host/tests/nocscript_ftable_test.cpp
index 99ac2231a..36aa314f2 100644
--- a/host/tests/nocscript_ftable_test.cpp
+++ b/host/tests/nocscript_ftable_test.cpp
@@ -6,15 +6,14 @@
//
#include "../lib/rfnoc/nocscript/function_table.hpp"
-#include <boost/test/unit_test.hpp>
-#include <boost/test/floating_point_comparison.hpp>
+#include "nocscript_common.hpp"
#include <boost/bind.hpp>
#include <boost/make_shared.hpp>
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/unit_test.hpp>
#include <algorithm>
#include <iostream>
-#include "nocscript_common.hpp"
-
BOOST_AUTO_TEST_CASE(test_basic_funcs)
{
function_table::sptr ft = function_table::make();
@@ -49,7 +48,7 @@ BOOST_AUTO_TEST_CASE(test_basic_funcs)
BOOST_REQUIRE_EQUAL(ft->get_type("DIV", two_double_args), expression::TYPE_DOUBLE);
expression_literal e_div_d = ft->eval("DIV", two_double_args, two_double_values);
BOOST_REQUIRE_EQUAL(e_div_d.infer_type(), expression::TYPE_DOUBLE);
- BOOST_CHECK_CLOSE(e_div_d.get_double(), 2.0/3.0, 0.01);
+ BOOST_CHECK_CLOSE(e_div_d.get_double(), 2.0 / 3.0, 0.01);
BOOST_REQUIRE_EQUAL(ft->get_type("MODULO", two_int_args), expression::TYPE_INT);
expression_literal e_modulo_i = ft->eval("MODULO", two_int_args, two_int_values);
@@ -103,15 +102,11 @@ BOOST_AUTO_TEST_CASE(test_add_funcs)
BOOST_CHECK(not ft->function_exists("ADD_PLUS_2"));
expression_function::argtype_list_type add_int_args{
+ expression::TYPE_INT, expression::TYPE_INT};
+ ft->register_function("ADD_PLUS_2",
+ boost::bind(&add_plus2_int, _1),
expression::TYPE_INT,
- expression::TYPE_INT
- };
- ft->register_function(
- "ADD_PLUS_2",
- boost::bind(&add_plus2_int, _1),
- expression::TYPE_INT,
- add_int_args
- );
+ add_int_args);
BOOST_CHECK(ft->function_exists("ADD_PLUS_2"));
BOOST_CHECK(ft->function_exists("ADD_PLUS_2", add_int_args));
@@ -144,22 +139,16 @@ BOOST_AUTO_TEST_CASE(test_conditionals)
{
function_table::sptr ft = function_table::make();
ft->register_function(
- "DUMMY",
- boost::bind(&dummy_true, _1),
- expression::TYPE_BOOL,
- no_args
- );
+ "DUMMY", boost::bind(&dummy_true, _1), expression::TYPE_BOOL, no_args);
ft->register_function(
- "DUMMY_F",
- boost::bind(&dummy_false, _1),
- expression::TYPE_BOOL,
- no_args
- );
+ "DUMMY_F", boost::bind(&dummy_false, _1), expression::TYPE_BOOL, no_args);
BOOST_REQUIRE(ft->function_exists("DUMMY", no_args));
BOOST_REQUIRE(ft->function_exists("DUMMY_F", no_args));
- expression_function::sptr dummy_statement = boost::make_shared<expression_function>("DUMMY", ft);
- expression_function::sptr if_statement = boost::make_shared<expression_function>("IF", ft);
+ expression_function::sptr dummy_statement =
+ boost::make_shared<expression_function>("DUMMY", ft);
+ expression_function::sptr if_statement =
+ boost::make_shared<expression_function>("IF", ft);
if_statement->add(E(true));
if_statement->add(dummy_statement);
@@ -170,7 +159,8 @@ BOOST_AUTO_TEST_CASE(test_conditionals)
std::cout << "END." << std::endl;
std::cout << "Dummy statement should not run until END:" << std::endl;
- expression_function::sptr if_statement2 = boost::make_shared<expression_function>("IF", ft);
+ expression_function::sptr if_statement2 =
+ boost::make_shared<expression_function>("IF", ft);
if_statement2->add(E(false));
if_statement2->add(dummy_statement);
dummy_true_counter = 0;
@@ -178,12 +168,14 @@ BOOST_AUTO_TEST_CASE(test_conditionals)
BOOST_CHECK_EQUAL(dummy_true_counter, 0);
std::cout << "END." << std::endl;
- expression_function::sptr if_else_statement = boost::make_shared<expression_function>("IF_ELSE", ft);
- expression_function::sptr dummy_statement_f = boost::make_shared<expression_function>("DUMMY_F", ft);
+ expression_function::sptr if_else_statement =
+ boost::make_shared<expression_function>("IF_ELSE", ft);
+ expression_function::sptr dummy_statement_f =
+ boost::make_shared<expression_function>("DUMMY_F", ft);
if_else_statement->add(E(true));
if_else_statement->add(dummy_statement);
if_else_statement->add(dummy_statement_f);
- dummy_true_counter = 0;
+ dummy_true_counter = 0;
dummy_false_counter = 0;
std::cout << "Should execute dummy/true statement before END:" << std::endl;
BOOST_CHECK(if_else_statement->eval().get_bool());
@@ -191,11 +183,12 @@ BOOST_AUTO_TEST_CASE(test_conditionals)
BOOST_CHECK_EQUAL(dummy_false_counter, 0);
std::cout << "END." << std::endl;
- expression_function::sptr if_else_statement2 = boost::make_shared<expression_function>("IF_ELSE", ft);
+ expression_function::sptr if_else_statement2 =
+ boost::make_shared<expression_function>("IF_ELSE", ft);
if_else_statement2->add(E(false));
if_else_statement2->add(dummy_statement);
if_else_statement2->add(dummy_statement_f);
- dummy_true_counter = 0;
+ dummy_true_counter = 0;
dummy_false_counter = 0;
std::cout << "Should execute dummy/false statement before END:" << std::endl;
BOOST_CHECK(not if_else_statement2->eval().get_bool());
@@ -221,33 +214,35 @@ BOOST_AUTO_TEST_CASE(test_bitwise_funcs)
// Bitwise Math
int int_value1 = 0x2;
int int_value2 = 0x3;
- expression_container::expr_list_type two_int_values{
- E(int_value1),
- E(int_value2)
- };
+ expression_container::expr_list_type two_int_values{E(int_value1), E(int_value2)};
BOOST_REQUIRE_EQUAL(ft->get_type("SHIFT_RIGHT", two_int_args), expression::TYPE_INT);
- expression_literal e_shift_right = ft->eval("SHIFT_RIGHT", two_int_args, two_int_values);
+ expression_literal e_shift_right =
+ ft->eval("SHIFT_RIGHT", two_int_args, two_int_values);
BOOST_REQUIRE_EQUAL(e_shift_right.infer_type(), expression::TYPE_INT);
BOOST_CHECK_EQUAL(e_shift_right.get_int(), int_value1 >> int_value2);
BOOST_REQUIRE_EQUAL(ft->get_type("SHIFT_LEFT", two_int_args), expression::TYPE_INT);
- expression_literal e_shift_left = ft->eval("SHIFT_LEFT", two_int_args, two_int_values);
+ expression_literal e_shift_left =
+ ft->eval("SHIFT_LEFT", two_int_args, two_int_values);
BOOST_REQUIRE_EQUAL(e_shift_left.infer_type(), expression::TYPE_INT);
BOOST_CHECK_EQUAL(e_shift_left.get_int(), int_value1 << int_value2);
BOOST_REQUIRE_EQUAL(ft->get_type("BITWISE_AND", two_int_args), expression::TYPE_INT);
- expression_literal e_bitwise_and = ft->eval("BITWISE_AND", two_int_args, two_int_values);
+ expression_literal e_bitwise_and =
+ ft->eval("BITWISE_AND", two_int_args, two_int_values);
BOOST_REQUIRE_EQUAL(e_bitwise_and.infer_type(), expression::TYPE_INT);
BOOST_CHECK_EQUAL(e_bitwise_and.get_int(), int_value1 & int_value2);
BOOST_REQUIRE_EQUAL(ft->get_type("BITWISE_OR", two_int_args), expression::TYPE_INT);
- expression_literal e_bitwise_or = ft->eval("BITWISE_OR", two_int_args, two_int_values);
+ expression_literal e_bitwise_or =
+ ft->eval("BITWISE_OR", two_int_args, two_int_values);
BOOST_REQUIRE_EQUAL(e_bitwise_or.infer_type(), expression::TYPE_INT);
BOOST_CHECK_EQUAL(e_bitwise_or.get_int(), int_value1 | int_value2);
BOOST_REQUIRE_EQUAL(ft->get_type("BITWISE_XOR", two_int_args), expression::TYPE_INT);
- expression_literal e_bitwise_xor = ft->eval("BITWISE_XOR", two_int_args, two_int_values);
+ expression_literal e_bitwise_xor =
+ ft->eval("BITWISE_XOR", two_int_args, two_int_values);
BOOST_REQUIRE_EQUAL(e_bitwise_xor.infer_type(), expression::TYPE_INT);
BOOST_CHECK_EQUAL(e_bitwise_xor.get_int(), int_value1 ^ int_value2);
}
diff --git a/host/tests/nocscript_parser_test.cpp b/host/tests/nocscript_parser_test.cpp
index caa2ae6e0..eb9352995 100644
--- a/host/tests/nocscript_parser_test.cpp
+++ b/host/tests/nocscript_parser_test.cpp
@@ -7,21 +7,20 @@
#include "../lib/rfnoc/nocscript/function_table.hpp"
#include "../lib/rfnoc/nocscript/parser.hpp"
+#include "nocscript_common.hpp"
#include <uhd/exception.hpp>
-#include <boost/test/unit_test.hpp>
-#include <boost/test/floating_point_comparison.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/bind.hpp>
#include <boost/make_shared.hpp>
+#include <boost/test/floating_point_comparison.hpp>
+#include <boost/test/unit_test.hpp>
#include <algorithm>
#include <iostream>
-#include "nocscript_common.hpp"
-
const int SPP_VALUE = 64;
// Need those for the variable testing:
-expression::type_t variable_get_type(const std::string &var_name)
+expression::type_t variable_get_type(const std::string& var_name)
{
if (var_name == "spp") {
std::cout << "Returning type for $spp..." << std::endl;
@@ -35,7 +34,7 @@ expression::type_t variable_get_type(const std::string &var_name)
throw uhd::syntax_error("Cannot infer type (unknown variable)");
}
-expression_literal variable_get_value(const std::string &var_name)
+expression_literal variable_get_value(const std::string& var_name)
{
if (var_name == "spp") {
std::cout << "Returning value for $spp..." << std::endl;
@@ -49,13 +48,10 @@ expression_literal variable_get_value(const std::string &var_name)
throw uhd::syntax_error("Cannot read value (unknown variable)");
}
-#define SETUP_FT_AND_PARSER() \
+#define SETUP_FT_AND_PARSER() \
function_table::sptr ft = function_table::make(); \
- parser::sptr p = parser::make( \
- ft, \
- boost::bind(&variable_get_type, _1), \
- boost::bind(&variable_get_value, _1) \
- );
+ parser::sptr p = parser::make( \
+ ft, boost::bind(&variable_get_type, _1), boost::bind(&variable_get_value, _1));
BOOST_AUTO_TEST_CASE(test_fail)
{
@@ -79,11 +75,11 @@ BOOST_AUTO_TEST_CASE(test_adds_no_vars)
BOOST_REQUIRE(ft->function_exists("ADD"));
const std::string line("ADD(1, ADD(2, ADD(3, 4)))");
- expression::sptr e = p->create_expr_tree(line);
+ expression::sptr e = p->create_expr_tree(line);
expression_literal result = e->eval();
BOOST_REQUIRE_EQUAL(result.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(result.get_int(), 1+2+3+4);
+ BOOST_CHECK_EQUAL(result.get_int(), 1 + 2 + 3 + 4);
}
BOOST_AUTO_TEST_CASE(test_adds_with_vars)
@@ -91,11 +87,11 @@ BOOST_AUTO_TEST_CASE(test_adds_with_vars)
SETUP_FT_AND_PARSER();
const std::string line("ADD(1, ADD(2, $spp))");
- expression::sptr e = p->create_expr_tree(line);
+ expression::sptr e = p->create_expr_tree(line);
expression_literal result = e->eval();
BOOST_REQUIRE_EQUAL(result.infer_type(), expression::TYPE_INT);
- BOOST_CHECK_EQUAL(result.get_int(), 1+2+SPP_VALUE);
+ BOOST_CHECK_EQUAL(result.get_int(), 1 + 2 + SPP_VALUE);
}
BOOST_AUTO_TEST_CASE(test_fft_check)
@@ -103,7 +99,7 @@ BOOST_AUTO_TEST_CASE(test_fft_check)
SETUP_FT_AND_PARSER();
const std::string line("GE($spp, 16) AND LE($spp, 4096) AND IS_PWR_OF_2($spp)");
- expression::sptr e = p->create_expr_tree(line);
+ expression::sptr e = p->create_expr_tree(line);
expression_literal result = e->eval();
BOOST_REQUIRE_EQUAL(result.infer_type(), expression::TYPE_BOOL);
@@ -135,11 +131,7 @@ BOOST_AUTO_TEST_CASE(test_multi_commmand)
SETUP_FT_AND_PARSER();
ft->register_function(
- "DUMMY",
- boost::bind(&dummy_false, _1),
- expression::TYPE_BOOL,
- no_args
- );
+ "DUMMY", boost::bind(&dummy_false, _1), expression::TYPE_BOOL, no_args);
dummy_false_counter = 0;
p->create_expr_tree("DUMMY(), DUMMY(), DUMMY()")->eval();
@@ -153,4 +145,3 @@ BOOST_AUTO_TEST_CASE(test_multi_commmand)
p->create_expr_tree("DUMMY() OR DUMMY() OR DUMMY()")->eval();
BOOST_CHECK_EQUAL(dummy_false_counter, 3);
}
-
diff --git a/host/tests/node_connect_test.cpp b/host/tests/node_connect_test.cpp
index dd3d8d08a..97d052a06 100644
--- a/host/tests/node_connect_test.cpp
+++ b/host/tests/node_connect_test.cpp
@@ -16,25 +16,22 @@ class source_node : public test_node
public:
typedef boost::shared_ptr<source_node> sptr;
- source_node(const std::string &test_id, size_t output_port)
- : test_node(test_id)
- , active_rx_streamer_on_port(0)
- , _output_port(output_port) {};
+ source_node(const std::string& test_id, size_t output_port)
+ : test_node(test_id), active_rx_streamer_on_port(0), _output_port(output_port){};
void set_rx_streamer(bool active, const size_t port)
{
if (active) {
- std::cout << "[source_node] Someone is registering a rx streamer on port " << port << std::endl;
+ std::cout << "[source_node] Someone is registering a rx streamer on port "
+ << port << std::endl;
active_rx_streamer_on_port = port;
}
}
size_t active_rx_streamer_on_port;
protected:
- size_t _request_output_port(
- const size_t,
- const uhd::device_addr_t &
- ) const {
+ size_t _request_output_port(const size_t, const uhd::device_addr_t&) const
+ {
return _output_port;
}
@@ -47,25 +44,22 @@ class sink_node : public test_node
public:
typedef boost::shared_ptr<sink_node> sptr;
- sink_node(const std::string &test_id, size_t input_port)
- : test_node(test_id)
- , active_tx_streamer_on_port(0)
- , _input_port(input_port) {};
+ sink_node(const std::string& test_id, size_t input_port)
+ : test_node(test_id), active_tx_streamer_on_port(0), _input_port(input_port){};
void set_tx_streamer(bool active, const size_t port)
{
if (active) {
- std::cout << "[sink_node] Someone is registering a tx streamer on port " << port << std::endl;
+ std::cout << "[sink_node] Someone is registering a tx streamer on port "
+ << port << std::endl;
active_tx_streamer_on_port = port;
}
}
size_t active_tx_streamer_on_port;
protected:
- size_t _request_input_port(
- const size_t,
- const uhd::device_addr_t &
- ) const {
+ size_t _request_input_port(const size_t, const uhd::device_addr_t&) const
+ {
return _input_port;
}
diff --git a/host/tests/packet_handler_benchmark.cpp b/host/tests/packet_handler_benchmark.cpp
index 37c6861bb..21e1430ae 100644
--- a/host/tests/packet_handler_benchmark.cpp
+++ b/host/tests/packet_handler_benchmark.cpp
@@ -11,16 +11,16 @@
// This should have very little effect on packet handler performance.
#define SRPH_DONT_CHECK_SEQUENCE 1
-#include "common/mock_zero_copy.hpp"
-#include "../lib/transport/super_send_packet_handler.hpp"
#include "../lib/transport/super_recv_packet_handler.hpp"
+#include "../lib/transport/super_send_packet_handler.hpp"
#include "../lib/usrp/device3/device3_flow_ctrl.hpp"
-#include <uhd/utils/safe_main.hpp>
-#include <uhd/utils/thread.hpp>
+#include "common/mock_zero_copy.hpp"
#include <uhd/convert.hpp>
#include <uhd/transport/chdr.hpp>
#include <uhd/transport/zero_copy.hpp>
#include <uhd/types/sid.hpp>
+#include <uhd/utils/safe_main.hpp>
+#include <uhd/utils/thread.hpp>
#include <boost/program_options.hpp>
#include <chrono>
#include <vector>
@@ -29,18 +29,13 @@ namespace po = boost::program_options;
using namespace uhd::transport;
using namespace uhd::usrp;
-void benchmark_recv_packet_handler(
- const size_t spp,
- const std::string& format
-) {
- const size_t bpi = uhd::convert::get_bytes_per_item(format);
+void benchmark_recv_packet_handler(const size_t spp, const std::string& format)
+{
+ const size_t bpi = uhd::convert::get_bytes_per_item(format);
const size_t frame_size = bpi * spp + DEVICE3_RX_MAX_HDR_LEN;
- mock_zero_copy::sptr xport(
- new mock_zero_copy(
- vrt::if_packet_info_t::LINK_TYPE_CHDR,
- frame_size,
- frame_size));
+ mock_zero_copy::sptr xport(new mock_zero_copy(
+ vrt::if_packet_info_t::LINK_TYPE_CHDR, frame_size, frame_size));
xport->set_reuse_recv_memory(true);
@@ -51,38 +46,35 @@ void benchmark_recv_packet_handler(
uhd::convert::id_type id;
id.output_format = format;
- id.num_inputs = 1;
- id.input_format = "sc16_item32_be";
- id.num_outputs = 1;
+ id.num_inputs = 1;
+ id.input_format = "sc16_item32_be";
+ id.num_outputs = 1;
streamer.set_converter(id);
- streamer.set_xport_chan_get_buff(
- 0,
- [xport](double timeout) {
- return xport->get_recv_buff(timeout);
- },
+ streamer.set_xport_chan_get_buff(0,
+ [xport](double timeout) { return xport->get_recv_buff(timeout); },
false // flush
);
// Create packet for packet handler to read
vrt::if_packet_info_t packet_info;
- packet_info.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ packet_info.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
packet_info.num_payload_words32 = spp;
- packet_info.num_payload_bytes = packet_info.num_payload_words32*sizeof(uint32_t);
- packet_info.has_tsf = true;
- packet_info.tsf = 1;
+ packet_info.num_payload_bytes = packet_info.num_payload_words32 * sizeof(uint32_t);
+ packet_info.has_tsf = true;
+ packet_info.tsf = 1;
std::vector<uint32_t> recv_data(spp, 0);
xport->push_back_recv_packet(packet_info, recv_data);
// Allocate buffer
- std::vector<uint8_t> buffer(spp*bpi);
+ std::vector<uint8_t> buffer(spp * bpi);
std::vector<void*> buffers;
buffers.push_back(buffer.data());
// Run benchmark
uhd::rx_metadata_t md;
- const auto start_time = std::chrono::steady_clock::now();
+ const auto start_time = std::chrono::steady_clock::now();
const size_t iterations = 1e7;
for (size_t i = 0; i < iterations; i++) {
@@ -90,29 +82,21 @@ void benchmark_recv_packet_handler(
}
const auto end_time = std::chrono::steady_clock::now();
- const std::chrono::duration<double> elapsed_time(end_time-start_time);
+ const std::chrono::duration<double> elapsed_time(end_time - start_time);
const double time_per_packet = elapsed_time.count() / iterations;
- std::cout << format << ": "
- << time_per_packet / spp * 1e9
- << " ns/sample, "
- << time_per_packet * 1e9
- << " ns/packet\n";
+ std::cout << format << ": " << time_per_packet / spp * 1e9 << " ns/sample, "
+ << time_per_packet * 1e9 << " ns/packet\n";
}
void benchmark_send_packet_handler(
- const size_t spp,
- const std::string& format,
- bool use_time_spec
-) {
- const size_t bpi = uhd::convert::get_bytes_per_item(format);
+ const size_t spp, const std::string& format, bool use_time_spec)
+{
+ const size_t bpi = uhd::convert::get_bytes_per_item(format);
const size_t frame_size = bpi * spp + DEVICE3_TX_MAX_HDR_LEN;
- mock_zero_copy::sptr xport(
- new mock_zero_copy(
- vrt::if_packet_info_t::LINK_TYPE_CHDR,
- frame_size,
- frame_size));
+ mock_zero_copy::sptr xport(new mock_zero_copy(
+ vrt::if_packet_info_t::LINK_TYPE_CHDR, frame_size, frame_size));
xport->set_reuse_send_memory(true);
@@ -120,21 +104,18 @@ void benchmark_send_packet_handler(
streamer.set_vrt_packer(&vrt::chdr::if_hdr_pack_be);
uhd::convert::id_type id;
- id.input_format = format;
- id.num_inputs = 1;
+ id.input_format = format;
+ id.num_inputs = 1;
id.output_format = "sc16_item32_be";
- id.num_outputs = 1;
+ id.num_outputs = 1;
streamer.set_converter(id);
streamer.set_enable_trailer(false);
streamer.set_xport_chan_get_buff(
- 0,
- [xport](double timeout) {
- return xport->get_send_buff(timeout);
- });
+ 0, [xport](double timeout) { return xport->get_send_buff(timeout); });
// Allocate buffer
- std::vector<uint8_t> buffer(spp*bpi);
+ std::vector<uint8_t> buffer(spp * bpi);
std::vector<void*> buffers;
buffers.push_back(buffer.data());
@@ -142,7 +123,7 @@ void benchmark_send_packet_handler(
uhd::tx_metadata_t md;
md.has_time_spec = use_time_spec;
- const auto start_time = std::chrono::steady_clock::now();
+ const auto start_time = std::chrono::steady_clock::now();
const size_t iterations = 1e7;
for (size_t i = 0; i < iterations; i++) {
@@ -153,44 +134,38 @@ void benchmark_send_packet_handler(
}
const auto end_time = std::chrono::steady_clock::now();
- const std::chrono::duration<double> elapsed_time(end_time-start_time);
+ const std::chrono::duration<double> elapsed_time(end_time - start_time);
const double time_per_packet = elapsed_time.count() / iterations;
- std::cout << format << ": "
- << time_per_packet / spp * 1e9
- << " ns/sample, "
- << time_per_packet * 1e9
- << " ns/packet\n";
+ std::cout << format << ": " << time_per_packet / spp * 1e9 << " ns/sample, "
+ << time_per_packet * 1e9 << " ns/packet\n";
}
-void benchmark_device3_rx_flow_ctrl(
- bool send_flow_control_packet
-) {
+void benchmark_device3_rx_flow_ctrl(bool send_flow_control_packet)
+{
// Arbitrary sizes
constexpr uint32_t fc_window = 10000;
- mock_zero_copy::sptr xport(
- new mock_zero_copy(
- vrt::if_packet_info_t::LINK_TYPE_CHDR));
+ mock_zero_copy::sptr xport(new mock_zero_copy(vrt::if_packet_info_t::LINK_TYPE_CHDR));
xport->set_reuse_recv_memory(true);
xport->set_reuse_send_memory(true);
boost::shared_ptr<rx_fc_cache_t> fc_cache(new rx_fc_cache_t());
- fc_cache->to_host = uhd::ntohx<uint32_t>;
+ fc_cache->to_host = uhd::ntohx<uint32_t>;
fc_cache->from_host = uhd::htonx<uint32_t>;
- fc_cache->pack = vrt::chdr::if_hdr_pack_be;
- fc_cache->unpack = vrt::chdr::if_hdr_unpack_be;
- fc_cache->xport = xport;
- fc_cache->interval = fc_window;
+ fc_cache->pack = vrt::chdr::if_hdr_pack_be;
+ fc_cache->unpack = vrt::chdr::if_hdr_unpack_be;
+ fc_cache->xport = xport;
+ fc_cache->interval = fc_window;
// Create data buffer to pass to flow control function. Number of payload
// words is arbitrary, just has to fit in the buffer.
vrt::if_packet_info_t packet_info;
- packet_info.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ packet_info.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
packet_info.num_payload_words32 = 100;
- packet_info.num_payload_bytes = packet_info.num_payload_words32*sizeof(uint32_t);
- packet_info.has_tsf = false;
+ packet_info.num_payload_bytes = packet_info.num_payload_words32 * sizeof(uint32_t);
+ packet_info.has_tsf = false;
std::vector<uint32_t> recv_data(packet_info.num_payload_words32, 0);
xport->push_back_recv_packet(packet_info, recv_data);
@@ -203,46 +178,44 @@ void benchmark_device3_rx_flow_ctrl(
constexpr size_t iterations = 1e7;
for (size_t i = 0; i < iterations; i++) {
- fc_cache->total_bytes_consumed = send_flow_control_packet? fc_window:0;
- fc_cache->last_byte_count = 0;
+ fc_cache->total_bytes_consumed = send_flow_control_packet ? fc_window : 0;
+ fc_cache->last_byte_count = 0;
rx_flow_ctrl(fc_cache, recv_buffer);
}
const auto end_time = std::chrono::steady_clock::now();
- const std::chrono::duration<double> elapsed_time(end_time-start_time);
+ const std::chrono::duration<double> elapsed_time(end_time - start_time);
- std::cout << elapsed_time.count() / iterations * 1e9
- << " ns per call\n";
+ std::cout << elapsed_time.count() / iterations * 1e9 << " ns per call\n";
}
-void benchmark_device3_handle_rx_flow_ctrl_ack() {
+void benchmark_device3_handle_rx_flow_ctrl_ack()
+{
// Arbitrary sizes
constexpr uint32_t fc_window = 10000;
- mock_zero_copy::sptr xport(
- new mock_zero_copy(
- vrt::if_packet_info_t::LINK_TYPE_CHDR));
+ mock_zero_copy::sptr xport(new mock_zero_copy(vrt::if_packet_info_t::LINK_TYPE_CHDR));
xport->set_reuse_recv_memory(true);
xport->set_reuse_send_memory(true);
boost::shared_ptr<rx_fc_cache_t> fc_cache(new rx_fc_cache_t());
- fc_cache->to_host = uhd::ntohx<uint32_t>;
- fc_cache->from_host = uhd::htonx<uint32_t>;
- fc_cache->pack = vrt::chdr::if_hdr_pack_be;
- fc_cache->unpack = vrt::chdr::if_hdr_unpack_be;
- fc_cache->xport = xport;
- fc_cache->interval = fc_window;
+ fc_cache->to_host = uhd::ntohx<uint32_t>;
+ fc_cache->from_host = uhd::htonx<uint32_t>;
+ fc_cache->pack = vrt::chdr::if_hdr_pack_be;
+ fc_cache->unpack = vrt::chdr::if_hdr_unpack_be;
+ fc_cache->xport = xport;
+ fc_cache->interval = fc_window;
fc_cache->total_bytes_consumed = 100;
// Payload should contain packet count and byte count
std::vector<uint32_t> payload_data;
- payload_data.push_back(fc_cache->to_host(10)); // packet count
+ payload_data.push_back(fc_cache->to_host(10)); // packet count
payload_data.push_back(fc_cache->to_host(100)); // byte count
// Run benchmark
- const auto start_time = std::chrono::steady_clock::now();
+ const auto start_time = std::chrono::steady_clock::now();
constexpr size_t iterations = 1e7;
for (size_t i = 0; i < iterations; i++) {
@@ -250,75 +223,66 @@ void benchmark_device3_handle_rx_flow_ctrl_ack() {
}
const auto end_time = std::chrono::steady_clock::now();
- const std::chrono::duration<double> elapsed_time(end_time-start_time);
+ const std::chrono::duration<double> elapsed_time(end_time - start_time);
- std::cout << elapsed_time.count() / iterations * 1e9
- << " ns per call\n";
+ std::cout << elapsed_time.count() / iterations * 1e9 << " ns per call\n";
}
-void benchmark_device3_tx_flow_ctrl(
- bool send_flow_control_packet
-) {
+void benchmark_device3_tx_flow_ctrl(bool send_flow_control_packet)
+{
// Arbitrary sizes
constexpr uint32_t fc_window = 10000;
- mock_zero_copy::sptr xport(
- new mock_zero_copy(
- vrt::if_packet_info_t::LINK_TYPE_CHDR));
+ mock_zero_copy::sptr xport(new mock_zero_copy(vrt::if_packet_info_t::LINK_TYPE_CHDR));
xport->set_reuse_recv_memory(true);
- boost::shared_ptr<tx_fc_cache_t>
- fc_cache(new tx_fc_cache_t(fc_window));
+ boost::shared_ptr<tx_fc_cache_t> fc_cache(new tx_fc_cache_t(fc_window));
- fc_cache->to_host = uhd::ntohx<uint32_t>;
+ fc_cache->to_host = uhd::ntohx<uint32_t>;
fc_cache->from_host = uhd::htonx<uint32_t>;
- fc_cache->pack = vrt::chdr::if_hdr_pack_be;
- fc_cache->unpack = vrt::chdr::if_hdr_unpack_be;
+ fc_cache->pack = vrt::chdr::if_hdr_pack_be;
+ fc_cache->unpack = vrt::chdr::if_hdr_unpack_be;
xport->push_back_flow_ctrl_packet(
- vrt::if_packet_info_t::PACKET_TYPE_FC,
- 1 /*packet*/,
- fc_window /*bytes*/);
+ vrt::if_packet_info_t::PACKET_TYPE_FC, 1 /*packet*/, fc_window /*bytes*/);
// Run benchmark
- const auto start_time = std::chrono::steady_clock::now();
- constexpr size_t iterations = 1e7;
+ const auto start_time = std::chrono::steady_clock::now();
+ constexpr size_t iterations = 1e7;
managed_send_buffer::sptr send_buffer = xport->get_send_buff(0.0);
for (size_t i = 0; i < iterations; i++) {
- fc_cache->byte_count = send_flow_control_packet? fc_window:0;
+ fc_cache->byte_count = send_flow_control_packet ? fc_window : 0;
fc_cache->last_byte_ack = 0;
tx_flow_ctrl(fc_cache, xport, send_buffer);
}
const auto end_time = std::chrono::steady_clock::now();
- const std::chrono::duration<double> elapsed_time(end_time-start_time);
+ const std::chrono::duration<double> elapsed_time(end_time - start_time);
- std::cout << elapsed_time.count() / iterations * 1e9
- << " ns per call\n";
+ std::cout << elapsed_time.count() / iterations * 1e9 << " ns per call\n";
}
-void benchmark_device3_tx_flow_ctrl_ack() {
+void benchmark_device3_tx_flow_ctrl_ack()
+{
// Arbitrary sizes
constexpr uint32_t fc_window = 10000;
- mock_zero_copy::sptr xport(
- new mock_zero_copy(
- vrt::if_packet_info_t::LINK_TYPE_CHDR));
+ mock_zero_copy::sptr xport(new mock_zero_copy(vrt::if_packet_info_t::LINK_TYPE_CHDR));
xport->set_reuse_send_memory(true);
boost::shared_ptr<tx_fc_cache_t> fc_cache(new tx_fc_cache_t(fc_window));
- fc_cache->to_host = uhd::ntohx<uint32_t>;
+ fc_cache->to_host = uhd::ntohx<uint32_t>;
fc_cache->from_host = uhd::htonx<uint32_t>;
- fc_cache->pack = vrt::chdr::if_hdr_pack_be;
- fc_cache->unpack = vrt::chdr::if_hdr_unpack_be;
+ fc_cache->pack = vrt::chdr::if_hdr_pack_be;
+ fc_cache->unpack = vrt::chdr::if_hdr_unpack_be;
// Run benchmark
- const auto start_time = std::chrono::steady_clock::now();
+ const auto start_time = std::chrono::steady_clock::now();
constexpr size_t iterations = 1e7;
uhd::sid_t send_sid;
@@ -330,18 +294,15 @@ void benchmark_device3_tx_flow_ctrl_ack() {
}
const auto end_time = std::chrono::steady_clock::now();
- const std::chrono::duration<double> elapsed_time(end_time-start_time);
+ const std::chrono::duration<double> elapsed_time(end_time - start_time);
- std::cout << elapsed_time.count() / iterations * 1e9
- << " ns per call\n";
+ std::cout << elapsed_time.count() / iterations * 1e9 << " ns per call\n";
}
-int UHD_SAFE_MAIN(int argc, char *argv[])
+int UHD_SAFE_MAIN(int argc, char* argv[])
{
po::options_description desc("Allowed options");
- desc.add_options()
- ("help", "help message")
- ;
+ desc.add_options()("help", "help message");
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
@@ -350,17 +311,17 @@ int UHD_SAFE_MAIN(int argc, char *argv[])
// Print the help message
if (vm.count("help")) {
std::cout << boost::format("UHD Packet Handler Benchmark %s") % desc << std::endl;
- std::cout <<
- " Benchmark of send and receive packet handlers and flow control\n"
- " functions. All benchmarks use mock transport objects. No\n"
- " parameters are needed to run this benchmark.\n"
- << std::endl;
+ std::cout
+ << " Benchmark of send and receive packet handlers and flow control\n"
+ " functions. All benchmarks use mock transport objects. No\n"
+ " parameters are needed to run this benchmark.\n"
+ << std::endl;
return EXIT_FAILURE;
}
uhd::set_thread_priority_safe();
- const char* formats[] = {"sc16", "fc32", "fc64" };
+ const char* formats[] = {"sc16", "fc32", "fc64"};
constexpr size_t rx_spp = 2000;
constexpr size_t tx_spp = 1000;
diff --git a/host/tests/paths_test.cpp b/host/tests/paths_test.cpp
index 0ccebd333..ef10414c7 100644
--- a/host/tests/paths_test.cpp
+++ b/host/tests/paths_test.cpp
@@ -8,12 +8,13 @@
#include <uhd/exception.hpp>
#include <uhd/utils/paths.hpp>
#include <uhdlib/utils/paths.hpp>
-#include <boost/test/unit_test.hpp>
#include <boost/filesystem/operations.hpp>
-#include <vector>
+#include <boost/test/unit_test.hpp>
#include <iostream>
+#include <vector>
-BOOST_AUTO_TEST_CASE(test_paths_expandvars) {
+BOOST_AUTO_TEST_CASE(test_paths_expandvars)
+{
#ifdef UHD_PLATFORM_WIN32
const std::string path_to_expand("\%programdata%/uhd/uhd.conf");
#else
@@ -21,8 +22,8 @@ BOOST_AUTO_TEST_CASE(test_paths_expandvars) {
#endif
const std::string expanded_path = uhd::path_expandvars(path_to_expand);
- std::cout << "Expanded path: " << path_to_expand << " -> "
- << expanded_path << std::endl;
+ std::cout << "Expanded path: " << path_to_expand << " -> " << expanded_path
+ << std::endl;
BOOST_CHECK(path_to_expand != expanded_path);
#ifdef UHD_PLATFORM_WIN32
@@ -35,13 +36,14 @@ BOOST_AUTO_TEST_CASE(test_paths_expandvars) {
}
-BOOST_AUTO_TEST_CASE(test_get_paths) {
+BOOST_AUTO_TEST_CASE(test_get_paths)
+{
using namespace uhd;
const std::string tmp_path = get_tmp_path();
const std::string app_path = get_app_path();
const std::string pkg_path = get_pkg_path();
- const auto module_paths = get_module_paths();
+ const auto module_paths = get_module_paths();
std::cout << "tmp_path: " << tmp_path << std::endl;
std::cout << "app_path: " << app_path << std::endl;
@@ -51,22 +53,14 @@ BOOST_AUTO_TEST_CASE(test_get_paths) {
}
const std::string images_dir_search_path = "";
- const std::string images_dir = get_images_dir(images_dir_search_path);
+ const std::string images_dir = get_images_dir(images_dir_search_path);
BOOST_REQUIRE_THROW(
- find_image_path("this_device_does_not_exist.bit", ""),
- uhd::io_error
- );
+ find_image_path("this_device_does_not_exist.bit", ""), uhd::io_error);
- const std::string utility_path = find_utility(
- "uhd_images_downloader"
- );
+ const std::string utility_path = find_utility("uhd_images_downloader");
std::cout << "utility_path: " << utility_path << std::endl;
- const std::string utility_error = print_utility_error(
- "uhd_images_downloader",
- "--help"
- );
+ const std::string utility_error =
+ print_utility_error("uhd_images_downloader", "--help");
std::cout << "utility_error: " << tmp_path << std::endl;
-
}
-
diff --git a/host/tests/property_test.cpp b/host/tests/property_test.cpp
index 3daeed510..b2086f288 100644
--- a/host/tests/property_test.cpp
+++ b/host/tests/property_test.cpp
@@ -5,22 +5,26 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/property_tree.hpp>
#include <boost/bind.hpp>
+#include <boost/test/unit_test.hpp>
#include <exception>
#include <iostream>
-struct coercer_type{
- int doit(int x){
+struct coercer_type
+{
+ int doit(int x)
+ {
return x & ~0x3;
}
};
-struct setter_type{
+struct setter_type
+{
setter_type() : _count(0), _x(0) {}
- void doit(int x){
+ void doit(int x)
+ {
_count++;
_x = x;
}
@@ -29,10 +33,12 @@ struct setter_type{
int _x;
};
-struct getter_type{
+struct getter_type
+{
getter_type() : _count(0), _x(0) {}
- int doit(void){
+ int doit(void)
+ {
_count++;
return _x;
}
@@ -41,9 +47,10 @@ struct getter_type{
int _x;
};
-BOOST_AUTO_TEST_CASE(test_prop_simple){
+BOOST_AUTO_TEST_CASE(test_prop_simple)
+{
uhd::property_tree::sptr tree = uhd::property_tree::make();
- uhd::property<int> &prop = tree->create<int>("/");
+ uhd::property<int>& prop = tree->create<int>("/");
BOOST_CHECK(prop.empty());
prop.set(0);
@@ -55,9 +62,10 @@ BOOST_AUTO_TEST_CASE(test_prop_simple){
BOOST_CHECK_EQUAL(prop.get(), 34);
}
-BOOST_AUTO_TEST_CASE(test_prop_with_desired_subscriber){
+BOOST_AUTO_TEST_CASE(test_prop_with_desired_subscriber)
+{
uhd::property_tree::sptr tree = uhd::property_tree::make();
- uhd::property<int> &prop = tree->create<int>("/");
+ uhd::property<int>& prop = tree->create<int>("/");
setter_type setter;
prop.add_desired_subscriber(boost::bind(&setter_type::doit, &setter, _1));
@@ -73,9 +81,10 @@ BOOST_AUTO_TEST_CASE(test_prop_with_desired_subscriber){
BOOST_CHECK_EQUAL(setter._x, 34);
}
-BOOST_AUTO_TEST_CASE(test_prop_with_coerced_subscriber){
+BOOST_AUTO_TEST_CASE(test_prop_with_coerced_subscriber)
+{
uhd::property_tree::sptr tree = uhd::property_tree::make();
- uhd::property<int> &prop = tree->create<int>("/");
+ uhd::property<int>& prop = tree->create<int>("/");
setter_type setter;
prop.add_coerced_subscriber(boost::bind(&setter_type::doit, &setter, _1));
@@ -91,9 +100,10 @@ BOOST_AUTO_TEST_CASE(test_prop_with_coerced_subscriber){
BOOST_CHECK_EQUAL(setter._x, 34);
}
-BOOST_AUTO_TEST_CASE(test_prop_manual_coercion){
+BOOST_AUTO_TEST_CASE(test_prop_manual_coercion)
+{
uhd::property_tree::sptr tree = uhd::property_tree::make();
- uhd::property<int> &prop = tree->create<int>("/", uhd::property_tree::MANUAL_COERCE);
+ uhd::property<int>& prop = tree->create<int>("/", uhd::property_tree::MANUAL_COERCE);
setter_type dsetter, csetter;
prop.add_desired_subscriber(boost::bind(&setter_type::doit, &dsetter, _1));
@@ -114,9 +124,10 @@ BOOST_AUTO_TEST_CASE(test_prop_manual_coercion){
BOOST_CHECK_EQUAL(csetter._x, 34);
}
-BOOST_AUTO_TEST_CASE(test_prop_with_publisher){
+BOOST_AUTO_TEST_CASE(test_prop_with_publisher)
+{
uhd::property_tree::sptr tree = uhd::property_tree::make();
- uhd::property<int> &prop = tree->create<int>("/");
+ uhd::property<int>& prop = tree->create<int>("/");
BOOST_CHECK(prop.empty());
getter_type getter;
@@ -124,17 +135,18 @@ BOOST_AUTO_TEST_CASE(test_prop_with_publisher){
BOOST_CHECK(not prop.empty());
getter._x = 42;
- prop.set(0); //should not change
+ prop.set(0); // should not change
BOOST_CHECK_EQUAL(prop.get(), 42);
getter._x = 34;
- prop.set(0); //should not change
+ prop.set(0); // should not change
BOOST_CHECK_EQUAL(prop.get(), 34);
}
-BOOST_AUTO_TEST_CASE(test_prop_with_publisher_and_subscriber){
+BOOST_AUTO_TEST_CASE(test_prop_with_publisher_and_subscriber)
+{
uhd::property_tree::sptr tree = uhd::property_tree::make();
- uhd::property<int> &prop = tree->create<int>("/");
+ uhd::property<int>& prop = tree->create<int>("/");
getter_type getter;
prop.set_publisher(boost::bind(&getter_type::doit, &getter));
@@ -153,9 +165,10 @@ BOOST_AUTO_TEST_CASE(test_prop_with_publisher_and_subscriber){
BOOST_CHECK_EQUAL(setter._x, 1);
}
-BOOST_AUTO_TEST_CASE(test_prop_with_coercion){
+BOOST_AUTO_TEST_CASE(test_prop_with_coercion)
+{
uhd::property_tree::sptr tree = uhd::property_tree::make();
- uhd::property<int> &prop = tree->create<int>("/");
+ uhd::property<int>& prop = tree->create<int>("/");
setter_type setter;
prop.add_coerced_subscriber(boost::bind(&setter_type::doit, &setter, _1));
@@ -172,7 +185,8 @@ BOOST_AUTO_TEST_CASE(test_prop_with_coercion){
BOOST_CHECK_EQUAL(setter._x, 32);
}
-BOOST_AUTO_TEST_CASE(test_prop_tree){
+BOOST_AUTO_TEST_CASE(test_prop_tree)
+{
uhd::property_tree::sptr tree = uhd::property_tree::make();
tree->create<int>("/test/prop0");
@@ -196,42 +210,43 @@ BOOST_AUTO_TEST_CASE(test_prop_tree){
tree->remove("/test");
BOOST_CHECK(not tree->exists("/test/prop0"));
BOOST_CHECK(not tree->exists("/test/prop1"));
-
}
-BOOST_AUTO_TEST_CASE(test_prop_subtree){
+BOOST_AUTO_TEST_CASE(test_prop_subtree)
+{
uhd::property_tree::sptr tree = uhd::property_tree::make();
tree->create<int>("/subdir1/subdir2");
- uhd::property_tree::sptr subtree1 = tree->subtree("/");
- const std::vector<std::string> tree_dirs1 = tree->list("/");
+ uhd::property_tree::sptr subtree1 = tree->subtree("/");
+ const std::vector<std::string> tree_dirs1 = tree->list("/");
const std::vector<std::string> subtree1_dirs = subtree1->list("");
- BOOST_CHECK_EQUAL_COLLECTIONS(tree_dirs1.begin(), tree_dirs1.end(), subtree1_dirs.begin(), subtree1_dirs.end());
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ tree_dirs1.begin(), tree_dirs1.end(), subtree1_dirs.begin(), subtree1_dirs.end());
- uhd::property_tree::sptr subtree2 = subtree1->subtree("subdir1");
- const std::vector<std::string> tree_dirs2 = tree->list("/subdir1");
+ uhd::property_tree::sptr subtree2 = subtree1->subtree("subdir1");
+ const std::vector<std::string> tree_dirs2 = tree->list("/subdir1");
const std::vector<std::string> subtree2_dirs = subtree2->list("");
- BOOST_CHECK_EQUAL_COLLECTIONS(tree_dirs2.begin(), tree_dirs2.end(), subtree2_dirs.begin(), subtree2_dirs.end());
-
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ tree_dirs2.begin(), tree_dirs2.end(), subtree2_dirs.begin(), subtree2_dirs.end());
}
BOOST_AUTO_TEST_CASE(test_prop_operators)
{
uhd::fs_path path1 = "/root/";
- path1 = path1 / "leaf";
+ path1 = path1 / "leaf";
BOOST_CHECK_EQUAL(path1, "/root/leaf");
uhd::fs_path path2 = "/root";
- path2 = path2 / "leaf";
+ path2 = path2 / "leaf";
BOOST_CHECK_EQUAL(path2, "/root/leaf");
uhd::fs_path path3 = "/root/";
- path3 = path3 / "/leaf/";
+ path3 = path3 / "/leaf/";
BOOST_CHECK_EQUAL(path3, "/root/leaf/");
uhd::fs_path path4 = "/root/";
- size_t x = 2;
- path4 = path4 / x;
+ size_t x = 2;
+ path4 = path4 / x;
BOOST_CHECK_EQUAL(path4, "/root/2");
}
diff --git a/host/tests/ranges_test.cpp b/host/tests/ranges_test.cpp
index fd6336a55..223560289 100644
--- a/host/tests/ranges_test.cpp
+++ b/host/tests/ranges_test.cpp
@@ -5,8 +5,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/types/ranges.hpp>
+#include <boost/test/unit_test.hpp>
#include <iostream>
using namespace uhd;
@@ -14,7 +14,8 @@ using namespace uhd;
static const double tolerance = 0.001; // %
-BOOST_AUTO_TEST_CASE(test_ranges_bounds){
+BOOST_AUTO_TEST_CASE(test_ranges_bounds)
+{
meta_range_t mr;
mr.push_back(range_t(-1.0, +1.0, 0.1));
BOOST_CHECK_CLOSE(mr.start(), -1.0, tolerance);
@@ -33,7 +34,8 @@ BOOST_AUTO_TEST_CASE(test_ranges_bounds){
BOOST_CHECK_CLOSE(mr[0].step(), 0.1, tolerance);
}
-BOOST_AUTO_TEST_CASE(test_ranges_clip){
+BOOST_AUTO_TEST_CASE(test_ranges_clip)
+{
meta_range_t mr;
mr.push_back(range_t(-1.0, +1.0, 0.1));
mr.push_back(range_t(40.0, 60.0, 1.0));
@@ -47,7 +49,8 @@ BOOST_AUTO_TEST_CASE(test_ranges_clip){
BOOST_CHECK_CLOSE(mr.clip(50.9, true), 51.0, tolerance);
}
-BOOST_AUTO_TEST_CASE(test_meta_range_t_ctor){
+BOOST_AUTO_TEST_CASE(test_meta_range_t_ctor)
+{
meta_range_t mr1(0.0, 10.0, 1.0);
BOOST_CHECK_CLOSE(mr1.clip(5.0), 5.0, tolerance);
BOOST_CHECK_CLOSE(mr1.clip(11.0), 10.0, tolerance);
@@ -64,7 +67,8 @@ BOOST_AUTO_TEST_CASE(test_meta_range_t_ctor){
BOOST_CHECK_CLOSE(mr3.clip(5.1, true), 5.1, tolerance);
}
-BOOST_AUTO_TEST_CASE(test_ranges_clip2){
+BOOST_AUTO_TEST_CASE(test_ranges_clip2)
+{
meta_range_t mr;
mr.push_back(range_t(1.));
mr.push_back(range_t(2.));
@@ -77,7 +81,8 @@ BOOST_AUTO_TEST_CASE(test_ranges_clip2){
BOOST_CHECK_CLOSE(mr.clip(4., true), 3., tolerance);
}
-BOOST_AUTO_TEST_CASE(test_ranges_compare){
+BOOST_AUTO_TEST_CASE(test_ranges_compare)
+{
range_t range(1);
range_t n_range(1);
range_t d_range(2);
diff --git a/host/tests/rate_node_test.cpp b/host/tests/rate_node_test.cpp
index f7e1bf30b..85502c325 100644
--- a/host/tests/rate_node_test.cpp
+++ b/host/tests/rate_node_test.cpp
@@ -18,7 +18,7 @@ class rate_aware_node : public test_node, public rate_node_ctrl
public:
typedef boost::shared_ptr<rate_aware_node> sptr;
- rate_aware_node(const std::string &test_id) : test_node(test_id) {};
+ rate_aware_node(const std::string& test_id) : test_node(test_id){};
}; /* class rate_aware_node */
@@ -28,10 +28,17 @@ class rate_setting_node : public test_node, public rate_node_ctrl
public:
typedef boost::shared_ptr<rate_setting_node> sptr;
- rate_setting_node(const std::string &test_id, double samp_rate) : test_node(test_id), _samp_rate(samp_rate) {};
+ rate_setting_node(const std::string& test_id, double samp_rate)
+ : test_node(test_id), _samp_rate(samp_rate){};
- double get_input_samp_rate(size_t) { return _samp_rate; };
- double get_output_samp_rate(size_t) { return _samp_rate; };
+ double get_input_samp_rate(size_t)
+ {
+ return _samp_rate;
+ };
+ double get_output_samp_rate(size_t)
+ {
+ return _samp_rate;
+ };
private:
double _samp_rate;
@@ -39,7 +46,8 @@ private:
}; /* class rate_setting_node */
#define MAKE_RATE_NODE(name) rate_aware_node::sptr name(new rate_aware_node(#name));
-#define MAKE_RATE_SETTING_NODE(name, rate) rate_setting_node::sptr name(new rate_setting_node(#name, rate));
+#define MAKE_RATE_SETTING_NODE(name, rate) \
+ rate_setting_node::sptr name(new rate_setting_node(#name, rate));
BOOST_AUTO_TEST_CASE(test_simplest_downstream_search)
{
@@ -126,4 +134,3 @@ BOOST_AUTO_TEST_CASE(test_skip_upstream_search)
double result_rate = node_C->get_output_samp_rate();
BOOST_CHECK_EQUAL(result_rate, test_rate);
}
-
diff --git a/host/tests/sensors_test.cpp b/host/tests/sensors_test.cpp
index 2136ca13b..925f1a711 100644
--- a/host/tests/sensors_test.cpp
+++ b/host/tests/sensors_test.cpp
@@ -4,20 +4,16 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/types/sensors.hpp>
+#include <boost/test/unit_test.hpp>
#include <map>
#include <string>
using uhd::sensor_value_t;
-BOOST_AUTO_TEST_CASE(test_sensor_bool) {
- auto sensor_bool = sensor_value_t(
- "bool_sensor",
- true,
- "true_unit",
- "false_unit"
- );
+BOOST_AUTO_TEST_CASE(test_sensor_bool)
+{
+ auto sensor_bool = sensor_value_t("bool_sensor", true, "true_unit", "false_unit");
BOOST_CHECK(sensor_bool.to_bool());
BOOST_CHECK_EQUAL(sensor_bool.unit, "true_unit");
@@ -34,11 +30,12 @@ BOOST_AUTO_TEST_CASE(test_sensor_bool) {
}
-BOOST_AUTO_TEST_CASE(test_sensor_real) {
- const double sens_val = 2.25;
+BOOST_AUTO_TEST_CASE(test_sensor_real)
+{
+ const double sens_val = 2.25;
const std::string sens_units = "floats";
- const std::string sens_name = "real_sensor";
- auto sensor_real = sensor_value_t(sens_name, sens_val, sens_units);
+ const std::string sens_name = "real_sensor";
+ auto sensor_real = sensor_value_t(sens_name, sens_val, sens_units);
BOOST_CHECK_EQUAL(sensor_real.to_real(), sens_val);
BOOST_CHECK_EQUAL(sensor_real.unit, sens_units);
@@ -54,11 +51,12 @@ BOOST_AUTO_TEST_CASE(test_sensor_real) {
BOOST_CHECK_EQUAL(sensor_real2.unit, sens_units);
}
-BOOST_AUTO_TEST_CASE(test_sensor_int) {
- const int sens_val = 5;
+BOOST_AUTO_TEST_CASE(test_sensor_int)
+{
+ const int sens_val = 5;
const std::string sens_units = "ints";
- const std::string sens_name = "int_sensor";
- auto sensor_int = sensor_value_t(sens_name, sens_val, sens_units);
+ const std::string sens_name = "int_sensor";
+ auto sensor_int = sensor_value_t(sens_name, sens_val, sens_units);
BOOST_CHECK_EQUAL(sensor_int.to_int(), sens_val);
BOOST_CHECK_EQUAL(sensor_int.unit, sens_units);
@@ -74,11 +72,12 @@ BOOST_AUTO_TEST_CASE(test_sensor_int) {
BOOST_CHECK_EQUAL(sensor_int2.unit, sens_units);
}
-BOOST_AUTO_TEST_CASE(test_sensor_string) {
- const std::string sens_val = "foo";
+BOOST_AUTO_TEST_CASE(test_sensor_string)
+{
+ const std::string sens_val = "foo";
const std::string sens_units = "strings";
- const std::string sens_name = "str_sensor";
- auto sensor_str = sensor_value_t(sens_name, sens_val, sens_units);
+ const std::string sens_name = "str_sensor";
+ auto sensor_str = sensor_value_t(sens_name, sens_val, sens_units);
BOOST_CHECK_EQUAL(sensor_str.value, sens_val);
BOOST_CHECK_EQUAL(sensor_str.unit, sens_units);
@@ -97,6 +96,4 @@ BOOST_AUTO_TEST_CASE(test_sensor_string) {
BOOST_CHECK_EQUAL(sensor_str2.value, sensor_str3.value);
BOOST_CHECK_EQUAL(sensor_str2.unit, sensor_str3.unit);
BOOST_CHECK_EQUAL(sensor_str2.type, sensor_str3.type);
-
}
-
diff --git a/host/tests/sid_t_test.cpp b/host/tests/sid_t_test.cpp
index 1e643e059..85d33c45e 100644
--- a/host/tests/sid_t_test.cpp
+++ b/host/tests/sid_t_test.cpp
@@ -5,15 +5,16 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
+#include <uhd/exception.hpp>
+#include <uhd/types/sid.hpp>
+#include <boost/test/unit_test.hpp>
#include <iostream>
#include <sstream>
-#include <boost/test/unit_test.hpp>
-#include <uhd/types/sid.hpp>
-#include <uhd/exception.hpp>
using uhd::sid_t;
-BOOST_AUTO_TEST_CASE(test_sid_t) {
+BOOST_AUTO_TEST_CASE(test_sid_t)
+{
uint32_t sid_value = 0x01020310;
sid_t sid(sid_value);
@@ -29,7 +30,7 @@ BOOST_AUTO_TEST_CASE(test_sid_t) {
BOOST_CHECK_EQUAL(sid == sid, true);
BOOST_CHECK_EQUAL(sid == sid_value, true);
- uint32_t check_sid_val = (uint32_t) sid;
+ uint32_t check_sid_val = (uint32_t)sid;
BOOST_CHECK_EQUAL(check_sid_val, sid_value);
std::stringstream ss_dec;
@@ -46,20 +47,21 @@ BOOST_AUTO_TEST_CASE(test_sid_t) {
BOOST_CHECK_EQUAL(empty_sid.to_pp_string_hex(), "xx:xx>xx:xx");
BOOST_CHECK_EQUAL(empty_sid == sid, false);
BOOST_CHECK_EQUAL(empty_sid == sid_value, false);
- BOOST_CHECK_EQUAL((bool) empty_sid, false);
+ BOOST_CHECK_EQUAL((bool)empty_sid, false);
empty_sid = sid_value; // No longer empty
BOOST_CHECK_EQUAL(empty_sid.is_set(), true);
BOOST_CHECK_EQUAL(empty_sid == sid, true);
}
-BOOST_AUTO_TEST_CASE(test_sid_t_set) {
+BOOST_AUTO_TEST_CASE(test_sid_t_set)
+{
uint32_t sid_value = 0x0;
sid_t sid(sid_value);
sid.set(0x01020304);
BOOST_CHECK_EQUAL(sid.get(), (uint32_t)0x01020304);
- BOOST_CHECK_EQUAL(sid.get_src_addr(),(uint32_t)0x01);
+ BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)0x01);
BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)0x02);
BOOST_CHECK_EQUAL(sid.get_dst_addr(), (uint32_t)0x03);
BOOST_CHECK_EQUAL(sid.get_dst_endpoint(), (uint32_t)0x04);
@@ -117,7 +119,8 @@ BOOST_AUTO_TEST_CASE(test_sid_t_set) {
BOOST_CHECK_EQUAL(sid.get(), (uint32_t)0x0cbc0a0b);
}
-BOOST_AUTO_TEST_CASE(test_sid_t_from_str) {
+BOOST_AUTO_TEST_CASE(test_sid_t_from_str)
+{
sid_t sid("1.2>3.4");
BOOST_CHECK_EQUAL(sid.get_src_addr(), (uint32_t)1);
BOOST_CHECK_EQUAL(sid.get_src_endpoint(), (uint32_t)2);
diff --git a/host/tests/soft_reg_test.cpp b/host/tests/soft_reg_test.cpp
index 8e53c61ca..2c1766cfe 100644
--- a/host/tests/soft_reg_test.cpp
+++ b/host/tests/soft_reg_test.cpp
@@ -9,21 +9,22 @@
using namespace uhd;
-BOOST_AUTO_TEST_CASE(test_soft_reg_field) {
+BOOST_AUTO_TEST_CASE(test_soft_reg_field)
+{
UHD_DEFINE_SOFT_REG_FIELD(test_reg1, /* width */ 1, /* shift */ 0);
BOOST_CHECK_EQUAL(soft_reg_field::width(test_reg1), 1);
BOOST_CHECK_EQUAL(soft_reg_field::shift(test_reg1), 0);
- BOOST_CHECK_EQUAL(soft_reg_field::mask<uint32_t>(test_reg1), 1<<0);
+ BOOST_CHECK_EQUAL(soft_reg_field::mask<uint32_t>(test_reg1), 1 << 0);
UHD_DEFINE_SOFT_REG_FIELD(test_reg2, /* width */ 5, /* shift */ 4);
BOOST_CHECK_EQUAL(soft_reg_field::width(test_reg2), 5);
BOOST_CHECK_EQUAL(soft_reg_field::shift(test_reg2), 4);
- BOOST_CHECK_EQUAL(soft_reg_field::mask<uint32_t>(test_reg2), 0x1F<<4);
+ BOOST_CHECK_EQUAL(soft_reg_field::mask<uint32_t>(test_reg2), 0x1F << 4);
UHD_DEFINE_SOFT_REG_FIELD(test_reg3, /* width */ 9, /* shift */ 0);
BOOST_CHECK_EQUAL(soft_reg_field::width(test_reg3), 9);
BOOST_CHECK_EQUAL(soft_reg_field::shift(test_reg3), 0);
- BOOST_CHECK_EQUAL(soft_reg_field::mask<uint8_t>(test_reg3), 0xFF);
+ BOOST_CHECK_EQUAL(soft_reg_field::mask<uint8_t>(test_reg3), 0xFF);
// This one is platform dependent:
UHD_DEFINE_SOFT_REG_FIELD(test_reg4, /* width */ 33, /* shift */ 0);
diff --git a/host/tests/sph_recv_test.cpp b/host/tests/sph_recv_test.cpp
index 705fd4f83..3c185d21a 100644
--- a/host/tests/sph_recv_test.cpp
+++ b/host/tests/sph_recv_test.cpp
@@ -5,14 +5,14 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
-#include "../lib/transport/super_recv_packet_handler.hpp"
#include "../common/mock_zero_copy.hpp"
-#include <boost/shared_array.hpp>
+#include "../lib/transport/super_recv_packet_handler.hpp"
#include <boost/bind.hpp>
+#include <boost/shared_array.hpp>
+#include <boost/test/unit_test.hpp>
#include <complex>
-#include <vector>
#include <list>
+#include <vector>
using namespace uhd::transport;
@@ -22,797 +22,775 @@ using namespace uhd::transport;
/***********************************************************************
* A dummy overflow handler for testing
**********************************************************************/
-struct overflow_handler_type{
- overflow_handler_type(void){
+struct overflow_handler_type
+{
+ overflow_handler_type(void)
+ {
num_overflow = 0;
}
- void handle(void){
+ void handle(void)
+ {
num_overflow++;
}
size_t num_overflow;
};
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_normal){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_normal)
+{
+ ////////////////////////////////////////////////////////////////////////
uhd::convert::id_type id;
- id.input_format = "sc16_item32_be";
- id.num_inputs = 1;
+ id.input_format = "sc16_item32_be";
+ id.num_inputs = 1;
id.output_format = "fc32";
- id.num_outputs = 1;
+ id.num_outputs = 1;
mock_zero_copy xport(vrt::if_packet_info_t::LINK_TYPE_VRLP);
vrt::if_packet_info_t ifpi;
- ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
ifpi.num_payload_words32 = 0;
- ifpi.packet_count = 0;
- ifpi.sob = true;
- ifpi.eob = false;
- ifpi.has_sid = false;
- ifpi.has_cid = false;
- ifpi.has_tsi = true;
- ifpi.has_tsf = true;
- ifpi.tsi = 0;
- ifpi.tsf = 0;
- ifpi.has_tlr = false;
-
- static const double TICK_RATE = 100e6;
- static const double SAMP_RATE = 10e6;
+ ifpi.packet_count = 0;
+ ifpi.sob = true;
+ ifpi.eob = false;
+ ifpi.has_sid = false;
+ ifpi.has_cid = false;
+ ifpi.has_tsi = true;
+ ifpi.has_tsf = true;
+ ifpi.tsi = 0;
+ ifpi.tsf = 0;
+ ifpi.has_tlr = false;
+
+ static const double TICK_RATE = 100e6;
+ static const double SAMP_RATE = 10e6;
static const size_t NUM_PKTS_TO_TEST = 30;
- //generate a bunch of packets
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
- ifpi.num_payload_words32 = 10 + i%10;
+ // generate a bunch of packets
+ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++) {
+ ifpi.num_payload_words32 = 10 + i % 10;
std::vector<uint32_t> data(ifpi.num_payload_words32, 0);
xport.push_back_recv_packet(ifpi, data);
ifpi.packet_count++;
- ifpi.tsf += ifpi.num_payload_words32*size_t(TICK_RATE/SAMP_RATE);
+ ifpi.tsf += ifpi.num_payload_words32 * size_t(TICK_RATE / SAMP_RATE);
}
- //create the super receive packet handler
+ // create the super receive packet handler
uhd::transport::sph::recv_packet_handler handler(1);
handler.set_vrt_unpacker(&uhd::transport::vrt::if_hdr_unpack_be);
handler.set_tick_rate(TICK_RATE);
handler.set_samp_rate(SAMP_RATE);
handler.set_xport_chan_get_buff(
- 0,
- [&xport](double timeout) {
- return xport.get_recv_buff(timeout);
- });
+ 0, [&xport](double timeout) { return xport.get_recv_buff(timeout); });
handler.set_converter(id);
- //check the received packets
+ // check the received packets
size_t num_accum_samps = 0;
- std::vector<std::complex<float> > buff(20);
+ std::vector<std::complex<float>> buff(20);
uhd::rx_metadata_t metadata;
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
+ 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, 1.0, true
- );
+ size_t num_samps_ret =
+ handler.recv(&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);
BOOST_CHECK(metadata.has_time_spec);
- BOOST_CHECK_TS_CLOSE(metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
- BOOST_CHECK_EQUAL(num_samps_ret, 10 + i%10);
+ BOOST_CHECK_TS_CLOSE(
+ metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
+ BOOST_CHECK_EQUAL(num_samps_ret, 10 + i % 10);
num_accum_samps += num_samps_ret;
}
- //subsequent receives should be a timeout
- for (size_t i = 0; i < 3; i++){
+ // subsequent receives should be a timeout
+ for (size_t i = 0; i < 3; i++) {
std::cout << "timeout check " << i << std::endl;
- handler.recv(
- &buff.front(), buff.size(), metadata, 1.0, true
- );
+ handler.recv(&buff.front(), buff.size(), metadata, 1.0, true);
BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT);
}
- //simulate the transport failing
+ // simulate the transport failing
xport.set_simulate_io_error(true);
- BOOST_REQUIRE_THROW(handler.recv(&buff.front(), buff.size(), metadata, 1.0, true), uhd::io_error);
+ BOOST_REQUIRE_THROW(
+ handler.recv(&buff.front(), buff.size(), metadata, 1.0, true), uhd::io_error);
}
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_sequence_error){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_sequence_error)
+{
+ ////////////////////////////////////////////////////////////////////////
uhd::convert::id_type id;
- id.input_format = "sc16_item32_be";
- id.num_inputs = 1;
+ id.input_format = "sc16_item32_be";
+ id.num_inputs = 1;
id.output_format = "fc32";
- id.num_outputs = 1;
+ id.num_outputs = 1;
mock_zero_copy xport(vrt::if_packet_info_t::LINK_TYPE_VRLP);
vrt::if_packet_info_t ifpi;
- ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
ifpi.num_payload_words32 = 0;
- ifpi.packet_count = 0;
- ifpi.sob = true;
- ifpi.eob = false;
- ifpi.has_sid = false;
- ifpi.has_cid = false;
- ifpi.has_tsi = true;
- ifpi.has_tsf = true;
- ifpi.tsi = 0;
- ifpi.tsf = 0;
- ifpi.has_tlr = false;
-
- static const double TICK_RATE = 100e6;
- static const double SAMP_RATE = 10e6;
+ ifpi.packet_count = 0;
+ ifpi.sob = true;
+ ifpi.eob = false;
+ ifpi.has_sid = false;
+ ifpi.has_cid = false;
+ ifpi.has_tsi = true;
+ ifpi.has_tsf = true;
+ ifpi.tsi = 0;
+ ifpi.tsf = 0;
+ ifpi.has_tlr = false;
+
+ static const double TICK_RATE = 100e6;
+ static const double SAMP_RATE = 10e6;
static const size_t NUM_PKTS_TO_TEST = 30;
- //generate a bunch of packets
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
- ifpi.num_payload_words32 = 10 + i%10;
- if (i != NUM_PKTS_TO_TEST/2){ //simulate a lost packet
+ // generate a bunch of packets
+ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++) {
+ ifpi.num_payload_words32 = 10 + i % 10;
+ if (i != NUM_PKTS_TO_TEST / 2) { // simulate a lost packet
std::vector<uint32_t> data(ifpi.num_payload_words32, 0);
xport.push_back_recv_packet(ifpi, data);
}
ifpi.packet_count++;
- ifpi.tsf += ifpi.num_payload_words32*size_t(TICK_RATE/SAMP_RATE);
+ ifpi.tsf += ifpi.num_payload_words32 * size_t(TICK_RATE / SAMP_RATE);
}
- //create the super receive packet handler
+ // create the super receive packet handler
sph::recv_packet_handler handler(1);
handler.set_vrt_unpacker(&vrt::if_hdr_unpack_be);
handler.set_tick_rate(TICK_RATE);
handler.set_samp_rate(SAMP_RATE);
handler.set_xport_chan_get_buff(
- 0,
- [&xport](double timeout) {
- return xport.get_recv_buff(timeout);
- }
- );
+ 0, [&xport](double timeout) { return xport.get_recv_buff(timeout); });
handler.set_converter(id);
- //check the received packets
+ // check the received packets
size_t num_accum_samps = 0;
- std::vector<std::complex<float> > buff(20);
+ std::vector<std::complex<float>> buff(20);
uhd::rx_metadata_t metadata;
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
+ 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, 1.0, true
- );
- if (i == NUM_PKTS_TO_TEST/2){
- //must get the soft overflow here
+ size_t num_samps_ret =
+ handler.recv(&buff.front(), buff.size(), metadata, 1.0, true);
+ if (i == NUM_PKTS_TO_TEST / 2) {
+ // must get the soft overflow here
BOOST_REQUIRE(metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_OVERFLOW);
BOOST_REQUIRE(metadata.out_of_sequence == true);
- BOOST_CHECK_TS_CLOSE(metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
- num_accum_samps += 10 + i%10;
- }
- else{
+ BOOST_CHECK_TS_CLOSE(metadata.time_spec,
+ uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
+ num_accum_samps += 10 + i % 10;
+ } else {
BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_NONE);
BOOST_CHECK(not metadata.more_fragments);
BOOST_CHECK(metadata.has_time_spec);
- BOOST_CHECK_TS_CLOSE(metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
- BOOST_CHECK_EQUAL(num_samps_ret, 10 + i%10);
+ BOOST_CHECK_TS_CLOSE(metadata.time_spec,
+ uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
+ BOOST_CHECK_EQUAL(num_samps_ret, 10 + i % 10);
num_accum_samps += num_samps_ret;
}
}
- //subsequent receives should be a timeout
- for (size_t i = 0; i < 3; i++){
+ // subsequent receives should be a timeout
+ for (size_t i = 0; i < 3; i++) {
std::cout << "timeout check " << i << std::endl;
- handler.recv(
- &buff.front(), buff.size(), metadata, 1.0, true
- );
+ handler.recv(&buff.front(), buff.size(), metadata, 1.0, true);
BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT);
}
- //simulate the transport failing
+ // simulate the transport failing
xport.set_simulate_io_error(true);
- BOOST_REQUIRE_THROW(handler.recv(&buff.front(), buff.size(), metadata, 1.0, true), uhd::io_error);
+ BOOST_REQUIRE_THROW(
+ handler.recv(&buff.front(), buff.size(), metadata, 1.0, true), uhd::io_error);
}
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_inline_message){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_sph_recv_one_channel_inline_message)
+{
+ ////////////////////////////////////////////////////////////////////////
uhd::convert::id_type id;
- id.input_format = "sc16_item32_be";
- id.num_inputs = 1;
+ id.input_format = "sc16_item32_be";
+ id.num_inputs = 1;
id.output_format = "fc32";
- id.num_outputs = 1;
+ id.num_outputs = 1;
mock_zero_copy xport(vrt::if_packet_info_t::LINK_TYPE_VRLP);
vrt::if_packet_info_t ifpi;
- ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
ifpi.num_payload_words32 = 0;
- ifpi.packet_count = 0;
- ifpi.sob = true;
- ifpi.eob = false;
- ifpi.has_sid = false;
- ifpi.has_cid = false;
- ifpi.has_tsi = true;
- ifpi.has_tsf = true;
- ifpi.tsi = 0;
- ifpi.tsf = 0;
- ifpi.has_tlr = false;
-
- static const double TICK_RATE = 100e6;
- static const double SAMP_RATE = 10e6;
+ ifpi.packet_count = 0;
+ ifpi.sob = true;
+ ifpi.eob = false;
+ ifpi.has_sid = false;
+ ifpi.has_cid = false;
+ ifpi.has_tsi = true;
+ ifpi.has_tsf = true;
+ ifpi.tsi = 0;
+ ifpi.tsf = 0;
+ ifpi.has_tlr = false;
+
+ static const double TICK_RATE = 100e6;
+ static const double SAMP_RATE = 10e6;
static const size_t NUM_PKTS_TO_TEST = 30;
- //generate a bunch of packets
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
- ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
- ifpi.num_payload_words32 = 10 + i%10;
+ // generate a bunch of packets
+ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++) {
+ ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ ifpi.num_payload_words32 = 10 + i % 10;
std::vector<uint32_t> data(ifpi.num_payload_words32, 0);
xport.push_back_recv_packet(ifpi, data);
ifpi.packet_count++;
- ifpi.tsf += ifpi.num_payload_words32*size_t(TICK_RATE/SAMP_RATE);
+ ifpi.tsf += ifpi.num_payload_words32 * size_t(TICK_RATE / SAMP_RATE);
- //simulate overflow
- if (i == NUM_PKTS_TO_TEST/2){
- ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_CONTEXT;
+ // simulate overflow
+ if (i == NUM_PKTS_TO_TEST / 2) {
+ ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_CONTEXT;
ifpi.num_payload_words32 = 1;
xport.push_back_inline_message_packet(
- ifpi,
- uhd::rx_metadata_t::ERROR_CODE_OVERFLOW);
+ ifpi, uhd::rx_metadata_t::ERROR_CODE_OVERFLOW);
}
}
- //create the super receive packet handler
+ // create the super receive packet handler
sph::recv_packet_handler handler(1);
handler.set_vrt_unpacker(&vrt::if_hdr_unpack_be);
handler.set_tick_rate(TICK_RATE);
handler.set_samp_rate(SAMP_RATE);
handler.set_xport_chan_get_buff(
- 0,
- [&xport](double timeout) {
- return xport.get_recv_buff(timeout);
- }
- );
+ 0, [&xport](double timeout) { return xport.get_recv_buff(timeout); });
handler.set_converter(id);
- //create an overflow handler
+ // create an overflow handler
overflow_handler_type overflow_handler;
- handler.set_overflow_handler(0, boost::bind(&overflow_handler_type::handle, &overflow_handler));
+ handler.set_overflow_handler(
+ 0, boost::bind(&overflow_handler_type::handle, &overflow_handler));
- //check the received packets
+ // check the received packets
size_t num_accum_samps = 0;
- std::vector<std::complex<float> > buff(20);
+ std::vector<std::complex<float>> buff(20);
uhd::rx_metadata_t metadata;
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
+ 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, 1.0, true
- );
+ size_t num_samps_ret =
+ handler.recv(&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);
BOOST_CHECK(metadata.has_time_spec);
- BOOST_CHECK_TS_CLOSE(metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
- BOOST_CHECK_EQUAL(num_samps_ret, 10 + i%10);
+ BOOST_CHECK_TS_CLOSE(
+ metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
+ BOOST_CHECK_EQUAL(num_samps_ret, 10 + i % 10);
num_accum_samps += num_samps_ret;
- if (i == NUM_PKTS_TO_TEST/2){
- handler.recv(
- &buff.front(), buff.size(), metadata, 1.0, true
- );
+ if (i == NUM_PKTS_TO_TEST / 2) {
+ handler.recv(&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);
- BOOST_CHECK_TS_CLOSE(metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
+ BOOST_CHECK_TS_CLOSE(metadata.time_spec,
+ uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
BOOST_CHECK_EQUAL(overflow_handler.num_overflow, size_t(1));
}
}
- //subsequent receives should be a timeout
- for (size_t i = 0; i < 3; i++){
+ // subsequent receives should be a timeout
+ for (size_t i = 0; i < 3; i++) {
std::cout << "timeout check " << i << std::endl;
- handler.recv(
- &buff.front(), buff.size(), metadata, 1.0, true
- );
+ handler.recv(&buff.front(), buff.size(), metadata, 1.0, true);
BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT);
}
- //simulate the transport failing
+ // simulate the transport failing
xport.set_simulate_io_error(true);
- BOOST_REQUIRE_THROW(handler.recv(&buff.front(), buff.size(), metadata, 1.0, true), uhd::io_error);
+ BOOST_REQUIRE_THROW(
+ handler.recv(&buff.front(), buff.size(), metadata, 1.0, true), uhd::io_error);
}
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_normal){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_normal)
+{
+ ////////////////////////////////////////////////////////////////////////
uhd::convert::id_type id;
- id.input_format = "sc16_item32_be";
- id.num_inputs = 1;
+ id.input_format = "sc16_item32_be";
+ id.num_inputs = 1;
id.output_format = "fc32";
- id.num_outputs = 1;
+ id.num_outputs = 1;
vrt::if_packet_info_t ifpi;
- ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
ifpi.num_payload_words32 = 0;
- ifpi.packet_count = 0;
- ifpi.sob = true;
- ifpi.eob = false;
- ifpi.has_sid = false;
- ifpi.has_cid = false;
- ifpi.has_tsi = true;
- ifpi.has_tsf = true;
- ifpi.tsi = 0;
- ifpi.tsf = 0;
- ifpi.has_tlr = false;
-
- static const double TICK_RATE = 100e6;
- static const double SAMP_RATE = 10e6;
- static const size_t NUM_PKTS_TO_TEST = 30;
+ ifpi.packet_count = 0;
+ ifpi.sob = true;
+ ifpi.eob = false;
+ ifpi.has_sid = false;
+ ifpi.has_cid = false;
+ ifpi.has_tsi = true;
+ ifpi.has_tsf = true;
+ ifpi.tsi = 0;
+ ifpi.tsf = 0;
+ ifpi.has_tlr = false;
+
+ static const double TICK_RATE = 100e6;
+ static const double SAMP_RATE = 10e6;
+ static const size_t NUM_PKTS_TO_TEST = 30;
static const size_t NUM_SAMPS_PER_BUFF = 20;
- static const size_t NCHANNELS = 4;
+ static const size_t NCHANNELS = 4;
std::vector<mock_zero_copy::sptr> xports;
for (size_t i = 0; i < NCHANNELS; i++) {
- xports.push_back(boost::make_shared<mock_zero_copy>(vrt::if_packet_info_t::LINK_TYPE_VRLP));
+ xports.push_back(
+ boost::make_shared<mock_zero_copy>(vrt::if_packet_info_t::LINK_TYPE_VRLP));
}
- //generate a bunch of packets
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
- ifpi.num_payload_words32 = 10 + i%10;
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ // generate a bunch of packets
+ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++) {
+ ifpi.num_payload_words32 = 10 + i % 10;
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
std::vector<uint32_t> data(ifpi.num_payload_words32, 0);
xports[ch]->push_back_recv_packet(ifpi, data);
}
ifpi.packet_count++;
- ifpi.tsf += ifpi.num_payload_words32*size_t(TICK_RATE/SAMP_RATE);
+ ifpi.tsf += ifpi.num_payload_words32 * size_t(TICK_RATE / SAMP_RATE);
}
- //create the super receive packet handler
+ // create the super receive packet handler
sph::recv_packet_handler handler(NCHANNELS);
handler.set_vrt_unpacker(&vrt::if_hdr_unpack_be);
handler.set_tick_rate(TICK_RATE);
handler.set_samp_rate(SAMP_RATE);
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
mock_zero_copy::sptr xport = xports[ch];
handler.set_xport_chan_get_buff(
- ch,
- [xport](double timeout) {
- return xport->get_recv_buff(timeout);
- }
- );
+ ch, [xport](double timeout) { return xport->get_recv_buff(timeout); });
}
handler.set_converter(id);
- //check the received packets
+ // check the received packets
size_t num_accum_samps = 0;
- std::complex<float> mem[NUM_SAMPS_PER_BUFF*NCHANNELS];
- std::vector<std::complex<float> *> buffs(NCHANNELS);
- for (size_t ch = 0; ch < NCHANNELS; ch++){
- buffs[ch] = &mem[ch*NUM_SAMPS_PER_BUFF];
+ std::complex<float> mem[NUM_SAMPS_PER_BUFF * NCHANNELS];
+ std::vector<std::complex<float>*> buffs(NCHANNELS);
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
+ buffs[ch] = &mem[ch * NUM_SAMPS_PER_BUFF];
}
uhd::rx_metadata_t metadata;
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
+ 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, 1.0, true
- );
+ size_t num_samps_ret =
+ handler.recv(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);
BOOST_CHECK(metadata.has_time_spec);
- BOOST_CHECK_TS_CLOSE(metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
- BOOST_CHECK_EQUAL(num_samps_ret, 10 + i%10);
+ BOOST_CHECK_TS_CLOSE(
+ metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
+ BOOST_CHECK_EQUAL(num_samps_ret, 10 + i % 10);
num_accum_samps += num_samps_ret;
}
- //subsequent receives should be a timeout
- for (size_t i = 0; i < 3; i++){
+ // subsequent receives should be a timeout
+ for (size_t i = 0; i < 3; i++) {
std::cout << "timeout check " << i << std::endl;
- handler.recv(
- buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true
- );
+ handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true);
BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT);
}
- //simulate the transport failing
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ // simulate the transport failing
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
xports[ch]->set_simulate_io_error(true);
}
- BOOST_REQUIRE_THROW(handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true), uhd::io_error);
+ BOOST_REQUIRE_THROW(
+ handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true), uhd::io_error);
}
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_sequence_error){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_sequence_error)
+{
+ ////////////////////////////////////////////////////////////////////////
uhd::convert::id_type id;
- id.input_format = "sc16_item32_be";
- id.num_inputs = 1;
+ id.input_format = "sc16_item32_be";
+ id.num_inputs = 1;
id.output_format = "fc32";
- id.num_outputs = 1;
+ id.num_outputs = 1;
vrt::if_packet_info_t ifpi;
- ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
ifpi.num_payload_words32 = 0;
- ifpi.packet_count = 0;
- ifpi.sob = true;
- ifpi.eob = false;
- ifpi.has_sid = false;
- ifpi.has_cid = false;
- ifpi.has_tsi = true;
- ifpi.has_tsf = true;
- ifpi.tsi = 0;
- ifpi.tsf = 0;
- ifpi.has_tlr = false;
-
- static const double TICK_RATE = 100e6;
- static const double SAMP_RATE = 10e6;
- static const size_t NUM_PKTS_TO_TEST = 30;
+ ifpi.packet_count = 0;
+ ifpi.sob = true;
+ ifpi.eob = false;
+ ifpi.has_sid = false;
+ ifpi.has_cid = false;
+ ifpi.has_tsi = true;
+ ifpi.has_tsf = true;
+ ifpi.tsi = 0;
+ ifpi.tsf = 0;
+ ifpi.has_tlr = false;
+
+ static const double TICK_RATE = 100e6;
+ static const double SAMP_RATE = 10e6;
+ static const size_t NUM_PKTS_TO_TEST = 30;
static const size_t NUM_SAMPS_PER_BUFF = 20;
- static const size_t NCHANNELS = 4;
+ static const size_t NCHANNELS = 4;
std::vector<mock_zero_copy::sptr> xports;
for (size_t i = 0; i < NCHANNELS; i++) {
- xports.push_back(boost::make_shared<mock_zero_copy>(vrt::if_packet_info_t::LINK_TYPE_VRLP));
+ xports.push_back(
+ boost::make_shared<mock_zero_copy>(vrt::if_packet_info_t::LINK_TYPE_VRLP));
}
- //generate a bunch of packets
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
- ifpi.num_payload_words32 = 10 + i%10;
- for (size_t ch = 0; ch < NCHANNELS; ch++){
- if (i == NUM_PKTS_TO_TEST/2 and ch == 2){
- continue; //simulates a lost packet
+ // generate a bunch of packets
+ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++) {
+ ifpi.num_payload_words32 = 10 + i % 10;
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
+ if (i == NUM_PKTS_TO_TEST / 2 and ch == 2) {
+ continue; // simulates a lost packet
}
std::vector<uint32_t> data(ifpi.num_payload_words32, 0);
xports[ch]->push_back_recv_packet(ifpi, data);
}
ifpi.packet_count++;
- ifpi.tsf += ifpi.num_payload_words32*size_t(TICK_RATE/SAMP_RATE);
+ ifpi.tsf += ifpi.num_payload_words32 * size_t(TICK_RATE / SAMP_RATE);
}
- //create the super receive packet handler
+ // create the super receive packet handler
sph::recv_packet_handler handler(NCHANNELS);
handler.set_vrt_unpacker(&vrt::if_hdr_unpack_be);
handler.set_tick_rate(TICK_RATE);
handler.set_samp_rate(SAMP_RATE);
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
mock_zero_copy::sptr xport = xports[ch];
handler.set_xport_chan_get_buff(
- ch,
- [xport](double timeout) {
- return xport->get_recv_buff(timeout);
- }
- );
+ ch, [xport](double timeout) { return xport->get_recv_buff(timeout); });
}
handler.set_converter(id);
- //check the received packets
+ // check the received packets
size_t num_accum_samps = 0;
- std::complex<float> mem[NUM_SAMPS_PER_BUFF*NCHANNELS];
- std::vector<std::complex<float> *> buffs(NCHANNELS);
- for (size_t ch = 0; ch < NCHANNELS; ch++){
- buffs[ch] = &mem[ch*NUM_SAMPS_PER_BUFF];
+ std::complex<float> mem[NUM_SAMPS_PER_BUFF * NCHANNELS];
+ std::vector<std::complex<float>*> buffs(NCHANNELS);
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
+ buffs[ch] = &mem[ch * NUM_SAMPS_PER_BUFF];
}
uhd::rx_metadata_t metadata;
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
+ 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, 1.0, true
- );
- if (i == NUM_PKTS_TO_TEST/2){
- //must get the soft overflow here
+ size_t num_samps_ret =
+ handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true);
+ if (i == NUM_PKTS_TO_TEST / 2) {
+ // must get the soft overflow here
BOOST_REQUIRE(metadata.error_code == uhd::rx_metadata_t::ERROR_CODE_OVERFLOW);
BOOST_REQUIRE(metadata.out_of_sequence == true);
- BOOST_CHECK_TS_CLOSE(metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
- num_accum_samps += 10 + i%10;
- }
- else{
+ BOOST_CHECK_TS_CLOSE(metadata.time_spec,
+ uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
+ num_accum_samps += 10 + i % 10;
+ } else {
BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_NONE);
BOOST_CHECK(not metadata.more_fragments);
BOOST_CHECK(metadata.has_time_spec);
- BOOST_CHECK_TS_CLOSE(metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
- BOOST_CHECK_EQUAL(num_samps_ret, 10 + i%10);
+ BOOST_CHECK_TS_CLOSE(metadata.time_spec,
+ uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
+ BOOST_CHECK_EQUAL(num_samps_ret, 10 + i % 10);
num_accum_samps += num_samps_ret;
}
}
- //subsequent receives should be a timeout
- for (size_t i = 0; i < 3; i++){
+ // subsequent receives should be a timeout
+ for (size_t i = 0; i < 3; i++) {
std::cout << "timeout check " << i << std::endl;
- handler.recv(
- buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true
- );
+ handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true);
BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT);
}
- //simulate the transport failing
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ // simulate the transport failing
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
xports[ch]->set_simulate_io_error(true);
}
- BOOST_REQUIRE_THROW(handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true), uhd::io_error);
+ BOOST_REQUIRE_THROW(
+ handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true), uhd::io_error);
}
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_time_error){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_time_error)
+{
+ ////////////////////////////////////////////////////////////////////////
uhd::convert::id_type id;
- id.input_format = "sc16_item32_be";
- id.num_inputs = 1;
+ id.input_format = "sc16_item32_be";
+ id.num_inputs = 1;
id.output_format = "fc32";
- id.num_outputs = 1;
+ id.num_outputs = 1;
vrt::if_packet_info_t ifpi;
- ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
ifpi.num_payload_words32 = 0;
- ifpi.packet_count = 0;
- ifpi.sob = true;
- ifpi.eob = false;
- ifpi.has_sid = false;
- ifpi.has_cid = false;
- ifpi.has_tsi = true;
- ifpi.has_tsf = true;
- ifpi.tsi = 0;
- ifpi.tsf = 0;
- ifpi.has_tlr = false;
-
- static const double TICK_RATE = 100e6;
- static const double SAMP_RATE = 10e6;
- static const size_t NUM_PKTS_TO_TEST = 30;
+ ifpi.packet_count = 0;
+ ifpi.sob = true;
+ ifpi.eob = false;
+ ifpi.has_sid = false;
+ ifpi.has_cid = false;
+ ifpi.has_tsi = true;
+ ifpi.has_tsf = true;
+ ifpi.tsi = 0;
+ ifpi.tsf = 0;
+ ifpi.has_tlr = false;
+
+ static const double TICK_RATE = 100e6;
+ static const double SAMP_RATE = 10e6;
+ static const size_t NUM_PKTS_TO_TEST = 30;
static const size_t NUM_SAMPS_PER_BUFF = 20;
- static const size_t NCHANNELS = 4;
+ static const size_t NCHANNELS = 4;
std::vector<mock_zero_copy::sptr> xports;
for (size_t i = 0; i < NCHANNELS; i++) {
- xports.push_back(boost::make_shared<mock_zero_copy>(vrt::if_packet_info_t::LINK_TYPE_VRLP));
+ xports.push_back(
+ boost::make_shared<mock_zero_copy>(vrt::if_packet_info_t::LINK_TYPE_VRLP));
}
- //generate a bunch of packets
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
- ifpi.num_payload_words32 = 10 + i%10;
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ // generate a bunch of packets
+ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++) {
+ ifpi.num_payload_words32 = 10 + i % 10;
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
std::vector<uint32_t> data(ifpi.num_payload_words32, 0);
xports[ch]->push_back_recv_packet(ifpi, data);
}
ifpi.packet_count++;
- ifpi.tsf += ifpi.num_payload_words32*size_t(TICK_RATE/SAMP_RATE);
- if (i == NUM_PKTS_TO_TEST/2){
- ifpi.tsf = 0; //simulate the user changing the time
+ ifpi.tsf += ifpi.num_payload_words32 * size_t(TICK_RATE / SAMP_RATE);
+ if (i == NUM_PKTS_TO_TEST / 2) {
+ ifpi.tsf = 0; // simulate the user changing the time
}
}
- //create the super receive packet handler
+ // create the super receive packet handler
sph::recv_packet_handler handler(NCHANNELS);
handler.set_vrt_unpacker(&vrt::if_hdr_unpack_be);
handler.set_tick_rate(TICK_RATE);
handler.set_samp_rate(SAMP_RATE);
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
mock_zero_copy::sptr xport = xports[ch];
handler.set_xport_chan_get_buff(
- ch,
- [xport](double timeout) {
- return xport->get_recv_buff(timeout);
- }
- );
+ ch, [xport](double timeout) { return xport->get_recv_buff(timeout); });
}
handler.set_converter(id);
- //check the received packets
+ // check the received packets
size_t num_accum_samps = 0;
- std::complex<float> mem[NUM_SAMPS_PER_BUFF*NCHANNELS];
- std::vector<std::complex<float> *> buffs(NCHANNELS);
- for (size_t ch = 0; ch < NCHANNELS; ch++){
- buffs[ch] = &mem[ch*NUM_SAMPS_PER_BUFF];
+ std::complex<float> mem[NUM_SAMPS_PER_BUFF * NCHANNELS];
+ std::vector<std::complex<float>*> buffs(NCHANNELS);
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
+ buffs[ch] = &mem[ch * NUM_SAMPS_PER_BUFF];
}
uhd::rx_metadata_t metadata;
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
+ 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, 1.0, true
- );
+ size_t num_samps_ret =
+ handler.recv(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);
BOOST_CHECK(metadata.has_time_spec);
- BOOST_CHECK_TS_CLOSE(metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
- BOOST_CHECK_EQUAL(num_samps_ret, 10 + i%10);
+ BOOST_CHECK_TS_CLOSE(
+ metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
+ BOOST_CHECK_EQUAL(num_samps_ret, 10 + i % 10);
num_accum_samps += num_samps_ret;
- if (i == NUM_PKTS_TO_TEST/2){
- num_accum_samps = 0; //simulate the user changing the time
+ if (i == NUM_PKTS_TO_TEST / 2) {
+ num_accum_samps = 0; // simulate the user changing the time
}
}
- //subsequent receives should be a timeout
- for (size_t i = 0; i < 3; i++){
+ // subsequent receives should be a timeout
+ for (size_t i = 0; i < 3; i++) {
std::cout << "timeout check " << i << std::endl;
- handler.recv(
- buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true
- );
+ handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true);
BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT);
}
- //simulate the transport failing
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ // simulate the transport failing
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
xports[ch]->set_simulate_io_error(true);
}
- BOOST_REQUIRE_THROW(handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true), uhd::io_error);
+ BOOST_REQUIRE_THROW(
+ handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true), uhd::io_error);
}
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_exception){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_exception)
+{
+ ////////////////////////////////////////////////////////////////////////
uhd::convert::id_type id;
- id.input_format = "sc16_item32_be";
- id.num_inputs = 1;
+ id.input_format = "sc16_item32_be";
+ id.num_inputs = 1;
id.output_format = "fc32";
- id.num_outputs = 1;
+ id.num_outputs = 1;
vrt::if_packet_info_t ifpi;
- ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
ifpi.num_payload_words32 = 0;
- ifpi.packet_count = 0;
- ifpi.sob = true;
- ifpi.eob = false;
- ifpi.has_sid = false;
- ifpi.has_cid = false;
- ifpi.has_tsi = true;
- ifpi.has_tsf = true;
- ifpi.tsi = 0;
- ifpi.tsf = 0;
- ifpi.has_tlr = false;
-
- static const double TICK_RATE = 100e6;
- static const double SAMP_RATE = 10e6;
- static const size_t NUM_PKTS_TO_TEST = 30;
+ ifpi.packet_count = 0;
+ ifpi.sob = true;
+ ifpi.eob = false;
+ ifpi.has_sid = false;
+ ifpi.has_cid = false;
+ ifpi.has_tsi = true;
+ ifpi.has_tsf = true;
+ ifpi.tsi = 0;
+ ifpi.tsf = 0;
+ ifpi.has_tlr = false;
+
+ static const double TICK_RATE = 100e6;
+ static const double SAMP_RATE = 10e6;
+ static const size_t NUM_PKTS_TO_TEST = 30;
static const size_t NUM_SAMPS_PER_BUFF = 20;
- static const size_t NCHANNELS = 4;
+ static const size_t NCHANNELS = 4;
std::vector<mock_zero_copy::sptr> xports;
for (size_t i = 0; i < NCHANNELS; i++) {
- xports.push_back(boost::make_shared<mock_zero_copy>(vrt::if_packet_info_t::LINK_TYPE_VRLP));
+ xports.push_back(
+ boost::make_shared<mock_zero_copy>(vrt::if_packet_info_t::LINK_TYPE_VRLP));
}
- //generate a bunch of packets
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
- ifpi.num_payload_words32 = 10 + i%10;
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ // generate a bunch of packets
+ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++) {
+ ifpi.num_payload_words32 = 10 + i % 10;
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
std::vector<uint32_t> data(ifpi.num_payload_words32, 0);
xports[ch]->push_back_recv_packet(ifpi, data);
}
ifpi.packet_count++;
- ifpi.tsf += ifpi.num_payload_words32*size_t(TICK_RATE/SAMP_RATE);
- if (i == NUM_PKTS_TO_TEST/2){
- ifpi.tsf = 0; //simulate the user changing the time
+ ifpi.tsf += ifpi.num_payload_words32 * size_t(TICK_RATE / SAMP_RATE);
+ if (i == NUM_PKTS_TO_TEST / 2) {
+ ifpi.tsf = 0; // simulate the user changing the time
}
}
- //create the super receive packet handler
+ // create the super receive packet handler
sph::recv_packet_handler handler(NCHANNELS);
handler.set_vrt_unpacker(&vrt::if_hdr_unpack_be);
handler.set_tick_rate(TICK_RATE);
handler.set_samp_rate(SAMP_RATE);
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
mock_zero_copy::sptr xport = xports[ch];
handler.set_xport_chan_get_buff(
- ch,
- [xport](double timeout) {
- return xport->get_recv_buff(timeout);
- }
- );
+ ch, [xport](double timeout) { return xport->get_recv_buff(timeout); });
}
handler.set_converter(id);
- std::complex<float> mem[NUM_SAMPS_PER_BUFF*NCHANNELS];
- std::vector<std::complex<float> *> buffs(NCHANNELS);
- for (size_t ch = 0; ch < NCHANNELS; ch++){
- buffs[ch] = &mem[ch*NUM_SAMPS_PER_BUFF];
+ std::complex<float> mem[NUM_SAMPS_PER_BUFF * NCHANNELS];
+ std::vector<std::complex<float>*> buffs(NCHANNELS);
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
+ buffs[ch] = &mem[ch * NUM_SAMPS_PER_BUFF];
}
// simulate a failure on a channel (the last one)
uhd::rx_metadata_t metadata;
- xports[NCHANNELS-1]->set_simulate_io_error(true);
+ xports[NCHANNELS - 1]->set_simulate_io_error(true);
std::cout << "exception check" << std::endl;
- BOOST_REQUIRE_THROW(handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true), uhd::io_error);
+ BOOST_REQUIRE_THROW(
+ handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true), uhd::io_error);
}
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_fragment){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_sph_recv_multi_channel_fragment)
+{
+ ////////////////////////////////////////////////////////////////////////
uhd::convert::id_type id;
- id.input_format = "sc16_item32_be";
- id.num_inputs = 1;
+ id.input_format = "sc16_item32_be";
+ id.num_inputs = 1;
id.output_format = "fc32";
- id.num_outputs = 1;
+ id.num_outputs = 1;
vrt::if_packet_info_t ifpi;
- ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
+ ifpi.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA;
ifpi.num_payload_words32 = 0;
- ifpi.packet_count = 0;
- ifpi.sob = true;
- ifpi.eob = false;
- ifpi.has_sid = false;
- ifpi.has_cid = false;
- ifpi.has_tsi = true;
- ifpi.has_tsf = true;
- ifpi.tsi = 0;
- ifpi.tsf = 0;
- ifpi.has_tlr = false;
-
- static const double TICK_RATE = 100e6;
- static const double SAMP_RATE = 10e6;
- static const size_t NUM_PKTS_TO_TEST = 30;
+ ifpi.packet_count = 0;
+ ifpi.sob = true;
+ ifpi.eob = false;
+ ifpi.has_sid = false;
+ ifpi.has_cid = false;
+ ifpi.has_tsi = true;
+ ifpi.has_tsf = true;
+ ifpi.tsi = 0;
+ ifpi.tsf = 0;
+ ifpi.has_tlr = false;
+
+ static const double TICK_RATE = 100e6;
+ static const double SAMP_RATE = 10e6;
+ static const size_t NUM_PKTS_TO_TEST = 30;
static const size_t NUM_SAMPS_PER_BUFF = 10;
- static const size_t NCHANNELS = 4;
+ static const size_t NCHANNELS = 4;
std::vector<mock_zero_copy::sptr> xports;
for (size_t i = 0; i < NCHANNELS; i++) {
- xports.push_back(boost::make_shared<mock_zero_copy>(vrt::if_packet_info_t::LINK_TYPE_VRLP));
+ xports.push_back(
+ boost::make_shared<mock_zero_copy>(vrt::if_packet_info_t::LINK_TYPE_VRLP));
}
- //generate a bunch of packets
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
- ifpi.num_payload_words32 = 10 + i%10;
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ // generate a bunch of packets
+ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++) {
+ ifpi.num_payload_words32 = 10 + i % 10;
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
std::vector<uint32_t> data(ifpi.num_payload_words32, 0);
xports[ch]->push_back_recv_packet(ifpi, data);
}
ifpi.packet_count++;
- ifpi.tsf += ifpi.num_payload_words32*size_t(TICK_RATE/SAMP_RATE);
+ ifpi.tsf += ifpi.num_payload_words32 * size_t(TICK_RATE / SAMP_RATE);
}
- //create the super receive packet handler
+ // create the super receive packet handler
sph::recv_packet_handler handler(NCHANNELS);
handler.set_vrt_unpacker(&vrt::if_hdr_unpack_be);
handler.set_tick_rate(TICK_RATE);
handler.set_samp_rate(SAMP_RATE);
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
mock_zero_copy::sptr xport = xports[ch];
handler.set_xport_chan_get_buff(
- ch,
- [xport](double timeout) {
- return xport->get_recv_buff(timeout);
- }
- );
+ ch, [xport](double timeout) { return xport->get_recv_buff(timeout); });
}
handler.set_converter(id);
- //check the received packets
+ // check the received packets
size_t num_accum_samps = 0;
- std::complex<float> mem[NUM_SAMPS_PER_BUFF*NCHANNELS];
- std::vector<std::complex<float> *> buffs(NCHANNELS);
- for (size_t ch = 0; ch < NCHANNELS; ch++){
- buffs[ch] = &mem[ch*NUM_SAMPS_PER_BUFF];
+ std::complex<float> mem[NUM_SAMPS_PER_BUFF * NCHANNELS];
+ std::vector<std::complex<float>*> buffs(NCHANNELS);
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
+ buffs[ch] = &mem[ch * NUM_SAMPS_PER_BUFF];
}
uhd::rx_metadata_t metadata;
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
+ 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, 1.0, true
- );
+ size_t num_samps_ret =
+ handler.recv(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);
- BOOST_CHECK_TS_CLOSE(metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
+ BOOST_CHECK_TS_CLOSE(
+ metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
BOOST_CHECK_EQUAL(num_samps_ret, 10UL);
num_accum_samps += num_samps_ret;
- if (not metadata.more_fragments) continue;
+ if (not metadata.more_fragments)
+ continue;
- num_samps_ret = handler.recv(
- buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true
- );
+ num_samps_ret = handler.recv(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);
BOOST_CHECK_EQUAL(metadata.fragment_offset, 10UL);
BOOST_CHECK(metadata.has_time_spec);
- BOOST_CHECK_TS_CLOSE(metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
- BOOST_CHECK_EQUAL(num_samps_ret, i%10);
+ BOOST_CHECK_TS_CLOSE(
+ metadata.time_spec, uhd::time_spec_t::from_ticks(num_accum_samps, SAMP_RATE));
+ BOOST_CHECK_EQUAL(num_samps_ret, i % 10);
num_accum_samps += num_samps_ret;
}
- //subsequent receives should be a timeout
- for (size_t i = 0; i < 3; i++){
+ // subsequent receives should be a timeout
+ for (size_t i = 0; i < 3; i++) {
std::cout << "timeout check " << i << std::endl;
- handler.recv(
- buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true
- );
+ handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true);
BOOST_CHECK_EQUAL(metadata.error_code, uhd::rx_metadata_t::ERROR_CODE_TIMEOUT);
}
- //simulate the transport failing
- for (size_t ch = 0; ch < NCHANNELS; ch++){
+ // simulate the transport failing
+ for (size_t ch = 0; ch < NCHANNELS; ch++) {
xports[ch]->set_simulate_io_error(true);
}
- BOOST_REQUIRE_THROW(handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true), uhd::io_error);
+ BOOST_REQUIRE_THROW(
+ handler.recv(buffs, NUM_SAMPS_PER_BUFF, metadata, 1.0, true), uhd::io_error);
}
diff --git a/host/tests/sph_send_test.cpp b/host/tests/sph_send_test.cpp
index 2db80c8de..6de4c9ffa 100644
--- a/host/tests/sph_send_test.cpp
+++ b/host/tests/sph_send_test.cpp
@@ -5,14 +5,14 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
-#include "../lib/transport/super_send_packet_handler.hpp"
#include "../common/mock_zero_copy.hpp"
-#include <boost/shared_array.hpp>
+#include "../lib/transport/super_send_packet_handler.hpp"
#include <boost/bind.hpp>
+#include <boost/shared_array.hpp>
+#include <boost/test/unit_test.hpp>
#include <complex>
-#include <vector>
#include <list>
+#include <vector>
using namespace uhd::transport;
@@ -20,120 +20,110 @@ using namespace uhd::transport;
BOOST_CHECK_CLOSE((a).get_real_secs(), (b).get_real_secs(), 0.001)
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_one_packet_mode){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_one_packet_mode)
+{
+ ////////////////////////////////////////////////////////////////////////
uhd::convert::id_type id;
- id.input_format = "fc32";
- id.num_inputs = 1;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
id.output_format = "sc16_item32_be";
- id.num_outputs = 1;
+ id.num_outputs = 1;
mock_zero_copy xport(vrt::if_packet_info_t::LINK_TYPE_VRLP);
- static const double TICK_RATE = 100e6;
- static const double SAMP_RATE = 10e6;
+ static const double TICK_RATE = 100e6;
+ static const double SAMP_RATE = 10e6;
static const size_t NUM_PKTS_TO_TEST = 30;
- //create the super send packet handler
+ // create the super send packet handler
sph::send_packet_handler handler(1);
handler.set_vrt_packer(&vrt::if_hdr_pack_be);
handler.set_tick_rate(TICK_RATE);
handler.set_samp_rate(SAMP_RATE);
handler.set_xport_chan_get_buff(
- 0,
- [&xport](double timeout) {
- return xport.get_send_buff(timeout);
- }
- );
+ 0, [&xport](double timeout) { return xport.get_send_buff(timeout); });
handler.set_converter(id);
handler.set_max_samples_per_packet(20);
- //allocate metadata and buffer
- std::vector<std::complex<float> > buff(20);
+ // allocate metadata and buffer
+ std::vector<std::complex<float>> buff(20);
uhd::tx_metadata_t metadata;
metadata.has_time_spec = true;
- metadata.time_spec = uhd::time_spec_t(0.0);
+ metadata.time_spec = uhd::time_spec_t(0.0);
- //generate the test data
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
+ // generate the test data
+ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++) {
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, 1.0
- );
- BOOST_CHECK_EQUAL(num_sent, 10 + i%10);
+ metadata.end_of_burst = (i == NUM_PKTS_TO_TEST - 1);
+ const size_t num_sent = handler.send(&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);
}
- //check the sent packets
+ // check the sent packets
size_t num_accum_samps = 0;
vrt::if_packet_info_t ifpi;
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
+ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++) {
std::cout << "data check " << i << std::endl;
xport.pop_send_packet(ifpi);
- BOOST_CHECK_EQUAL(ifpi.num_payload_words32, 10+i%10);
+ BOOST_CHECK_EQUAL(ifpi.num_payload_words32, 10 + i % 10);
BOOST_CHECK(ifpi.has_tsf);
- BOOST_CHECK_EQUAL(ifpi.tsf, num_accum_samps*TICK_RATE/SAMP_RATE);
+ BOOST_CHECK_EQUAL(ifpi.tsf, num_accum_samps * TICK_RATE / SAMP_RATE);
BOOST_CHECK_EQUAL(ifpi.sob, i == 0);
- BOOST_CHECK_EQUAL(ifpi.eob, i == NUM_PKTS_TO_TEST-1);
+ BOOST_CHECK_EQUAL(ifpi.eob, i == NUM_PKTS_TO_TEST - 1);
num_accum_samps += ifpi.num_payload_words32;
}
}
////////////////////////////////////////////////////////////////////////
-BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_full_buffer_mode){
-////////////////////////////////////////////////////////////////////////
+BOOST_AUTO_TEST_CASE(test_sph_send_one_channel_full_buffer_mode)
+{
+ ////////////////////////////////////////////////////////////////////////
uhd::convert::id_type id;
- id.input_format = "fc32";
- id.num_inputs = 1;
+ id.input_format = "fc32";
+ id.num_inputs = 1;
id.output_format = "sc16_item32_be";
- id.num_outputs = 1;
+ id.num_outputs = 1;
mock_zero_copy xport(vrt::if_packet_info_t::LINK_TYPE_VRLP);
- static const double TICK_RATE = 100e6;
- static const double SAMP_RATE = 10e6;
+ static const double TICK_RATE = 100e6;
+ static const double SAMP_RATE = 10e6;
static const size_t NUM_PKTS_TO_TEST = 30;
- //create the super send packet handler
+ // create the super send packet handler
sph::send_packet_handler handler(1);
handler.set_vrt_packer(&vrt::if_hdr_pack_be);
handler.set_tick_rate(TICK_RATE);
handler.set_samp_rate(SAMP_RATE);
handler.set_xport_chan_get_buff(
- 0,
- [&xport](double timeout) {
- return xport.get_send_buff(timeout);
- }
- );
+ 0, [&xport](double timeout) { return xport.get_send_buff(timeout); });
handler.set_converter(id);
handler.set_max_samples_per_packet(20);
- //allocate metadata and buffer
- std::vector<std::complex<float> > buff(20*NUM_PKTS_TO_TEST);
+ // allocate metadata and buffer
+ std::vector<std::complex<float>> buff(20 * NUM_PKTS_TO_TEST);
uhd::tx_metadata_t metadata;
metadata.start_of_burst = true;
- metadata.end_of_burst = true;
- metadata.has_time_spec = true;
- metadata.time_spec = uhd::time_spec_t(0.0);
+ metadata.end_of_burst = true;
+ metadata.has_time_spec = true;
+ metadata.time_spec = uhd::time_spec_t(0.0);
- //generate the test data
- const size_t num_sent = handler.send(
- &buff.front(), buff.size(), metadata, 1.0
- );
+ // generate the test data
+ const size_t num_sent = handler.send(&buff.front(), buff.size(), metadata, 1.0);
BOOST_CHECK_EQUAL(num_sent, buff.size());
- //check the sent packets
+ // check the sent packets
size_t num_accum_samps = 0;
vrt::if_packet_info_t ifpi;
- for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++){
+ for (size_t i = 0; i < NUM_PKTS_TO_TEST; i++) {
std::cout << "data check " << i << std::endl;
xport.pop_send_packet(ifpi);
BOOST_CHECK_EQUAL(ifpi.num_payload_words32, 20UL);
BOOST_CHECK(ifpi.has_tsf);
- BOOST_CHECK_EQUAL(ifpi.tsf, num_accum_samps*TICK_RATE/SAMP_RATE);
+ BOOST_CHECK_EQUAL(ifpi.tsf, num_accum_samps * TICK_RATE / SAMP_RATE);
BOOST_CHECK_EQUAL(ifpi.sob, i == 0);
- BOOST_CHECK_EQUAL(ifpi.eob, i == NUM_PKTS_TO_TEST-1);
+ BOOST_CHECK_EQUAL(ifpi.eob, i == NUM_PKTS_TO_TEST - 1);
num_accum_samps += ifpi.num_payload_words32;
}
}
diff --git a/host/tests/stream_sig_test.cpp b/host/tests/stream_sig_test.cpp
index 88344faf5..41c07c14f 100644
--- a/host/tests/stream_sig_test.cpp
+++ b/host/tests/stream_sig_test.cpp
@@ -5,14 +5,15 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <iostream>
-#include <boost/test/unit_test.hpp>
#include <uhd/exception.hpp>
#include <uhd/rfnoc/stream_sig.hpp>
+#include <boost/test/unit_test.hpp>
+#include <iostream>
using namespace uhd::rfnoc;
-BOOST_AUTO_TEST_CASE(test_stream_sig) {
+BOOST_AUTO_TEST_CASE(test_stream_sig)
+{
stream_sig_t stream_sig;
BOOST_CHECK_EQUAL(stream_sig.item_type, "");
@@ -26,7 +27,8 @@ BOOST_AUTO_TEST_CASE(test_stream_sig) {
std::cout << ss.str() << std::endl;
}
-BOOST_AUTO_TEST_CASE(test_stream_sig_compat) {
+BOOST_AUTO_TEST_CASE(test_stream_sig_compat)
+{
stream_sig_t upstream_sig;
stream_sig_t downstream_sig;
@@ -47,12 +49,13 @@ BOOST_AUTO_TEST_CASE(test_stream_sig_compat) {
BOOST_CHECK(stream_sig_t::is_compatible(upstream_sig, downstream_sig));
downstream_sig.item_type = "";
BOOST_CHECK(stream_sig_t::is_compatible(upstream_sig, downstream_sig));
- upstream_sig.item_type = "sc16";
+ upstream_sig.item_type = "sc16";
downstream_sig.item_type = "s8";
BOOST_CHECK(not stream_sig_t::is_compatible(upstream_sig, downstream_sig));
}
-BOOST_AUTO_TEST_CASE(test_stream_sig_types) {
+BOOST_AUTO_TEST_CASE(test_stream_sig_types)
+{
stream_sig_t stream_sig;
BOOST_CHECK_EQUAL(stream_sig.get_bytes_per_item(), 0);
stream_sig.item_type = "sc16";
diff --git a/host/tests/subdev_spec_test.cpp b/host/tests/subdev_spec_test.cpp
index b87981392..533e8f90d 100644
--- a/host/tests/subdev_spec_test.cpp
+++ b/host/tests/subdev_spec_test.cpp
@@ -5,34 +5,35 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/usrp/subdev_spec.hpp>
+#include <boost/test/unit_test.hpp>
#include <iostream>
-BOOST_AUTO_TEST_CASE(test_subdevice_spec){
+BOOST_AUTO_TEST_CASE(test_subdevice_spec)
+{
std::cout << "Testing subdevice specification..." << std::endl;
- //load the subdev spec with something
+ // load the subdev spec with something
uhd::usrp::subdev_spec_t sd_spec;
sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("A", "AB"));
sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("B", "AB"));
- //create a subdev_spec with something different
+ // create a subdev_spec with something different
uhd::usrp::subdev_spec_t diff_sd_spec;
diff_sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("B", "BA"));
diff_sd_spec.push_back(uhd::usrp::subdev_spec_pair_t("B", "BA"));
- //convert to and from args string
+ // convert to and from args string
std::cout << "Pretty Print: " << std::endl << sd_spec.to_pp_string();
std::string markup_str = sd_spec.to_string();
std::cout << "Markup String: " << markup_str << std::endl;
uhd::usrp::subdev_spec_t new_sd_spec(markup_str);
- //they should be the same size
+ // they should be the same size
BOOST_REQUIRE_EQUAL(sd_spec.size(), new_sd_spec.size());
- //the contents should match
- for (size_t i = 0; i < sd_spec.size(); i++){
+ // the contents should match
+ for (size_t i = 0; i < sd_spec.size(); i++) {
BOOST_CHECK_EQUAL(sd_spec.at(i).db_name, new_sd_spec.at(i).db_name);
BOOST_CHECK_EQUAL(sd_spec.at(i).sd_name, new_sd_spec.at(i).sd_name);
diff --git a/host/tests/system_time_test.cpp b/host/tests/system_time_test.cpp
index 3fc759391..3f4f8a814 100644
--- a/host/tests/system_time_test.cpp
+++ b/host/tests/system_time_test.cpp
@@ -4,20 +4,21 @@
// SPDX-License-Identifier: GPL-3.0+
//
-#include <boost/test/unit_test.hpp>
-#include <uhd/types/time_spec.hpp>
#include "system_time.hpp"
-#include <iostream>
-#include <iomanip>
-#include <cstdint>
+#include <uhd/types/time_spec.hpp>
+#include <boost/test/unit_test.hpp>
#include <chrono>
+#include <cstdint>
+#include <iomanip>
+#include <iostream>
#include <thread>
-BOOST_AUTO_TEST_CASE(test_time_spec_get_system_time){
+BOOST_AUTO_TEST_CASE(test_time_spec_get_system_time)
+{
std::cout << "Testing time specification get system time..." << std::endl;
- //Not really checking for high resolution timing here,
- //just need to check that system time is minimally working.
+ // Not really checking for high resolution timing here,
+ // just need to check that system time is minimally working.
auto start = uhd::get_system_time();
std::this_thread::sleep_for(std::chrono::milliseconds(500));
@@ -27,7 +28,6 @@ BOOST_AUTO_TEST_CASE(test_time_spec_get_system_time){
std::cout << "start: " << start.get_real_secs() << std::endl;
std::cout << "stop: " << stop.get_real_secs() << std::endl;
std::cout << "diff: " << diff.get_real_secs() << std::endl;
- BOOST_CHECK(diff.get_real_secs() > 0); //assert positive
- BOOST_CHECK(diff.get_real_secs() < 1.0); //assert under 1s
+ BOOST_CHECK(diff.get_real_secs() > 0); // assert positive
+ BOOST_CHECK(diff.get_real_secs() < 1.0); // assert under 1s
}
-
diff --git a/host/tests/tasks_test.cpp b/host/tests/tasks_test.cpp
index f3bb07653..c236287e3 100644
--- a/host/tests/tasks_test.cpp
+++ b/host/tests/tasks_test.cpp
@@ -5,24 +5,24 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/utils/tasks.hpp>
-#include <thread>
+#include <boost/test/unit_test.hpp>
#include <chrono>
-#include <vector>
#include <iostream>
+#include <thread>
+#include <vector>
void test_tasks_sleep(size_t usecs)
{
std::this_thread::sleep_for(std::chrono::milliseconds(usecs));
}
-BOOST_AUTO_TEST_CASE(tasks_test) {
-
+BOOST_AUTO_TEST_CASE(tasks_test)
+{
static const size_t N_TASKS = 100;
std::vector<uhd::task::sptr> test_vec;
for (size_t i = 0; i < N_TASKS; i++) {
- test_vec.push_back(uhd::task::make([i](){ test_tasks_sleep(i); }));
+ test_vec.push_back(uhd::task::make([i]() { test_tasks_sleep(i); }));
}
}
diff --git a/host/tests/tick_node_test.cpp b/host/tests/tick_node_test.cpp
index 173481fb1..ccec67c43 100644
--- a/host/tests/tick_node_test.cpp
+++ b/host/tests/tick_node_test.cpp
@@ -18,7 +18,7 @@ class tick_aware_node : public test_node, public tick_node_ctrl
public:
typedef boost::shared_ptr<tick_aware_node> sptr;
- tick_aware_node(const std::string &test_id) : test_node(test_id) {};
+ tick_aware_node(const std::string& test_id) : test_node(test_id){};
}; /* class tick_aware_node */
@@ -28,10 +28,14 @@ class tick_setting_node : public test_node, public tick_node_ctrl
public:
typedef boost::shared_ptr<tick_setting_node> sptr;
- tick_setting_node(const std::string &test_id, double tick_rate) : test_node(test_id), _tick_rate(tick_rate) {};
+ tick_setting_node(const std::string& test_id, double tick_rate)
+ : test_node(test_id), _tick_rate(tick_rate){};
protected:
- double _get_tick_rate() { return _tick_rate; };
+ double _get_tick_rate()
+ {
+ return _tick_rate;
+ };
private:
const double _tick_rate;
@@ -39,7 +43,8 @@ private:
}; /* class tick_setting_node */
#define MAKE_TICK_NODE(name) tick_aware_node::sptr name(new tick_aware_node(#name));
-#define MAKE_TICK_SETTING_NODE(name, rate) tick_setting_node::sptr name(new tick_setting_node(#name, rate));
+#define MAKE_TICK_SETTING_NODE(name, rate) \
+ tick_setting_node::sptr name(new tick_setting_node(#name, rate));
BOOST_AUTO_TEST_CASE(test_simplest_downstream_search)
{
diff --git a/host/tests/time_spec_test.cpp b/host/tests/time_spec_test.cpp
index 89a5370bd..dee8d414e 100644
--- a/host/tests/time_spec_test.cpp
+++ b/host/tests/time_spec_test.cpp
@@ -5,14 +5,15 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/types/time_spec.hpp>
+#include <stdint.h>
+#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp> //sleep
-#include <iostream>
#include <iomanip>
-#include <stdint.h>
+#include <iostream>
-BOOST_AUTO_TEST_CASE(test_time_spec_compare){
+BOOST_AUTO_TEST_CASE(test_time_spec_compare)
+{
std::cout << "Testing time specification compare..." << std::endl;
BOOST_CHECK(uhd::time_spec_t(2.0) == uhd::time_spec_t(2.0));
@@ -31,7 +32,8 @@ BOOST_AUTO_TEST_CASE(test_time_spec_compare){
#define CHECK_TS_EQUAL(lhs, rhs) \
BOOST_CHECK_CLOSE((lhs).get_real_secs(), (rhs).get_real_secs(), 0.001)
-BOOST_AUTO_TEST_CASE(test_time_spec_arithmetic){
+BOOST_AUTO_TEST_CASE(test_time_spec_arithmetic)
+{
std::cout << "Testing time specification arithmetic..." << std::endl;
CHECK_TS_EQUAL(uhd::time_spec_t(2.3) + uhd::time_spec_t(1.0), uhd::time_spec_t(3.3));
@@ -40,7 +42,8 @@ BOOST_AUTO_TEST_CASE(test_time_spec_arithmetic){
CHECK_TS_EQUAL(uhd::time_spec_t(1.0) - uhd::time_spec_t(2.3), uhd::time_spec_t(-1.3));
}
-BOOST_AUTO_TEST_CASE(test_time_spec_parts){
+BOOST_AUTO_TEST_CASE(test_time_spec_parts)
+{
std::cout << "Testing time specification parts..." << std::endl;
BOOST_CHECK_EQUAL(uhd::time_spec_t(1.1).get_full_secs(), 1);
@@ -52,7 +55,8 @@ BOOST_AUTO_TEST_CASE(test_time_spec_parts){
BOOST_CHECK_EQUAL(uhd::time_spec_t(-1.1).to_ticks(100), -110);
}
-BOOST_AUTO_TEST_CASE(test_time_spec_neg_values){
+BOOST_AUTO_TEST_CASE(test_time_spec_neg_values)
+{
uhd::time_spec_t ts1(0.3);
uhd::time_spec_t ts2(1, -0.9);
std::cout << "ts1 " << ts1.get_real_secs() << std::endl;
@@ -74,7 +78,7 @@ BOOST_AUTO_TEST_CASE(test_time_spec_neg_values){
BOOST_AUTO_TEST_CASE(test_time_large_ticks_to_time_spec)
{
std::cout << "sizeof(time_t) " << sizeof(time_t) << std::endl;
- const uint64_t ticks0 = uint64_t(100e6*1360217663.739296);
+ const uint64_t ticks0 = uint64_t(100e6 * 1360217663.739296);
const uhd::time_spec_t t0 = uhd::time_spec_t::from_ticks(ticks0, 100e6);
std::cout << "t0.get_real_secs() " << t0.get_real_secs() << std::endl;
std::cout << "t0.get_full_secs() " << t0.get_full_secs() << std::endl;
@@ -84,11 +88,11 @@ BOOST_AUTO_TEST_CASE(test_time_large_ticks_to_time_spec)
BOOST_AUTO_TEST_CASE(test_time_error_irrational_rate)
{
- static const double rate = 1625e3/6.0;
- const long long tick_in = 23423436291667ll;
+ static const double rate = 1625e3 / 6.0;
+ const long long tick_in = 23423436291667ll;
const uhd::time_spec_t ts = uhd::time_spec_t::from_ticks(tick_in, rate);
- const long long tick_out = ts.to_ticks(rate);
- const long long err = tick_in - tick_out;
+ const long long tick_out = ts.to_ticks(rate);
+ const long long err = tick_in - tick_out;
std::streamsize precision = std::cout.precision();
std::cout << std::setprecision(18);
diff --git a/host/tests/vrt_test.cpp b/host/tests/vrt_test.cpp
index 1b4df8fc7..ea639c65c 100644
--- a/host/tests/vrt_test.cpp
+++ b/host/tests/vrt_test.cpp
@@ -5,65 +5,63 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-#include <boost/test/unit_test.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
#include <uhd/utils/byteswap.hpp>
#include <boost/format.hpp>
+#include <boost/test/unit_test.hpp>
#include <cstdlib>
#include <iostream>
using namespace uhd::transport;
-static void pack_and_unpack(
- vrt::if_packet_info_t &if_packet_info_in
-){
- if (if_packet_info_in.num_payload_bytes == 0)
- {
- if_packet_info_in.num_payload_bytes = if_packet_info_in.num_payload_words32 * sizeof(uint32_t);
+static void pack_and_unpack(vrt::if_packet_info_t& if_packet_info_in)
+{
+ if (if_packet_info_in.num_payload_bytes == 0) {
+ if_packet_info_in.num_payload_bytes =
+ if_packet_info_in.num_payload_words32 * sizeof(uint32_t);
}
uint32_t packet_buff[2048];
- //pack metadata into a vrt header
- vrt::if_hdr_pack_be(
- packet_buff, if_packet_info_in
- );
+ // pack metadata into a vrt header
+ vrt::if_hdr_pack_be(packet_buff, if_packet_info_in);
std::cout << std::endl;
- for (size_t i = 0; i < 5; i++)
- {
- std::cout << boost::format("packet_buff[%u] = 0x%.8x") % i % uhd::byteswap(packet_buff[i]) << std::endl;
+ for (size_t i = 0; i < 5; i++) {
+ std::cout << boost::format("packet_buff[%u] = 0x%.8x") % i
+ % uhd::byteswap(packet_buff[i])
+ << std::endl;
}
vrt::if_packet_info_t if_packet_info_out;
- if_packet_info_out.link_type = if_packet_info_in.link_type;
+ if_packet_info_out.link_type = if_packet_info_in.link_type;
if_packet_info_out.num_packet_words32 = if_packet_info_in.num_packet_words32;
- //unpack the vrt header back into metadata
- vrt::if_hdr_unpack_be(
- packet_buff, if_packet_info_out
- );
+ // unpack the vrt header back into metadata
+ vrt::if_hdr_unpack_be(packet_buff, if_packet_info_out);
- //check the the unpacked metadata is the same
+ // check the the unpacked metadata is the same
BOOST_CHECK_EQUAL(if_packet_info_in.packet_count, if_packet_info_out.packet_count);
- BOOST_CHECK_EQUAL(if_packet_info_in.num_header_words32, if_packet_info_out.num_header_words32);
- BOOST_CHECK_EQUAL(if_packet_info_in.num_payload_words32, if_packet_info_out.num_payload_words32);
+ BOOST_CHECK_EQUAL(
+ if_packet_info_in.num_header_words32, if_packet_info_out.num_header_words32);
+ BOOST_CHECK_EQUAL(
+ if_packet_info_in.num_payload_words32, if_packet_info_out.num_payload_words32);
BOOST_CHECK_EQUAL(if_packet_info_in.has_sid, if_packet_info_out.has_sid);
- if (if_packet_info_in.has_sid and if_packet_info_out.has_sid){
+ if (if_packet_info_in.has_sid and if_packet_info_out.has_sid) {
BOOST_CHECK_EQUAL(if_packet_info_in.sid, if_packet_info_out.sid);
}
BOOST_CHECK_EQUAL(if_packet_info_in.has_cid, if_packet_info_out.has_cid);
- if (if_packet_info_in.has_cid and if_packet_info_out.has_cid){
+ if (if_packet_info_in.has_cid and if_packet_info_out.has_cid) {
BOOST_CHECK_EQUAL(if_packet_info_in.cid, if_packet_info_out.cid);
}
BOOST_CHECK_EQUAL(if_packet_info_in.has_tsi, if_packet_info_out.has_tsi);
- if (if_packet_info_in.has_tsi and if_packet_info_out.has_tsi){
+ if (if_packet_info_in.has_tsi and if_packet_info_out.has_tsi) {
BOOST_CHECK_EQUAL(if_packet_info_in.tsi, if_packet_info_out.tsi);
}
BOOST_CHECK_EQUAL(if_packet_info_in.has_tsf, if_packet_info_out.has_tsf);
- if (if_packet_info_in.has_tsf and if_packet_info_out.has_tsf){
+ if (if_packet_info_in.has_tsf and if_packet_info_out.has_tsf) {
BOOST_CHECK_EQUAL(if_packet_info_in.tsf, if_packet_info_out.tsf);
}
BOOST_CHECK_EQUAL(if_packet_info_in.has_tlr, if_packet_info_out.has_tlr);
- if (if_packet_info_in.has_tlr and if_packet_info_out.has_tlr){
+ if (if_packet_info_in.has_tlr and if_packet_info_out.has_tlr) {
BOOST_CHECK_EQUAL(if_packet_info_in.tlr, if_packet_info_out.tlr);
}
}
@@ -73,102 +71,109 @@ static void pack_and_unpack(
* The trailer is not tested as it is not convenient to do so.
**********************************************************************/
-BOOST_AUTO_TEST_CASE(test_with_none){
+BOOST_AUTO_TEST_CASE(test_with_none)
+{
vrt::if_packet_info_t if_packet_info;
- if_packet_info.packet_count = 0;
- if_packet_info.has_sid = false;
- if_packet_info.has_cid = false;
- if_packet_info.has_tsi = false;
- if_packet_info.has_tsf = false;
- if_packet_info.has_tlr = false;
+ if_packet_info.packet_count = 0;
+ if_packet_info.has_sid = false;
+ if_packet_info.has_cid = false;
+ if_packet_info.has_tsi = false;
+ if_packet_info.has_tsf = false;
+ if_packet_info.has_tlr = false;
if_packet_info.num_payload_words32 = 0;
pack_and_unpack(if_packet_info);
}
-BOOST_AUTO_TEST_CASE(test_with_sid){
+BOOST_AUTO_TEST_CASE(test_with_sid)
+{
vrt::if_packet_info_t if_packet_info;
- if_packet_info.packet_count = 1;
- if_packet_info.has_sid = true;
- if_packet_info.has_cid = false;
- if_packet_info.has_tsi = false;
- if_packet_info.has_tsf = false;
- if_packet_info.has_tlr = false;
- if_packet_info.sid = std::rand();
+ if_packet_info.packet_count = 1;
+ if_packet_info.has_sid = true;
+ if_packet_info.has_cid = false;
+ if_packet_info.has_tsi = false;
+ if_packet_info.has_tsf = false;
+ if_packet_info.has_tlr = false;
+ if_packet_info.sid = std::rand();
if_packet_info.num_payload_words32 = 11;
pack_and_unpack(if_packet_info);
}
static const bool cid_enb = false;
-BOOST_AUTO_TEST_CASE(test_with_cid){
+BOOST_AUTO_TEST_CASE(test_with_cid)
+{
vrt::if_packet_info_t if_packet_info;
- if_packet_info.packet_count = 2;
- if_packet_info.has_sid = false;
- if_packet_info.has_cid = cid_enb;
- if_packet_info.has_tsi = false;
- if_packet_info.has_tsf = false;
- if_packet_info.has_tlr = false;
- if_packet_info.cid = std::rand();
+ if_packet_info.packet_count = 2;
+ if_packet_info.has_sid = false;
+ if_packet_info.has_cid = cid_enb;
+ if_packet_info.has_tsi = false;
+ if_packet_info.has_tsf = false;
+ if_packet_info.has_tlr = false;
+ if_packet_info.cid = std::rand();
if_packet_info.num_payload_words32 = 22;
pack_and_unpack(if_packet_info);
}
-BOOST_AUTO_TEST_CASE(test_with_time){
+BOOST_AUTO_TEST_CASE(test_with_time)
+{
vrt::if_packet_info_t if_packet_info;
- if_packet_info.packet_count = 3;
- if_packet_info.has_sid = false;
- if_packet_info.has_cid = false;
- if_packet_info.has_tsi = true;
- if_packet_info.has_tsf = true;
- if_packet_info.has_tlr = false;
- if_packet_info.tsi = std::rand();
- if_packet_info.tsf = std::rand();
+ if_packet_info.packet_count = 3;
+ if_packet_info.has_sid = false;
+ if_packet_info.has_cid = false;
+ if_packet_info.has_tsi = true;
+ if_packet_info.has_tsf = true;
+ if_packet_info.has_tlr = false;
+ if_packet_info.tsi = std::rand();
+ if_packet_info.tsf = std::rand();
if_packet_info.num_payload_words32 = 33;
pack_and_unpack(if_packet_info);
}
-BOOST_AUTO_TEST_CASE(test_with_all){
+BOOST_AUTO_TEST_CASE(test_with_all)
+{
vrt::if_packet_info_t if_packet_info;
- if_packet_info.packet_count = 4;
- if_packet_info.has_sid = true;
- if_packet_info.has_cid = cid_enb;
- if_packet_info.has_tsi = true;
- if_packet_info.has_tsf = true;
- if_packet_info.has_tlr = false;
- if_packet_info.sid = std::rand();
- if_packet_info.cid = std::rand();
- if_packet_info.tsi = std::rand();
- if_packet_info.tsf = std::rand();
+ if_packet_info.packet_count = 4;
+ if_packet_info.has_sid = true;
+ if_packet_info.has_cid = cid_enb;
+ if_packet_info.has_tsi = true;
+ if_packet_info.has_tsf = true;
+ if_packet_info.has_tlr = false;
+ if_packet_info.sid = std::rand();
+ if_packet_info.cid = std::rand();
+ if_packet_info.tsi = std::rand();
+ if_packet_info.tsf = std::rand();
if_packet_info.num_payload_words32 = 44;
pack_and_unpack(if_packet_info);
}
-BOOST_AUTO_TEST_CASE(test_with_vrlp){
+BOOST_AUTO_TEST_CASE(test_with_vrlp)
+{
vrt::if_packet_info_t if_packet_info;
- if_packet_info.link_type = vrt::if_packet_info_t::LINK_TYPE_VRLP;
- if_packet_info.packet_count = 3;
- if_packet_info.has_sid = true;
- if_packet_info.has_cid = false;
- if_packet_info.has_tsi = false;
- if_packet_info.has_tsf = true;
- if_packet_info.has_tlr = true;
- if_packet_info.tsi = std::rand();
- if_packet_info.tsf = std::rand();
+ if_packet_info.link_type = vrt::if_packet_info_t::LINK_TYPE_VRLP;
+ if_packet_info.packet_count = 3;
+ if_packet_info.has_sid = true;
+ if_packet_info.has_cid = false;
+ if_packet_info.has_tsi = false;
+ if_packet_info.has_tsf = true;
+ if_packet_info.has_tlr = true;
+ if_packet_info.tsi = std::rand();
+ if_packet_info.tsf = std::rand();
if_packet_info.num_payload_words32 = 42;
pack_and_unpack(if_packet_info);
}
-BOOST_AUTO_TEST_CASE(test_with_chdr){
+BOOST_AUTO_TEST_CASE(test_with_chdr)
+{
vrt::if_packet_info_t if_packet_info;
- if_packet_info.link_type = vrt::if_packet_info_t::LINK_TYPE_CHDR;
- if_packet_info.packet_count = 7;
- if_packet_info.has_sid = true;
- if_packet_info.has_cid = false;
- if_packet_info.has_tsi = false;
- if_packet_info.has_tsf = true;
- if_packet_info.has_tlr = false; //tlr not suported in CHDR
- if_packet_info.tsi = std::rand();
- if_packet_info.tsf = std::rand();
+ if_packet_info.link_type = vrt::if_packet_info_t::LINK_TYPE_CHDR;
+ if_packet_info.packet_count = 7;
+ if_packet_info.has_sid = true;
+ if_packet_info.has_cid = false;
+ if_packet_info.has_tsi = false;
+ if_packet_info.has_tsf = true;
+ if_packet_info.has_tlr = false; // tlr not suported in CHDR
+ if_packet_info.tsi = std::rand();
+ if_packet_info.tsf = std::rand();
if_packet_info.num_payload_words32 = 24;
pack_and_unpack(if_packet_info);
}