aboutsummaryrefslogtreecommitdiffstats
path: root/host/test/vrt_test.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-06-29 22:55:45 -0700
committerJosh Blum <josh@joshknows.com>2010-07-05 13:45:11 -0700
commit08fad28f209a2f6c79d939ad54ca3a1d4e270b0b (patch)
tree6561410b24bcf0f3e72d680c27143b3b2a015bd0 /host/test/vrt_test.cpp
parent01e5f592d62e2193cc88081bd88765cae4708148 (diff)
downloaduhd-08fad28f209a2f6c79d939ad54ca3a1d4e270b0b.tar.gz
uhd-08fad28f209a2f6c79d939ad54ca3a1d4e270b0b.tar.bz2
uhd-08fad28f209a2f6c79d939ad54ca3a1d4e270b0b.zip
uhd: work vectorizing the vrt packet handler, reworked vrt packet stuff, needs testing
Diffstat (limited to 'host/test/vrt_test.cpp')
-rw-r--r--host/test/vrt_test.cpp147
1 files changed, 93 insertions, 54 deletions
diff --git a/host/test/vrt_test.cpp b/host/test/vrt_test.cpp
index 3776e33aa..3f74a836e 100644
--- a/host/test/vrt_test.cpp
+++ b/host/test/vrt_test.cpp
@@ -17,84 +17,123 @@
#include <boost/test/unit_test.hpp>
#include <uhd/transport/vrt.hpp>
+#include <cstdlib>
using namespace uhd::transport;
static void pack_and_unpack(
- const uhd::tx_metadata_t &metadata,
- size_t num_payload_words32,
- size_t packet_count
+ vrt::if_packet_info_t &if_packet_info_in
){
- boost::uint32_t header_buff[vrt::max_header_words32];
- size_t num_header_words32;
- size_t num_packet_words32;
+ boost::uint32_t header_buff[vrt::max_if_hdr_words32];
//pack metadata into a vrt header
- vrt::pack_be(
- metadata, //input
- header_buff, //output
- num_header_words32, //output
- num_payload_words32, //input
- num_packet_words32, //output
- packet_count, //input
- 100e6
+ vrt::if_hdr_pack_be(
+ header_buff, if_packet_info_in
);
- uhd::rx_metadata_t metadata_out;
- size_t num_header_words32_out;
- size_t num_payload_words32_out;
- size_t packet_count_out;
+ vrt::if_packet_info_t if_packet_info_out;
+ if_packet_info_out.num_packet_words32 = if_packet_info_in.num_packet_words32;
//unpack the vrt header back into metadata
- vrt::unpack_be(
- metadata_out, //output
- header_buff, //input
- num_header_words32_out, //output
- num_payload_words32_out, //output
- num_packet_words32, //input
- packet_count_out, //output
- 100e6
+ vrt::if_hdr_unpack_be(
+ header_buff, if_packet_info_out
);
//check the the unpacked metadata is the same
- BOOST_CHECK_EQUAL(packet_count, packet_count_out);
- BOOST_CHECK_EQUAL(num_header_words32, num_header_words32_out);
- BOOST_CHECK_EQUAL(num_payload_words32, num_payload_words32_out);
- BOOST_CHECK_EQUAL(metadata.has_stream_id, metadata_out.has_stream_id);
- if (metadata.has_stream_id and metadata_out.has_stream_id){
- BOOST_CHECK_EQUAL(metadata.stream_id, metadata_out.stream_id);
+ 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.has_sid, 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(metadata.has_time_spec, metadata_out.has_time_spec);
- if (metadata.has_time_spec and metadata_out.has_time_spec){
- BOOST_CHECK_EQUAL(metadata.time_spec.get_full_secs(), metadata_out.time_spec.get_full_secs());
- BOOST_CHECK_EQUAL(metadata.time_spec.get_frac_secs(), metadata_out.time_spec.get_frac_secs());
+ 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){
+ 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){
+ 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){
+ 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){
+ BOOST_CHECK_EQUAL(if_packet_info_in.tlr, if_packet_info_out.tlr);
}
}
+/***********************************************************************
+ * Loopback test the vrt packer/unpacker with various packet info combos
+ * The trailer is not tested as it is not convenient to do so.
+ **********************************************************************/
+
BOOST_AUTO_TEST_CASE(test_with_none){
- uhd::tx_metadata_t metadata;
- pack_and_unpack(metadata, 300, 1);
+ 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.num_payload_words32 = 0;
+ pack_and_unpack(if_packet_info);
}
BOOST_AUTO_TEST_CASE(test_with_sid){
- uhd::tx_metadata_t metadata;
- metadata.has_stream_id = true;
- metadata.stream_id = 6;
- pack_and_unpack(metadata, 400, 2);
+ 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.num_payload_words32 = 1111;
+ pack_and_unpack(if_packet_info);
+}
+
+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 = true;
+ 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 = 2222;
+ pack_and_unpack(if_packet_info);
}
-BOOST_AUTO_TEST_CASE(test_with_time_spec){
- uhd::tx_metadata_t metadata;
- metadata.has_time_spec = true;
- metadata.time_spec = uhd::time_spec_t(7, 0.2);
- pack_and_unpack(metadata, 500, 3);
+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.num_payload_words32 = 33333;
+ pack_and_unpack(if_packet_info);
}
-BOOST_AUTO_TEST_CASE(test_with_sid_and_time_spec){
- uhd::tx_metadata_t metadata;
- metadata.has_stream_id = true;
- metadata.stream_id = 2;
- metadata.has_time_spec = true;
- metadata.time_spec = uhd::time_spec_t(5, 0.1);
- pack_and_unpack(metadata, 600, 4);
+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 = true;
+ 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 = 44444;
+ pack_and_unpack(if_packet_info);
}