test: rfnoc: Add tests for Tune Requests

This adds tests for action forwarding in DDC and DUC block tests which
are required for Tune Requests in RFNoC.

Co-authored-by: Riya Alias <riya.alias@ni.com>
This commit is contained in:
Martin Anderseck 2024-10-02 10:52:55 +02:00 committed by joergho
parent 7833aa71c3
commit fc7123e5e9
5 changed files with 62 additions and 4 deletions

View File

@ -66,8 +66,8 @@ BOOST_AUTO_TEST_CASE(test_ddc_block)
edge_info.is_forward_edge = true;
edge_info.edge = detail::graph_t::graph_edge_t::DYNAMIC;
mock_terminator_t mock_source_term(1);
mock_terminator_t mock_sink_term(1);
mock_terminator_t mock_source_term(1, {ACTION_KEY_TUNE_REQUEST});
mock_terminator_t mock_sink_term(1, {ACTION_KEY_TUNE_REQUEST});
UHD_LOG_INFO("TEST", "Priming mock source node props");
mock_source_term.set_edge_property<std::string>(
@ -142,4 +142,24 @@ BOOST_AUTO_TEST_CASE(test_ddc_block)
test_ddc->set_properties(uhd::device_addr_t("decim=1,freq=0.0,foo=bar"), 0);
BOOST_CHECK_EQUAL(test_ddc->get_property<int>("decim", 0), 1);
BOOST_CHECK_EQUAL(test_ddc->get_property<double>("freq", 0), 0.0);
// Check that an action originating on an input stream is forwarded to
// the port corresponding to that stream on all output branches.
UHD_LOG_INFO("TEST", "DDC: Testing Tune request action forwarding");
uhd::tune_request_t tune_request(70e6, 20e6);
auto tune_req_action = uhd::rfnoc::tune_request_action_info::make(tune_request);
tune_req_action->tune_request = tune_request;
node_accessor.post_action(
&mock_source_term, {res_source_info::OUTPUT_EDGE, 0}, tune_req_action);
BOOST_REQUIRE(!mock_sink_term.received_actions.empty());
auto tune_req_received = std::dynamic_pointer_cast<tune_request_action_info>(
mock_sink_term.received_actions.back());
BOOST_CHECK(tune_req_received);
BOOST_CHECK_EQUAL(
tune_req_received->tune_request.target_freq, tune_request.target_freq);
BOOST_CHECK_CLOSE(tune_req_received->tune_result.target_dsp_freq,
tune_req_received->tune_result.actual_dsp_freq,
1e-5);
}

View File

@ -62,8 +62,9 @@ BOOST_AUTO_TEST_CASE(test_duc_block)
edge_info.is_forward_edge = true;
edge_info.edge = detail::graph_t::graph_edge_t::DYNAMIC;
mock_terminator_t mock_source_term(1, {ACTION_KEY_STREAM_CMD});
mock_terminator_t mock_sink_term(1, {ACTION_KEY_STREAM_CMD});
mock_terminator_t mock_source_term(
1, {ACTION_KEY_STREAM_CMD, ACTION_KEY_TUNE_REQUEST});
mock_terminator_t mock_sink_term(1, {ACTION_KEY_STREAM_CMD, ACTION_KEY_TUNE_REQUEST});
UHD_LOG_INFO("TEST", "Priming mock source node props");
mock_source_term.set_edge_property<std::string>(
@ -188,4 +189,19 @@ BOOST_AUTO_TEST_CASE(test_duc_block)
mock_sink_term.received_actions.back());
BOOST_CHECK(stream_cmd_recv_by_src3);
BOOST_CHECK_EQUAL(stream_cmd_recv_by_src3->stream_cmd.num_samps, 100 * TEST_INTERP);
UHD_LOG_INFO("TEST", "DUC: Testing Tune Request action forwarding");
uhd::tune_request_t tune_request(70e6, 20e6);
auto tune_req_action = uhd::rfnoc::tune_request_action_info::make(tune_request);
tune_req_action->tune_request = tune_request;
node_accessor.post_action(
&mock_sink_term, {res_source_info::INPUT_EDGE, 0}, tune_req_action);
BOOST_REQUIRE(!mock_source_term.received_actions.empty());
auto tune_req_received = std::dynamic_pointer_cast<tune_request_action_info>(
mock_source_term.received_actions.back());
BOOST_CHECK(tune_req_received);
BOOST_CHECK_EQUAL(
abs(tune_req_received->tune_request.target_freq), tune_request.target_freq);
BOOST_CHECK_CLOSE(tune_req_received->tune_result.target_dsp_freq,
tune_req_received->tune_result.actual_dsp_freq,
1e-5);
}

View File

@ -126,6 +126,11 @@ public:
void issue_stream_cmd(const stream_cmd_t&) override {}
void post_input_action(
const std::shared_ptr<uhd::rfnoc::action_info>&, const size_t) override
{
}
void set_tick_rate(double rate)
{
rx_streamer_impl::set_tick_rate(rate);

View File

@ -196,6 +196,11 @@ public:
}
void issue_stream_cmd(const stream_cmd_t& /*stream_cmd*/) override {}
void post_input_action(
const std::shared_ptr<uhd::rfnoc::action_info>&, const size_t) override
{
}
};
/*!
@ -230,6 +235,11 @@ public:
{
return false;
}
void post_output_action(
const std::shared_ptr<uhd::rfnoc::action_info>&, const size_t) override
{
}
};
using rx_streamer_mock_xport = mock_rx_streamer<mock_rx_data_xport>;

View File

@ -68,6 +68,7 @@ public:
return get_mtu() - get_chdr_hdr_len();
}
private:
mock_send_link::sptr _send_link;
};
@ -103,6 +104,12 @@ public:
{
return false;
}
void post_output_action(
const std::shared_ptr<uhd::rfnoc::action_info>&, const size_t) override
{
// NOP
}
};
}} // namespace uhd::transport