Skip to content

Commit c05a66f

Browse files
committed
yanglint UPDATE ni schema-comparison support
1 parent f66f25d commit c05a66f

File tree

16 files changed

+192
-38
lines changed

16 files changed

+192
-38
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module ietf-schema-comparison {
1010
prefix yanglib;
1111
}
1212

13-
revision 2025-09-03 {
13+
revision 2025-09-19 {
1414
description
1515
"Initial revision.";
1616
}
@@ -590,6 +590,11 @@ module ietf-schema-comparison {
590590
description
591591
"Compared module revision.";
592592
}
593+
leaf-list enabled-feature {
594+
type yang:yang-identifier;
595+
description
596+
"All the enabled features of the module.";
597+
}
593598
}
594599

595600
container schema-comparison {

src/plugins_exts/schema_comparison.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ bc_parse(struct lysp_ctx *pctx, struct lysp_ext_instance *ext)
5252
const struct lyplg_ext_record plugins_schema_cmp[] = {
5353
{
5454
.module = "ietf-schema-comparison",
55-
.revision = "2025-09-03",
55+
.revision = "2025-09-19",
5656
.name = "backwards-compatible",
5757

5858
.plugin.id = "ly2 schema-comparison",

src/schema_diff_tree.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,29 @@ schema_diff_ext_inst(const struct lysc_ext_instance *ext, struct lyd_node *chang
12071207
return rc;
12081208
}
12091209

1210+
/**
1211+
* @brief Create leaf-list of enabled features as part of cmp YANG data.
1212+
*
1213+
* @param[in] mod Module to use.
1214+
* @param[in,out] parent Node to append to.
1215+
* @return LY_ERR value.
1216+
*/
1217+
static LY_ERR
1218+
schema_diff_enabled_features(const struct lys_module *mod, struct lyd_node *parent)
1219+
{
1220+
LY_ARRAY_COUNT_TYPE u;
1221+
1222+
if (!mod->implemented) {
1223+
return LY_SUCCESS;
1224+
}
1225+
1226+
LY_ARRAY_FOR(mod->compiled->features, u) {
1227+
LY_CHECK_RET(lyd_new_term(parent, NULL, "enabled-feature", mod->compiled->features[u], 0, NULL));
1228+
}
1229+
1230+
return LY_SUCCESS;
1231+
}
1232+
12101233
/**
12111234
* @brief Create cmp YANG data from module imports.
12121235
*
@@ -1222,6 +1245,7 @@ schema_diff_imports(const struct lys_module *mod, const struct lysc_node *schema
12221245
LY_ARRAY_COUNT_TYPE u;
12231246
char *keys = NULL;
12241247
const struct lys_module *imp;
1248+
struct lyd_node *mod_list;
12251249

12261250
LY_ARRAY_FOR(mod->parsed->imports, u) {
12271251
imp = mod->parsed->imports[u].module;
@@ -1238,7 +1262,8 @@ schema_diff_imports(const struct lys_module *mod, const struct lysc_node *schema
12381262
}
12391263

12401264
/* add the imports, recursively */
1241-
LY_CHECK_GOTO(rc = lyd_new_list(diff_list, NULL, schema->name, 0, NULL, imp->name, imp->revision), cleanup);
1265+
LY_CHECK_GOTO(rc = lyd_new_list(diff_list, NULL, schema->name, 0, &mod_list, imp->name, imp->revision), cleanup);
1266+
LY_CHECK_GOTO(rc = schema_diff_enabled_features(imp, mod_list), cleanup);
12421267
LY_CHECK_GOTO(rc = schema_diff_imports(imp, schema, diff_list), cleanup);
12431268
}
12441269

@@ -2023,6 +2048,7 @@ lysc_diff_tree(const struct lys_module *mod1, const struct lys_module *mod2, con
20232048
LY_CHECK_GOTO(rc = lyd_new_inner(diff_list, NULL, "source", 0, &mod_cont), cleanup);
20242049
LY_CHECK_GOTO(rc = lyd_new_term(mod_cont, NULL, "module", mod1->name, 0, NULL), cleanup);
20252050
LY_CHECK_GOTO(rc = lyd_new_term(mod_cont, NULL, "revision", mod1->revision, 0, NULL), cleanup);
2051+
LY_CHECK_GOTO(rc = schema_diff_enabled_features(mod1, mod_cont), cleanup);
20262052

20272053
imp_schema = lys_find_path(NULL, diff_list->schema, "source-import", 0);
20282054
LY_CHECK_GOTO(rc = schema_diff_imports(mod1, imp_schema, diff_list), cleanup);
@@ -2031,6 +2057,7 @@ lysc_diff_tree(const struct lys_module *mod1, const struct lys_module *mod2, con
20312057
LY_CHECK_GOTO(rc = lyd_new_inner(diff_list, NULL, "target", 0, &mod_cont), cleanup);
20322058
LY_CHECK_GOTO(rc = lyd_new_term(mod_cont, NULL, "module", mod2->name, 0, NULL), cleanup);
20332059
LY_CHECK_GOTO(rc = lyd_new_term(mod_cont, NULL, "revision", mod2->revision, 0, NULL), cleanup);
2060+
LY_CHECK_GOTO(rc = schema_diff_enabled_features(mod2, mod_cont), cleanup);
20342061

20352062
imp_schema = lys_find_path(NULL, diff_list->schema, "target-import", 0);
20362063
LY_CHECK_GOTO(rc = schema_diff_imports(mod2, imp_schema, diff_list), cleanup);

src/tree_schema.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,8 +1228,8 @@ lysc_compare(const struct ly_ctx *ctx, const struct lys_module *src_mod, const s
12281228
LOGERR(ctx, LY_ENOTFOUND, "Module \"ietf-schema-comparison\" not found.");
12291229
rc = LY_ENOTFOUND;
12301230
goto cleanup;
1231-
} else if (!cmp_mod->revision || strcmp(cmp_mod->revision, "2025-09-03")) {
1232-
LOGERR(ctx, LY_ENOTFOUND, "Module \"ietf-schema-comparison\" not in the expected revision \"2025-09-03\".");
1231+
} else if (!cmp_mod->revision || strcmp(cmp_mod->revision, "2025-09-19")) {
1232+
LOGERR(ctx, LY_ENOTFOUND, "Module \"ietf-schema-comparison\" not in the expected revision \"2025-09-19\".");
12331233
rc = LY_ENOTFOUND;
12341234
goto cleanup;
12351235
}

tests/utests/schema_comparison/bc/12 description/description_cmp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"target-import": [
1414
{
1515
"module": "ietf-schema-comparison",
16-
"revision": "2025-09-03"
16+
"revision": "2025-09-19"
1717
},
1818
{
1919
"module": "ietf-yang-types",

tests/utests/schema_comparison/bc/3 pattern/pattern_cmp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"target-import": [
1414
{
1515
"module": "ietf-schema-comparison",
16-
"revision": "2025-09-03"
16+
"revision": "2025-09-19"
1717
},
1818
{
1919
"module": "ietf-yang-types",

tests/utests/schema_comparison/bc/7 must/must_cmp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"target-import": [
1414
{
1515
"module": "ietf-schema-comparison",
16-
"revision": "2025-09-03"
16+
"revision": "2025-09-19"
1717
},
1818
{
1919
"module": "ietf-yang-types",

tests/utests/schema_comparison/bc/8 when/when_cmp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"target-import": [
1414
{
1515
"module": "ietf-schema-comparison",
16-
"revision": "2025-09-03"
16+
"revision": "2025-09-19"
1717
},
1818
{
1919
"module": "ietf-yang-types",

tests/utests/schema_comparison/test_schema_comparison.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ setup(void **state)
5858
}
5959

6060
/* load ietf-schema-comparison into both contexts, the module is imported */
61-
if (lys_parse_path(st->ctx1, TESTS_SRC "/../modules/ietf-schema-comparison@2025-09-03.yang", LYS_IN_YANG, NULL)) {
61+
if (lys_parse_path(st->ctx1, TESTS_SRC "/../modules/ietf-schema-comparison@2025-09-19.yang", LYS_IN_YANG, NULL)) {
6262
return 1;
6363
}
64-
if (lys_parse_path(st->ctx2, TESTS_SRC "/../modules/ietf-schema-comparison@2025-09-03.yang", LYS_IN_YANG, NULL)) {
64+
if (lys_parse_path(st->ctx2, TESTS_SRC "/../modules/ietf-schema-comparison@2025-09-19.yang", LYS_IN_YANG, NULL)) {
6565
return 1;
6666
}
6767

tools/lint/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ set(lintsrc
1414
cmd_help.c
1515
cmd_verb.c
1616
cmd_debug.c
17+
cmd_cmp.c
1718
yl_opt.c
1819
yl_schema_features.c
1920
common.c

0 commit comments

Comments
 (0)