summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2018-12-08 20:31:16 +0100
committerRenato Westphal <renato@opensourcerouting.org>2018-12-09 16:58:53 +0100
commit99fb518fef7d40c20921ce63764e7578d1149fa8 (patch)
treec2f15f9d552ed00f4cc1b5f8bbf3dbbc30a71b26 /tests/lib
parentMerge pull request #3449 from opensourcerouting/network-wide-transactions (diff)
downloadfrr-99fb518fef7d40c20921ce63764e7578d1149fa8.tar.xz
frr-99fb518fef7d40c20921ce63764e7578d1149fa8.zip
lib, tests: add support for keyless YANG lists
YANG allows lists without keys for operational data, in which case the list elements are uniquely identified using a positional index (starting from one). This commit does the following: * Remove the need to implement the 'get_keys' and 'lookup_entry' callbacks for keyless lists. * Extend nb_oper_data_iter_list() so that it special-cases keyless lists appropriately. Since both the CLI and the sysrepo plugin use nb_oper_data_iterate() to fetch operational data, both these northbound clients automatically gain the ability to understand keyless lists without additional changes. * Extend the confd plugin to special-case keyless lists as well. This was a bit painful to implement given ConfD's clumsy API, but keyless lists should work ok now. * Update the "test_oper_data" unit test to test keyless YANG lists in addition to regular lists. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/northbound/test_oper_data.c35
1 files changed, 0 insertions, 35 deletions
diff --git a/tests/lib/northbound/test_oper_data.c b/tests/lib/northbound/test_oper_data.c
index 7c5713d8f..7cd622854 100644
--- a/tests/lib/northbound/test_oper_data.c
+++ b/tests/lib/northbound/test_oper_data.c
@@ -153,39 +153,6 @@ frr_test_module_vrfs_vrf_routes_route_get_next(const void *parent_list_entry,
return node;
}
-static int
-frr_test_module_vrfs_vrf_routes_route_get_keys(const void *list_entry,
- struct yang_list_keys *keys)
-{
- const struct troute *route;
-
- route = listgetdata((struct listnode *)list_entry);
-
- keys->num = 1;
- (void)prefix2str(&route->prefix, keys->key[0], sizeof(keys->key[0]));
-
- return NB_OK;
-}
-
-static const void *frr_test_module_vrfs_vrf_routes_route_lookup_entry(
- const void *parent_list_entry, const struct yang_list_keys *keys)
-{
- const struct tvrf *vrf;
- const struct troute *route;
- struct listnode *node;
- struct prefix prefix;
-
- yang_str2ipv4p(keys->key[0], &prefix);
-
- vrf = listgetdata((struct listnode *)parent_list_entry);
- for (ALL_LIST_ELEMENTS_RO(vrf->routes, node, route)) {
- if (prefix_same((struct prefix *)&route->prefix, &prefix))
- return node;
- }
-
- return NULL;
-}
-
/*
* XPath: /frr-test-module:frr-test-module/vrfs/vrf/routes/route/prefix
*/
@@ -276,8 +243,6 @@ const struct frr_yang_module_info frr_test_module_info = {
{
.xpath = "/frr-test-module:frr-test-module/vrfs/vrf/routes/route",
.cbs.get_next = frr_test_module_vrfs_vrf_routes_route_get_next,
- .cbs.get_keys = frr_test_module_vrfs_vrf_routes_route_get_keys,
- .cbs.lookup_entry = frr_test_module_vrfs_vrf_routes_route_lookup_entry,
},
{
.xpath = "/frr-test-module:frr-test-module/vrfs/vrf/routes/route/prefix",