diff options
author | Martin Braun <martin.braun@ettus.com> | 2019-05-30 13:55:36 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:20 -0800 |
commit | 0347974ae3cc36bc0cadf4add080f5ea8781a295 (patch) | |
tree | 2e2ac15d5ea3b3599ecd07e6f65fcf502527833a /host/tests | |
parent | e87b21408873ca34a575a3658dfa00d7fa80ecb8 (diff) | |
download | uhd-0347974ae3cc36bc0cadf4add080f5ea8781a295.tar.gz uhd-0347974ae3cc36bc0cadf4add080f5ea8781a295.tar.bz2 uhd-0347974ae3cc36bc0cadf4add080f5ea8781a295.zip |
rfnoc: node: Fix resolution of properties with circular dependencies
When a node has multiple properties that depend on each other (and
possible have circular dependencies), the previous version of property
propagation would not correctly resolve properties that got flagged
dirty during the execution of other resolvers.
Diffstat (limited to 'host/tests')
-rw-r--r-- | host/tests/rfnoc_propprop_test.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/host/tests/rfnoc_propprop_test.cpp b/host/tests/rfnoc_propprop_test.cpp index 1b9b94b05..20d7d96f5 100644 --- a/host/tests/rfnoc_propprop_test.cpp +++ b/host/tests/rfnoc_propprop_test.cpp @@ -111,6 +111,52 @@ private: property_t<double> _out{"out", 2.0, {res_source_info::OUTPUT_EDGE}}; }; +/*! Mock node, circular prop deps + */ +class mock_circular_prop_node_t : public node_t +{ +public: + mock_circular_prop_node_t() + { + register_property(&_x1); + register_property(&_x2); + register_property(&_x4); + + add_property_resolver({&_x1}, {&_x2}, [this]() { + RFNOC_LOG_INFO("Calling resolver for _x1"); + _x2 = 2.0 * _x1.get(); + }); + add_property_resolver({&_x2}, {&_x4}, [this]() { + RFNOC_LOG_INFO("Calling resolver for _x2"); + _x4 = 2.0 * _x2.get(); + }); + add_property_resolver({&_x4}, {&_x1}, [this]() { + RFNOC_LOG_INFO("Calling resolver for _x4"); + _x1 = _x4.get() / 4.0; + }); + } + + size_t get_num_input_ports() const + { + return 1; + } + + size_t get_num_output_ports() const + { + return 1; + } + + std::string get_unique_id() const + { + return "MOCK_CIRCULAR_PROPS"; + } + + property_t<double> _x1{"x1", 1.0, {res_source_info::USER}}; + property_t<double> _x2{"x2", 2.0, {res_source_info::USER}}; + property_t<double> _x4{"x4", 4.0, {res_source_info::USER}}; +}; + + // Do some sanity checks on the mock just so we don't get surprised later BOOST_AUTO_TEST_CASE(test_mock) { @@ -364,3 +410,17 @@ BOOST_AUTO_TEST_CASE(test_graph_crisscross_fifo) UHD_LOG_INFO("TEST", "Now testing criss-cross prop resolution"); graph.initialize(); } + +BOOST_AUTO_TEST_CASE(test_circular_deps) +{ + node_accessor_t node_accessor{}; + // Define some mock nodes: + // Source radios + mock_circular_prop_node_t mock_circular_prop_node{}; + + // These init calls would normally be done by the framework + node_accessor.init_props(&mock_circular_prop_node); + + mock_circular_prop_node.set_property<double>("x1", 5.0, 0); + BOOST_CHECK_EQUAL(mock_circular_prop_node.get_property<double>("x4"), 4 * 5.0); +} |