aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Rossetto <aaron.rossetto@ni.com>2020-11-17 13:52:51 -0600
committerAaron Rossetto <aaron.rossetto@ni.com>2020-11-20 07:21:52 -0600
commit27858fe5c8a512fe3a332d70e20847697e7a50c9 (patch)
treed00883bedf6f8fb07aa801b3e1f54e7ff758f4b8
parentcdcdcf5fb2308ba1dd27fbb3c8a28f6e92e13a37 (diff)
downloaduhd-27858fe5c8a512fe3a332d70e20847697e7a50c9.tar.gz
uhd-27858fe5c8a512fe3a332d70e20847697e7a50c9.tar.bz2
uhd-27858fe5c8a512fe3a332d70e20847697e7a50c9.zip
tests: Add UT for node removal prop resol'n restoration
-rw-r--r--host/tests/rfnoc_propprop_test.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/host/tests/rfnoc_propprop_test.cpp b/host/tests/rfnoc_propprop_test.cpp
index 224783e22..f07e9848e 100644
--- a/host/tests/rfnoc_propprop_test.cpp
+++ b/host/tests/rfnoc_propprop_test.cpp
@@ -540,3 +540,56 @@ BOOST_AUTO_TEST_CASE(test_propagation_map_exception_invalid_destination)
BOOST_REQUIRE_THROW(graph.commit(), uhd::rfnoc_error);
}
+BOOST_AUTO_TEST_CASE(test_graph_node_deletion_resolver_fix)
+{
+ node_accessor_t node_accessor{};
+ uhd::rfnoc::detail::graph_t graph{};
+
+ // First node: Source radio
+ mock_radio_node_t mock_rx_radio(0);
+ // Second node: DDC
+ mock_ddc_node_t mock_ddc{};
+
+ // These init calls would normally be done by the framework
+ node_accessor.init_props(&mock_rx_radio);
+ node_accessor.init_props(&mock_ddc);
+
+ // The DDC node at this point is not and has never been part of a
+ // graph, but setting the decimation property should still invoke
+ // that resolver
+ constexpr int new_interp_ratio = 100;
+ mock_ddc.set_property<int>("decim", new_interp_ratio, 0);
+ BOOST_CHECK_EQUAL(
+ mock_ddc._samp_rate_in.get() / new_interp_ratio, mock_ddc._samp_rate_out.get());
+
+ // Connect the radio to the DDC in a simple graph
+ uhd::rfnoc::detail::graph_t::graph_edge_t edge_info;
+ edge_info.src_port = 0;
+ edge_info.dst_port = 0;
+ edge_info.property_propagation_active = true;
+ edge_info.edge = uhd::rfnoc::detail::graph_t::graph_edge_t::DYNAMIC;
+
+ graph.connect(&mock_rx_radio, &mock_ddc, edge_info);
+ BOOST_CHECK_EQUAL(mock_ddc._decim.get(), new_interp_ratio);
+
+ // Set the radio MCR; after graph committal, that should propagate
+ // to the DDC input rate
+ const int ddc_input_rate = mock_ddc._samp_rate_in.get();
+ mock_rx_radio.set_property<double>("master_clock_rate", 100e6, 0);
+ BOOST_CHECK_EQUAL(mock_ddc._samp_rate_in.get(), ddc_input_rate);
+ graph.commit();
+ BOOST_CHECK_EQUAL(mock_ddc._samp_rate_in.get(), 100e6);
+
+ // Now disconect the DDC from the radio--as there are no incoming or
+ // outgoing edges on either node afterwards, the nodes should be removed
+ // from the graph altogether and thus their resolver callbacks should
+ // also be reset to the default behavior
+ graph.disconnect(&mock_rx_radio, &mock_ddc, edge_info);
+
+ // Setting a new decimation ratio even after the DDC node has been
+ // removed from the graph should work as expected
+ constexpr int disconnected_interp_ratio = 20;
+ mock_ddc.set_property<int>("decim", disconnected_interp_ratio, 0);
+ BOOST_CHECK_EQUAL(mock_ddc._samp_rate_in.get() / disconnected_interp_ratio,
+ mock_ddc._samp_rate_out.get());
+}