aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests/device3_test.cpp
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/device3_test.cpp
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/device3_test.cpp')
-rw-r--r--host/tests/device3_test.cpp95
1 files changed, 50 insertions, 45 deletions
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: