summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-17 03:00:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-17 03:00:07 +0000
commitfef792e47eab0ebe386c4bc7f61ac07c35d3fc50 (patch)
tree0f7617c3a1a10794e8c07db7d8ebe831e7e61c94 /tests
parentReleasing debian version 3.1.0+dfsg-5. (diff)
downloadlibyang3-fef792e47eab0ebe386c4bc7f61ac07c35d3fc50.tar.xz
libyang3-fef792e47eab0ebe386c4bc7f61ac07c35d3fc50.zip
Merging upstream version 3.4.2+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/modules/yang/notifications@2008-07-14.yang4
-rw-r--r--tests/perf/perf.c3
-rw-r--r--tests/utests/basic/test_context.c8
-rw-r--r--tests/utests/data/test_parser_xml.c14
-rw-r--r--tests/utests/data/test_tree_data.c2
-rw-r--r--tests/utests/data/test_tree_data_sorted.c52
-rw-r--r--tests/utests/schema/test_schema.c4
-rw-r--r--tests/utests/schema/test_tree_schema_compile.c15
-rw-r--r--tests/utests/schema/test_yang.c2
-rw-r--r--tests/utests/types/yang_types.c7
-rw-r--r--tests/yanglint/interactive/debug.test33
-rw-r--r--tests/yanglint/interactive/ly.tcl14
12 files changed, 93 insertions, 65 deletions
diff --git a/tests/modules/yang/notifications@2008-07-14.yang b/tests/modules/yang/notifications@2008-07-14.yang
index b696f39..8a723b2 100644
--- a/tests/modules/yang/notifications@2008-07-14.yang
+++ b/tests/modules/yang/notifications@2008-07-14.yang
@@ -80,7 +80,7 @@ module notifications {
}
}
- /*container notification {
+ container notification {
description "internal struct to start a notification";
config false;
@@ -90,6 +90,6 @@ module notifications {
}
// eventType and any data content goes here
- }*/
+ }
}
diff --git a/tests/perf/perf.c b/tests/perf/perf.c
index da1eb93..37591cb 100644
--- a/tests/perf/perf.c
+++ b/tests/perf/perf.c
@@ -580,6 +580,9 @@ test_dup_siblings_to_empty(struct test_state *state, struct timespec *ts_start,
TEST_END(ts_end);
+ /* need to remove the duplicated nodes if the test is repeated */
+ lyd_free_siblings(lyd_child(state->data1));
+
return LY_SUCCESS;
}
diff --git a/tests/utests/basic/test_context.c b/tests/utests/basic/test_context.c
index 7feb65f..476fd81 100644
--- a/tests/utests/basic/test_context.c
+++ b/tests/utests/basic/test_context.c
@@ -831,8 +831,8 @@ check_ext_instance_priv_parsed_is_set(struct lysc_ext_instance *ext)
LY_ARRAY_FOR(ext, u) {
substmts = ext[u].substmts;
LY_ARRAY_FOR(substmts, v) {
- if (substmts && substmts[v].storage && (substmts[v].stmt & LY_STMT_DATA_NODE_MASK)) {
- cnode = *(struct lysc_node **)substmts[v].storage;
+ if (substmts && substmts[v].storage_p && (substmts[v].stmt & LY_STMT_DATA_NODE_MASK)) {
+ cnode = *(struct lysc_node **)substmts[v].storage_p;
iter = check;
assert_int_equal(LY_SUCCESS, lysc_tree_dfs_full(cnode, check_node_priv_parsed_is_set, &iter));
}
@@ -850,8 +850,8 @@ check_ext_instance_priv_parsed_not_set(struct lysc_ext_instance *ext)
LY_ARRAY_FOR(ext, u) {
substmts = ext[u].substmts;
LY_ARRAY_FOR(substmts, v) {
- if (substmts && substmts[v].storage && (substmts[v].stmt & LY_STMT_DATA_NODE_MASK)) {
- cnode = *(struct lysc_node **)substmts[v].storage;
+ if (substmts && substmts[v].storage_p && (substmts[v].stmt & LY_STMT_DATA_NODE_MASK)) {
+ cnode = *(struct lysc_node **)substmts[v].storage_p;
if (cnode) {
CHECK_POINTER((struct lysp_node *)cnode->priv, 0);
}
diff --git a/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index d5336c0..d7203fa 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -193,6 +193,18 @@ test_anyxml(void **state)
free(str);
CHECK_LYD_STRING(tree, LYD_PRINT_WITHSIBLINGS, data_expected);
lyd_free_all(tree);
+
+ data = "<anyx xmlns=\"urn:tests:a\"><x>1</x><x>0</x><x>-1</x><x>4294967295</x><x>4294967296</x><x>-2147483648</x><x>-2147483649</x></anyx>";
+ CHECK_PARSE_LYD(data, 0, LYD_VALIDATE_PRESENT, tree);
+ assert_non_null(tree);
+ tree = tree->next;
+ assert_int_equal(LY_SUCCESS, lyd_print_mem(&str, tree, LYD_XML, LYD_PRINT_SHRINK));
+ CHECK_STRING(str, data);
+ free(str);
+ assert_int_equal(LY_SUCCESS, lyd_print_mem(&str, tree, LYD_JSON, LYD_PRINT_SHRINK));
+ CHECK_STRING(str, "{\"a:anyx\":{\"x\":[1,0,-1,4294967295,\"4294967296\",-2147483648,\"-2147483649\"]}}");
+ free(str);
+ lyd_free_all(tree);
}
static void
@@ -349,7 +361,7 @@ test_opaq(void **state)
" <c xmld:id=\"D\">1</c>\n"
"</a>\n",
LYD_XML, LYD_PARSE_OPAQ, LYD_VALIDATE_PRESENT, &tree));
- CHECK_LOG_CTX("Unknown XML prefix \"xmld\".", "/a", 3);
+ CHECK_LOG_CTX("Unknown XML prefix \"xmld\" at attribute \"id\".", "/a", 3);
}
static void
diff --git a/tests/utests/data/test_tree_data.c b/tests/utests/data/test_tree_data.c
index fabd170..b3dde5a 100644
--- a/tests/utests/data/test_tree_data.c
+++ b/tests/utests/data/test_tree_data.c
@@ -409,7 +409,7 @@ test_target(void **state)
assert_string_equal(lyd_get_value(term->prev), "b");
lyd_free_all(tree);
- ly_path_free(UTEST_LYCTX, path);
+ ly_path_free(path);
lyxp_expr_free(UTEST_LYCTX, exp);
}
diff --git a/tests/utests/data/test_tree_data_sorted.c b/tests/utests/data/test_tree_data_sorted.c
index 0e812e7..bb6e4d6 100644
--- a/tests/utests/data/test_tree_data_sorted.c
+++ b/tests/utests/data/test_tree_data_sorted.c
@@ -131,6 +131,57 @@ test_insert_cont_leaflist(void **state)
}
static void
+test_dup_sort(void **state)
+{
+ const char *schema;
+ struct lys_module *mod;
+ struct lyd_node *cont, *cont2;
+ char *str;
+
+ schema = "module a {namespace urn:tests:a;prefix a;yang-version 1.1;revision 2014-05-08;"
+ "container cn { list lst {key \"k\"; leaf k {type uint32;}}}}";
+ UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, &mod);
+
+ assert_int_equal(lyd_new_inner(NULL, mod, "cn", 0, &cont), LY_SUCCESS);
+ assert_int_equal(lyd_new_list(cont, NULL, "lst", 0, NULL, "2"), LY_SUCCESS);
+ assert_int_equal(lyd_new_list(cont, NULL, "lst", 0, NULL, "5"), LY_SUCCESS);
+ assert_int_equal(lyd_new_list(cont, NULL, "lst", 0, NULL, "9"), LY_SUCCESS);
+
+ assert_int_equal(lyd_new_inner(NULL, mod, "cn", 0, &cont2), LY_SUCCESS);
+ assert_int_equal(lyd_new_list(cont2, NULL, "lst", 0, NULL, "1"), LY_SUCCESS);
+ assert_int_equal(lyd_new_list(cont2, NULL, "lst", 0, NULL, "3"), LY_SUCCESS);
+ assert_int_equal(lyd_new_list(cont2, NULL, "lst", 0, NULL, "8"), LY_SUCCESS);
+
+ assert_int_equal(lyd_dup_siblings(lyd_child(cont2), (struct lyd_node_inner *)cont, 0, NULL), LY_SUCCESS);
+ lyd_print_mem(&str, cont, LYD_XML, 0);
+ assert_string_equal(str,
+ "<cn xmlns=\"urn:tests:a\">\n"
+ " <lst>\n"
+ " <k>1</k>\n"
+ " </lst>\n"
+ " <lst>\n"
+ " <k>2</k>\n"
+ " </lst>\n"
+ " <lst>\n"
+ " <k>3</k>\n"
+ " </lst>\n"
+ " <lst>\n"
+ " <k>5</k>\n"
+ " </lst>\n"
+ " <lst>\n"
+ " <k>8</k>\n"
+ " </lst>\n"
+ " <lst>\n"
+ " <k>9</k>\n"
+ " </lst>\n"
+ "</cn>\n");
+ free(str);
+
+ lyd_free_all(cont);
+ lyd_free_all(cont2);
+}
+
+static void
test_try_user_order_func(void **state)
{
const char *schema;
@@ -1599,6 +1650,7 @@ main(void)
UTEST(test_insert_top_level_leaflist),
UTEST(test_insert_cont_list),
UTEST(test_insert_cont_leaflist),
+ UTEST(test_dup_sort),
UTEST(test_try_user_order_func),
UTEST(test_ordered_by_user),
UTEST(test_remove),
diff --git a/tests/utests/schema/test_schema.c b/tests/utests/schema/test_schema.c
index 953aad8..cba2b2d 100644
--- a/tests/utests/schema/test_schema.c
+++ b/tests/utests/schema/test_schema.c
@@ -1712,7 +1712,7 @@ test_extension_compile(void **state)
LY_ARRAY_NEW_GOTO(UTEST_LYCTX, ext_p.substmts, substmtp, rc, cleanup);
substmtp->stmt = LY_STMT_ERROR_MESSAGE;
- substmtp->storage = (uintptr_t)(void *)&ext_p.parsed;
+ substmtp->storage_p = &ext_p.parsed;
/* fake parse */
lydict_insert(UTEST_LYCTX, "my error", 0, (const char **)&ext_p.parsed);
@@ -1721,7 +1721,7 @@ test_extension_compile(void **state)
LY_ARRAY_NEW_GOTO(UTEST_LYCTX, ext_c.substmts, substmt, rc, cleanup);
substmt->stmt = LY_STMT_ERROR_MESSAGE;
- substmt->storage = (uintptr_t)(void *)&ext_c.compiled;
+ substmt->storage_p = &ext_c.compiled;
/*
* error-message
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index 3d4fbf7..04c30db 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -1233,6 +1233,7 @@ test_type_instanceid(void **state)
{
struct lys_module *mod;
struct lysc_type *type;
+ char *str;
assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module a {namespace urn:a;prefix a;typedef mytype {type instance-identifier {require-instance false;}}"
"leaf l1 {type instance-identifier {require-instance true;}}"
@@ -1252,12 +1253,22 @@ test_type_instanceid(void **state)
assert_int_equal(LY_TYPE_INST, type->basetype);
assert_int_equal(1, ((struct lysc_type_instanceid *)type)->require_instance);
+ /* default value */
+ str = "module b1 {namespace urn:b1;prefix b1;"
+ "leaf l1 {type string;}}";
+ ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, str);
+ ly_ctx_set_options(UTEST_LYCTX, LY_CTX_REF_IMPLEMENTED);
+ assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module b2 {namespace urn:b2;prefix b2;"
+ "import b1 {prefix b1;}"
+ "leaf l1 {type instance-identifier; default \"/b1:l1\";}}", LYS_IN_YANG, NULL));
+ ly_ctx_set_options(UTEST_LYCTX, 0);
+
/* 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));
+ 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, NULL));
CHECK_LOG_CTX("Parsing module \"aa\" failed.", NULL, 0);
CHECK_LOG_CTX("Invalid value \"yes\" of \"require-instance\".", NULL, 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));
+ 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, NULL));
CHECK_LOG_CTX("Invalid type restrictions for instance-identifier type.", "/aa:l", 0);
}
diff --git a/tests/utests/schema/test_yang.c b/tests/utests/schema/test_yang.c
index 67f9747..034f95d 100644
--- a/tests/utests/schema/test_yang.c
+++ b/tests/utests/schema/test_yang.c
@@ -284,8 +284,6 @@ test_arg(void **state)
TEST_GET_ARGUMENT_SUCCESS("hello ", YCTX, Y_STR_ARG, "hello ", 5, " ", 1);
- TEST_GET_ARGUMENT_SUCCESS("hello/*comment*/\n", YCTX, Y_STR_ARG, "hello/*comment*/\n", 5, "\n", 1);
-
TEST_GET_ARGUMENT_SUCCESS("\"hello\\n\\t\\\"\\\\\";", YCTX, Y_STR_ARG, "hello\n\t\"\\", 9, ";", 1);
free(buf);
diff --git a/tests/utests/types/yang_types.c b/tests/utests/types/yang_types.c
index f79238e..07c5e16 100644
--- a/tests/utests/types/yang_types.c
+++ b/tests/utests/types/yang_types.c
@@ -112,14 +112,13 @@ test_data_xml(void **state)
TEST_SUCCESS_XML("a", "l", "2021-02-29T00:00:00-00:00", STRING, "2021-03-01T00:00:00-00:00");
TEST_ERROR_XML("a", "l", "2005-05-31T23:15:15.-08:00", LY_EVALID);
- CHECK_LOG_CTX("Unsatisfied pattern - \"2005-05-31T23:15:15.-08:00\" does not conform to "
- "\"\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[\\+\\-]\\d{2}:\\d{2})\".",
+ CHECK_LOG_CTX("Missing date-and-time fractions after '.'.",
"/a:l", 1);
- TEST_ERROR_XML("a", "l", "2023-16-15T20:13:01+01:00", LY_EINVAL);
+ TEST_ERROR_XML("a", "l", "2023-16-15T20:13:01+01:00", LY_EVALID);
CHECK_LOG_CTX("Invalid date-and-time month \"15\".", "/a:l", 1);
- TEST_ERROR_XML("a", "l", "2023-10-15T20:13:01+95:00", LY_EINVAL);
+ TEST_ERROR_XML("a", "l", "2023-10-15T20:13:01+95:00", LY_EVALID);
CHECK_LOG_CTX("Invalid date-and-time timezone hour \"95\".", "/a:l", 1);
/* hex-string */
diff --git a/tests/yanglint/interactive/debug.test b/tests/yanglint/interactive/debug.test
deleted file mode 100644
index 8a64c92..0000000
--- a/tests/yanglint/interactive/debug.test
+++ /dev/null
@@ -1,33 +0,0 @@
-source [expr {[info exists ::env(TESTS_DIR)] ? "$env(TESTS_DIR)/interactive/ly.tcl" : "ly.tcl"}]
-
-set mdir $::env(YANG_MODULES_DIR)
-
-test debug_dict {Check debug message DICT} {
--setup $ly_setup -cleanup $ly_cleanup -constraints {[yanglint_debug]} -body {
- ly_cmd "verb debug"
- ly_cmd "debug dict"
- ly_cmd "load modleaf" "DICT"
-}}
-
-test debug_xpath {Check debug message XPATH} {
--setup $ly_setup -cleanup $ly_cleanup -constraints {[yanglint_debug]} -body {
- ly_cmd "verb debug"
- ly_cmd "debug xpath"
- ly_cmd "load modmust" "XPATH"
-}}
-
-test debug_dep_sets {Check debug message DEPSETS} {
--setup $ly_setup -cleanup $ly_cleanup -constraints {[yanglint_debug]} -body {
- ly_cmd "verb debug"
- ly_cmd "debug dep-sets"
- ly_cmd "load modleaf" "DEPSETS"
-}}
-
-test debug_depsets_xpath {Check debug message DEPSETS and XPATH} {
--setup $ly_setup -cleanup $ly_cleanup -constraints {[yanglint_debug]} -body {
- ly_cmd "verb debug"
- ly_cmd "debug dep-sets xpath"
- ly_cmd "load modmust" "DEPSETS.*XPATH"
-}}
-
-cleanupTests
diff --git a/tests/yanglint/interactive/ly.tcl b/tests/yanglint/interactive/ly.tcl
index 4c56be4..efa57f2 100644
--- a/tests/yanglint/interactive/ly.tcl
+++ b/tests/yanglint/interactive/ly.tcl
@@ -65,17 +65,3 @@ proc ly_exit {} {
send "exit\r"
expect eof
}
-
-# Check if yanglint is configured as DEBUG.
-# Return 1 on success.
-proc yanglint_debug {} {
- global TUT
- # Call non-interactive yanglint with --help.
- set output [exec -- $TUT "-h"]
- # Find option --debug.
- if { [regexp -- "--debug=GROUPS" $output] } {
- return 1
- } else {
- return 0
- }
-}