schema compile BUGFIX config flag for grouping nodes in augment
Test included.
Fixes #1776
diff --git a/src/schema_compile_node.c b/src/schema_compile_node.c
index d39c37f..dc2afaa 100644
--- a/src/schema_compile_node.c
+++ b/src/schema_compile_node.c
@@ -2470,7 +2470,8 @@
node->flags &= ~LYS_CONFIG_MASK;
} else if (!(node->flags & LYS_CONFIG_MASK)) {
/* config not explicitly set, inherit it from parent */
- if (node->parent) {
+ assert(!node->parent || (node->parent->flags & LYS_CONFIG_MASK) || (node->parent->nodetype & LYS_AUGMENT));
+ if (node->parent && (node->parent->flags & LYS_CONFIG_MASK)) {
node->flags |= node->parent->flags & LYS_CONFIG_MASK;
} else {
/* default is config true */
@@ -3936,6 +3937,13 @@
LY_ERR ret;
char *path;
int len;
+ uint16_t cont_flags;
+
+ cont_flags = pnode ? pnode->flags & LYS_FLAGS_COMPILED_MASK : 0;
+ if (!(cont_flags & LYS_CONFIG_MASK)) {
+ /* default config */
+ cont_flags |= LYS_CONFIG_W;
+ }
struct lysp_node_uses fake_uses = {
.parent = pnode,
@@ -3947,7 +3955,7 @@
};
struct lysc_node_container fake_container = {
.nodetype = LYS_CONTAINER,
- .flags = pnode ? (pnode->flags & LYS_FLAGS_COMPILED_MASK) : 0,
+ .flags = cont_flags,
.module = ctx->cur_mod,
.parent = NULL, .next = NULL,
.prev = &fake_container.node,
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index 77bf19c..ca70ced 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -2338,6 +2338,22 @@
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");
+
+ /* config check */
+ ly_ctx_set_module_imp_clb(UTEST_LYCTX, test_imp_clb, "module z1 {namespace urn:z1;prefix z1;"
+ "container root;}\n"
+ "module z2 {namespace urn:z2;prefix z2;"
+ "grouping leafs_group {"
+ " leaf name {type string; config true;}"
+ " leaf value {type uint32; config true;}"
+ "}}");
+ assert_int_equal(LY_SUCCESS, lys_parse_mem(UTEST_LYCTX, "module z3 {namespace urn:z3;prefix z3;"
+ "import z1 {prefix z1;} import z2 {prefix z2;}"
+ "grouping grp_a_top {leaf a1 {type int8;}}"
+ "grouping list_group {"
+ " list mylist {key \"name\"; unique \"value\"; uses z2:leafs_group;}"
+ "}"
+ "augment /z1:root { uses list_group;} }", LYS_IN_YANG, NULL));
}
static void