diff options
Diffstat (limited to 'host/tests')
-rw-r--r-- | host/tests/rfnoc_block_tests/replay_block_test.cpp | 18 | ||||
-rw-r--r-- | host/tests/rfnoc_block_tests/siggen_block_test.cpp | 14 | ||||
-rw-r--r-- | host/tests/rx_streamer_test.cpp | 12 | ||||
-rw-r--r-- | host/tests/streamer_benchmark.cpp | 25 | ||||
-rw-r--r-- | host/tests/tx_streamer_test.cpp | 13 |
5 files changed, 64 insertions, 18 deletions
diff --git a/host/tests/rfnoc_block_tests/replay_block_test.cpp b/host/tests/rfnoc_block_tests/replay_block_test.cpp index f84b98ac8..db9f8c177 100644 --- a/host/tests/rfnoc_block_tests/replay_block_test.cpp +++ b/host/tests/rfnoc_block_tests/replay_block_test.cpp @@ -157,7 +157,7 @@ BOOST_FIXTURE_TEST_CASE(replay_test_construction, replay_block_fixture) BOOST_CHECK_EQUAL(reg_iface->write_memory[reg_play_base_addr], 0); BOOST_CHECK_EQUAL(reg_iface->write_memory[reg_play_base_addr + 4], 0); BOOST_CHECK_EQUAL(reg_iface->write_memory[reg_words_per_pkt], - (DEFAULT_MTU - CHDR_MAX_LEN_HDR) / word_size); + (DEFAULT_MTU - test_replay->get_chdr_hdr_len()) / word_size); BOOST_CHECK_EQUAL(reg_iface->write_memory[reg_play_item_size], default_item_size); } } @@ -353,18 +353,20 @@ BOOST_FIXTURE_TEST_CASE(replay_test_configure_play, replay_block_fixture) } /* - * This test case ensures that the hardware is programmed correctly throough the playback + * This test case ensures that the hardware is programmed correctly through the playback * packet API calls. */ BOOST_FIXTURE_TEST_CASE(replay_test_packet_size, replay_block_fixture) { for (size_t port = 0; port < num_output_ports; port++) { // Test the defaults - const uint32_t default_ipp = DEFAULT_SPP; - BOOST_CHECK_EQUAL(test_replay->get_max_items_per_packet(port), default_ipp); - - const uint32_t item_size = test_replay->get_play_item_size(port); - const uint32_t default_packet_size = default_ipp * item_size + CHDR_MAX_LEN_HDR; + const uint32_t item_size = test_replay->get_play_item_size(port); + const uint32_t expected_ipp = + test_replay->get_max_payload_size({res_source_info::OUTPUT_EDGE, port}) + / item_size; + BOOST_CHECK_EQUAL(test_replay->get_max_items_per_packet(port), expected_ipp); + const uint32_t default_packet_size = + expected_ipp * item_size + test_replay->get_chdr_hdr_len(); BOOST_CHECK_EQUAL(test_replay->get_max_packet_size(port), default_packet_size); } @@ -374,7 +376,7 @@ BOOST_FIXTURE_TEST_CASE(replay_test_packet_size, replay_block_fixture) BOOST_CHECK_EQUAL(test_replay->get_max_items_per_packet(port), ipp); const uint32_t item_size = test_replay->get_play_item_size(port); - const uint32_t packet_size = ipp * item_size + CHDR_MAX_LEN_HDR; + const uint32_t packet_size = ipp * item_size + test_replay->get_chdr_hdr_len(); BOOST_CHECK_EQUAL(test_replay->get_max_packet_size(port), packet_size); const uint32_t wpp = ipp * item_size / word_size; diff --git a/host/tests/rfnoc_block_tests/siggen_block_test.cpp b/host/tests/rfnoc_block_tests/siggen_block_test.cpp index ea52530e0..d453e898e 100644 --- a/host/tests/rfnoc_block_tests/siggen_block_test.cpp +++ b/host/tests/rfnoc_block_tests/siggen_block_test.cpp @@ -191,7 +191,10 @@ BOOST_FIXTURE_TEST_CASE(siggen_test_construction, siggen_block_fixture) BOOST_CHECK_EQUAL(reg_iface->phase_increments.at(port), siggen_mock_reg_iface_t::phase_increment_to_register(1.0)); BOOST_CHECK_EQUAL(reg_iface->phasors.at(port), siggen_mock_reg_iface_t::phasor_to_register({0.0, 0.0})); - BOOST_CHECK_EQUAL(reg_iface->spps.at(port), DEFAULT_SPP); + constexpr int bpi = 4; // sc16 has 4 bytes per item + const int expected_spp = + test_siggen->get_max_payload_size({res_source_info::OUTPUT_EDGE, port}) / bpi; + BOOST_CHECK_EQUAL(reg_iface->spps.at(port), expected_spp); } } @@ -315,10 +318,11 @@ BOOST_FIXTURE_TEST_CASE(siggen_test_ranges, siggen_block_fixture) */ BOOST_FIXTURE_TEST_CASE(siggen_test_spp_coercion, siggen_block_fixture) { - constexpr size_t mtu_in_samps = DEFAULT_MTU / 4 /* bytes/samp */; - size_t high_spp = mtu_in_samps + 10; - test_siggen->set_samples_per_packet(high_spp, 0); - BOOST_CHECK_EQUAL(test_siggen->get_samples_per_packet(0), mtu_in_samps); + const size_t max_samps = + (DEFAULT_MTU - test_siggen->get_chdr_hdr_len()) / 4 /* bytes/samp */; + const size_t too_high_spp = max_samps + 10; + test_siggen->set_samples_per_packet(too_high_spp, 0); + BOOST_CHECK_EQUAL(test_siggen->get_samples_per_packet(0), max_samps); } /* diff --git a/host/tests/rx_streamer_test.cpp b/host/tests/rx_streamer_test.cpp index 03ab3f456..a2969d608 100644 --- a/host/tests/rx_streamer_test.cpp +++ b/host/tests/rx_streamer_test.cpp @@ -95,9 +95,19 @@ public: _recv_link->release_recv_buff(std::move(buff)); } + size_t get_mtu() const + { + return _recv_link->get_recv_frame_size(); + } + + size_t get_chdr_hdr_len() const + { + return sizeof(mock_header_t); + } + size_t get_max_payload_size() const { - return _recv_link->get_recv_frame_size() - sizeof(packet_info_t); + return get_mtu() - get_chdr_hdr_len(); } private: diff --git a/host/tests/streamer_benchmark.cpp b/host/tests/streamer_benchmark.cpp index a11db3e68..b180e7393 100644 --- a/host/tests/streamer_benchmark.cpp +++ b/host/tests/streamer_benchmark.cpp @@ -76,11 +76,21 @@ public: _buff = std::move(buff); } - size_t get_max_payload_size() const + size_t get_mtu() const { return _buff_size; } + size_t get_chdr_hdr_len() const + { + return sizeof(packet_info_t); + } + + size_t get_max_payload_size() const + { + return get_mtu() - sizeof(packet_info_t); + } + private: size_t _buff_size; buff_t::uptr _buff; @@ -137,11 +147,22 @@ public: _buff = std::move(buff); } + size_t get_mtu() const + { + return _buff_size; + } + + size_t get_chdr_hdr_len() const + { + return sizeof(packet_info_t); + } + size_t get_max_payload_size() const { - return _buff_size - sizeof(packet_info_t); + return get_mtu() - sizeof(packet_info_t); } + private: size_t _buff_size; buff_t::uptr _buff; diff --git a/host/tests/tx_streamer_test.cpp b/host/tests/tx_streamer_test.cpp index 75511c329..11e33d413 100644 --- a/host/tests/tx_streamer_test.cpp +++ b/host/tests/tx_streamer_test.cpp @@ -53,10 +53,19 @@ public: _send_link->release_send_buff(std::move(buff)); } + size_t get_mtu() const + { + return _send_link->get_send_frame_size(); + } + + size_t get_chdr_hdr_len() const + { + return sizeof(packet_info_t); + } + size_t get_max_payload_size() const { - return _send_link->get_send_frame_size() - sizeof(packet_info_t); - ; + return get_mtu() - get_chdr_hdr_len(); } private: |