diff options
author | michael-west <michael.west@ettus.com> | 2020-07-27 22:20:09 -0700 |
---|---|---|
committer | Aaron Rossetto <aaron.rossetto@ni.com> | 2020-08-04 15:41:07 -0500 |
commit | 18aeb2077b8c6a339f833fb53d90171a359175be (patch) | |
tree | c564ed974164f2433981855b52cec687af89f583 /host/tests | |
parent | 6647dacff16c15c0dc55b81f7f2a7a8e07ff2699 (diff) | |
download | uhd-18aeb2077b8c6a339f833fb53d90171a359175be.tar.gz uhd-18aeb2077b8c6a339f833fb53d90171a359175be.tar.bz2 uhd-18aeb2077b8c6a339f833fb53d90171a359175be.zip |
tests: Add graph disconnect/reconnect unit test
Signed-off-by: michael-west <michael.west@ettus.com>
Diffstat (limited to 'host/tests')
-rw-r--r-- | host/tests/rfnoc_detailgraph_test.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/host/tests/rfnoc_detailgraph_test.cpp b/host/tests/rfnoc_detailgraph_test.cpp index 9a2a57ce4..ec4ba36f5 100644 --- a/host/tests/rfnoc_detailgraph_test.cpp +++ b/host/tests/rfnoc_detailgraph_test.cpp @@ -221,3 +221,40 @@ BOOST_AUTO_TEST_CASE(test_graph_unresolvable) uhd::resolve_error); UHD_LOG_INFO("TEST", "^^^ Expected ERROR here."); } + +BOOST_AUTO_TEST_CASE(test_graph_disconnect_reconnect) +{ + graph_t graph{}; + node_accessor_t node_accessor{}; + + // Define some mock nodes: + // Source radio + mock_radio_node_t mock_rx_radio(0); + // Sink radio + mock_radio_node_t mock_tx_radio(1); + + // These init calls would normally be done by the framework + node_accessor.init_props(&mock_rx_radio); + node_accessor.init_props(&mock_tx_radio); + + uhd::rfnoc::detail::graph_t::graph_edge_t edge_info( + 0, 0, graph_t::graph_edge_t::DYNAMIC, true); + + // Now create the graph and commit: + graph.connect(&mock_rx_radio, &mock_tx_radio, edge_info); + graph.commit(); + + BOOST_CHECK_EQUAL(graph.enumerate_edges().size(), 1); + + // disconnect: + graph.disconnect(&mock_rx_radio, &mock_tx_radio, edge_info); + graph.release(); + + BOOST_CHECK_EQUAL(graph.enumerate_edges().size(), 0); + + // Reconnect: + graph.connect(&mock_rx_radio, &mock_tx_radio, edge_info); + graph.commit(); + + BOOST_CHECK_EQUAL(graph.enumerate_edges().size(), 1); +} |