diff options
author | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-14 10:35:25 -0800 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-01-16 11:40:23 -0800 |
commit | 967be2a4e82b1a125b26bb72a60318a4fb2b50c4 (patch) | |
tree | 8a24954b54d1546dc8049a17e485adb0a605f74f /host/tests/chdr_test.cpp | |
parent | aafe4e8b742a0e21d3818f21f34e3c8613132530 (diff) | |
download | uhd-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/chdr_test.cpp')
-rw-r--r-- | host/tests/chdr_test.cpp | 141 |
1 files changed, 72 insertions, 69 deletions
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); } - |