aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests/common
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/common
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/common')
-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
4 files changed, 114 insertions, 114 deletions
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);
}