plugins exts CHANGE ext parsing isolated into a callback
Lots of refactoring and finishing up included.
diff --git a/tests/plugins/simple.c b/tests/plugins/simple.c
index b910f9e..a794804 100644
--- a/tests/plugins/simple.c
+++ b/tests/plugins/simple.c
@@ -23,18 +23,18 @@
*/
/**
- * @brief Compile NAMC's extension instances.
+ * @brief Compile simple extension instances.
*
* Implementation of ::lyplg_ext_compile_clb callback set as lyext_plugin::compile.
*/
static LY_ERR
-hint_compile(struct lysc_ctx *cctx, const struct lysp_ext_instance *p_ext, struct lysc_ext_instance *c_ext)
+hint_compile(struct lysc_ctx *cctx, const struct lysp_ext_instance *extp, struct lysc_ext_instance *ext)
{
/* check that the extension is instantiated at an allowed place - data node */
- if (!LY_STMT_IS_DATA_NODE(c_ext->parent_stmt)) {
- lyplg_ext_log(c_ext, LY_LLWRN, 0, lysc_ctx_get_path(cctx),
+ if (!(ext->parent_stmt & LY_STMT_DATA_NODE_MASK)) {
+ lyplg_ext_compile_log(cctx, ext, LY_LLWRN, 0,
"Extension %s is allowed only in a data nodes, but it is placed in \"%s\" statement.",
- p_ext->name, ly_stmt2str(c_ext->parent_stmt));
+ extp->name, lyplg_ext_stmt2str(ext->parent_stmt));
return LY_ENOT;
}
@@ -50,13 +50,15 @@
.revision = NULL,
.name = "hint",
- .plugin.id = "libyang 2 - simple test, version 1",
- .plugin.compile = &hint_compile,
+ .plugin.id = "ly2 simple test v1",
+ .plugin.parse = NULL,
+ .plugin.compile = hint_compile,
.plugin.sprinter = NULL,
- .plugin.free = NULL,
.plugin.node = NULL,
.plugin.snode = NULL,
- .plugin.validate = NULL
+ .plugin.validate = NULL,
+ .plugin.pfree = NULL,
+ .plugin.cfree = NULL
},
{0} /* terminating zeroed item */
};
@@ -76,7 +78,7 @@
.revision = NULL,
.name = "note",
- .plugin.id = "libyang 2 - simple test, version 1",
+ .plugin.id = "ly2 simple test v1",
.plugin.store = lyplg_type_store_string,
.plugin.validate = NULL,
.plugin.compare = lyplg_type_compare_simple,
diff --git a/tests/utests/basic/test_context.c b/tests/utests/basic/test_context.c
index 2340d1e..ad81fb4 100644
--- a/tests/utests/basic/test_context.c
+++ b/tests/utests/basic/test_context.c
@@ -814,7 +814,7 @@
LY_ARRAY_FOR(ext, u) {
substmts = ext[u].substmts;
LY_ARRAY_FOR(substmts, v) {
- if (substmts && substmts[v].storage && LY_STMT_IS_NODE(substmts[v].stmt)) {
+ if (substmts && substmts[v].storage && (substmts[v].stmt & LY_STMT_DATA_NODE_MASK)) {
cnode = *(struct lysc_node **)substmts[v].storage;
iter = check;
assert_int_equal(LY_SUCCESS, lysc_tree_dfs_full(cnode, check_node_priv_parsed_is_set, &iter));
@@ -833,7 +833,7 @@
LY_ARRAY_FOR(ext, u) {
substmts = ext[u].substmts;
LY_ARRAY_FOR(substmts, v) {
- if (substmts && substmts[v].storage && LY_STMT_IS_NODE(substmts[v].stmt)) {
+ if (substmts && substmts[v].storage && (substmts[v].stmt & LY_STMT_DATA_NODE_MASK)) {
cnode = *(struct lysc_node **)substmts[v].storage;
if (cnode) {
CHECK_POINTER((struct lysp_node *)cnode->priv, 0);
diff --git a/tests/utests/basic/test_plugins.c b/tests/utests/basic/test_plugins.c
index ef40965..7f3fe40 100644
--- a/tests/utests/basic/test_plugins.c
+++ b/tests/utests/basic/test_plugins.c
@@ -55,12 +55,12 @@
assert_int_equal(LYS_LEAF, leaf->nodetype);
assert_non_null(plugin_t = lyplg_type_plugin_find("libyang-plugins-simple", NULL, "note"));
- assert_string_equal("libyang 2 - simple test, version 1", plugin_t->id);
+ assert_string_equal("ly2 simple test v1", plugin_t->id);
assert_ptr_equal(leaf->type->plugin, plugin_t);
assert_int_equal(1, LY_ARRAY_COUNT(leaf->exts));
assert_non_null(record_e = lyplg_ext_record_find("libyang-plugins-simple", NULL, "hint"));
- assert_string_equal("libyang 2 - simple test, version 1", record_e->plugin.id);
+ assert_string_equal("ly2 simple test v1", record_e->plugin.id);
assert_ptr_equal(leaf->exts[0].def->plugin, &record_e->plugin);
/* the second loading of the same plugin - still success */
diff --git a/tests/utests/basic/test_set.c b/tests/utests/basic/test_set.c
index 5913e62..af39afa 100644
--- a/tests/utests/basic/test_set.c
+++ b/tests/utests/basic/test_set.c
@@ -134,7 +134,7 @@
ly_set_free(new, NULL);
/* duplicate the set - with duplicator, so the new set will point to a different buffer with the same content */
- assert_int_equal(LY_SUCCESS, ly_set_dup(orig, (void *(*)(void *))strdup, &new));
+ assert_int_equal(LY_SUCCESS, ly_set_dup(orig, (void *(*)(const void *))strdup, &new));
assert_non_null(new);
assert_ptr_not_equal(orig, new);
assert_int_equal(orig->count, new->count);
@@ -211,7 +211,7 @@
/* merge without checking duplicities - two items are added into one;
* here also with duplicator */
- assert_int_equal(LY_SUCCESS, ly_set_merge(&one, &two, 1, (void *(*)(void *))strdup));
+ assert_int_equal(LY_SUCCESS, ly_set_merge(&one, &two, 1, (void *(*)(const void *))strdup));
assert_int_equal(3, one.count);
assert_ptr_not_equal(one.objs[1], two.objs[0]);
assert_string_equal(one.objs[1], two.objs[0]);
diff --git a/tests/utests/extensions/test_metadata.c b/tests/utests/extensions/test_metadata.c
index 8ebe67b..f41a51a 100644
--- a/tests/utests/extensions/test_metadata.c
+++ b/tests/utests/extensions/test_metadata.c
@@ -1,9 +1,9 @@
-/*
+/**
* @file test_metadata.c
- * @author: Radek Krejci <rkrejci@cesnet.cz>
+ * @author Radek Krejci <rkrejci@cesnet.cz>
* @brief unit tests for Metadata extension (annotation) support
*
- * Copyright (c) 2019-2020 CESNET, z.s.p.o.
+ * Copyright (c) 2019 - 2022 CESNET, z.s.p.o.
*
* This source code is licensed under BSD 3-Clause License (the "License").
* You may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
{
struct lys_module *mod;
struct lysc_ext_instance *e;
+ const char *units;
const char *data = "module a {yang-version 1.1; namespace urn:tests:extensions:metadata:a; prefix a;"
"import ietf-yang-metadata {prefix md;}"
@@ -40,9 +41,10 @@
UTEST_ADD_MODULE(data, LYS_IN_YANG, feats, &mod);
assert_int_equal(1, LY_ARRAY_COUNT(mod->compiled->exts));
e = &mod->compiled->exts[0];
- assert_non_null(e->data);
+ assert_non_null(e->compiled);
assert_non_null(e->substmts);
- assert_string_equal("meters", *(const char **)e->substmts[ANNOTATION_SUBSTMT_UNITS].storage);
+ lyplg_ext_get_storage(e, LY_STMT_UNITS, (const void **)&units);
+ assert_string_equal("meters", units);
/* invalid */
/* missing mandatory type substatement */
@@ -50,43 +52,48 @@
"import ietf-yang-metadata {prefix md;}"
"md:annotation aa;}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Missing mandatory keyword \"type\" as a child of \"md:annotation aa\".", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Ext plugin \"ly2 metadata v1\": Missing mandatory keyword \"type\" as a child of \"md:annotation aa\".",
+ "/aa:{extension='md:annotation'}/aa");
/* not allowed substatement */
data = "module aa {yang-version 1.1; namespace urn:tests:extensions:metadata:aa; prefix aa;"
"import ietf-yang-metadata {prefix md;}"
"md:annotation aa {default x;}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Invalid keyword \"default\" as a child of \"md:annotation aa\" extension instance.", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Invalid keyword \"default\" as a child of \"md:annotation aa\" extension instance.",
+ "/aa:{extension='md:annotation'}/aa");
/* invalid cardinality of units substatement */
data = "module aa {yang-version 1.1; namespace urn:tests:extensions:metadata:aa; prefix aa;"
"import ietf-yang-metadata {prefix md;}"
"md:annotation aa {type string; units x; units y;}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Duplicate keyword \"units\".", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Duplicate keyword \"units\".",
+ "/aa:{extension='md:annotation'}/aa");
/* invalid cardinality of status substatement */
data = "module aa {yang-version 1.1; namespace urn:tests:extensions:metadata:aa; prefix aa;"
"import ietf-yang-metadata {prefix md;}"
"md:annotation aa {type string; status current; status obsolete;}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Duplicate keyword \"status\".", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Duplicate keyword \"status\".",
+ "/aa:{extension='md:annotation'}/aa");
/* invalid cardinality of status substatement */
data = "module aa {yang-version 1.1; namespace urn:tests:extensions:metadata:aa; prefix aa;"
"import ietf-yang-metadata {prefix md;}"
"md:annotation aa {type string; type uint8;}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Duplicate keyword \"type\".", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Duplicate keyword \"type\".",
+ "/aa:{extension='md:annotation'}/aa");
/* duplication of the same annotation */
data = "module aa {yang-version 1.1; namespace urn:tests:extensions:metadata:aa; prefix aa;"
"import ietf-yang-metadata {prefix md;}"
"md:annotation aa {type string;} md:annotation aa {type uint8;}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - metadata, version 1\": "
- "Extension md:annotation is instantiated multiple times.", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Ext plugin \"ly2 metadata v1\": Extension md:annotation is instantiated multiple times.",
+ "/aa:{extension='md:annotation'}/aa");
}
static void
@@ -94,7 +101,7 @@
{
struct lys_module *mod;
struct lysc_ext_instance *e;
- const char *data;
+ const char *data, *units;
data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"a\">\n"
"<yang-version value=\"1.1\"/><namespace uri=\"urn:tests:extensions:metadata:a\"/><prefix value=\"a\"/>\n"
@@ -113,9 +120,10 @@
UTEST_ADD_MODULE(data, LYS_IN_YIN, feats, &mod);
assert_int_equal(1, LY_ARRAY_COUNT(mod->compiled->exts));
e = &mod->compiled->exts[0];
- assert_non_null(e->data);
+ assert_non_null(e->compiled);
assert_non_null(e->substmts);
- assert_string_equal("meters", *(const char **)e->substmts[ANNOTATION_SUBSTMT_UNITS].storage);
+ lyplg_ext_get_storage(e, LY_STMT_UNITS, (const void **)&units);
+ assert_string_equal("meters", units);
/* invalid */
/* missing mandatory type substatement */
@@ -125,7 +133,8 @@
"<md:annotation name=\"aa\"/>\n"
"</module>";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
- CHECK_LOG_CTX("Missing mandatory keyword \"type\" as a child of \"md:annotation aa\".", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Ext plugin \"ly2 metadata v1\": Missing mandatory keyword \"type\" as a child of \"md:annotation aa\".",
+ "/aa:{extension='md:annotation'}/aa");
/* not allowed substatement */
data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"aa\">\n"
@@ -135,7 +144,8 @@
" <default value=\"x\"/>\n"
"</md:annotation></module>";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
- CHECK_LOG_CTX("Invalid keyword \"default\" as a child of \"md:annotation aa\" extension instance.", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Invalid keyword \"default\" as a child of \"md:annotation aa\" extension instance.",
+ "/aa:{extension='md:annotation'}/aa");
/* invalid cardinality of units substatement */
data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"aa\">\n"
@@ -147,7 +157,8 @@
" <units name=\"y\"/>\n"
"</md:annotation></module>";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
- CHECK_LOG_CTX("Duplicate keyword \"units\".", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Duplicate keyword \"units\".",
+ "/aa:{extension='md:annotation'}/aa");
/* invalid cardinality of status substatement */
data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"aa\">\n"
@@ -159,7 +170,8 @@
" <status value=\"obsolete\"/>\n"
"</md:annotation></module>";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
- CHECK_LOG_CTX("Duplicate keyword \"status\".", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Duplicate keyword \"status\".",
+ "/aa:{extension='md:annotation'}/aa");
/* invalid cardinality of status substatement */
data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"aa\">\n"
@@ -170,7 +182,8 @@
" <type name=\"uint8\"/>\n"
"</md:annotation></module>";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
- CHECK_LOG_CTX("Duplicate keyword \"type\".", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Duplicate keyword \"type\".",
+ "/aa:{extension='md:annotation'}/aa");
/* duplication of the same annotation */
data = "<module xmlns=\"urn:ietf:params:xml:ns:yang:yin:1\" xmlns:md=\"urn:ietf:params:xml:ns:yang:ietf-yang-metadata\" name=\"aa\">\n"
@@ -182,8 +195,8 @@
" <type name=\"uint8\"/>\n"
"</md:annotation></module>";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YIN, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - metadata, version 1\": "
- "Extension md:annotation is instantiated multiple times.", "/aa:{extension='md:annotation'}/aa");
+ CHECK_LOG_CTX("Ext plugin \"ly2 metadata v1\": Extension md:annotation is instantiated multiple times.",
+ "/aa:{extension='md:annotation'}/aa");
}
int
diff --git a/tests/utests/extensions/test_nacm.c b/tests/utests/extensions/test_nacm.c
index 2298dea..1c999fb 100644
--- a/tests/utests/extensions/test_nacm.c
+++ b/tests/utests/extensions/test_nacm.c
@@ -48,7 +48,7 @@
assert_int_equal(LY_ARRAY_COUNT(cont->exts), 1);
assert_int_equal(LY_ARRAY_COUNT(leaf->exts), 1); /* NACM extensions inherit */
assert_ptr_equal(e->def, leaf->exts[0].def);
- assert_int_equal(1, *((uint8_t *)e->data)); /* plugin's value for default-deny-all */
+ assert_int_equal(1, *((uint8_t *)e->compiled)); /* plugin's value for default-deny-all */
assert_null(cont->next->exts);
/* ignored - valid with warning */
@@ -56,7 +56,7 @@
"import ietf-netconf-acm {revision-date 2018-02-14; prefix nacm;}"
"nacm:default-deny-all;}";
assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - NACM, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 NACM v1\": "
"Extension nacm:default-deny-all is allowed only in a data nodes, but it is placed in \"module\" statement.",
"/b:{extension='nacm:default-deny-all'}");
@@ -65,9 +65,9 @@
"import ietf-netconf-acm {revision-date 2018-02-14; prefix nacm;}"
"leaf l { type string; nacm:default-deny-all; nacm:default-deny-write;}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - NACM, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 NACM v1\": "
"Extension nacm:default-deny-write is mixed with nacm:default-deny-all.",
- "/aa:l/{extension='nacm:default-deny-write'}");
+ "/aa:l/{extension='nacm:default-deny-all'}");
}
static void
@@ -91,14 +91,14 @@
assert_int_equal(LY_ARRAY_COUNT(cont->exts), 1);
assert_int_equal(LY_ARRAY_COUNT(leaf->exts), 1); /* NACM extensions inherit */
assert_ptr_equal(e->def, leaf->exts[0].def);
- assert_int_equal(2, *((uint8_t *)e->data)); /* plugin's value for default-deny-write */
+ assert_int_equal(2, *((uint8_t *)e->compiled)); /* plugin's value for default-deny-write */
/* ignored - valid with warning */
data = "module b {yang-version 1.1; namespace urn:tests:extensions:nacm:b; prefix en;"
"import ietf-netconf-acm {revision-date 2018-02-14; prefix nacm;}"
"notification notif {nacm:default-deny-write;}}";
assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - NACM, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 NACM v1\": "
"Extension nacm:default-deny-write is not allowed in notification statement.",
"/b:notif/{extension='nacm:default-deny-write'}");
@@ -107,7 +107,7 @@
"import ietf-netconf-acm {revision-date 2018-02-14; prefix nacm;}"
"leaf l { type string; nacm:default-deny-write; nacm:default-deny-write;}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - NACM, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 NACM v1\": "
"Extension nacm:default-deny-write is instantiated multiple times.",
"/aa:l/{extension='nacm:default-deny-write'}");
}
diff --git a/tests/utests/extensions/test_schema_mount.c b/tests/utests/extensions/test_schema_mount.c
index b9b81c0..d97c777 100644
--- a/tests/utests/extensions/test_schema_mount.c
+++ b/tests/utests/extensions/test_schema_mount.c
@@ -73,7 +73,7 @@
" }\n"
"}\n";
assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
+ 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");
@@ -90,7 +90,7 @@
" yangmnt:mount-point \"root\";\n"
"}\n";
assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
+ 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");
@@ -112,7 +112,7 @@
" }\n"
"}\n";
assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
+ 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");
@@ -136,9 +136,9 @@
" }\n"
"}\n";
assert_int_equal(LY_EINVAL, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
"Multiple extension \"yangmnt:mount-point\" instances.",
- "/sm:l/{extension='yangmnt:mount-point'}/root2");
+ "/sm:l/{extension='yangmnt:mount-point'}/root");
/* valid */
schema =
@@ -156,7 +156,7 @@
" }\n"
"}\n";
assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, &mod));
- lys_print_mem(&str, mod, LYS_OUT_YIN, 0);
+ lys_print_mem(&str, mod, LYS_OUT_YANG, 0);
assert_string_equal(str, schema);
free(str);
}
@@ -195,7 +195,7 @@
" </unknown>"
"</root>";
CHECK_PARSE_LYD_PARAM(xml, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EINVAL, data);
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": Failed to get extension data, no callback set.",
+ CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": Failed to get extension data, no callback set.",
NULL);
json =
@@ -212,7 +212,7 @@
" }"
"}";
CHECK_PARSE_LYD_PARAM(json, LYD_JSON, 0, LYD_VALIDATE_PRESENT, LY_EINVAL, data);
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": Failed to get extension data, no callback set.",
+ CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": Failed to get extension data, no callback set.",
NULL);
/* unknown data */
@@ -338,9 +338,9 @@
" </mount-point>"
"</schema-mounts>");
CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
- CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", "Line number 1.");
+ CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", NULL);
CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
- CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", "Line number 1.");
+ CHECK_LOG_CTX("Node \"interfaces\" not found as a child of \"root\" node.", NULL);
/* callback data correct, invalid YANG data */
ly_ctx_set_ext_data_clb(UTEST_LYCTX, test_ext_data_clb,
@@ -404,25 +404,25 @@
" </mount-point>"
"</schema-mounts>");
CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
"Mandatory node \"type\" instance does not exist.",
"Schema location \"/ietf-interfaces:interfaces/interface/type\".");
CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
"Mandatory node \"type\" instance does not exist.",
- "Schema location \"/ietf-interfaces:interfaces/interface/type\", line number 1.");
+ "Schema location \"/ietf-interfaces:interfaces/interface/type\".");
/* 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("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
"Mandatory node \"type\" instance does not exist.",
"Schema location \"/ietf-interfaces:interfaces/interface/type\".");
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("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
"Mandatory node \"type\" instance does not exist.",
"Schema location \"/ietf-interfaces:interfaces/interface/type\".");
lyd_free_siblings(data);
@@ -865,7 +865,7 @@
" </interfaces-state>\n"
"</root2>\n";
CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
+ 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");
@@ -1121,7 +1121,7 @@
"</root3>\n"
"<target xmlns=\"urn:sm\">wrong-target-value</target>\n";
CHECK_PARSE_LYD_PARAM(xml, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
"Invalid leafref value \"target-value\" - no target instance \"/sm:target\" with the same value.",
"Data location \"/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name\".");
@@ -1146,7 +1146,7 @@
" \"sm:target\": \"wrong-target-value\"\n"
"}\n";
CHECK_PARSE_LYD_PARAM(json, LYD_JSON, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, LY_EVALID, data);
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - Schema Mount, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 schema mount v1\": "
"Invalid leafref value \"target-value\" - no target instance \"/sm:target\" with the same value.",
"Data location \"/ietf-interfaces:interfaces/interface[name='bu']/sm:sm-name\", line number 18.");
diff --git a/tests/utests/extensions/test_structure.c b/tests/utests/extensions/test_structure.c
index 408d164..00e8677 100644
--- a/tests/utests/extensions/test_structure.c
+++ b/tests/utests/extensions/test_structure.c
@@ -34,14 +34,12 @@
" reference no-ref;"
" typedef my-type {type string;}"
" grouping my-grp {leaf gl {type my-type;}}"
- " grouping my-grp2 {leaf gl-obs {type uint16;}}"
" container n1 {leaf l {config false; type uint32;}}"
" list n2 {leaf l {type leafref {path /n1/l;}}}"
" uses my-grp;"
- " uses my-grp2 {status obsolete;}"
"}}";
- assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, &mod));
+ UTEST_ADD_MODULE(data, LYS_IN_YANG, NULL, &mod);
assert_non_null(e = mod->compiled->exts);
assert_int_equal(LY_ARRAY_COUNT(mod->compiled->exts), 1);
@@ -55,7 +53,7 @@
" leaf aug-leaf {type string;}"
"}}";
- assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, &mod));
+ UTEST_ADD_MODULE(data, LYS_IN_YANG, NULL, &mod);
assert_non_null(e = mod->compiled->exts);
assert_int_equal(LY_ARRAY_COUNT(mod->compiled->exts), 1);
@@ -100,10 +98,6 @@
" type string;\n"
" status deprecated;\n"
" }\n"
- " leaf gl-obs {\n"
- " type uint16;\n"
- " status obsolete;\n"
- " }\n"
" }\n"
"}\n";
@@ -138,7 +132,8 @@
"\n"
" ietf-yang-structure-ext:structure \"struct\";\n"
"}\n";
- assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, &mod));
+
+ UTEST_ADD_MODULE(data, LYS_IN_YANG, NULL, &mod);
assert_non_null(e = mod->compiled->exts);
assert_int_equal(LY_ARRAY_COUNT(mod->compiled->exts), 1);
assert_int_equal(LY_SUCCESS, lys_print_mem(&printed, mod, LYS_OUT_YANG_COMPILED, 0));
@@ -154,41 +149,39 @@
data = "module a {yang-version 1.1; namespace urn:tests:extensions:structure:a; prefix self;"
"import ietf-yang-structure-ext {prefix sx;}"
"sx:structure struct {import yang;}}";
- assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
+ UTEST_INVALID_MODULE(data, LYS_IN_YANG, NULL, LY_EVALID);
CHECK_LOG_CTX("Invalid keyword \"import\" as a child of \"sx:structure struct\" extension instance.",
"/a:{extension='sx:structure'}/struct");
data = "module a {yang-version 1.1; namespace urn:tests:extensions:structure:a; prefix self;"
"import ietf-yang-structure-ext {prefix sx;}"
"container b { sx:structure struct { container x { leaf x {type string;}}}}}";
- assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - structure, version 1\": "
+ UTEST_INVALID_MODULE(data, LYS_IN_YANG, NULL, LY_EVALID);
+ CHECK_LOG_CTX("Ext plugin \"ly2 structure v1\": "
"Extension sx:structure must not be used as a non top-level statement in \"container\" statement.",
"/a:b/{extension='sx:structure'}/struct");
data = "module a {yang-version 1.1; namespace urn:tests:extensions:structure:a; prefix self;"
"import ietf-yang-structure-ext {prefix sx;}"
"sx:structure { container x { leaf x {type string;}}}}";
- assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension instance \"sx:structure\" misses argument element \"name\".",
- "/a:{extension='sx:structure'}");
+ UTEST_INVALID_MODULE(data, LYS_IN_YANG, NULL, LY_EVALID);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
+ "Extension instance \"sx:structure\" missing argument element \"name\".", NULL);
data = "module a {yang-version 1.1; namespace urn:tests:extensions:structure:a; prefix self;"
"import ietf-yang-structure-ext {prefix sx;}"
"sx:structure struct { container x { leaf x {type string;}}}"
"sx:structure struct { container y { leaf y {type string;}}}}";
- assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - structure, version 1\": "
- "Extension sx:structure is instantiated multiple times.",
+ UTEST_INVALID_MODULE(data, LYS_IN_YANG, NULL, LY_EVALID);
+ CHECK_LOG_CTX("Ext plugin \"ly2 structure v1\": Extension sx:structure is instantiated multiple times.",
"/a:{extension='sx:structure'}/struct");
data = "module a {yang-version 1.1; namespace urn:tests:extensions:structure:a; prefix self;"
"import ietf-yang-structure-ext {prefix sx;}"
"sx:structure struct { container x { leaf x {type string;}}}"
"choice struct { container y { leaf y {type string;}}}}";
- assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - structure, version 1\": "
- "Extension sx:structure collides with a choice with the same identifier.",
+ UTEST_INVALID_MODULE(data, LYS_IN_YANG, NULL, LY_EVALID);
+ CHECK_LOG_CTX("Ext plugin \"ly2 structure v1\": Extension sx:structure collides with a choice with the same identifier.",
"/a:{extension='sx:structure'}/struct");
}
@@ -204,7 +197,7 @@
const char *xml = "<x xmlns=\"urn:tests:extensions:structure:a\"><x>test</x></x>";
const char *json = "{\"a:x\":{\"x\":\"test\"}}";
- assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, schema, LYS_IN_YANG, &mod));
+ UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, &mod);
assert_non_null(e = mod->compiled->exts);
assert_int_equal(LY_SUCCESS, ly_in_new_memory(xml, &UTEST_IN));
diff --git a/tests/utests/extensions/test_yangdata.c b/tests/utests/extensions/test_yangdata.c
index e7e7bc1..8c0176f 100644
--- a/tests/utests/extensions/test_yangdata.c
+++ b/tests/utests/extensions/test_yangdata.c
@@ -117,7 +117,7 @@
"}\n";
assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, &mod));
assert_null(mod->compiled->exts);
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - yang-data, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
"Extension rc:yang-data is ignored since it appears as a non top-level statement in \"container\" statement.",
"/b:b/{extension='rc:yang-data'}/template");
assert_int_equal(LY_SUCCESS, lys_print_mem(&printed, mod, LYS_OUT_YANG_COMPILED, 0));
@@ -174,7 +174,7 @@
"import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
"rc:yang-data template { choice x { leaf x {type string;}}}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - yang-data, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
"Extension rc:yang-data is instantiated with leaf top level data node (inside a choice), "
"but only a single container data node is allowed.",
"/a:{extension='rc:yang-data'}/template");
@@ -183,7 +183,7 @@
"import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
"rc:yang-data template { choice x { case x { container z {presence ppp;} leaf x {type string;}}}}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - yang-data, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
"Extension rc:yang-data is instantiated with multiple top level data nodes (inside a single choice's case), "
"but only a single container data node is allowed.",
"/a:{extension='rc:yang-data'}/template");
@@ -192,7 +192,7 @@
"import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
"rc:yang-data template { container x { leaf x {type string;}} container y { leaf y {type string;}}}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - yang-data, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
"Extension rc:yang-data is instantiated with multiple top level data nodes, "
"but only a single container data node is allowed.",
"/a:{extension='rc:yang-data'}/template");
@@ -201,7 +201,7 @@
"import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
"rc:yang-data template;}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - yang-data, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
"Extension rc:yang-data is instantiated without any top level data node, "
"but exactly one container data node is expected.",
"/a:{extension='rc:yang-data'}/template");
@@ -210,15 +210,15 @@
"import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
"rc:yang-data { container x { leaf x {type string;}}}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension instance \"rc:yang-data\" misses argument element \"name\".",
- "/a:{extension='rc:yang-data'}");
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
+ "Extension instance \"rc:yang-data\" missing argument element \"name\".", NULL);
data = "module a {yang-version 1.1; namespace urn:tests:extensions:yangdata:a; prefix self;"
"import ietf-restconf {revision-date 2017-01-26; prefix rc;}"
"rc:yang-data template { container x { leaf x {type string;}}}"
"rc:yang-data template { container y { leaf y {type string;}}}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - yang-data, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
"Extension rc:yang-data is instantiated multiple times.",
"/a:{extension='rc:yang-data'}/template");
@@ -227,7 +227,7 @@
"grouping t { leaf-list x {type string;}}"
"rc:yang-data template { uses t;}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, data, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension plugin \"libyang 2 - yang-data, version 1\": "
+ CHECK_LOG_CTX("Ext plugin \"ly2 yang-data v1\": "
"Extension rc:yang-data is instantiated with leaf-list top level data node, "
"but only a single container data node is allowed.",
"/a:{extension='rc:yang-data'}/template");
diff --git a/tests/utests/schema/test_schema.c b/tests/utests/schema/test_schema.c
index 9d19de3..e4c4210 100644
--- a/tests/utests/schema/test_schema.c
+++ b/tests/utests/schema/test_schema.c
@@ -1606,7 +1606,8 @@
/* invalid */
mod_test_yang = "module x { namespace \"urn:x\"; prefix x; import a { prefix a; } a:e; }";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, mod_test_yang, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Extension instance \"a:e\" misses argument element \"name\".", "/x:{extension='a:e'}");
+ CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL,
+ "Extension instance \"a:e\" missing argument element \"name\".", NULL);
mod_test_yin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<module name=\"x\"\n"
@@ -1621,7 +1622,8 @@
" <a:e/>\n"
"</module>\n";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, mod_test_yin, LYS_IN_YIN, NULL));
- CHECK_LOG_CTX("Extension instance \"a:e\" misses argument element \"name\".", "/x:{extension='a:e'}");
+ CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL,
+ "Extension instance \"a:e\" missing argument element \"name\".", NULL);
mod_test_yin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<module name=\"x\"\n"
@@ -1636,7 +1638,8 @@
" <a:e name=\"xxx\"/>\n"
"</module>\n";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, mod_test_yin, LYS_IN_YIN, NULL));
- CHECK_LOG_CTX("Extension instance \"a:e\" misses argument element \"name\".", "/x:{extension='a:e'}");
+ CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL,
+ "Extension instance \"a:e\" missing argument element \"name\".", NULL);
mod_test_yin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<module name=\"x\"\n"
@@ -1653,8 +1656,9 @@
" </a:e>\n"
"</module>\n";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, mod_test_yin, LYS_IN_YIN, NULL));
- CHECK_LOG_CTX("Extension instance \"a:e\" element and its argument element \"name\" are expected in the same namespace, but they differ.",
- "/x:{extension='a:e'}");
+ CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL,
+ "Extension instance \"a:e\" element and its argument element \"name\" are expected in the same namespace, but they differ.",
+ NULL);
mod_test_yin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<module name=\"x\"\n"
@@ -1671,8 +1675,9 @@
" </a:e>\n"
"</module>\n";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, mod_test_yin, LYS_IN_YIN, NULL));
- CHECK_LOG_CTX("Extension instance \"a:e\" expects argument element \"name\" as its first XML child, but \"value\" element found.",
- "/x:{extension='a:e'}");
+ CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL,
+ "Extension instance \"a:e\" expects argument element \"name\" as its first XML child, but \"value\" element found.",
+ NULL);
}
@@ -1682,6 +1687,7 @@
struct lys_module *mod;
struct lysc_ctx cctx = {0};
struct lysp_ext_instance ext_p = {0};
+ struct lysp_ext_substmt *substmtp;
struct lysp_stmt child = {0};
struct lysc_ext_instance ext_c = {0};
struct lysc_ext_substmt *substmt;
@@ -1703,11 +1709,20 @@
ext_p.format = LY_VALUE_JSON;
ext_p.parent_stmt = LY_STMT_MODULE;
+ LY_ARRAY_NEW_GOTO(UTEST_LYCTX, ext_p.substmts, substmtp, rc, cleanup);
+
+ substmtp->stmt = LY_STMT_ERROR_MESSAGE;
+ substmtp->storage = &ext_p.parsed;
+ /* fake parse */
+ lydict_insert(UTEST_LYCTX, "my error", 0, (const char **)&ext_p.parsed);
+
/* compiled ext instance */
ext_c.parent_stmt = ext_p.parent_stmt;
- // ext_c.parent =
LY_ARRAY_NEW_GOTO(UTEST_LYCTX, ext_c.substmts, substmt, rc, cleanup);
+ substmt->stmt = LY_STMT_ERROR_MESSAGE;
+ substmt->storage = &ext_c.compiled;
+
/*
* error-message
*/
@@ -1717,22 +1732,20 @@
child.format = LY_VALUE_JSON;
child.kw = LY_STMT_ERROR_MESSAGE;
- substmt->stmt = LY_STMT_ERROR_MESSAGE;
- substmt->storage = &ext_c.data;
-
/* compile */
- assert_int_equal(LY_SUCCESS, lys_compile_extension_instance(&cctx, &ext_p, &ext_c));
+ assert_int_equal(LY_SUCCESS, lyplg_ext_compile_extension_instance(&cctx, &ext_p, &ext_c));
/* check */
- assert_string_equal(ext_c.data, "my error");
+ assert_string_equal(ext_c.compiled, "my error");
cleanup:
lydict_remove(UTEST_LYCTX, ext_p.name);
lydict_remove(UTEST_LYCTX, child.stmt);
lydict_remove(UTEST_LYCTX, child.arg);
+ LY_ARRAY_FREE(ext_p.substmts);
+ lydict_remove(UTEST_LYCTX, ext_p.parsed);
LY_ARRAY_FREE(ext_c.substmts);
-
- lydict_remove(UTEST_LYCTX, ext_c.data);
+ lydict_remove(UTEST_LYCTX, ext_c.compiled);
if (rc) {
fail();
}
diff --git a/tests/utests/schema/test_yang.c b/tests/utests/schema/test_yang.c
index 1069982..4f11500 100644
--- a/tests/utests/schema/test_yang.c
+++ b/tests/utests/schema/test_yang.c
@@ -54,7 +54,7 @@
LY_ERR parse_submodule(struct lysp_yang_ctx *ctx, struct lysp_submodule *submod);
LY_ERR parse_uses(struct lysp_yang_ctx *ctx, struct lysp_node *parent, struct lysp_node **siblings);
LY_ERR parse_when(struct lysp_yang_ctx *ctx, struct lysp_when **when_p);
-LY_ERR parse_type_enum_value_pos(struct lysp_yang_ctx *ctx, enum ly_stmt val_kw, int64_t *value, uint16_t *flags, struct lysp_ext_instance **exts);
+LY_ERR parse_type_enum_value_pos(struct lysp_yang_ctx *ctx, enum ly_stmt val_kw, struct lysp_type_enum *enm);
struct lysp_yang_ctx *YCTX;
struct lysf_ctx fctx;
@@ -1702,16 +1702,15 @@
static void
test_value(void **state)
{
- int64_t val = 0;
- uint16_t flags = 0;
+ struct lysp_type_enum enm;
in.current = "-0;";
- assert_int_equal(parse_type_enum_value_pos(YCTX, LY_STMT_VALUE, &val, &flags, NULL), LY_SUCCESS);
- assert_int_equal(val, 0);
+ memset(&enm, 0, sizeof enm);
+ assert_int_equal(parse_type_enum_value_pos(YCTX, LY_STMT_VALUE, &enm), LY_SUCCESS);
in.current = "-0;";
- flags = 0;
- assert_int_equal(parse_type_enum_value_pos(YCTX, LY_STMT_POSITION, &val, &flags, NULL), LY_EVALID);
+ memset(&enm, 0, sizeof enm);
+ assert_int_equal(parse_type_enum_value_pos(YCTX, LY_STMT_POSITION, &enm), LY_EVALID);
CHECK_LOG_CTX("Invalid value \"-0\" of \"position\".", "Line number 1.");
}
diff --git a/tests/utests/schema/test_yin.c b/tests/utests/schema/test_yin.c
index 6b20016..af8de4d 100644
--- a/tests/utests/schema/test_yin.c
+++ b/tests/utests/schema/test_yin.c
@@ -92,12 +92,12 @@
/* prototypes of static functions */
enum yin_argument yin_match_argument_name(const char *name, size_t len);
LY_ERR yin_parse_content(struct lysp_yin_ctx *ctx, struct yin_subelement *subelem_info, size_t subelem_info_size,
- enum ly_stmt current_element, const char **text_content, struct lysp_ext_instance **exts);
+ const void *parent, enum ly_stmt parent_stmt, const char **text_content, struct lysp_ext_instance **exts);
LY_ERR yin_validate_value(struct lysp_yin_ctx *ctx, enum yang_arg val_type);
enum ly_stmt yin_match_keyword(struct lysp_yin_ctx *ctx, const char *name, size_t name_len,
const char *prefix, size_t prefix_len, enum ly_stmt parrent);
-LY_ERR yin_parse_extension_instance(struct lysp_yin_ctx *ctx, enum ly_stmt subelem, LY_ARRAY_COUNT_TYPE subelem_index,
- struct lysp_ext_instance **exts);
+LY_ERR yin_parse_extension_instance(struct lysp_yin_ctx *ctx, const void *parent, enum ly_stmt parent_stmt,
+ LY_ARRAY_COUNT_TYPE parent_stmt_index, struct lysp_ext_instance **exts);
LY_ERR yin_parse_element_generic(struct lysp_yin_ctx *ctx, enum ly_stmt parent, struct lysp_stmt **element);
LY_ERR yin_parse_mod(struct lysp_yin_ctx *ctx, struct lysp_module *mod);
LY_ERR yin_parse_submod(struct lysp_yin_ctx *ctx, struct lysp_submodule *submod);
@@ -330,7 +330,7 @@
lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);
lyxml_ctx_next(YCTX->xmlctx);
- ret = yin_parse_content(YCTX, subelems2, 2, LY_STMT_STATUS, NULL, &exts);
+ ret = yin_parse_content(YCTX, subelems2, 2, NULL, LY_STMT_STATUS, NULL, &exts);
assert_int_equal(ret, LY_EVALID);
CHECK_LOG_CTX("Redefinition of \"text\" sub-element in \"status\" element.", "Line number 1.");
lydict_remove(UTEST_LYCTX, prefix_value);
@@ -350,7 +350,7 @@
lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);
lyxml_ctx_next(YCTX->xmlctx);
- ret = yin_parse_content(YCTX, subelems3, 2, LY_STMT_STATUS, NULL, &exts);
+ ret = yin_parse_content(YCTX, subelems3, 2, NULL, LY_STMT_STATUS, NULL, &exts);
assert_int_equal(ret, LY_EVALID);
CHECK_LOG_CTX("Sub-element \"text\" of \"status\" element must be defined as it's first sub-element.", "Line number 1.");
lydict_remove(UTEST_LYCTX, prefix_value);
@@ -364,7 +364,7 @@
lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx);
lyxml_ctx_next(YCTX->xmlctx);
- ret = yin_parse_content(YCTX, subelems4, 1, LY_STMT_STATUS, NULL, &exts);
+ ret = yin_parse_content(YCTX, subelems4, 1, NULL, LY_STMT_STATUS, NULL, &exts);
assert_int_equal(ret, LY_EVALID);
CHECK_LOG_CTX("Missing mandatory sub-element \"prefix\" of \"status\" element.", "Line number 1.");
}
@@ -1258,7 +1258,8 @@
name_len = YCTX->xmlctx->name_len;
lyxml_ctx_next(YCTX->xmlctx);
- ret = yin_parse_content(YCTX, subelems, 71, yin_match_keyword(YCTX, name, name_len, prefix, prefix_len, LY_STMT_NONE), text, exts);
+ ret = yin_parse_content(YCTX, subelems, 71, NULL,
+ yin_match_keyword(YCTX, name, name_len, prefix, prefix_len, LY_STMT_NONE), text, exts);
/* free parser and input */
lyxml_ctx_free(YCTX->xmlctx);
@@ -3480,7 +3481,7 @@
"</module>";
assert_int_equal(ly_in_new_memory(data, &in), LY_SUCCESS);
assert_int_equal(yin_parse_submodule(&yin_ctx, UTEST_LYCTX, (struct lysp_ctx *)YCTX, in, &submod), LY_EINVAL);
- CHECK_LOG_CTX("Input data contains module in situation when a submodule is expected.", NULL);
+ CHECK_LOG_CTX("Input data contains module when a submodule is expected.", NULL);
lysp_module_free(&fctx, (struct lysp_module *)submod);
lysp_yin_ctx_free(yin_ctx);
ly_in_free(in, 0);
diff --git a/tests/utests/utests.h b/tests/utests/utests.h
index b1af68d..8726910 100644
--- a/tests/utests/utests.h
+++ b/tests/utests/utests.h
@@ -1212,7 +1212,16 @@
*/
#define UTEST_ADD_MODULE(DATA, FORMAT, FEATURES, MOD) \
assert_int_equal(LY_SUCCESS, ly_in_new_memory(DATA, &_UC->in)); \
- assert_int_equal(LY_SUCCESS, lys_parse(_UC->ctx, _UC->in, FORMAT, FEATURES, MOD)); \
+ { \
+ LY_ERR __r = lys_parse(_UC->ctx, _UC->in, FORMAT, FEATURES, MOD); \
+ if (__r != LY_SUCCESS) { \
+ print_message("[ MSG ] Module parsing failed:\n"); \
+ for (struct ly_err_item *e = ly_err_first(_UC->ctx); e; e = e->next) { \
+ print_message("[ MSG ] \t%s Path %s\n", e->msg, e->path); \
+ } \
+ fail(); \
+ } \
+ } \
ly_in_free(_UC->in, 0); \
_UC->in = NULL
@@ -1223,7 +1232,6 @@
* @param[in] ERR Error information record from libyang context.
* @param[in] MSG Expected error message.
* @param[in] PATH Expected error path.
- *
*/
#define _CHECK_LOG_CTX(ERR, MSG, PATH) \
if (!MSG) { \