schema features BUGFIX error on non-existing feature
Fixes #1679
diff --git a/src/schema_features.c b/src/schema_features.c
index 79f4714..28830a6 100644
--- a/src/schema_features.c
+++ b/src/schema_features.c
@@ -593,6 +593,14 @@
}
}
} else {
+ /* check that all the features exist */
+ for (j = 0; features[j]; ++j) {
+ if (!lysp_feature_find(pmod, features[j], strlen(features[j]), 0)) {
+ LOGERR(pmod->mod->ctx, LY_EINVAL, "Feature \"%s\" not found in module \"%s\".", features[j], pmod->mod->name);
+ return LY_EINVAL;
+ }
+ }
+
/* enable specific features, disable the rest */
while ((f = lysp_feature_next(f, pmod, &i))) {
for (j = 0; features[j]; ++j) {
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index de11f05..d4891e5 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -67,7 +67,7 @@
static void
test_module(void **state)
{
- const char *str;
+ const char *str, *feats[] = {"invalid", NULL};
struct ly_in *in;
struct lys_module *mod = NULL;
struct lysp_feature *f;
@@ -81,6 +81,7 @@
lys_unres_glob_erase(&unres);
ly_in_free(in, 0);
assert_int_equal(0, mod->implemented);
+ assert_int_equal(LY_EINVAL, lys_set_implemented(mod, feats));
assert_int_equal(LY_SUCCESS, lys_set_implemented(mod, NULL));
assert_non_null(mod->compiled);
assert_string_equal("test", mod->name);