xpath BUGFIX evaluation of * on schema
All modules of the nodes must match.
Refs #1780
diff --git a/src/xpath.c b/src/xpath.c
index 6001949..8afebb3 100644
--- a/src/xpath.c
+++ b/src/xpath.c
@@ -5472,7 +5472,7 @@
moveto_scnode_check(const struct lysc_node *node, const struct lysc_node *ctx_scnode, const struct lyxp_set *set,
const char *node_name, const struct lys_module *moveto_mod)
{
- if (!moveto_mod && (!node_name || strcmp(node_name, "*"))) {
+ if (!moveto_mod && node_name && strcmp(node_name, "*")) {
switch (set->format) {
case LY_VALUE_SCHEMA:
case LY_VALUE_SCHEMA_RESOLVED:
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index 3c12f70..c28bf5d 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -3727,6 +3727,47 @@
LYS_IN_YANG, NULL));
}
+static void
+test_must(void **state)
+{
+ /* "*" must not be restricted to any module */
+ ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb,
+ "module a {"
+ " namespace urn:a;"
+ " prefix a;"
+ " container cont {"
+ " leaf l {"
+ " type empty;"
+ " }"
+ " list lst {"
+ " key \"k\";"
+ " leaf k {"
+ " type uint8;"
+ " }"
+ " }"
+ " }"
+ "}");
+ assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX,
+ "module a-aug {"
+ " namespace urn:aa;"
+ " prefix aa;"
+ " import a {"
+ " prefix a;"
+ " }"
+ " augment /a:cont {"
+ " container cont2 {"
+ " must \"/a:cont/*/a:k\";"
+ " leaf aug {"
+ " type empty;"
+ " }"
+ " }"
+ " }"
+ "}",
+ LYS_IN_YANG, NULL));
+ /* no warnings */
+ CHECK_LOG_CTX(NULL, NULL);
+}
+
int
main(void)
{
@@ -3759,6 +3800,7 @@
UTEST(test_augment, setup),
UTEST(test_deviation, setup),
UTEST(test_when, setup),
+ UTEST(test_must, setup),
};
return cmocka_run_group_tests(tests, NULL, NULL);