utest UPDATE log check simplification
diff --git a/tests/utests/basic/test_context.c b/tests/utests/basic/test_context.c
index 4c4cc3f..800a714 100644
--- a/tests/utests/basic/test_context.c
+++ b/tests/utests/basic/test_context.c
@@ -298,8 +298,8 @@
assert_int_equal(LY_EVALID, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres.creating, &mod1));
lys_unres_glob_erase(&unres);
ly_in_free(in, 0);
- CHECK_LOG_CTX("Parsing module \"y\" failed.", NULL,
- "Name collision between module and submodule of name \"y\".", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"y\" failed.", NULL);
+ CHECK_LOG_CTX("Name collision between module and submodule of name \"y\".", "Line number 1.");
assert_int_equal(LY_SUCCESS, ly_in_new_memory("module a {namespace urn:a;prefix a;include y;revision 2018-10-30; }", &in));
assert_int_equal(LY_SUCCESS, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres.creating, &mod1));
@@ -308,8 +308,8 @@
assert_int_equal(LY_EVALID, lys_parse_in(UTEST_LYCTX, in, LYS_IN_YANG, NULL, NULL, &unres.creating, &mod1));
lys_unres_glob_erase(&unres);
ly_in_free(in, 0);
- CHECK_LOG_CTX("Parsing module \"y\" failed.", NULL,
- "Name collision between module and submodule of name \"y\".", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"y\" failed.", NULL);
+ CHECK_LOG_CTX("Name collision between module and submodule of name \"y\".", "Line number 1.");
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule y {belongs-to b {prefix b;}}");
assert_int_equal(LY_SUCCESS, ly_in_new_memory("module b {namespace urn:b;prefix b;include y;}", &in));
@@ -317,10 +317,10 @@
lys_unres_glob_revert(UTEST_LYCTX, &unres);
lys_unres_glob_erase(&unres);
ly_in_free(in, 0);
- CHECK_LOG_CTX("Parsing module \"b\" failed.", NULL,
- "Including \"y\" submodule into \"b\" failed.", NULL,
- "Parsing submodule failed.", NULL,
- "Name collision between submodules of name \"y\".", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"b\" failed.", NULL);
+ CHECK_LOG_CTX("Including \"y\" submodule into \"b\" failed.", NULL);
+ CHECK_LOG_CTX("Parsing submodule failed.", NULL);
+ CHECK_LOG_CTX("Name collision between submodules of name \"y\".", "Line number 1.");
/* selecting correct revision of the submodules */
ly_ctx_reset_latests(UTEST_LYCTX);
@@ -338,19 +338,6 @@
assert_non_null(mod1->compiled);
assert_non_null(mod1->parsed);
-#if 0
- /* TODO in case we are able to remove the parsed schema, here we will test how it will handle missing import parsed schema */
-
- assert_int_equal(LY_SUCCESS, ly_in_new_memory("module z {namespace urn:z;prefix z;import w {prefix w;revision-date 2018-10-24;}}", &in));
- /* mod1->parsed is necessary to compile mod2 because of possible groupings, typedefs, ... */
- ly_ctx_set_module_imp_clb(UTEST_LYCTX, NULL, NULL);
- assert_int_equal(LY_ENOTFOUND, lys_create_module(UTEST_LYCTX, in, LYS_IN_YANG, 1, NULL, NULL, &mod2));
- /*logbuf_assert("Unable to reload \"w\" module to import it into \"z\", source data not found.");*/
- CHECK_LOG_CTX("Recompilation of module \"w\" failed.", NULL);
- assert_null(mod2);
- ly_in_free(in, 0);
-#endif
-
assert_int_equal(LY_SUCCESS, ly_in_new_memory("module z {namespace urn:z;prefix z;import w {prefix w;revision-date 2018-10-24;}}", &in));
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "module w {namespace urn:w;prefix w;revision 2018-10-24;}");
assert_int_equal(LY_SUCCESS, lys_parse(UTEST_LYCTX, in, LYS_IN_YANG, NULL, &mod2));
@@ -425,6 +412,7 @@
"import a {prefix a;}"
"}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
+ ly_err_clean(UTEST_LYCTX, NULL);
}
static void
diff --git a/tests/utests/basic/test_json.c b/tests/utests/basic/test_json.c
index 1896b8a..2778f7b 100644
--- a/tests/utests/basic/test_json.c
+++ b/tests/utests/basic/test_json.c
@@ -532,68 +532,12 @@
str = "";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
-#if 0
- /* simple string */
- str = "\"hello\"";
- assert_int_equal(LY_SUCCESS, lyjson_ctx_new(UTEST_LYCTX, in, 0, &jsonctx));
- assert_int_equal(LYJSON_STRING, lyjson_ctx_status(jsonctx, 0));
- assert_ptr_equal(&str[1], jsonctx->value);
- assert_int_equal(5, jsonctx->value_len);
- assert_int_equal(0, jsonctx->dynamic);
- lyjson_ctx_free(jsonctx);
-
- /* 4-byte utf8 character */
- str = "\"\\t𠜎\"";
- assert_non_null(ly_in_memory(in, str));
- assert_int_equal(LY_SUCCESS, lyjson_ctx_new(UTEST_LYCTX, in, 0, &jsonctx));
- assert_int_equal(LYJSON_STRING, lyjson_ctx_status(jsonctx, 0));
- assert_string_equal("\t𠜎", jsonctx->value);
- assert_int_equal(5, jsonctx->value_len);
- assert_int_equal(1, jsonctx->dynamic);
- lyjson_ctx_free(jsonctx);
-
- /* valid escape sequences - note that here it mixes valid JSON string characters (RFC 7159, sec. 7) and
- * valid characters in YANG string type (RFC 7950, sec. 9.4). Since the latter is a subset of JSON string,
- * the YANG string type's restrictions apply to the JSON escape sequences */
- str = "\"\\\" \\\\ \\r \\/ \\n \\t \\u20ac\"";
- assert_non_null(ly_in_memory(in, str));
- assert_int_equal(LY_SUCCESS, lyjson_ctx_new(UTEST_LYCTX, in, 0, &jsonctx));
- assert_int_equal(LYJSON_STRING, lyjson_ctx_status(jsonctx, 0));
- assert_string_equal("\" \\ \r / \n \t €", jsonctx->value);
- assert_int_equal(15, jsonctx->value_len);
- assert_int_equal(1, jsonctx->dynamic);
- lyjson_ctx_free(jsonctx);
-
- /* backspace and form feed are valid JSON escape sequences, but the control characters they represents are not allowed values for YANG string type */
- str = "\"\\b\"";
- assert_non_null(ly_in_memory(in, str));
- assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, 0, &jsonctx));
- CHECK_LOG_CTX("Invalid character reference \"\\b\" (0x00000008).", "Line number 1.");
-
- str = "\"\\f\"";
- assert_non_null(ly_in_memory(in, str));
- assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, 0, &jsonctx));
- CHECK_LOG_CTX("Invalid character reference \"\\f\" (0x0000000c).", "Line number 1.");
-#endif
-
/* unterminated string */
str = "\"unterminated string";
assert_non_null(ly_in_memory(in, str));
assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, 0, &jsonctx));
CHECK_LOG_CTX("Missing quotation-mark at the end of a JSON string.", "Line number 1.");
-#if 0
- /* invalid escape sequence */
- str = "\"char \\x \"";
- assert_non_null(ly_in_memory(in, str));
- assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, 0, &jsonctx));
- CHECK_LOG_CTX("Invalid character escape sequence \\x.", "Line number 1.");
-
- /* new line is allowed only as escaped character in JSON */
- str = "\"\n\"";
- assert_non_null(ly_in_memory(in, str));
- assert_int_equal(LY_EVALID, lyjson_ctx_new(UTEST_LYCTX, in, 0, &jsonctx));
- CHECK_LOG_CTX("Invalid character in JSON string \"\n\" (0x0000000a).", "Line number 1.");
-#endif
+ CHECK_LOG_CTX("Unexpected end-of-input.", "Line number 1.");
ly_in_free(in, 0);
}
diff --git a/tests/utests/basic/test_xpath.c b/tests/utests/basic/test_xpath.c
index b388dc3..d28de43 100644
--- a/tests/utests/basic/test_xpath.c
+++ b/tests/utests/basic/test_xpath.c
@@ -254,9 +254,11 @@
assert_int_equal(LY_EVALID, lyd_find_xpath(tree, "/a:foo2[.=]", &set));
assert_null(set);
+ CHECK_LOG_CTX("Unexpected XPath token \"]\" (\"]\").", NULL);
assert_int_equal(LY_EVALID, lyd_find_xpath(tree, "/a:", &set));
assert_null(set);
+ CHECK_LOG_CTX("Invalid character 'a'[2] of expression '/a:'.", NULL);
lyd_free_all(tree);
}
@@ -898,6 +900,7 @@
LOCAL_SETUP(data, tree);
assert_int_equal(LY_SUCCESS, lyxp_vars_set(&vars, "var1", "\"mstr\""));
assert_int_equal(LY_ENOTFOUND, lyd_find_xpath2(tree, "/foo[text() = $var55]", vars, &set));
+ CHECK_LOG_CTX("XPath variable \"var55\" not defined.", NULL);
LOCAL_TEARDOWN(set, tree, vars);
/* Syntax error in value. */
@@ -906,6 +909,7 @@
LOCAL_SETUP(data, tree);
assert_int_equal(LY_SUCCESS, lyxp_vars_set(&vars, "var", "\""));
assert_int_equal(LY_EVALID, lyd_find_xpath2(tree, "/foo[$var]", vars, &set));
+ CHECK_LOG_CTX("Unterminated string delimited with \" (\").", "Data location \"/a:foo\".");
LOCAL_TEARDOWN(set, tree, vars);
/* Prefix is not supported. */
@@ -914,7 +918,7 @@
LOCAL_SETUP(data, tree);
assert_int_equal(LY_SUCCESS, lyxp_vars_set(&vars, "var", "\""));
assert_int_equal(LY_EVALID, lyd_find_xpath2(tree, "/foo[$pref:var]", vars, &set));
- assert_string_equal("Variable with prefix is not supported.", _UC->err_msg);
+ CHECK_LOG_CTX("Variable with prefix is not supported.", NULL);
LOCAL_TEARDOWN(set, tree, vars);
#undef LOCAL_SETUP
diff --git a/tests/utests/data/test_diff.c b/tests/utests/data/test_diff.c
index 1b7592a..a84c3f6 100644
--- a/tests/utests/data/test_diff.c
+++ b/tests/utests/data/test_diff.c
@@ -312,6 +312,8 @@
struct lyd_node *diff = NULL;
assert_int_equal(lyd_diff_siblings(model_1, lyd_child(model_1), 0, &diff), LY_EINVAL);
+ CHECK_LOG_CTX("Invalid arguments - cannot create diff for unrelated data (lyd_diff()).", NULL);
+
assert_int_equal(lyd_diff_siblings(NULL, NULL, 0, NULL), LY_EINVAL);
lyd_free_all(model_1);
diff --git a/tests/utests/data/test_new.c b/tests/utests/data/test_new.c
index 7642960..553a487 100644
--- a/tests/utests/data/test_new.c
+++ b/tests/utests/data/test_new.c
@@ -290,6 +290,7 @@
ret = lyd_new_path2(root, NULL, "/a:c2/l3[1]", NULL, 0, 0, 0, NULL, &node);
assert_int_equal(ret, LY_EEXIST);
+ CHECK_LOG_CTX("Path \"/a:c2/l3[1]\" already exists.", "Data location \"/a:c2/l3[1]\".");
ret = lyd_new_path2(root, NULL, "/a:c2/l3[2]/x", "val2", 0, 0, 0, NULL, &node);
assert_int_equal(ret, LY_SUCCESS);
@@ -348,6 +349,7 @@
ret = lyd_new_path2(root, NULL, "/a:ll2[1]", "", 0, 0, 0, NULL, &node);
assert_int_equal(ret, LY_EEXIST);
+ CHECK_LOG_CTX("Path \"/a:ll2[1]\" already exists.", "Data location \"/a:ll2[1]\".");
ret = lyd_new_path2(root, NULL, "/a:ll2[2]", "val2", 0, 0, 0, NULL, &node);
assert_int_equal(ret, LY_SUCCESS);
@@ -362,6 +364,7 @@
ret = lyd_new_path2(root, NULL, "/a:ll2[3][.='val3']", NULL, 0, 0, 0, NULL, &node);
assert_int_equal(ret, LY_EVALID);
+ CHECK_LOG_CTX("Unparsed characters \"[.='val3']\" left at the end of path.", NULL);
lyd_print_mem(&str, root, LYD_XML, LYD_PRINT_WITHSIBLINGS);
assert_string_equal(str,
diff --git a/tests/utests/data/test_parser_json.c b/tests/utests/data/test_parser_json.c
index d341e31..09466bb 100644
--- a/tests/utests/data/test_parser_json.c
+++ b/tests/utests/data/test_parser_json.c
@@ -160,6 +160,7 @@
/* reverse solidus in JSON object member name */
data = "{\"@a:foo\":{\"a:hi\\nt\":1},\"a:foo\":\"xxx\"}";
assert_int_equal(LY_EINVAL, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_JSON, 0, LYD_VALIDATE_PRESENT, &tree));
+ CHECK_LOG_CTX("Annotation definition for attribute \"a:hi\nt\" not found.", "Data location \"/@a:foo\", line number 1.");
}
static void
@@ -556,6 +557,7 @@
data = "{\"@a:foo\":\"str\",\"@a:foo3\":1,\"a:foo3\":2}";
PARSER_CHECK_ERROR(data, 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
"Unknown module of node \"@a:foo\".", "Data location \"/@a:foo\".");
+ CHECK_LOG_CTX("Missing JSON data instance to be coupled with @a:foo metadata.", "Data location \"/@a:foo\", line number 1.");
/* empty name */
PARSER_CHECK_ERROR("{\"@a:foo\":{\"\":0}}", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
diff --git a/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index 7defd9c..a662828 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -170,17 +170,21 @@
/* missing keys */
PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
"List instance is missing its key \"a\".", "Data location \"/a:l1[b='b'][c='1']\", line number 1.");
+ CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL);
PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><a>a</a></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
"List instance is missing its key \"b\".", "Data location \"/a:l1[a='a']\", line number 1.");
PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><b>b</b><a>a</a></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
"List instance is missing its key \"c\".", "Data location \"/a:l1[a='a'][b='b']\", line number 1.");
+ CHECK_LOG_CTX("Invalid position of the key \"a\" in a list.", NULL);
/* key duplicate */
PARSER_CHECK_ERROR("<l1 xmlns=\"urn:tests:a\"><c>1</c><b>b</b><a>a</a><c>1</c></l1>", 0, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
"Duplicate instance of \"c\".",
"Data location \"/a:l1[a='a'][b='b'][c='1'][c='1']/c\", line number 1.");
+ CHECK_LOG_CTX("Invalid position of the key \"a\" in a list.", NULL);
+ CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL);
/* keys order */
CHECK_PARSE_LYD("<l1 xmlns=\"urn:tests:a\"><d>d</d><a>a</a><c>1</c><b>b</b></l1>", 0, LYD_VALIDATE_PRESENT, tree);
@@ -209,6 +213,7 @@
assert_non_null(leaf = (struct lyd_node_term *)leaf->next);
CHECK_LYSC_NODE(leaf->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR | LYS_KEY, 1, "c", 1, LYS_LEAF, 1, 0, NULL, 0);
CHECK_LOG_CTX("Invalid position of the key \"a\" in a list.", NULL);
+ CHECK_LOG_CTX("Invalid position of the key \"b\" in a list.", NULL);
lyd_free_all(tree);
PARSER_CHECK_ERROR(data, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, tree, LY_EVALID,
diff --git a/tests/utests/data/test_tree_data.c b/tests/utests/data/test_tree_data.c
index 27dba42..2f03c90 100644
--- a/tests/utests/data/test_tree_data.c
+++ b/tests/utests/data/test_tree_data.c
@@ -363,6 +363,8 @@
CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree1);
assert_int_equal(LY_EINVAL, lyd_dup_single(((struct lyd_node_inner *)tree1)->child->prev,
(struct lyd_node_inner *)tree1->next, LYD_DUP_WITH_PARENTS, NULL));
+ CHECK_LOG_CTX("Invalid argument parent (lyd_dup_get_local_parent()) - does not interconnect with the created node's parents chain.",
+ NULL);
lyd_free_all(tree1);
}
@@ -525,6 +527,7 @@
/* The run must not crash due to the assert that checks the hash. */
CHECK_PARSE_LYD_PARAM(data, LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
+ CHECK_LOG_CTX("Duplicate instance of \"ll\".", "Data location \"/test-data-hash:c/ll[.='']\", line number 1.");
lyd_free_all(tree);
}
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index 415e16a..7bc3dc8 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -1212,6 +1212,7 @@
struct lyd_node *tree, *op_tree;
UTEST_ADD_MODULE(schema_j, LYS_IN_YANG, feats_j, NULL);
+ UTEST_LOG_CTX_CLEAN;
assert_int_equal(LY_SUCCESS, ly_in_new_memory(
"<cont xmlns=\"urn:tests:j\">\n"
@@ -1304,6 +1305,7 @@
struct lyd_node *tree, *op_tree;
UTEST_ADD_MODULE(schema_j, LYS_IN_YANG, feats_j, NULL);
+ UTEST_LOG_CTX_CLEAN;
assert_int_equal(LY_SUCCESS, ly_in_new_memory(
"<cont xmlns=\"urn:tests:j\">\n"
diff --git a/tests/utests/extensions/test_structure.c b/tests/utests/extensions/test_structure.c
index 23af450..9b238a9 100644
--- a/tests/utests/extensions/test_structure.c
+++ b/tests/utests/extensions/test_structure.c
@@ -162,8 +162,8 @@
"import ietf-yang-structure-ext {prefix sx;}"
"sx:structure { container x { leaf x {type string;}}}}";
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);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("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;}"
diff --git a/tests/utests/extensions/test_yangdata.c b/tests/utests/extensions/test_yangdata.c
index 8c0176f..89d3231 100644
--- a/tests/utests/extensions/test_yangdata.c
+++ b/tests/utests/extensions/test_yangdata.c
@@ -210,8 +210,8 @@
"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("Parsing module \"a\" failed.", NULL,
- "Extension instance \"rc:yang-data\" missing argument element \"name\".", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("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;}"
diff --git a/tests/utests/node/list.c b/tests/utests/node/list.c
index 8b14ece..bb56e8d 100644
--- a/tests/utests/node/list.c
+++ b/tests/utests/node/list.c
@@ -169,8 +169,8 @@
"leaf group{type string;}"
"}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL,
- "Invalid value \"-1\" of \"max-elements\".", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"-1\" of \"max-elements\".", "Line number 5.");
schema = MODULE_CREATE_YANG("TERR_0", "list user {"
"key uid;"
@@ -181,8 +181,8 @@
"leaf group{type string;}"
"}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL,
- "Value \"4294967298\" is out of \"max-elements\" bounds.", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
+ CHECK_LOG_CTX("Value \"4294967298\" is out of \"max-elements\" bounds.", "Line number 5.");
schema = MODULE_CREATE_YANG("TERR_0", "list user {"
"key uid;"
@@ -204,8 +204,8 @@
"leaf group{type string;}"
"}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL,
- "Invalid value \"-1\" of \"min-elements\".", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"-1\" of \"min-elements\".", "Line number 5.");
schema = MODULE_CREATE_YANG("TERR_0", "list user {"
"key uid;"
@@ -215,8 +215,8 @@
"leaf group{type string;}"
"}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL,
- "Duplicate keyword \"key\".", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate keyword \"key\".", "Line number 5.");
schema = MODULE_CREATE_YANG("T6", "list user {"
"config false;"
@@ -282,8 +282,8 @@
"leaf group{type string;}"
"}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL,
- "Invalid value \"systeme\" of \"ordered-by\".", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"systeme\" of \"ordered-by\".", "Line number 5.");
schema = MODULE_CREATE_YANG("TERROR0", "list \"\" {"
"key uid;"
@@ -294,8 +294,8 @@
"leaf group{type string;}"
"}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL,
- "Statement argument is required.", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL);
+ CHECK_LOG_CTX("Statement argument is required.", "Line number 5.");
schema = MODULE_CREATE_YANG("T9", "list user {"
"key uid;"
@@ -498,8 +498,8 @@
" <leaf name=\"uid\"> <type name=\"int32\"> </leaf>"
"</list>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL,
- "Invalid value \"-1\" of \"value\" attribute in \"max-elements\" element.", "Line number 8.");
+ CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"-1\" of \"value\" attribute in \"max-elements\" element.", "Line number 8.");
schema = MODULE_CREATE_YIN("TERR_0",
"<list name=\"user\">"
@@ -511,8 +511,8 @@
" <leaf name=\"group\"> <type name=\"string\"/> </leaf>"
"</list>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL,
- "Value \"4294967298\" of \"value\" attribute in \"max-elements\" element is out of bounds.", "Line number 8.");
+ CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
+ CHECK_LOG_CTX("Value \"4294967298\" of \"value\" attribute in \"max-elements\" element is out of bounds.", "Line number 8.");
schema = MODULE_CREATE_YIN("TERR_0",
"<list name=\"user\">"
@@ -524,8 +524,9 @@
" <leaf name=\"group\"> <type name=\"string\"/> </leaf>"
"</list>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL,
- "Invalid combination of min-elements and max-elements: min value 20 is bigger than the max value 10.", "Line number 8.");
+ CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid combination of min-elements and max-elements: min value 20 is bigger than the max value 10.",
+ "Line number 8.");
schema = MODULE_CREATE_YIN("TERR_0",
"<list name=\"user\">"
@@ -537,8 +538,8 @@
" <leaf name=\"group\"> <type name=\"string\"/> </leaf>"
"</list>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL,
- "Value \"-1\" of \"value\" attribute in \"min-elements\" element is out of bounds.", "Line number 8.");
+ CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
+ CHECK_LOG_CTX("Value \"-1\" of \"value\" attribute in \"min-elements\" element is out of bounds.", "Line number 8.");
schema = MODULE_CREATE_YIN("TERR_0",
"<list name=\"user\">"
@@ -549,8 +550,8 @@
" <leaf name=\"group\"> <type name=\"string\"/> </leaf>"
"</list>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL,
- "Redefinition of \"key\" sub-element in \"list\" element.", "Line number 8.");
+ CHECK_LOG_CTX("Parsing module \"TERR_0\" failed.", NULL);
+ CHECK_LOG_CTX("Redefinition of \"key\" sub-element in \"list\" element.", "Line number 8.");
schema = MODULE_CREATE_YIN("T6",
"<list name=\"user\">"
@@ -620,8 +621,8 @@
" <leaf name=\"group\"><type name=\"string\"/> </leaf>"
"</list>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL,
- "Invalid value \"systeme\" of \"value\" attribute in \"ordered-by\" element. Valid values are \"system\" and \"user\".",
+ CHECK_LOG_CTX("Parsing module \"TERROR0\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"systeme\" of \"value\" attribute in \"ordered-by\" element. Valid values are \"system\" and \"user\".",
"Line number 8.");
schema = MODULE_CREATE_YIN("T_DEFS1",
diff --git a/tests/utests/schema/test_schema.c b/tests/utests/schema/test_schema.c
index 175b569..010b4a4 100644
--- a/tests/utests/schema/test_schema.c
+++ b/tests/utests/schema/test_schema.c
@@ -91,7 +91,8 @@
const char *test_str__; \
TEST_SCHEMA_STR(RFC7950, YIN, MOD_NAME, CONTENT, test_str__) \
assert_int_not_equal(lys_parse_mem(UTEST_LYCTX, test_str__, YIN ? LYS_IN_YIN : LYS_IN_YANG, NULL), LY_SUCCESS); \
- CHECK_LOG_CTX("Parsing module \""MOD_NAME"\" failed.", NULL, ERRMSG, ERRPATH); \
+ CHECK_LOG_CTX("Parsing module \""MOD_NAME"\" failed.", NULL); \
+ CHECK_LOG_CTX(ERRMSG, ERRPATH); \
}
#define TEST_STMT_DUP(RFC7950, YIN, STMT, MEMBER, VALUE1, VALUE2, LINE) \
@@ -306,80 +307,80 @@
/* collision with a built-in type */
str = "module a {namespace urn:a; prefix a; typedef binary {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"binary\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"binary\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef bits {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"bits\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"bits\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef boolean {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"boolean\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"boolean\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef decimal64 {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"decimal64\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"decimal64\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef empty {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"empty\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"empty\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef enumeration {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"enumeration\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"enumeration\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef int8 {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"int8\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"int8\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef int16 {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"int16\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"int16\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef int32 {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"int32\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"int32\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef int64 {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"int64\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"int64\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef instance-identifier {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"instance-identifier\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"instance-identifier\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef identityref {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"identityref\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"identityref\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef leafref {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"leafref\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"leafref\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef string {type int8;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"string\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"string\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef union {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"union\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"union\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef uint8 {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"uint8\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"uint8\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef uint16 {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"uint16\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"uint16\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef uint32 {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"uint32\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"uint32\" of typedef statement - name collision with a built-in type.", NULL);
str = "module a {namespace urn:a; prefix a; typedef uint64 {type string;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"uint64\" of typedef statement - name collision with a built-in type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"uint64\" of typedef statement - name collision with a built-in type.", NULL);
str = "module mytypes {namespace urn:types; prefix t; typedef binary_ {type string;} typedef bits_ {type string;} typedef boolean_ {type string;} "
"typedef decimal64_ {type string;} typedef empty_ {type string;} typedef enumeration_ {type string;} typedef int8_ {type string;} typedef int16_ {type string;}"
@@ -391,34 +392,34 @@
/* collision in node's scope */
str = "module a {namespace urn:a; prefix a; container c {typedef y {type int8;} typedef y {type string;}}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"y\" of typedef statement - name collision with sibling type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"y\" of typedef statement - name collision with sibling type.", NULL);
/* collision with parent node */
str = "module a {namespace urn:a; prefix a; container c {container d {typedef y {type int8;}} typedef y {type string;}}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"y\" of typedef statement - name collision with another scoped type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"y\" of typedef statement - name collision with another scoped type.", NULL);
/* collision with module's top-level */
str = "module a {namespace urn:a; prefix a; typedef x {type string;} container c {typedef x {type int8;}}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL);
/* collision of submodule's node with module's top-level */
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} container c {typedef x {type string;}}}");
str = "module a {namespace urn:a; prefix a; include b; typedef x {type int8;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL);
/* collision of module's node with submodule's top-level */
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} typedef x {type int8;}}");
str = "module a {namespace urn:a; prefix a; include b; container c {typedef x {type string;}}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - scoped type collide with a top-level type.", NULL);
/* collision of submodule's node with another submodule's top-level */
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -426,29 +427,29 @@
list[1].data = "submodule bsub {belongs-to a {prefix a;} container c {typedef g {type int;}}}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of typedef statement - scoped type collide with a top-level type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of typedef statement - scoped type collide with a top-level type.", NULL);
/* collision of module's top-levels */
str = "module a {namespace urn:a; prefix a; typedef test {type string;} typedef test {type int8;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"test\" of typedef statement - name collision with another top-level type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"test\" of typedef statement - name collision with another top-level type.", NULL);
/* collision of submodule's top-levels */
submod = "submodule asub {belongs-to a {prefix a;} typedef g {type int;} typedef g {type int;}}";
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub;}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of typedef statement - name collision with another top-level type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of typedef statement - name collision with another top-level type.", NULL);
/* collision of module's top-level with submodule's top-levels */
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} typedef x {type string;}}");
str = "module a {namespace urn:a; prefix a; include b; typedef x {type int8;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"x\" of typedef statement - name collision with another top-level type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"x\" of typedef statement - name collision with another top-level type.", NULL);
/* collision of submodule's top-level with another submodule's top-levels */
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -456,15 +457,14 @@
list[1].data = "submodule bsub {belongs-to a {prefix a;} typedef g {type int;}}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of typedef statement - name collision with another top-level type.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of typedef statement - name collision with another top-level type.", NULL);
/* error in type-stmt */
str = "module a {namespace urn:a; prefix a; container c {typedef x {type t{}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Unexpected end-of-input.", "Line number 1.");
- UTEST_LOG_CLEAN;
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Unexpected end-of-input.", "Line number 1.");
/* no collision if the same names are in different scope */
str = "module a {yang-version 1.1; namespace urn:a; prefix a;"
@@ -485,34 +485,34 @@
/* collision in node's scope */
str = "module a {namespace urn:a; prefix a; container c {grouping y; grouping y;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"y\" of grouping statement - name collision with sibling grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"y\" of grouping statement - name collision with sibling grouping.", NULL);
/* collision with parent node */
str = "module a {namespace urn:a; prefix a; container c {container d {grouping y;} grouping y;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"y\" of grouping statement - name collision with another scoped grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"y\" of grouping statement - name collision with another scoped grouping.", NULL);
/* collision with module's top-level */
str = "module a {namespace urn:a; prefix a; grouping x; container c {grouping x;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
/* collision of submodule's node with module's top-level */
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} container c {grouping x;}}");
str = "module a {namespace urn:a; prefix a; include b; grouping x;}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
/* collision of module's node with submodule's top-level */
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} grouping x;}");
str = "module a {namespace urn:a; prefix a; include b; container c {grouping x;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
/* collision of submodule's node with another submodule's top-level */
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -520,29 +520,29 @@
list[1].data = "submodule bsub {belongs-to a {prefix a;} container c {grouping g;}}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
/* collision of module's top-levels */
str = "module a {namespace urn:a; prefix a; grouping test; grouping test;}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"test\" of grouping statement - name collision with another top-level grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"test\" of grouping statement - name collision with another top-level grouping.", NULL);
/* collision of submodule's top-levels */
submod = "submodule asub {belongs-to a {prefix a;} grouping g; grouping g;}";
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub;}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of grouping statement - name collision with another top-level grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - name collision with another top-level grouping.", NULL);
/* collision of module's top-level with submodule's top-levels */
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "submodule b {belongs-to a {prefix a;} grouping x;}");
str = "module a {namespace urn:a; prefix a; include b; grouping x;}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"x\" of grouping statement - name collision with another top-level grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"x\" of grouping statement - name collision with another top-level grouping.", NULL);
/* collision of submodule's top-level with another submodule's top-levels */
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -550,25 +550,27 @@
list[1].data = "submodule bsub {belongs-to a {prefix a;} grouping g;}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of grouping statement - name collision with another top-level grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - name collision with another top-level grouping.", NULL);
/* collision in nested groupings, top-level */
str = "module a {namespace urn:a; prefix a; grouping g {grouping g;}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - scoped grouping collide with a top-level grouping.", NULL);
/* collision in nested groupings, in node */
str = "module a {namespace urn:a; prefix a; container c {grouping g {grouping g;}}}";
assert_int_equal(lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of grouping statement - name collision with another scoped grouping.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of grouping statement - name collision with another scoped grouping.", NULL);
/* no collision if the same names are in different scope */
str = "module a {yang-version 1.1; namespace urn:a; prefix a;"
"container c {grouping g;} container d {grouping g;}}";
assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
+ CHECK_LOG_CTX("Locally scoped grouping \"g\" not used.", NULL);
+ CHECK_LOG_CTX("Locally scoped grouping \"g\" not used.", NULL);
}
static void
@@ -584,24 +586,24 @@
/* collision of module's top-levels */
str = "module a {yang-version 1.1; namespace urn:a; prefix a; identity g; identity g;}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
/* collision of submodule's top-levels */
submod = "submodule asub {belongs-to a {prefix a;} identity g; identity g;}";
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub;}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
/* collision of module's top-level with submodule's top-levels */
submod = "submodule asub {belongs-to a {prefix a;} identity g;}";
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; identity g;}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
/* collision of submodule's top-level with another submodule's top-levels */
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -609,8 +611,8 @@
list[1].data = "submodule bsub {belongs-to a {prefix a;} identity g;}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of identity statement - name collision with another top-level identity.", NULL);
}
static void
@@ -626,24 +628,24 @@
/* collision of module's top-levels */
str = "module a {yang-version 1.1; namespace urn:a; prefix a; feature g; feature g;}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
/* collision of submodule's top-levels */
submod = "submodule asub {belongs-to a {prefix a;} feature g; feature g;}";
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub;}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
/* collision of module's top-level with submodule's top-levels */
submod = "submodule asub {belongs-to a {prefix a;} feature g;}";
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; feature g;}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, submod);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
/* collision of submodule's top-level with another submodule's top-levels */
str = "module a {yang-version 1.1; namespace urn:a; prefix a; include asub; include bsub;}";
@@ -651,8 +653,8 @@
list[1].data = "submodule bsub {belongs-to a {prefix a;} feature g;}";
ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL,
- "Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
+ CHECK_LOG_CTX("Parsing module \"a\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"g\" of feature statement - name collision with another top-level feature.", NULL);
}
static void
@@ -1046,15 +1048,15 @@
ly_ctx_set_module_imp_clb(UTEST_LYCTX, module_clb, list);
mod = ly_ctx_load_module(UTEST_LYCTX, "main_b", NULL, NULL);
assert_null(mod);
- CHECK_LOG_CTX("Loading \"main_b\" module failed.", NULL,
- "Data model \"main_b\" not found in local searchdirs.", NULL,
- "Parsing module \"main_b\" failed.", NULL,
- "Including \"sub_b_one\" submodule into \"main_b\" failed.", NULL,
- "Data model \"sub_b_one\" not found in local searchdirs.", NULL,
- "Parsing submodule \"sub_b_one\" failed.", NULL,
- "YANG 1.1 requires all submodules to be included from main module. But submodule \"sub_b_one\" includes "
- "submodule \"sub_b_two\" which is not included by main module \"main_b\".", NULL,
- "YANG version 1.1 expects all includes in main module, includes in submodules (sub_b_one) are not necessary.", NULL);
+ CHECK_LOG_CTX("Loading \"main_b\" module failed.", NULL);
+ CHECK_LOG_CTX("Data model \"main_b\" not found in local searchdirs.", NULL);
+ CHECK_LOG_CTX("Parsing module \"main_b\" failed.", NULL);
+ CHECK_LOG_CTX("Including \"sub_b_one\" submodule into \"main_b\" failed.", NULL);
+ CHECK_LOG_CTX("Data model \"sub_b_one\" not found in local searchdirs.", NULL);
+ CHECK_LOG_CTX("Parsing submodule \"sub_b_one\" failed.", NULL);
+ CHECK_LOG_CTX("YANG 1.1 requires all submodules to be included from main module. But submodule \"sub_b_one\" includes "
+ "submodule \"sub_b_two\" which is not included by main module \"main_b\".", NULL);
+ CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (sub_b_one) are not necessary.", NULL);
}
{
@@ -1073,6 +1075,7 @@
assert_false(mod->parsed->includes[1].injected);
/* result is ok, but log includes the warning */
CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (sub_c_two) are not necessary.", NULL);
+ CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (sub_c_one) are not necessary.", NULL);
}
}
@@ -1606,8 +1609,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("Parsing module \"x\" failed.", NULL,
- "Extension instance \"a:e\" missing argument element \"name\".", NULL);
+ CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL);
+ CHECK_LOG_CTX("Extension instance \"a:e\" missing argument element \"name\".", NULL);
mod_test_yin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<module name=\"x\"\n"
@@ -1622,8 +1625,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("Parsing module \"x\" failed.", NULL,
- "Extension instance \"a:e\" missing argument element \"name\".", NULL);
+ CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL);
+ CHECK_LOG_CTX("Extension instance \"a:e\" missing argument element \"name\".", NULL);
mod_test_yin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<module name=\"x\"\n"
@@ -1638,8 +1641,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("Parsing module \"x\" failed.", NULL,
- "Extension instance \"a:e\" missing argument element \"name\".", NULL);
+ CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL);
+ CHECK_LOG_CTX("Extension instance \"a:e\" missing argument element \"name\".", NULL);
mod_test_yin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
"<module name=\"x\"\n"
@@ -1656,8 +1659,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("Parsing module \"x\" failed.", NULL,
- "Extension instance \"a:e\" element and its argument element \"name\" are expected in the same namespace, but they differ.",
+ CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL);
+ CHECK_LOG_CTX("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"
@@ -1675,8 +1678,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("Parsing module \"x\" failed.", NULL,
- "Extension instance \"a:e\" expects argument element \"name\" as its first XML child, but \"value\" element found.",
+ CHECK_LOG_CTX("Parsing module \"x\" failed.", NULL);
+ CHECK_LOG_CTX("Extension instance \"a:e\" expects argument element \"name\" as its first XML child, but \"value\" element found.",
NULL);
}
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index d6f0538..b61c765 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -82,6 +82,7 @@
ly_in_free(in, 0);
assert_int_equal(0, mod->implemented);
assert_int_equal(LY_EINVAL, lys_set_implemented(mod, feats));
+ CHECK_LOG_CTX("Feature \"invalid\" not found in module \"test\".", NULL);
assert_int_equal(LY_SUCCESS, lys_set_implemented(mod, NULL));
assert_non_null(mod->compiled);
assert_string_equal("test", mod->name);
@@ -250,15 +251,6 @@
assert_non_null(((struct lysc_type_leafref *)type)->realtype);
assert_int_equal(LY_TYPE_INT8, ((struct lysc_type_leafref *)type)->realtype->basetype);
- /* now test for string type is in file ./tests/utests/types/string.c */
-#if 0
- assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module b {namespace urn:b;prefix b;leaf-list ll {type string;}}", LYS_IN_YANG, &mod));
- assert_non_null(mod->compiled);
- assert_non_null((ll = (struct lysc_node_leaflist *)mod->compiled->data));
- assert_int_equal(0, ll->min);
- assert_int_equal((uint32_t)-1, ll->max);
-#endif
-
assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module c {yang-version 1.1;namespace urn:c;prefix c;typedef mytype {type int8;default 10;}"
"leaf-list ll1 {type mytype;default 1; default 1; config false;}"
"leaf-list ll2 {type mytype; ordered-by user;}}", LYS_IN_YANG, &mod));
@@ -323,6 +315,7 @@
"leaf ref {type instance-identifier {require-instance true;} default \"/ee:g\";}}", LYS_IN_YANG, NULL));
CHECK_LOG_CTX("Invalid default - value does not fit the type "
"(Invalid instance-identifier \"/ee:g\" value - semantic error.).", "Schema location \"/ee:ref\".");
+ CHECK_LOG_CTX("Not found node \"g\" in path.", "Schema location \"/ee:ref\".");
}
static void
@@ -544,8 +537,9 @@
/* invalid */
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;anydata any;}", LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Invalid keyword \"anydata\" as a child of \"module\" - the statement is allowed only in YANG 1.1 modules.", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid keyword \"anydata\" as a child of \"module\" - the statement is allowed only in YANG 1.1 modules.",
+ "Line number 1.");
}
static void
@@ -579,8 +573,9 @@
/* invalid */
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;container top {action x;}}",
LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Invalid keyword \"action\" as a child of \"container\" - the statement is allowed only in YANG 1.1 modules.", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid keyword \"action\" as a child of \"container\" - the statement is allowed only in YANG 1.1 modules.",
+ "Line number 1.");
assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;leaf x{type string;} rpc x;}",
LYS_IN_YANG, NULL));
@@ -650,8 +645,9 @@
/* invalid */
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;container top {notification x;}}",
LYS_IN_YANG, NULL));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Invalid keyword \"notification\" as a child of \"container\" - the statement is allowed only in YANG 1.1 modules.", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid keyword \"notification\" as a child of \"container\" - the statement is allowed only in YANG 1.1 modules.",
+ "Line number 1.");
assert_int_equal(LY_EEXIST, lys_parse_mem(UTEST_LYCTX, "module bb {namespace urn:bb;prefix bb;leaf x{type string;} notification x;}", LYS_IN_YANG, NULL));
CHECK_LOG_CTX("Duplicate identifier \"x\" of data definition/RPC/action/notification statement.", "/bb:x");
@@ -686,21 +682,6 @@
struct lys_module *mod;
struct lysc_type *type;
-#if 0
- /*test about int8 should be in tests/utests/types/int8.c*/
- assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module a {namespace urn:a;prefix a;leaf l {type int8 {range min..10|max;}}}", LYS_IN_YANG, &mod));
- type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
- assert_non_null(type);
- assert_int_equal(LY_TYPE_INT8, type->basetype);
- assert_non_null(((struct lysc_type_num *)type)->range);
- assert_non_null(((struct lysc_type_num *)type)->range->parts);
- assert_int_equal(2, LY_ARRAY_COUNT(((struct lysc_type_num *)type)->range->parts));
- assert_int_equal(-128, ((struct lysc_type_num *)type)->range->parts[0].min_64);
- assert_int_equal(10, ((struct lysc_type_num *)type)->range->parts[0].max_64);
- assert_int_equal(127, ((struct lysc_type_num *)type)->range->parts[1].min_64);
- assert_int_equal(127, ((struct lysc_type_num *)type)->range->parts[1].max_64);
-#endif
-
assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module b {namespace urn:b;prefix b;leaf l {type int16 {range min..10|max;}}}", LYS_IN_YANG, &mod));
type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
assert_non_null(type);
@@ -1152,32 +1133,33 @@
/* invalid cases */
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; feature f; leaf l {type enumeration {"
"enum one {if-feature f;}}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Invalid keyword \"if-feature\" as a child of \"enum\" - the statement is allowed only in YANG 1.1 modules.", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid keyword \"if-feature\" as a child of \"enum\" - the statement is allowed only in YANG 1.1 modules.",
+ "Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
"enum one {value -2147483649;}}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Invalid value \"-2147483649\" of \"value\".", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"-2147483649\" of \"value\".", "Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
"enum one {value 2147483648;}}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Invalid value \"2147483648\" of \"value\".", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"2147483648\" of \"value\".", "Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
"enum one; enum one;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Duplicate identifier \"one\" of enum statement.", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"one\" of enum statement.", "Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
"enum '';}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Enum name must not be zero-length.", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Enum name must not be zero-length.", "Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
"enum ' x';}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Enum name must not have any leading or trailing whitespaces (\" x\").", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Enum name must not have any leading or trailing whitespaces (\" x\").", "Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
"enum 'x ';}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Enum name must not have any leading or trailing whitespaces (\"x \").", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Enum name must not have any leading or trailing whitespaces (\"x \").", "Line number 1.");
assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type enumeration {"
"enum 'inva\nlid';}}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Control characters in enum name should be avoided (\"inva\nlid\", character number 5).", NULL);
@@ -1256,14 +1238,14 @@
/* invalid cases */
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type decimal64 {fraction-digits 0;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Invalid value \"0\" of \"fraction-digits\".", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"0\" of \"fraction-digits\".", "Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type decimal64 {fraction-digits -1;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Invalid value \"-1\" of \"fraction-digits\".", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"-1\" of \"fraction-digits\".", "Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type decimal64 {fraction-digits 19;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Value \"19\" is out of \"fraction-digits\" bounds.", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Value \"19\" is out of \"fraction-digits\" bounds.", "Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type decimal64;}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Missing fraction-digits substatement for decimal64 type.", "/aa:l");
@@ -1321,8 +1303,8 @@
/* invalid cases */
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type instance-identifier {require-instance yes;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL,
- "Invalid value \"yes\" of \"require-instance\".", "Line number 1.");
+ CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"yes\" of \"require-instance\".", "Line number 1.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa; leaf l {type instance-identifier {fraction-digits 1;}}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Invalid type restrictions for instance-identifier type.", "/aa:l");
@@ -1759,18 +1741,27 @@
path = "invalid_path";
assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &expr));
+ CHECK_LOG_CTX("Unexpected XPath token \"NameTest\" (\"invalid_path\"), expected \"..\".", NULL);
+
path = "..";
assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &expr));
+ CHECK_LOG_CTX("Unexpected XPath expression end.", NULL);
+
path = "..[";
assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &expr));
+ CHECK_LOG_CTX("Unparsed characters \"[\" left at the end of an XPath expression.", NULL);
+
path = "../";
assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &expr));
+ CHECK_LOG_CTX("Unexpected XPath expression end.", NULL);
+
path = "/";
assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
LY_PATH_PREFIX_OPTIONAL, LY_PATH_PRED_LEAFREF, &expr));
+ CHECK_LOG_CTX("Unexpected XPath expression end.", NULL);
path = "../../pref:id/xxx[predicate]/invalid!!!";
assert_int_equal(LY_EVALID, ly_path_parse(UTEST_LYCTX, NULL, path, strlen(path), 1, LY_PATH_BEGIN_EITHER,
@@ -1861,6 +1852,7 @@
"leaf target {if-feature 'f1'; type boolean;}}";
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, str, LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Target of leafref \"ref1\" cannot be referenced because it is disabled.", "Schema location \"/e:ref1\".");
+ CHECK_LOG_CTX("Not found node \"target\" in path.", "Schema location \"/e:ref1\".");
str = "module en {yang-version 1.1;namespace urn:en;prefix en;feature f1;"
"leaf ref1 {if-feature 'f1'; type leafref {path /target;}}"
@@ -1881,6 +1873,7 @@
"leaf ref {must \"/cl:h > 0\"; type uint16;}}", LYS_IN_YANG, &mod));
ly_ctx_unset_options(UTEST_LYCTX, LY_CTX_REF_IMPLEMENTED);
CHECK_LOG_CTX("Target of leafref \"g\" cannot be referenced because it is disabled.", "Schema location \"/cl:g\".");
+ CHECK_LOG_CTX("Not found node \"f\" in path.", "Schema location \"/cl:g\".");
assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module f {namespace urn:f;prefix f;"
"list interface{key name;leaf name{type string;}list address {key ip;leaf ip {type string;}}}"
@@ -1972,8 +1965,8 @@
CHECK_LOG_CTX("List predicate defined for container \"a\" in path.", "Schema location \"/dd:ref1\".");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee;\n container a {leaf target2 {type uint8;}}\n"
"leaf ref1 {type leafref {path /a!invalid;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"ee\" failed.", NULL,
- "Invalid character 0x21 ('!'), perhaps \"a\" is supposed to be a function call.", "Line number 3.");
+ CHECK_LOG_CTX("Parsing module \"ee\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid character 0x21 ('!'), perhaps \"a\" is supposed to be a function call.", "Line number 3.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff {namespace urn:ff;prefix ff;container a {leaf target2 {type uint8;}}"
"leaf ref1 {type leafref {path /a;}}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Invalid leafref path \"/a\" - target node is container instead of leaf or leaf-list.", "Schema location \"/ff:ref1\".");
@@ -2003,16 +1996,16 @@
"leaf ifname{type leafref{ path \"../interface/name\";}}\n"
"leaf address {type leafref{\n path \"/interface[name is current()/../ifname]/ip\";}}}",
LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"nn\" failed.", NULL,
- "Invalid character 0x69 ('i'), perhaps \"name\" is supposed to be a function call.", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"nn\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid character 0x69 ('i'), perhaps \"name\" is supposed to be a function call.", "Line number 5.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module oo {namespace urn:oo;prefix oo;\n"
"list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
"leaf ifname{type leafref{ path \"../interface/name\";}}\n"
"leaf address {type leafref{\n path \"/interface[name=current()/../ifname/ip\";}}}",
LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"oo\" failed.", NULL,
- "Unexpected XPath expression end.", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"oo\" failed.", NULL);
+ CHECK_LOG_CTX("Unexpected XPath expression end.", "Line number 5.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module pp {namespace urn:pp;prefix pp;"
"list interface{key name;leaf name{type string;}leaf ip {type string;}}"
@@ -2034,56 +2027,56 @@
"leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
"leaf address {type leafref{ path \"/interface[name=current() / .. / ifname][name=current()/../test]/ip\";}}}",
LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"rr\" failed.", NULL,
- "Duplicate predicate key \"name\" in path.", "Line number 4.");
+ CHECK_LOG_CTX("Parsing module \"rr\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate predicate key \"name\" in path.", "Line number 4.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ss {namespace urn:ss;prefix ss;\n"
"list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
"leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
"leaf address {type leafref{ path \"/interface[name = ../ifname]/ip\";}}}",
LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"ss\" failed.", NULL,
- "Unexpected XPath token \"..\" (\"../ifname]/ip\"), expected \"FunctionName\".", "Line number 4.");
+ CHECK_LOG_CTX("Parsing module \"ss\" failed.", NULL);
+ CHECK_LOG_CTX("Unexpected XPath token \"..\" (\"../ifname]/ip\"), expected \"FunctionName\".", "Line number 4.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module tt {namespace urn:tt;prefix tt;\n"
"list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
"leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
"leaf address {type leafref{ path \"/interface[name = current()../ifname]/ip\";}}}",
LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"tt\" failed.", NULL,
- "Unexpected XPath token \"..\" (\"../ifname]/ip\"), expected \"]\".", "Line number 4.");
+ CHECK_LOG_CTX("Parsing module \"tt\" failed.", NULL);
+ CHECK_LOG_CTX("Unexpected XPath token \"..\" (\"../ifname]/ip\"), expected \"]\".", "Line number 4.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module uu {namespace urn:uu;prefix uu;\n"
"list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
"leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
"leaf address {type leafref{ path \"/interface[name = current()/..ifname]/ip\";}}}",
LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"uu\" failed.", NULL,
- "Invalid character 'i'[31] of expression '/interface[name = current()/..ifname]/ip'.", "Line number 4.");
+ CHECK_LOG_CTX("Parsing module \"uu\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid character 'i'[31] of expression '/interface[name = current()/..ifname]/ip'.", "Line number 4.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module vv {namespace urn:vv;prefix vv;\n"
"list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
"leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
"leaf address {type leafref{ path \"/interface[name = current()/ifname]/ip\";}}}",
LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"vv\" failed.", NULL,
- "Unexpected XPath token \"NameTest\" (\"ifname]/ip\"), expected \"..\".", "Line number 4.");
+ CHECK_LOG_CTX("Parsing module \"vv\" failed.", NULL);
+ CHECK_LOG_CTX("Unexpected XPath token \"NameTest\" (\"ifname]/ip\"), expected \"..\".", "Line number 4.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ww {namespace urn:ww;prefix ww;\n"
"list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
"leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
"leaf address {type leafref{ path \"/interface[name = current()/../]/ip\";}}}",
LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"ww\" failed.", NULL,
- "Unexpected XPath token \"]\" (\"]/ip\").", "Line number 4.");
+ CHECK_LOG_CTX("Parsing module \"ww\" failed.", NULL);
+ CHECK_LOG_CTX("Unexpected XPath token \"]\" (\"]/ip\").", "Line number 4.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module xx {namespace urn:xx;prefix xx;\n"
"list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
"leaf ifname{type leafref{ path \"../interface/name\";}}leaf test{type string;}\n"
"leaf address {type leafref{ path \"/interface[name = current()/../#node]/ip\";}}}",
LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Parsing module \"xx\" failed.", NULL,
- "Invalid character '#'[32] of expression '/interface[name = current()/../#node]/ip'.", "Line number 4.");
+ CHECK_LOG_CTX("Parsing module \"xx\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid character '#'[32] of expression '/interface[name = current()/../#node]/ip'.", "Line number 4.");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module yy {namespace urn:yy;prefix yy;\n"
"list interface{key name;leaf name{type string;}leaf ip {type string;}}\n"
@@ -2345,10 +2338,11 @@
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;"
"grouping grp {leaf x {type leafref;}}}", LYS_IN_YANG, NULL));
CHECK_LOG_CTX("Missing path substatement for leafref type.", "/aa:{grouping='grp'}/x");
- UTEST_LOG_CLEAN;
+
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module aa {namespace urn:aa;prefix aa;"
"container a {grouping grp {leaf x {type leafref;}}}}", LYS_IN_YANG, NULL));
CHECK_LOG_CTX("Missing path substatement for leafref type.", "/aa:a/{grouping='grp'}/x");
+ CHECK_LOG_CTX("Locally scoped grouping \"grp\" not used.", NULL);
/* config check */
ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "module z1 {namespace urn:z1;prefix z1;"
@@ -2682,13 +2676,13 @@
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ee {namespace urn:ee;prefix ee;import grp {prefix g;}"
"uses g:grp {refine c/l {mandatory true;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ee:{uses='g:grp'}/ee:c/l",
- "Invalid mandatory leaf with a default value.", "/ee:{uses='g:grp'}/ee:c/l");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ee:{uses='g:grp'}/ee:c/l");
+ CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "/ee:{uses='g:grp'}/ee:c/l");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ef {namespace urn:ef;prefix ef;import grp {prefix g;}"
"uses g:grp {refine c/ch {mandatory true;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ef:{uses='g:grp'}/ef:c/ch",
- "Invalid mandatory choice with a default case.", "/ef:{uses='g:grp'}/ef:c/ch");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ef:{uses='g:grp'}/ef:c/ch");
+ CHECK_LOG_CTX("Invalid mandatory choice with a default case.", "/ef:{uses='g:grp'}/ef:c/ch");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ff {namespace urn:ff;prefix ff;import grp {prefix g;}"
"uses g:grp {refine c/ch/ca/ca {mandatory true;}}}", LYS_IN_YANG, &mod));
@@ -2696,13 +2690,13 @@
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg {namespace urn:gg;prefix gg;import grp {prefix g;}"
"uses g:grp {refine c/x {default hello;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/gg:{uses='g:grp'}/gg:c/x",
- "Invalid mandatory leaf with a default value.", "/gg:{uses='g:grp'}/gg:c/x");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/gg:{uses='g:grp'}/gg:c/x");
+ CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "/gg:{uses='g:grp'}/gg:c/x");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module hh {namespace urn:hh;prefix hh;import grp {prefix g;}"
"uses g:grp {refine c/c/l {config true;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/hh:{uses='g:grp'}/hh:c/c/l",
- "Configuration node cannot be child of any state data node.", "/hh:{uses='g:grp'}/hh:c/c/l");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/hh:{uses='g:grp'}/hh:c/c/l");
+ CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "/hh:{uses='g:grp'}/hh:c/c/l");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ii {namespace urn:ii;prefix ii;grouping grp {leaf l {type string; status deprecated;}}"
"uses grp {status obsolete;}}", LYS_IN_YANG, &mod));
@@ -2723,8 +2717,8 @@
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm {namespace urn:mm;prefix mm;import grp {prefix g;}"
"uses g:grp {refine c/ll {min-elements 1;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm:{uses='g:grp'}/mm:c/ll",
- "The default statement is present on leaf-list with a nonzero min-elements.", "/mm:{uses='g:grp'}/mm:c/ll");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm:{uses='g:grp'}/mm:c/ll");
+ CHECK_LOG_CTX("The default statement is present on leaf-list with a nonzero min-elements.", "/mm:{uses='g:grp'}/mm:c/ll");
}
static void
@@ -2901,6 +2895,7 @@
"augment /hi:func/input {leaf x {type string;}}"
"augment /hi:func/output {leaf y {type string;}}}", LYS_IN_YANG, NULL));
CHECK_LOG_CTX("Augment target node \"/hi:func/input\" from module \"hh\" was not found.", "/hh:{augment='/hi:func/input'}");
+ CHECK_LOG_CTX("Augment target node \"/hi:func/output\" from module \"hh\" was not found.", "/hh:{augment='/hi:func/output'}");
}
static void
@@ -3414,23 +3409,23 @@
CHECK_LOG_CTX("Invalid deviation adding \"default\" property which already exists (with value \"x:ba\").", "/gg1:{deviation='/e:b'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg2 {namespace urn:gg2;prefix gg2; import e {prefix e;}"
"deviation /e:a {deviate add {default x:a;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/e:a",
- "Default case prefix \"x\" not found in imports of \"gg2\".", "/e:a");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/e:a");
+ CHECK_LOG_CTX("Default case prefix \"x\" not found in imports of \"gg2\".", "/e:a");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg3 {namespace urn:gg3;prefix gg3; import e {prefix e;}"
"deviation /e:a {deviate add {default a;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/e:a",
- "Default case \"a\" not found.", "/e:a");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/e:a");
+ CHECK_LOG_CTX("Default case \"a\" not found.", "/e:a");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg4 {namespace urn:gg4;prefix gg4; import e {prefix e;}"
"deviation /e:c {deviate add {default hi;}}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Invalid deviation adding \"default\" property which already exists (with value \"hello\").", "/gg4:{deviation='/e:c'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg4 {namespace urn:gg4;prefix gg4; import e {prefix e;}"
"deviation /e:a {deviate add {default e:ac;}}}", LYS_IN_YANG, &mod));
- /*CHECK_LOG_CTX("Invalid deviation adding \"default\" property \"e:ac\" of choice - mandatory node \"ac\" under the default case.", "/gg4:{deviation='/e:a'}");*/
CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/e:a");
+ CHECK_LOG_CTX("Mandatory node \"ac\" under the default case \"e:ac\".", "/e:a");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module gg5 {namespace urn:gg5;prefix gg5; leaf x {type string; mandatory true;}"
"deviation /x {deviate add {default error;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/gg5:{deviation='/x'}",
- "Invalid mandatory leaf with a default value.", "/gg5:{deviation='/x'}");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/gg5:{deviation='/x'}");
+ CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "/gg5:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module hh1 {yang-version 1.1; namespace urn:hh1;prefix hh1; import e {prefix e;}"
"deviation /e:d {deviate replace {default hi;}}}", LYS_IN_YANG, &mod));
@@ -3454,8 +3449,8 @@
CHECK_LOG_CTX("Invalid deviation of case node - it is not possible to add \"config\" property.", "/jj1:{deviation='/ch/a'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj2 {namespace urn:jj2;prefix jj2; container top {config false; leaf x {type string;}}"
"deviation /top/x {deviate add {config true;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/jj2:{deviation='/top/x'}",
- "Configuration node cannot be child of any state data node.", "/jj2:{deviation='/top/x'}");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/jj2:{deviation='/top/x'}");
+ CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "/jj2:{deviation='/top/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj3 {namespace urn:jj3;prefix jj3; container top {leaf x {type string;}}"
"deviation /top/x {deviate replace {config false;}}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Invalid deviation replacing \"config\" property \"config false\" which is not present.", "/jj3:{deviation='/top/x'}");
@@ -3464,8 +3459,8 @@
CHECK_LOG_CTX("Invalid deviation of case node - it is not possible to replace \"config\" property.", "/jj4:{deviation='/ch/a'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj5 {namespace urn:jj5;prefix jj5; container top {leaf x {type string; config true;}}"
"deviation /top {deviate add {config false;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/jj5:top",
- "Configuration node cannot be child of any state data node.", "/jj5:top/x");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/jj5:top");
+ CHECK_LOG_CTX("Configuration node cannot be child of any state data node.", "/jj5:top/x");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module jj6 {namespace urn:jj6;prefix jj6; leaf x {config false; type string;}"
"deviation /x {deviate add {config true;}}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Invalid deviation adding \"config\" property which already exists (with value \"config false\").", "/jj6:{deviation='/x'}");
@@ -3485,33 +3480,33 @@
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ll1 {namespace urn:ll1;prefix ll1; leaf x {default test; type string;}"
"deviation /x {deviate add {mandatory true;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ll1:{deviation='/x'}",
- "Invalid mandatory leaf with a default value.", "/ll1:{deviation='/x'}");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ll1:{deviation='/x'}");
+ CHECK_LOG_CTX("Invalid mandatory leaf with a default value.", "/ll1:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ll2 {yang-version 1.1; namespace urn:ll2;prefix ll2; leaf-list x {default test; type string;}"
"deviation /x {deviate add {min-elements 1;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ll2:{deviation='/x'}",
- "The default statement is present on leaf-list with a nonzero min-elements.", "/ll2:{deviation='/x'}");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ll2:{deviation='/x'}");
+ CHECK_LOG_CTX("The default statement is present on leaf-list with a nonzero min-elements.", "/ll2:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module ll2 {namespace urn:ll2;prefix ll2; choice ch {default a; leaf a {type string;} leaf b {type string;}}"
"deviation /ch {deviate add {mandatory true;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ll2:ch",
- "Invalid mandatory choice with a default case.", "/ll2:ch");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/ll2:ch");
+ CHECK_LOG_CTX("Invalid mandatory choice with a default case.", "/ll2:ch");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm1 {namespace urn:mm1;prefix mm1; leaf-list x {min-elements 10; type string;}"
"deviation /x {deviate add {max-elements 5;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm1:{deviation='/x'}",
- "Leaf-list min-elements 10 is bigger than max-elements 5.", "/mm1:{deviation='/x'}");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm1:{deviation='/x'}");
+ CHECK_LOG_CTX("Leaf-list min-elements 10 is bigger than max-elements 5.", "/mm1:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm2 {namespace urn:mm2;prefix mm2; leaf-list x {max-elements 10; type string;}"
"deviation /x {deviate add {min-elements 20;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm2:{deviation='/x'}",
- "Leaf-list min-elements 20 is bigger than max-elements 10.", "/mm2:{deviation='/x'}");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm2:{deviation='/x'}");
+ CHECK_LOG_CTX("Leaf-list min-elements 20 is bigger than max-elements 10.", "/mm2:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm3 {namespace urn:mm3;prefix mm3; list x {min-elements 5; max-elements 10; config false;}"
"deviation /x {deviate replace {max-elements 1;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm3:{deviation='/x'}",
- "List min-elements 5 is bigger than max-elements 1.", "/mm3:{deviation='/x'}");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm3:{deviation='/x'}");
+ CHECK_LOG_CTX("List min-elements 5 is bigger than max-elements 1.", "/mm3:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm4 {namespace urn:mm4;prefix mm4; list x {min-elements 5; max-elements 10; config false;}"
"deviation /x {deviate replace {min-elements 20;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm4:{deviation='/x'}",
- "List min-elements 20 is bigger than max-elements 10.", "/mm4:{deviation='/x'}");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/mm4:{deviation='/x'}");
+ CHECK_LOG_CTX("List min-elements 20 is bigger than max-elements 10.", "/mm4:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module mm5 {namespace urn:mm5;prefix mm5; leaf-list x {type string; min-elements 5;}"
"deviation /x {deviate add {min-elements 1;}}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Invalid deviation adding \"min-elements\" property which already exists (with value \"5\").", "/mm5:{deviation='/x'}");
@@ -3542,8 +3537,8 @@
CHECK_LOG_CTX("Invalid deviation of anyxml node - it is not possible to replace \"type\" property.", "/nn1:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module nn2 {namespace urn:nn2;prefix nn2; leaf-list x {type string;}"
"deviation /x {deviate replace {type empty;}}}", LYS_IN_YANG, &mod));
- CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/nn2:{deviation='/x'}",
- "Leaf-list of type \"empty\" is allowed only in YANG 1.1 modules.", "/nn2:{deviation='/x'}");
+ CHECK_LOG_CTX("Compilation of a deviated and/or refined node failed.", "/nn2:{deviation='/x'}");
+ CHECK_LOG_CTX("Leaf-list of type \"empty\" is allowed only in YANG 1.1 modules.", "/nn2:{deviation='/x'}");
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module oo1 {namespace urn:oo1;prefix oo1; leaf x {type uint16; default 300;}"
"deviation /x {deviate replace {type uint8;}}}", LYS_IN_YANG, &mod));
@@ -3563,6 +3558,7 @@
assert_int_equal(LY_EVALID, lys_parse_mem(UTEST_LYCTX, "module pp1 {namespace urn:pp1;prefix pp1; import pp {prefix pp;}"
"deviation /pp:c/pp:x {deviate not-supported;}}", LYS_IN_YANG, &mod));
CHECK_LOG_CTX("Target of leafref \"l\" cannot be referenced because it is disabled.", "Schema location \"/pp:l\".");
+ CHECK_LOG_CTX("Not found node \"x\" in path.", "Schema location \"/pp:l\".");
}
static void
diff --git a/tests/utests/schema/test_yang.c b/tests/utests/schema/test_yang.c
index 78b1798..6d1c2ae 100644
--- a/tests/utests/schema/test_yang.c
+++ b/tests/utests/schema/test_yang.c
@@ -155,6 +155,7 @@
assert_int_equal(LY_EVALID, buf_store_char(YCTX, Y_IDENTIF_ARG, &p, &len, &buf, &size, 1, &prefix));
in.current = ":";
assert_int_equal(LY_EVALID, buf_store_char(YCTX, Y_IDENTIF_ARG, &p, &len, &buf, &size, 1, &prefix));
+ UTEST_LOG_CTX_CLEAN;
/* valid colon for prefixed identifiers */
len = size = 0;
p = NULL;
@@ -183,6 +184,7 @@
assert_int_equal(LY_SUCCESS, lysp_check_identifierchar((struct lysp_ctx *)YCTX, ':', 0, &prefix));
assert_int_equal(1, prefix);
assert_int_equal(LY_EVALID, lysp_check_identifierchar((struct lysp_ctx *)YCTX, ':', 0, &prefix));
+ CHECK_LOG_CTX("Invalid identifier first character ':' (0x003a).", "Line number 1.");
assert_int_equal(1, prefix);
assert_int_equal(LY_SUCCESS, lysp_check_identifierchar((struct lysp_ctx *)YCTX, 'b', 0, &prefix));
assert_int_equal(2, prefix);
@@ -887,12 +889,18 @@
ly_ctx_set_module_imp_clb(PARSER_CUR_PMOD(YCTX)->mod->ctx, test_imp_clb, "module xxx { namespace urn:xxx; prefix x;}");
in.current = "module" SCHEMA_BEGINNING "include xxx;}";
assert_int_equal(lys_parse_mem(PARSER_CUR_PMOD(YCTX)->mod->ctx, in.current, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"name\" failed.", NULL, "Including \"xxx\" submodule into \"name\" failed.", NULL);
+ CHECK_LOG_CTX("Parsing module \"name\" failed.", NULL);
+ CHECK_LOG_CTX("Including \"xxx\" submodule into \"name\" failed.", NULL);
+ CHECK_LOG_CTX("Data model \"xxx\" not found in local searchdirs.", NULL);
+ CHECK_LOG_CTX("Parsing submodule failed.", NULL);
+ CHECK_LOG_CTX("Input data contains module in situation when a submodule is expected.", NULL);
ly_ctx_set_module_imp_clb(PARSER_CUR_PMOD(YCTX)->mod->ctx, test_imp_clb, "submodule xxx {belongs-to wrong-name {prefix w;}}");
in.current = "module" SCHEMA_BEGINNING "include xxx;}";
assert_int_equal(lys_parse_mem(PARSER_CUR_PMOD(YCTX)->mod->ctx, in.current, LYS_IN_YANG, NULL), LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"name\" failed.", NULL, "Including \"xxx\" submodule into \"name\" failed.", NULL);
+ CHECK_LOG_CTX("Parsing module \"name\" failed.", NULL);
+ CHECK_LOG_CTX("Including \"xxx\" submodule into \"name\" failed.", NULL);
+ UTEST_LOG_CTX_CLEAN;
ly_ctx_set_module_imp_clb(PARSER_CUR_PMOD(YCTX)->mod->ctx, test_imp_clb, "submodule xxx {belongs-to name {prefix x;}}");
TEST_GENERIC("include xxx;}", mod->includes,
diff --git a/tests/utests/schema/test_yin.c b/tests/utests/schema/test_yin.c
index 0ce3abc..d5469f7 100644
--- a/tests/utests/schema/test_yin.c
+++ b/tests/utests/schema/test_yin.c
@@ -395,11 +395,13 @@
YCTX->xmlctx->value = "pre:b";
YCTX->xmlctx->value_len = 5;
assert_int_equal(yin_validate_value(YCTX, Y_IDENTIF_ARG), LY_EVALID);
+ CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", "Line number 1.");
assert_int_equal(yin_validate_value(YCTX, Y_PREF_IDENTIF_ARG), LY_SUCCESS);
YCTX->xmlctx->value = "pre:pre:b";
YCTX->xmlctx->value_len = 9;
assert_int_equal(yin_validate_value(YCTX, Y_PREF_IDENTIF_ARG), LY_EVALID);
+ CHECK_LOG_CTX("Invalid identifier character ':' (0x003a).", "Line number 1.");
}
static void
@@ -3230,6 +3232,8 @@
assert_int_equal(lyxml_ctx_new(UTEST_LYCTX, UTEST_IN, &YCTX->xmlctx), LY_SUCCESS);
assert_int_equal(yin_parse_submod(YCTX, lysp_submod), LY_SUCCESS);
+ CHECK_LOG_CTX("YANG version 1.1 expects all includes in main module, includes in submodules (mod) are not necessary.",
+ NULL);
assert_string_equal(lysp_submod->name, "mod");
assert_string_equal(lysp_submod->revs, "2019-02-02");
assert_string_equal(lysp_submod->prefix, "pref");
diff --git a/tests/utests/types/bits.c b/tests/utests/types/bits.c
index 3d42ebc..3dcdf98 100644
--- a/tests/utests/types/bits.c
+++ b/tests/utests/types/bits.c
@@ -194,8 +194,8 @@
" bit first {position -1;} bit second;"
"}}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_2\" failed.", NULL,
- "Invalid value \"-1\" of \"position\".", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERR_2\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"-1\" of \"position\".", "Line number 5.");
/* different max value => autoadd index */
schema = MODULE_CREATE_YANG("TERR_3", "leaf port {type bits {"
@@ -209,38 +209,38 @@
" bit first {position 10;} bit \"\";"
"}}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_4\" failed.", NULL,
- "Statement argument is required.", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERR_4\" failed.", NULL);
+ CHECK_LOG_CTX("Statement argument is required.", "Line number 5.");
/* wrong character */
schema = MODULE_CREATE_YANG("TERR_5", "leaf port {type bits {"
" bit first {position 10;} bit abcd^;"
"}}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_5\" failed.", NULL,
- "Invalid identifier character '^' (0x005e).", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERR_5\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid identifier character '^' (0x005e).", "Line number 5.");
schema = MODULE_CREATE_YANG("TERR_6", "leaf port {type bits {"
" bit hi; bit hi;"
"}}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_6\" failed.", NULL,
- "Duplicate identifier \"hi\" of bit statement.", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERR_6\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"hi\" of bit statement.", "Line number 5.");
/* wrong character */
schema = MODULE_CREATE_YANG("TERR_7", "leaf port {type bits {"
" bit first {position 10;} bit \"ab&cd\";"
"}}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_7\" failed.", NULL,
- "Invalid identifier character '&' (0x0026).", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERR_7\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid identifier character '&' (0x0026).", "Line number 5.");
schema = MODULE_CREATE_YANG("TERR_8", "leaf port {type bits {"
" bit first {position 10;} bit \"4abcd\";"
"}}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_8\" failed.", NULL,
- "Invalid identifier first character '4' (0x0034).", "Line number 5.");
+ CHECK_LOG_CTX("Parsing module \"TERR_8\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid identifier first character '4' (0x0034).", "Line number 5.");
schema = MODULE_CREATE_YANG("TERR_9", "leaf port {type bits;}");
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
@@ -256,8 +256,8 @@
" }}"
"}";
UTEST_INVALID_MODULE(schema, LYS_IN_YANG, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_10\" failed.", NULL,
- "Invalid keyword \"if-feature\" as a child of \"bit\" - the statement is allowed only in YANG 1.1 modules.",
+ CHECK_LOG_CTX("Parsing module \"TERR_10\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid keyword \"if-feature\" as a child of \"bit\" - the statement is allowed only in YANG 1.1 modules.",
"Line number 1.");
schema = "module TERR_11 {"
@@ -440,8 +440,8 @@
" <bit name=\"second\">"
"</type></leaf>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_2\" failed.", NULL,
- "Invalid value \"-1\" of \"value\" attribute in \"position\" element.", "Line number 8.");
+ CHECK_LOG_CTX("Parsing module \"TERR_2\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid value \"-1\" of \"value\" attribute in \"position\" element.", "Line number 8.");
/* different max value => autoadd index */
schema = MODULE_CREATE_YIN("TERR_3",
@@ -459,9 +459,8 @@
" <bit name=\"second\"/>"
"</type></leaf>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_4\" failed.", NULL,
- "Invalid identifier first character ' ' (0x0020).",
- "Line number 8.");
+ CHECK_LOG_CTX("Parsing module \"TERR_4\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid identifier first character ' ' (0x0020).", "Line number 8.");
schema = MODULE_CREATE_YIN("TERR_5",
"<leaf name=\"port\"> <type name=\"bits\">"
@@ -469,9 +468,8 @@
" <bit name=\"second\"/>"
"</type></leaf>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_5\" failed.", NULL,
- "Invalid identifier character ' ' (0x0020).",
- "Line number 8.");
+ CHECK_LOG_CTX("Parsing module \"TERR_5\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid identifier character ' ' (0x0020).", "Line number 8.");
schema = MODULE_CREATE_YIN("TERR_6",
"<leaf name=\"port\"> <type name=\"bits\">"
@@ -479,9 +477,8 @@
" <bit name=\"hi\"/>"
"</type></leaf>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_6\" failed.", NULL,
- "Duplicate identifier \"hi\" of bit statement.",
- "Line number 8.");
+ CHECK_LOG_CTX("Parsing module \"TERR_6\" failed.", NULL);
+ CHECK_LOG_CTX("Duplicate identifier \"hi\" of bit statement.", "Line number 8.");
schema = MODULE_CREATE_YIN("TERR_7",
"<leaf name=\"port\"> <type name=\"bits\">"
@@ -489,9 +486,8 @@
" <bit name=\"second\"/>"
"</type></leaf>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_7\" failed.", NULL,
- "Invalid identifier first character '4' (0x0034).",
- "Line number 8.");
+ CHECK_LOG_CTX("Parsing module \"TERR_7\" failed.", NULL);
+ CHECK_LOG_CTX("Invalid identifier first character '4' (0x0034).", "Line number 8.");
/* TEST EMPTY NAME*/
schema = MODULE_CREATE_YIN("TERR_8",
@@ -500,9 +496,8 @@
" <bit name=\"second\"/>"
"</type></leaf>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
- CHECK_LOG_CTX("Parsing module \"TERR_8\" failed.", NULL,
- "Empty identifier is not allowed.",
- "Line number 8.");
+ CHECK_LOG_CTX("Parsing module \"TERR_8\" failed.", NULL);
+ CHECK_LOG_CTX("Empty identifier is not allowed.", "Line number 8.");
}
static void
diff --git a/tests/utests/types/instanceid.c b/tests/utests/types/instanceid.c
index 06c8622..4c46b64 100644
--- a/tests/utests/types/instanceid.c
+++ b/tests/utests/types/instanceid.c
@@ -138,21 +138,29 @@
"defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l1", "/xdf:list[2]/xdf:value", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:list[2]/xdf:value\" value - semantic error.",
"Schema location \"/defs:l1\", line number 1.");
+ CHECK_LOG_CTX("Positional predicate defined for configuration list \"list\" in path.",
+ "Schema location \"/defs:l1\", line number 1.");
TEST_ERROR_XML2("",
"defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l1", "/t:cont/t:1l", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/t:cont/t:1l\" value - syntax error.",
"Schema location \"/defs:l1\", line number 1.");
+ CHECK_LOG_CTX("Invalid character 't'[9] of expression '/t:cont/t:1l'.",
+ "Schema location \"/defs:l1\", line number 1.");
TEST_ERROR_XML2("",
"defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l1", "/t:cont:t:1l", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/t:cont:t:1l\" value - syntax error.",
"Schema location \"/defs:l1\", line number 1.");
+ CHECK_LOG_CTX("Invalid character ':'[8] of expression '/t:cont:t:1l'.",
+ "Schema location \"/defs:l1\", line number 1.");
TEST_ERROR_XML2("",
"defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l1", "/xdf:cont/xdf:invalid/xdf:path", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:cont/xdf:invalid/xdf:path\" value - semantic error.",
"Schema location \"/defs:l1\", line number 1.");
+ CHECK_LOG_CTX("Not found node \"invalid\" in path.",
+ "Schema location \"/defs:l1\", line number 1.");
/* non-existing instances, instance-identifier is here in JSON format because it is already in internal
* representation without canonical prefixes */
@@ -192,71 +200,99 @@
"defs", "xmlns:t=\"urn:tests:defs\"", "t:l1", "/t:llist[1", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[1\" value - syntax error.",
"Schema location \"/defs:l1\", line number 1.");
+ CHECK_LOG_CTX("Unexpected XPath expression end.",
+ "Schema location \"/defs:l1\", line number 1.");
TEST_ERROR_XML2("<cont xmlns=\"urn:tests:mod\"/>",
"defs", "xmlns:m=\"urn:tests:mod\"", "l1", "/m:cont[1]", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/m:cont[1]\" value - semantic error.",
"Schema location \"/defs:l1\", line number 1.");
+ CHECK_LOG_CTX("Positional predicate defined for container \"cont\" in path.",
+ "Schema location \"/defs:l1\", line number 1.");
TEST_ERROR_XML2("<cont xmlns=\"urn:tests:mod\"/>",
"defs", "xmlns:m=\"urn:tests:mod\"", "l1", "[1]", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"[1]\" value - syntax error.",
"Schema location \"/defs:l1\", line number 1.");
+ CHECK_LOG_CTX("Unexpected XPath token \"[\" (\"[1]\").",
+ "Schema location \"/defs:l1\", line number 1.");
TEST_ERROR_XML2("<cont xmlns=\"urn:tests:mod\"><l2/></cont>",
"defs", "xmlns:m=\"urn:tests:mod\"", "l1", "/m:cont/m:l2[l2='1']", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/m:cont/m:l2[l2='1']\" value - syntax error.",
"Schema location \"/defs:l1\", line number 1.");
+ CHECK_LOG_CTX("Prefix missing for \"l2\" in path.",
+ "Schema location \"/defs:l1\", line number 1.");
TEST_ERROR_XML2("<cont xmlns=\"urn:tests:mod\"><l2/></cont>",
"defs", "xmlns:m=\"urn:tests:mod\"", "l1", "/m:cont/m:l2[m:l2='1']", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/m:cont/m:l2[m:l2='1']\" value - semantic error.",
"Schema location \"/defs:l1\", line number 1.");
+ CHECK_LOG_CTX("List predicate defined for leaf \"l2\" in path.",
+ "Schema location \"/defs:l1\", line number 1.");
TEST_ERROR_XML2("<llist xmlns=\"urn:tests:defs\">1</llist><llist xmlns=\"urn:tests:defs\">2</llist>",
"defs", "xmlns:t=\"urn:tests:defs\"", "t:l1", "/t:llist[4]", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[4]\" value - semantic error.",
"Schema location \"/defs:l1\", line number 1.");
+ CHECK_LOG_CTX("Positional predicate defined for configuration leaf-list \"llist\" in path.",
+ "Schema location \"/defs:l1\", line number 1.");
TEST_ERROR_XML2("",
"defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/t:llist[6]", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[6]\" value - semantic error.",
"Schema location \"/defs:l2\", line number 1.");
+ CHECK_LOG_CTX("No module connected with the prefix \"t\" found (prefix format XML prefixes).",
+ "Schema location \"/defs:l2\", line number 1.");
TEST_ERROR_XML2("<list xmlns=\"urn:tests:defs\"><id>1</id><value>x</value></list>",
"defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/xdf:list[xdf:value='x']", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:list[xdf:value='x']\" value - semantic error.",
"Schema location \"/defs:l2\", line number 1.");
+ CHECK_LOG_CTX("Key expected instead of leaf \"value\" in path.",
+ "Schema location \"/defs:l2\", line number 1.");
TEST_ERROR_XML2("",
"defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/xdf:list[.='x']", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:list[.='x']\" value - semantic error.",
"Schema location \"/defs:l2\", line number 1.");
+ CHECK_LOG_CTX("Leaf-list predicate defined for list \"list\" in path.",
+ "Schema location \"/defs:l2\", line number 1.");
TEST_ERROR_XML2("<llist xmlns=\"urn:tests:defs\">1</llist>",
"defs", "xmlns:t=\"urn:tests:defs\"", "t:l1", "/t:llist[.='x']", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[.='x']\" value - semantic error.",
"Schema location \"/defs:l1\", line number 1.");
+ CHECK_LOG_CTX("Invalid type uint32 value \"x\".",
+ "Schema location \"/defs:llist\", line number 1.");
TEST_ERROR_XML2("",
"defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/t:llist[1][2]", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[1][2]\" value - syntax error.",
"Schema location \"/defs:l2\", line number 1.");
+ CHECK_LOG_CTX("Unparsed characters \"[2]\" left at the end of path.",
+ "Schema location \"/defs:l2\", line number 1.");
TEST_ERROR_XML2("",
"defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/t:llist[.='a'][.='b']", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/t:llist[.='a'][.='b']\" value - syntax error.",
"Schema location \"/defs:l2\", line number 1.");
+ CHECK_LOG_CTX("Unparsed characters \"[.='b']\" left at the end of path.",
+ "Schema location \"/defs:l2\", line number 1.");
TEST_ERROR_XML2("<list xmlns=\"urn:tests:defs\"><id>1</id><value>x</value></list>",
"defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/xdf:list[xdf:id='1'][xdf:id='2']/xdf:value", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:list[xdf:id='1'][xdf:id='2']/xdf:value\" value - syntax error.",
"Schema location \"/defs:l2\", line number 1.");
+ CHECK_LOG_CTX("Duplicate predicate key \"id\" in path.",
+ "Schema location \"/defs:l2\", line number 1.");
TEST_ERROR_XML2("",
"defs", "xmlns:xdf=\"urn:tests:defs\"", "xdf:l2", "/xdf:list2[xdf:id='1']/xdf:value", LY_EVALID);
CHECK_LOG_CTX("Invalid instance-identifier \"/xdf:list2[xdf:id='1']/xdf:value\" value - semantic error.",
"Schema location \"/defs:l2\", line number 1.");
+ CHECK_LOG_CTX("Predicate missing for a key of list \"list2\" in path.",
+ "Schema location \"/defs:l2\", line number 1.");
}
static void
diff --git a/tests/utests/types/int8.c b/tests/utests/types/int8.c
index 7d0b9ad..5259eca 100644
--- a/tests/utests/types/int8.c
+++ b/tests/utests/types/int8.c
@@ -1243,8 +1243,14 @@
TEST_SUCCESS_JSON("T0", "127", INT8, "127", 127);
/* leading zeros */
TEST_ERROR_JSON("T0", "015");
+ CHECK_LOG_CTX("Unexpected character \"1\" after JSON number.",
+ "Line number 1.");
TEST_ERROR_JSON("T0", "-015");
+ CHECK_LOG_CTX("Unexpected character \"1\" after JSON number.",
+ "Line number 1.");
TEST_ERROR_JSON("defs", "+50");
+ CHECK_LOG_CTX("Invalid character sequence \"+50}\", expected a JSON value.",
+ "Line number 1.");
TEST_ERROR_JSON("T0", "-129");
CHECK_LOG_CTX("Value \"-129\" is out of type int8 min/max bounds.",
"Schema location \"/T0:port\", line number 1.");
@@ -1510,6 +1516,7 @@
ly_ret = type->store(UTEST_LYCTX, &lysc_type_test, val_text, strlen(val_text),
0, LY_VALUE_XML, NULL, LYD_VALHINT_HEXNUM, NULL, &value, NULL, &err);
assert_int_equal(LY_EINT, ly_ret);
+ UTEST_LOG_CTX_CLEAN;
/*
* ERROR TESTS
@@ -1541,6 +1548,8 @@
0, LY_VALUE_XML, NULL, LYD_VALHINT_DECNUM, NULL, &value, NULL, &err);
assert_int_equal(LY_EVALID, ly_ret);
ly_err_free(err);
+
+ UTEST_LOG_CTX_CLEAN;
}
static void
diff --git a/tests/utests/types/string.c b/tests/utests/types/string.c
index d232e9d..c110321 100644
--- a/tests/utests/types/string.c
+++ b/tests/utests/types/string.c
@@ -618,16 +618,8 @@
"</typedef>"
"<leaf name=\"port\"> <type name=\"my_type\"/> </leaf>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
-
- schema = MODULE_CREATE_YIN("TDEFAULT_2",
- "<typedef name=\"my_type\">"
- " <type name=\"string\">"
- " <length value=\"2\"/>"
- " </type>"
- " <default value=\"a1i-j<\"/>"
- "</typedef>"
- "<leaf name=\"port\"> <type name=\"my_type\"/> </leaf>");
- UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
+ CHECK_LOG_CTX("Invalid default - value does not fit the type (Unsatisfied length - string \"a1i-j<\" length is not allowed.).",
+ "Schema location \"/TDEFAULT_2:port\".");
schema = MODULE_CREATE_YIN("TDEFAULT_3",
"<typedef name=\"my_type\">"
@@ -636,6 +628,8 @@
"</type> </typedef>"
"<leaf name=\"port\"><type name=\"my_type\"> <pattern value=\"bcd.*\"/> </type></leaf>");
UTEST_INVALID_MODULE(schema, LYS_IN_YIN, NULL, LY_EVALID);
+ CHECK_LOG_CTX("Invalid default - value does not fit the type (Unsatisfied pattern - \"a1i-j<\" does not conform to \"bcd.*\".).",
+ "Schema location \"/TDEFAULT_3:port\".");
}
diff --git a/tests/utests/types/yang_types.c b/tests/utests/types/yang_types.c
index 6ce7671..7bcb5e6 100644
--- a/tests/utests/types/yang_types.c
+++ b/tests/utests/types/yang_types.c
@@ -147,8 +147,8 @@
CHECK_LOG_CTX("Failed to resolve prefix \"a\".", "Schema location \"/a:l2\", line number 1.");
TEST_ERROR_XML("a\" xmlns:yl=\"urn:ietf:params:xml:ns:yang:ietf-yang-library", "l2",
"/yl:yang-library/yl:datastore/yl::name");
- CHECK_LOG_CTX("Storing value failed.", "Schema location \"/a:l2\", line number 1.",
- "Invalid character 'y'[31] of expression '/yl:yang-library/yl:datastore/yl::name'.",
+ CHECK_LOG_CTX("Storing value failed.", "Schema location \"/a:l2\", line number 1.");
+ CHECK_LOG_CTX("Invalid character 'y'[31] of expression '/yl:yang-library/yl:datastore/yl::name'.",
"Schema location \"/a:l2\", line number 1.");
}
diff --git a/tests/utests/utests.h b/tests/utests/utests.h
index 877d048..594d528 100644
--- a/tests/utests/utests.h
+++ b/tests/utests/utests.h
@@ -1224,98 +1224,25 @@
_UC->in = NULL
/**
- * @brief Internal macro to compare error info record with the expected error message and path.
- * If NULL is provided as MSG, no error info record (NULL) is expected.
+ * @brief Check expected last error in libyang context, which is then cleared. Can be called repeatedly to check
+ * several errors. If NULL is provided as MSG, no error info record (NULL) is expected.
*
- * @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) { \
- assert_null(ERR); \
- } else { \
- assert_non_null(ERR); \
- CHECK_STRING((ERR)->msg, MSG); \
- CHECK_STRING((ERR)->path, PATH); \
+#define CHECK_LOG_CTX(MSG, PATH) \
+ { \
+ struct ly_err_item *_e = ly_err_last(_UC->ctx); \
+ if (!MSG) { \
+ assert_null(_e); \
+ } else { \
+ assert_non_null(_e); \
+ CHECK_STRING(_e->msg, MSG); \
+ CHECK_STRING(_e->path, PATH); \
+ } \
+ ly_err_clean(_UC->ctx, _e); \
}
-/**`
- * @brief Internal macro to check the last libyang's context error.
- */
-#define _CHECK_LOG_CTX1(MSG, PATH) \
- _CHECK_LOG_CTX(ly_err_last(_UC->ctx), MSG, PATH)
-
-/**
- * @brief Internal macro to check the last two libyang's context error.
- */
-#define _CHECK_LOG_CTX2(MSG1, PATH1, MSG2, PATH2) \
- _CHECK_LOG_CTX(ly_err_last(_UC->ctx), MSG1, PATH1); \
- _CHECK_LOG_CTX(ly_err_last(_UC->ctx)->prev, MSG2, PATH2)
-
-/**
- * @brief Internal macro to check the last three libyang's context error.
- */
-#define _CHECK_LOG_CTX3(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3) \
- _CHECK_LOG_CTX2(MSG1, PATH1, MSG2, PATH2); \
- _CHECK_LOG_CTX(ly_err_last(_UC->ctx)->prev->prev, MSG3, PATH3)
-
-/**
- * @brief Internal macro to check the last three libyang's context error.
- */
-#define _CHECK_LOG_CTX4(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4) \
- _CHECK_LOG_CTX3(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3); \
- _CHECK_LOG_CTX(ly_err_last(_UC->ctx)->prev->prev->prev, MSG4, PATH4)
-
-/**
- * @brief Internal macro to check the last three libyang's context error.
- */
-#define _CHECK_LOG_CTX5(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4, MSG5, PATH5) \
- _CHECK_LOG_CTX4(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4); \
- _CHECK_LOG_CTX(ly_err_last(_UC->ctx)->prev->prev->prev->prev, MSG5, PATH5)
-
-/**
- * @brief Internal macro to check the last three libyang's context error.
- */
-#define _CHECK_LOG_CTX6(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4, MSG5, PATH5, MSG6, PATH6) \
- _CHECK_LOG_CTX5(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4, MSG5, PATH5); \
- _CHECK_LOG_CTX(ly_err_last(_UC->ctx)->prev->prev->prev->prev->prev, MSG6, PATH6)
-
-/**
- * @brief Internal macro to check the last three libyang's context error.
- */
-#define _CHECK_LOG_CTX7(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4, MSG5, PATH5, MSG6, PATH6, MSG7, PATH7) \
- _CHECK_LOG_CTX6(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4, MSG5, PATH5, MSG6, PATH6); \
- _CHECK_LOG_CTX(ly_err_last(_UC->ctx)->prev->prev->prev->prev->prev->prev, MSG7, PATH7)
-
-/**
- * @brief Internal macro to check the last three libyang's context error.
- */
-#define _CHECK_LOG_CTX8(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4, MSG5, PATH5, MSG6, PATH6, MSG7, PATH7, MSG8, PATH8) \
- _CHECK_LOG_CTX7(MSG1, PATH1, MSG2, PATH2, MSG3, PATH3, MSG4, PATH4, MSG5, PATH5, MSG6, PATH6, MSG7, PATH7); \
- _CHECK_LOG_CTX(ly_err_last(_UC->ctx)->prev->prev->prev->prev->prev->prev->prev, MSG8, PATH8)
-
-/**
- * @brief Internal helper macro to select _CHECK_LOG_CTX* macro according to the provided parameters.
- */
-#define _GET_CHECK_LOG_MACRO(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, NAME, ...) NAME
-
-/**
- * @brief Check expected error(s) in libyang context.
- *
- * Macro has variadic parameters expected to be provided in pairs of error message and error path starting
- * from the latest error. Current limit is checking at most 3 last errors. After checking, macro cleans up
- * all the errors from the libyang context.
- *
- * @param[in] MSG Expected error message.
- * @param[in] PATH Expected error path.
- */
-#define CHECK_LOG_CTX(...) \
- _GET_CHECK_LOG_MACRO(__VA_ARGS__, _CHECK_LOG_CTX8, _INVAL, _CHECK_LOG_CTX7, _INVAL, \
- _CHECK_LOG_CTX6, _INVAL, _CHECK_LOG_CTX5, _INVAL, _CHECK_LOG_CTX4, _INVAL, \
- _CHECK_LOG_CTX3, _INVAL, _CHECK_LOG_CTX2, _INVAL, _CHECK_LOG_CTX1, DUMMY)(__VA_ARGS__); \
- ly_err_clean(_UC->ctx, NULL)
-
/**
* @brief Check expected error in libyang context including error-app-tag.
*
@@ -1324,14 +1251,23 @@
* @param[in] APPTAG Expected error-app-tag.
*/
#define CHECK_LOG_CTX_APPTAG(MSG, PATH, APPTAG) \
- if (!MSG) { \
- assert_null(ly_err_last(_UC->ctx)); \
- } else { \
- assert_non_null(ly_err_last(_UC->ctx)); \
- CHECK_STRING(ly_err_last(_UC->ctx)->msg, MSG); \
- CHECK_STRING(ly_err_last(_UC->ctx)->path, PATH); \
- CHECK_STRING(ly_err_last(_UC->ctx)->apptag, APPTAG); \
- } \
+ { \
+ struct ly_err_item *_e = ly_err_last(_UC->ctx); \
+ if (!MSG) { \
+ assert_null(_e); \
+ } else { \
+ assert_non_null(_e); \
+ CHECK_STRING(_e->msg, MSG); \
+ CHECK_STRING(_e->path, PATH); \
+ CHECK_STRING(_e->apptag, APPTAG); \
+ } \
+ ly_err_clean(_UC->ctx, _e); \
+ }
+
+/**
+ * @brief Clear all errors stored in the libyang context.
+ */
+#define UTEST_LOG_CTX_CLEAN \
ly_err_clean(_UC->ctx, NULL)
/**
@@ -1435,7 +1371,8 @@
{
*state = NULL;
- /* libyang context */
+ /* libyang context, no leftover messages */
+ assert_null(ly_err_last(current_utest_context->ctx));
ly_ctx_destroy(current_utest_context->ctx);
if (current_utest_context->orig_tz) {