From 27858fe5c8a512fe3a332d70e20847697e7a50c9 Mon Sep 17 00:00:00 2001 From: Aaron Rossetto Date: Tue, 17 Nov 2020 13:52:51 -0600 Subject: tests: Add UT for node removal prop resol'n restoration --- host/tests/rfnoc_propprop_test.cpp | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'host/tests/rfnoc_propprop_test.cpp') 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("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("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("decim", disconnected_interp_ratio, 0); + BOOST_CHECK_EQUAL(mock_ddc._samp_rate_in.get() / disconnected_interp_ratio, + mock_ddc._samp_rate_out.get()); +} -- cgit v1.2.3