aboutsummaryrefslogtreecommitdiffstats
path: root/host/tests/rfnoc_property_test.cpp
diff options
context:
space:
mode:
authorAaron Rossetto <aaron.rossetto@ni.com>2020-07-22 12:51:21 -0500
committerAaron Rossetto <aaron.rossetto@ni.com>2020-07-24 13:15:30 -0500
commita5fe0b071d7041f0539804cd16ada27d920bc96d (patch)
tree840f254f2f2d0165681706f7c539bdc48a52e67f /host/tests/rfnoc_property_test.cpp
parent4b01628cad132db68ec1cc8cce211f2df0f62770 (diff)
downloaduhd-a5fe0b071d7041f0539804cd16ada27d920bc96d.tar.gz
uhd-a5fe0b071d7041f0539804cd16ada27d920bc96d.tar.bz2
uhd-a5fe0b071d7041f0539804cd16ada27d920bc96d.zip
rfnoc: Support instance overrides in set_properties()
This commit adds an enhancement to node_t::set_properties() in which the instance argument provided to the function (which normally applies to all properties in the key/value list) can be overridden on a per-property basis using a special syntax. If the key consists of the property name followed by a colon (':') and then a number, the number following the colon is used to determine which instance of the property this set pertains to, and the value passed via the instance parameter is ignored for that property. For example, in the following call: node->set_properties("dog=10,cat:2=5,bird:0=0.5", 1) instance 1 of node's 'dog' property is set to 10, the 1 coming from the instance parameter, instance 2 of the node's 'cat' property is set to 5 due to the override syntax provided in the string, and instance 0 of the node's 'bird' property is set to 0.5 due to its override. If the name/instance pair is malformed, e.g. 'value:=10' or 'value:foobar=10', a runtime error is thrown.
Diffstat (limited to 'host/tests/rfnoc_property_test.cpp')
-rw-r--r--host/tests/rfnoc_property_test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/host/tests/rfnoc_property_test.cpp b/host/tests/rfnoc_property_test.cpp
index eb22424b1..d1a8ba981 100644
--- a/host/tests/rfnoc_property_test.cpp
+++ b/host/tests/rfnoc_property_test.cpp
@@ -65,6 +65,19 @@ BOOST_AUTO_TEST_CASE(test_get_set)
BOOST_CHECK(prop_i.is_dirty());
}
+BOOST_AUTO_TEST_CASE(test_valid_names)
+{
+ bool value_error_caught = false;
+ try {
+ property_t<int> prop_i{"int_prop:0", 10, {res_source_info::USER, 0}};
+ } catch(const uhd::value_error& e) {
+ value_error_caught = true;
+ } catch(...) {
+ }
+
+ BOOST_CHECK(value_error_caught);
+}
+
BOOST_AUTO_TEST_CASE(test_lock)
{
prop_accessor_t prop_accessor;