summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2024-12-19 07:58:03 -0600
committerChristian Hopps <chopps@labn.net>2025-01-07 07:01:46 -0500
commite729676cfe7d0074484bba3fab9840baa2192818 (patch)
tree23f3e5f14243928bf3afb2367ea1688a037802a8
parent4379066fdd111a3c07152ad7ac9f3df6133c135a (diff)
tests: add test for new northbound get function
Signed-off-by: Christian Hopps <chopps@labn.net>
-rw-r--r--tests/lib/northbound/test_oper_data.c41
-rw-r--r--tests/lib/northbound/test_oper_data.refout12
-rw-r--r--yang/frr-test-module.yang3
3 files changed, 52 insertions, 4 deletions
diff --git a/tests/lib/northbound/test_oper_data.c b/tests/lib/northbound/test_oper_data.c
index 3d700d8a19..0b334c6522 100644
--- a/tests/lib/northbound/test_oper_data.c
+++ b/tests/lib/northbound/test_oper_data.c
@@ -120,6 +120,26 @@ static const void *frr_test_module_vrfs_vrf_interfaces_interface_get_next(
}
/*
+ * XPath: /frr-test-module:frr-test-module/vrfs/vrf/interfaces/interface-new
+ */
+static enum nb_error frr_test_module_vrfs_vrf_interfaces_interface_new_get(
+ const struct nb_node *nb_node, const void *parent_list_entry, struct lyd_node *parent)
+{
+ const struct lysc_node *snode = nb_node->snode;
+ const struct tvrf *vrf;
+ struct listnode *node;
+ const char *interface;
+ LY_ERR err;
+
+ vrf = listgetdata((struct listnode *)parent_list_entry);
+ for (ALL_LIST_ELEMENTS_RO(vrf->interfaces, node, interface)) {
+ err = lyd_new_term(parent, snode->module, snode->name, interface, false, NULL);
+ assert(err == LY_SUCCESS);
+ }
+ return NB_OK;
+}
+
+/*
* XPath: /frr-test-module:frr-test-module/vrfs/vrf/routes/route
*/
static const void *
@@ -228,10 +248,19 @@ frr_test_module_c1value_get_elem(struct nb_cb_get_elem_args *args)
/*
* XPath: /frr-test-module:frr-test-module/c2cont/c2value
*/
-static struct yang_data *
-frr_test_module_c2cont_c2value_get_elem(struct nb_cb_get_elem_args *args)
+static enum nb_error frr_test_module_c2cont_c2value_get(const struct nb_node *nb_node,
+ const void *parent_list_entry,
+ struct lyd_node *parent)
{
- return yang_data_new_uint32(args->xpath, 0xAB010203);
+ const struct lysc_node *snode = nb_node->snode;
+ uint32_t value = 0xAB010203;
+ LY_ERR err;
+
+ err = lyd_new_term_bin(parent, snode->module, snode->name, &value, sizeof(value),
+ LYD_NEW_PATH_UPDATE, NULL);
+ assert(err == LY_SUCCESS);
+
+ return NB_OK;
}
/* clang-format off */
@@ -254,6 +283,10 @@ const struct frr_yang_module_info frr_test_module_info = {
.cbs.get_next = frr_test_module_vrfs_vrf_interfaces_interface_get_next,
},
{
+ .xpath = "/frr-test-module:frr-test-module/vrfs/vrf/interfaces/interface-new",
+ .cbs.get = frr_test_module_vrfs_vrf_interfaces_interface_new_get,
+ },
+ {
.xpath = "/frr-test-module:frr-test-module/vrfs/vrf/routes/route",
.cbs.get_next = frr_test_module_vrfs_vrf_routes_route_get_next,
},
@@ -287,7 +320,7 @@ const struct frr_yang_module_info frr_test_module_info = {
},
{
.xpath = "/frr-test-module:frr-test-module/c2cont/c2value",
- .cbs.get_elem = frr_test_module_c2cont_c2value_get_elem,
+ .cbs.get = frr_test_module_c2cont_c2value_get,
},
{
.xpath = NULL,
diff --git a/tests/lib/northbound/test_oper_data.refout b/tests/lib/northbound/test_oper_data.refout
index 7c56564143..eadb639645 100644
--- a/tests/lib/northbound/test_oper_data.refout
+++ b/tests/lib/northbound/test_oper_data.refout
@@ -11,6 +11,12 @@ test# show yang operational-data /frr-test-module:frr-test-module
"eth1",
"eth2",
"eth3"
+ ],
+ "interface-new": [
+ "eth0",
+ "eth1",
+ "eth2",
+ "eth3"
]
},
"routes": {
@@ -65,6 +71,12 @@ test# show yang operational-data /frr-test-module:frr-test-module
"eth1",
"eth2",
"eth3"
+ ],
+ "interface-new": [
+ "eth0",
+ "eth1",
+ "eth2",
+ "eth3"
]
},
"routes": {
diff --git a/yang/frr-test-module.yang b/yang/frr-test-module.yang
index dcf204a956..90086d05a2 100644
--- a/yang/frr-test-module.yang
+++ b/yang/frr-test-module.yang
@@ -60,6 +60,9 @@ module frr-test-module {
leaf-list interface {
type frr-interface:interface-ref;
}
+ leaf-list interface-new {
+ type frr-interface:interface-ref;
+ }
}
container routes {
list route {