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
|
@ -135,8 +135,7 @@ proc ly_completion {input output} {
|
|||
global prompt
|
||||
|
||||
send -- "${input}\t"
|
||||
# expecting echoing input, output and 10 terminal control characters
|
||||
expect -re "^${input}\r${prompt}${output}.*\r.*$"
|
||||
expect -re "${input}${output}"
|
||||
}
|
||||
|
||||
# Send a completion request and check if the anchored regex hint options match.
|
||||
|
@ -146,11 +145,13 @@ proc ly_hint {input prev_input hints} {
|
|||
set output {}
|
||||
foreach i $hints {
|
||||
# each element might have some number of spaces and CRLF around it
|
||||
append output "${i} *(?:\\r\\n)?"
|
||||
append output "${i} *(\\r\\n)?"
|
||||
}
|
||||
set termcode1 "\r\\u001b\\\[0K"
|
||||
set termcode2 ".*"
|
||||
|
||||
send -- "${input}\t"
|
||||
# expecting the hints, previous input from which the hints were generated
|
||||
# and some number of terminal control characters
|
||||
expect -re "${output}\r${prompt}${prev_input}.*\r.*$"
|
||||
expect -re "${output}${termcode1}${prompt}${prev_input}${termcode2}"
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
if(WIN32)
|
||||
if(WIN32 OR NOT ENABLE_YANGLINT_INTERACTIVE)
|
||||
set(YANGLINT_INTERACTIVE OFF)
|
||||
else()
|
||||
set(YANGLINT_INTERACTIVE ON)
|
||||
|
|
|
@ -12,14 +12,15 @@ test completion_hints_ietf_ip {Completion and hints for ietf-ip.yang} {
|
|||
ly_cmd "add $mdir/ietf-ip.yang"
|
||||
|
||||
# completion and hint
|
||||
ly_completion "print -f info -P " "print -f info -P /ietf-"
|
||||
ly_completion "print -f info -P " "/ietf-"
|
||||
|
||||
set hints {"/ietf-yang-schema-mount:schema-mounts" "/ietf-interfaces:interfaces" "/ietf-interfaces:interfaces-state"}
|
||||
ly_hint "" "print -f info -P /ietf-" $hints
|
||||
|
||||
# double completion
|
||||
ly_completion "i" "print -f info -P /ietf-interfaces:interfaces"
|
||||
ly_completion "/" "print -f info -P /ietf-interfaces:interfaces/interface"
|
||||
ly_completion "i" "nterfaces:interfaces"
|
||||
ly_completion "/" "interface"
|
||||
# current cli: print -f info -P /ietf-interfaces:interfaces/interface
|
||||
|
||||
# a lot of hints
|
||||
set hints {"/ietf-interfaces:interfaces/interface"
|
||||
|
@ -31,16 +32,20 @@ test completion_hints_ietf_ip {Completion and hints for ietf-ip.yang} {
|
|||
ly_hint "" "print -f info -P /ietf-interfaces:interfaces/interface" $hints
|
||||
|
||||
# double tab
|
||||
ly_completion "/i" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv"
|
||||
ly_completion "4" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv4"
|
||||
ly_completion "/i" "etf-ip:ipv"
|
||||
# current cli: print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv
|
||||
ly_completion "4" ""
|
||||
# current cli: print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv4
|
||||
|
||||
set hints { "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4" "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/enabled"
|
||||
"/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/forwarding" "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/mtu"
|
||||
"/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/address" "/ietf-interfaces:interfaces/interface/ietf-ip:ipv4/neighbor"
|
||||
}
|
||||
ly_hint "\t" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv" $hints
|
||||
ly_hint "\t" "print -f info -P /ietf-interfaces:interfaces/interface" $hints
|
||||
|
||||
# no more completion
|
||||
ly_completion "/e" "print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv4/enabled "
|
||||
ly_completion "/e" "nabled "
|
||||
# current cli: print -f info -P /ietf-interfaces:interfaces/interface/ietf-ip:ipv4/enabled
|
||||
}}
|
||||
|
||||
# Note that somehow a command is automatically sent again (\t\t replaced by \r) after the hints.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue