Adding upstream version 3.7.8.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
338ffded6d
commit
76b2c91d7e
52 changed files with 13518 additions and 998 deletions
|
@ -65,6 +65,13 @@ const char *schema_a =
|
|||
" fraction-digits 5;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" leaf foo5 {\n"
|
||||
" type decimal64 {\n"
|
||||
" fraction-digits 1;\n"
|
||||
" range \"0.5 .. 99.5\";\n"
|
||||
" }\n"
|
||||
" must \"(. - 0.5) mod 0.5 = 0\";\n"
|
||||
" }\n"
|
||||
" container c {\n"
|
||||
" leaf x {\n"
|
||||
" type string;\n"
|
||||
|
@ -519,7 +526,7 @@ test_atomize(void **state)
|
|||
|
||||
/* some random paths just making sure the API function works */
|
||||
assert_int_equal(LY_SUCCESS, lys_find_xpath_atoms(UTEST_LYCTX, NULL, "/a:*", 0, &set));
|
||||
assert_int_equal(7, set->count);
|
||||
assert_int_equal(8, set->count);
|
||||
ly_set_free(set, NULL);
|
||||
|
||||
/* all nodes from all modules (including internal, which can change easily, so check just the test modules) */
|
||||
|
@ -536,7 +543,7 @@ test_atomize(void **state)
|
|||
ly_set_free(set, NULL);
|
||||
|
||||
assert_int_equal(LY_SUCCESS, lys_find_xpath_atoms(UTEST_LYCTX, NULL, "/*", 0, &set));
|
||||
assert_int_equal(14, set->count);
|
||||
assert_int_equal(15, set->count);
|
||||
ly_set_free(set, NULL);
|
||||
|
||||
/*
|
||||
|
@ -570,7 +577,7 @@ test_atomize(void **state)
|
|||
|
||||
/* descendant-or-self */
|
||||
assert_int_equal(LY_SUCCESS, lys_find_xpath_atoms(UTEST_LYCTX, NULL, "/a:*/descendant-or-self::c", 0, &set));
|
||||
assert_int_equal(8, set->count);
|
||||
assert_int_equal(9, set->count);
|
||||
ly_set_free(set, NULL);
|
||||
|
||||
/* following */
|
||||
|
@ -585,7 +592,7 @@ test_atomize(void **state)
|
|||
|
||||
/* parent */
|
||||
assert_int_equal(LY_SUCCESS, lys_find_xpath_atoms(UTEST_LYCTX, NULL, "/child::a:*/c/parent::l1", 0, &set));
|
||||
assert_int_equal(8, set->count);
|
||||
assert_int_equal(9, set->count);
|
||||
ly_set_free(set, NULL);
|
||||
|
||||
assert_int_equal(LY_SUCCESS, lys_find_xpath_atoms(UTEST_LYCTX, NULL, "/child::a:c//..", 0, &set));
|
||||
|
@ -1240,6 +1247,20 @@ test_trim(void **state)
|
|||
lyd_free_all(tree);
|
||||
}
|
||||
|
||||
static void
|
||||
test_mod(void **state)
|
||||
{
|
||||
const char *data;
|
||||
struct lyd_node *tree;
|
||||
|
||||
data = "<foo5 xmlns=\"urn:tests:a\">10.5</foo5>";
|
||||
|
||||
/* parse and validate */
|
||||
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(UTEST_LYCTX, data, LYD_XML, LYD_PARSE_STRICT, LYD_VALIDATE_PRESENT, &tree));
|
||||
assert_non_null(tree);
|
||||
lyd_free_siblings(tree);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@ -1257,6 +1278,7 @@ main(void)
|
|||
UTEST(test_variables, setup),
|
||||
UTEST(test_axes, setup),
|
||||
UTEST(test_trim, setup),
|
||||
UTEST(test_mod, setup),
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
|
|
|
@ -353,6 +353,14 @@ test_path(void **state)
|
|||
assert_int_equal(ret, LY_SUCCESS);
|
||||
assert_non_null(node);
|
||||
|
||||
/* too high index */
|
||||
ret = lyd_new_path2(root, NULL, "/a:c2/l3[8]", NULL, 0, 0, 0, NULL, &node);
|
||||
assert_int_equal(ret, LY_EINVAL);
|
||||
CHECK_LOG_CTX("Cannot create \"l3\" on position 8, only 6 instances exist.", NULL, 0);
|
||||
ret = lyd_new_path2(root, NULL, "/a:l2[2]", NULL, 0, 0, 0, NULL, &node);
|
||||
assert_int_equal(ret, LY_EINVAL);
|
||||
CHECK_LOG_CTX("Cannot create \"l2\" on position 2, no instances exist.", NULL, 0);
|
||||
|
||||
lyd_print_mem(&str, root, LYD_XML, LYD_PRINT_WITHSIBLINGS);
|
||||
assert_string_equal(str,
|
||||
"<c2 xmlns=\"urn:tests:a\">\n"
|
||||
|
|
|
@ -1605,21 +1605,22 @@ test_order_violation(void **state)
|
|||
UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, &mod);
|
||||
|
||||
/* inserting a new node causes the nodes to be sorted */
|
||||
data = "{\"a:ll\":[1,8,2]}";
|
||||
data = "{\"a:ll\":[8,2,1]}";
|
||||
CHECK_PARSE_LYD_PARAM(data, LYD_JSON, LYD_PARSE_ORDERED, LYD_VALIDATE_PRESENT, LY_SUCCESS, tree);
|
||||
assert_true(tree && !tree->meta && tree->next && tree->next->next);
|
||||
assert_string_equal(lyd_get_value(tree), "1");
|
||||
assert_string_equal(lyd_get_value(tree->next), "8");
|
||||
assert_string_equal(lyd_get_value(tree->next->next), "2");
|
||||
#ifndef NDEBUG
|
||||
CHECK_LOG_CTX("Data in \"ll\" are not sorted, inserted node should not be added to the end.", NULL, 0);
|
||||
CHECK_LOG_CTX("Data in \"ll\" are not sorted, inserted node should not be added to the end.", NULL, 0);
|
||||
#endif
|
||||
assert_int_equal(lyd_new_term(NULL, mod, "ll", "3", 0, &node), LY_SUCCESS);
|
||||
lyd_insert_sibling(tree, node, NULL);
|
||||
assert_string_equal(lyd_get_value(tree), "1");
|
||||
assert_true(tree && !tree->meta && tree->next && tree->next->next);
|
||||
assert_string_equal(lyd_get_value(tree), "8");
|
||||
assert_string_equal(lyd_get_value(tree->next), "2");
|
||||
assert_string_equal(lyd_get_value(tree->next->next), "3");
|
||||
assert_string_equal(lyd_get_value(tree->next->next->next), "8");
|
||||
assert_string_equal(lyd_get_value(tree->next->next), "1");
|
||||
assert_int_equal(lyd_new_term(NULL, mod, "ll", "3", 0, &node), LY_SUCCESS);
|
||||
lyd_insert_sibling(tree, node, &first);
|
||||
assert_string_equal(lyd_get_value(first), "1");
|
||||
assert_string_equal(lyd_get_value(first->next), "2");
|
||||
assert_string_equal(lyd_get_value(first->next->next), "3");
|
||||
assert_string_equal(lyd_get_value(first->next->next->next), "8");
|
||||
lyd_free_all(tree);
|
||||
|
||||
/* move unsorted nodes causes the nodes to be sorted */
|
||||
|
|
|
@ -163,6 +163,37 @@ test_type_incomplete_when(void **state)
|
|||
lyd_free_all(tree);
|
||||
}
|
||||
|
||||
static void
|
||||
test_unprefixed_ident(void **state)
|
||||
{
|
||||
struct lyd_node *tree;
|
||||
const char *schema =
|
||||
"module a {\n"
|
||||
" namespace urn:tests:a;\n"
|
||||
" prefix a;\n"
|
||||
" yang-version 1.1;\n"
|
||||
"\n"
|
||||
" identity d3 {base d2;}\n"
|
||||
" identity d2 {base d1;}\n"
|
||||
" identity d1;\n"
|
||||
"\n"
|
||||
" leaf a {type identityref {base d1;}}\n"
|
||||
" leaf b {type string; must \"derived-from-or-self(/a, 'd2')\";}\n"
|
||||
" leaf c {type string; when \"derived-from(/a, 'd2')\";}\n"
|
||||
"}";
|
||||
|
||||
UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, NULL);
|
||||
|
||||
CHECK_PARSE_LYD_PARAM("<b xmlns=\"urn:tests:a\">hey</b>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
|
||||
CHECK_LOG_CTX("Must condition \"derived-from-or-self(/a, 'd2')\" not satisfied.", "/a:b", 0);
|
||||
|
||||
CHECK_PARSE_LYD_PARAM("<c xmlns=\"urn:tests:a\">hey</c>", LYD_XML, 0, LYD_VALIDATE_PRESENT, LY_EVALID, tree);
|
||||
CHECK_LOG_CTX("When condition \"derived-from(/a, 'd2')\" not satisfied.", "/a:c", 0);
|
||||
|
||||
LYD_TREE_CREATE("<a xmlns=\"urn:tests:a\">d3</a><b xmlns=\"urn:tests:a\">b-val</b><c xmlns=\"urn:tests:a\">c-val</c>", tree);
|
||||
lyd_free_all(tree);
|
||||
}
|
||||
|
||||
static void
|
||||
test_mandatory(void **state)
|
||||
{
|
||||
|
@ -1515,6 +1546,20 @@ test_case(void **state)
|
|||
CHECK_LOG_CTX("Data for both cases \"v0\" and \"v2\" exist.", "/k:ch", 6);
|
||||
}
|
||||
|
||||
static void
|
||||
test_pattern(void **UNUSED(state))
|
||||
{
|
||||
pcre2_code *pcode = NULL;
|
||||
|
||||
assert_int_equal(ly_pattern_match(NULL, "a.b.c", "abc", 0, NULL), LY_ENOT);
|
||||
assert_int_equal(ly_pattern_match(NULL, "a.b.c", "a0b1c", 0, NULL), LY_SUCCESS);
|
||||
|
||||
assert_int_equal(ly_pattern_match(NULL, "a.b.c", "abc", 0, &pcode), LY_ENOT);
|
||||
assert_int_equal(ly_pattern_match(NULL, NULL, "a0b1c", 0, &pcode), LY_SUCCESS);
|
||||
|
||||
pcre2_code_free(pcode);
|
||||
}
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@ -1523,6 +1568,7 @@ main(void)
|
|||
UTEST(test_mandatory),
|
||||
UTEST(test_mandatory_when),
|
||||
UTEST(test_type_incomplete_when),
|
||||
UTEST(test_unprefixed_ident),
|
||||
UTEST(test_minmax),
|
||||
UTEST(test_unique),
|
||||
UTEST(test_unique_nested),
|
||||
|
@ -1535,6 +1581,7 @@ main(void)
|
|||
UTEST(test_rpc),
|
||||
UTEST(test_reply),
|
||||
UTEST(test_case),
|
||||
UTEST(test_pattern),
|
||||
};
|
||||
|
||||
return cmocka_run_group_tests(tests, NULL, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue