Skip to content

Commit 8cfaf13

Browse files
committed
tree schema BUGFIX loading includes with revisions
Fixes #2467
1 parent f94169e commit 8cfaf13

5 files changed

Lines changed: 52 additions & 2 deletions

File tree

src/tree_schema_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,8 +1228,8 @@ lysp_load_submodules(struct lysp_ctx *pctx, struct lysp_module *pmod, struct ly_
12281228
submod_included = 0;
12291229
} else if (r) {
12301230
return r;
1231-
} else if (inc->submodule->latest_revision == 2) {
1232-
/* submodule found and is the latest existing revision */
1231+
} else if (inc->rev[0] || (inc->submodule->latest_revision == 2)) {
1232+
/* submodule found and is the specific requested revision/latest existing revision */
12331233
continue;
12341234
}
12351235
}

tests/modules/yang/b.yang

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module b {
2+
namespace "urn:b";
3+
prefix "b";
4+
5+
include d {
6+
revision-date "2026-01-09";
7+
}
8+
include c {
9+
revision-date "2026-01-09";
10+
}
11+
revision 2026-01-09 {
12+
description "example";
13+
}
14+
}

tests/modules/yang/c.yang

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
submodule c {
2+
belongs-to b {
3+
prefix b;
4+
}
5+
include d {
6+
revision-date "2026-01-09";
7+
}
8+
9+
revision 2026-01-09 {
10+
description "example";
11+
}
12+
}

tests/modules/yang/d.yang

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
submodule d {
2+
belongs-to b {
3+
prefix b;
4+
}
5+
6+
revision 2026-01-09 {
7+
description "example";
8+
}
9+
}

tests/utests/basic/test_context.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,20 @@ test_imports(void **state)
464464
ly_err_clean(UTEST_LYCTX, NULL);
465465
}
466466

467+
static void
468+
test_includes(void **state)
469+
{
470+
struct lys_module *mod;
471+
472+
ly_ctx_set_searchdir(UTEST_LYCTX, TESTS_DIR_MODULES_YANG);
473+
474+
/* load b with c and d submodules */
475+
mod = ly_ctx_load_module(UTEST_LYCTX, "b", NULL, NULL);
476+
assert_non_null(mod);
477+
478+
ly_ctx_unset_searchdir(UTEST_LYCTX, TESTS_DIR_MODULES_YANG);
479+
}
480+
467481
static void
468482
test_get_models(void **state)
469483
{
@@ -1119,6 +1133,7 @@ main(void)
11191133
UTEST(test_options),
11201134
UTEST(test_models),
11211135
UTEST(test_imports),
1136+
UTEST(test_includes),
11221137
UTEST(test_get_models),
11231138
UTEST(test_ylmem),
11241139
UTEST(test_set_priv_parsed),

0 commit comments

Comments
 (0)