From b90161ccd3b318f3314a23cb10c387651ad35831 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 06:23:18 +0200 Subject: Adding upstream version 2.1.148. Signed-off-by: Daniel Baumann --- tests/utests/extensions/test_schema_mount.c | 121 +++++++++++++++++++++++++--- 1 file changed, 112 insertions(+), 9 deletions(-) (limited to 'tests/utests/extensions/test_schema_mount.c') diff --git a/tests/utests/extensions/test_schema_mount.c b/tests/utests/extensions/test_schema_mount.c index be879ec..17a4c94 100644 --- a/tests/utests/extensions/test_schema_mount.c +++ b/tests/utests/extensions/test_schema_mount.c @@ -75,7 +75,7 @@ test_schema(void **state) assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL)); CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": " "Extension \"yangmnt:mount-point\" instance not allowed in YANG version 1 module.", - "/sm:root/{extension='yangmnt:mount-point'}/root"); + "Path \"/sm:root/{extension='yangmnt:mount-point'}/root\"."); schema = "module sm {\n" @@ -92,7 +92,7 @@ test_schema(void **state) assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL)); CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": " "Extension \"yangmnt:mount-point\" instance allowed only in container or list statement.", - "/sm:{extension='yangmnt:mount-point'}/root"); + "Path \"/sm:{extension='yangmnt:mount-point'}/root\"."); schema = "module sm {\n" @@ -114,7 +114,7 @@ test_schema(void **state) assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL)); CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": " "Extension \"yangmnt:mount-point\" instance allowed only in container or list statement.", - "/sm:root/l/{extension='yangmnt:mount-point'}/root"); + "Path \"/sm:root/l/{extension='yangmnt:mount-point'}/root\"."); schema = "module sm {\n" @@ -138,7 +138,7 @@ test_schema(void **state) assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL)); CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": " "Multiple extension \"yangmnt:mount-point\" instances.", - "/sm:l/{extension='yangmnt:mount-point'}/root"); + "Path \"/sm:l/{extension='yangmnt:mount-point'}/root\"."); /* valid */ schema = @@ -410,25 +410,25 @@ test_parse_invalid(void **state) CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data); CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": " "Mandatory node \"type\" instance does not exist.", - "Schema location \"/ietf-interfaces:interfaces/interface/type\"."); + "Data location \"/ietf-interfaces:interfaces/interface[name='bu']\"."); CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data); CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": " "Mandatory node \"type\" instance does not exist.", - "Schema location \"/ietf-interfaces:interfaces/interface/type\"."); + "Data location \"/ietf-interfaces:interfaces/interface[name='bu']\"."); /* same validation fail in separate validation */ CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT | LYD_PARSE_ONLY, 0, LY_SUCCESS, data); assert_int_equal(LY_EVALID, lyd_validate_all(&data, NULL, LYD_VALIDATE_PRESENT, NULL)); CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": " "Mandatory node \"type\" instance does not exist.", - "Schema location \"/ietf-interfaces:interfaces/interface/type\"."); + "Data location \"/ietf-interfaces:interfaces/interface[name='bu']\"."); lyd_free_siblings(data); CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT | LYD_PARSE_ONLY, 0, LY_SUCCESS, data); assert_int_equal(LY_EVALID, lyd_validate_all(&data, NULL, LYD_VALIDATE_PRESENT, NULL)); CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": " "Mandatory node \"type\" instance does not exist.", - "Schema location \"/ietf-interfaces:interfaces/interface/type\"."); + "Data location \"/ietf-interfaces:interfaces/interface[name='bu']\"."); lyd_free_siblings(data); /* success */ @@ -878,7 +878,7 @@ test_parse_shared(void **state) CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data); CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": " "Shared-schema yang-library content-id \"2\" differs from \"1\" used previously.", - "/ietf-yang-library:yang-library/content-id"); + "Path \"/ietf-yang-library:yang-library/content-id\"."); /* data for 2 mount points */ ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb, @@ -1549,6 +1549,108 @@ test_new(void **state) lyd_free_siblings(data); } +static void +test_lys_getnext(void **state) +{ + const struct lysc_node *parent, *node; + struct ly_ctx *sm_ctx; + + ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb, + "" + " " + " test-set" + " " + " ietf-datastores" + " 2018-02-14" + " urn:ietf:params:xml:ns:yang:ietf-datastores" + " " + " " + " ietf-yang-library" + " 2019-01-04" + " urn:ietf:params:xml:ns:yang:ietf-yang-library" + " " + " " + " ietf-yang-schema-mount" + " 2019-01-14" + " urn:ietf:params:xml:ns:yang:ietf-yang-schema-mount" + " " + " " + " ietf-interfaces" + " 2014-05-08" + " urn:ietf:params:xml:ns:yang:ietf-interfaces" + " " + " " + " iana-if-type" + " 2014-05-08" + " urn:ietf:params:xml:ns:yang:iana-if-type" + " " + " " + " ietf-ip" + " 2014-06-16" + " urn:ietf:params:xml:ns:yang:ietf-ip" + " " + " " + " ietf-yang-types" + " 2013-07-15" + " urn:ietf:params:xml:ns:yang:ietf-yang-types" + " " + " " + " " + " test-schema" + " test-set" + " " + " " + " ds:running" + " test-schema" + " " + " " + " ds:operational" + " test-schema" + " " + " 1" + "" + "" + " 1" + "" + "" + " " + " sm" + " " + " " + " " + ""); + + parent = lys_find_path(UTEST_LYCTX, NULL, "/sm:root", 0); + assert_non_null(parent); + + node = lys_getnext(NULL, parent, NULL, LYS_GETNEXT_WITHSCHEMAMOUNT); + assert_non_null(node); + assert_string_equal(node->name, "schema-mounts"); + sm_ctx = node->module->ctx; + + node = lys_getnext(node, parent, NULL, LYS_GETNEXT_WITHSCHEMAMOUNT); + assert_non_null(node); + assert_string_equal(node->name, "yang-library"); + + node = lys_getnext(node, parent, NULL, LYS_GETNEXT_WITHSCHEMAMOUNT); + assert_non_null(node); + assert_string_equal(node->name, "modules-state"); + + node = lys_getnext(node, parent, NULL, LYS_GETNEXT_WITHSCHEMAMOUNT); + assert_non_null(node); + assert_string_equal(node->name, "interfaces"); + + node = lys_getnext(node, parent, NULL, LYS_GETNEXT_WITHSCHEMAMOUNT); + assert_non_null(node); + assert_string_equal(node->name, "interfaces-state"); + + node = lys_getnext(node, parent, NULL, LYS_GETNEXT_WITHSCHEMAMOUNT); + assert_null(node); + + ly_ctx_destroy(sm_ctx); +} + int main(void) { @@ -1560,6 +1662,7 @@ main(void) UTEST(test_parse_shared_parent_ref, setup), UTEST(test_parse_config, setup), UTEST(test_new, setup), + UTEST(test_lys_getnext, setup), }; return cmocka_run_group_tests(tests, NULL, NULL); -- cgit v1.2.3