schema tree REFACTOR evaluate features during compilation
So that the compiled schema tree reflects the state
of all the features.
diff --git a/tests/utests/data/test_diff.c b/tests/utests/data/test_diff.c
index c1a1cf2..f29e80d 100644
--- a/tests/utests/data/test_diff.c
+++ b/tests/utests/data/test_diff.c
@@ -227,7 +227,7 @@
(*state) = st = calloc(1, sizeof *st);
assert_non_null(st);
assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &st->ctx));
- assert_non_null(ly_ctx_load_module(st->ctx, "ietf-netconf-acm", "2018-02-14"));
+ assert_non_null(ly_ctx_load_module(st->ctx, "ietf-netconf-acm", "2018-02-14", NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, schema, LYS_IN_YANG, NULL));
return 0;
diff --git a/tests/utests/data/test_lyb.c b/tests/utests/data/test_lyb.c
index 588ad22..91117f0 100644
--- a/tests/utests/data/test_lyb.c
+++ b/tests/utests/data/test_lyb.c
@@ -280,8 +280,8 @@
"</interfaces>";
- assert_non_null(ly_ctx_load_module(st->ctx, "ietf-ip", NULL));
- assert_non_null(ly_ctx_load_module(st->ctx, "iana-if-type", NULL));
+ assert_non_null(ly_ctx_load_module(st->ctx, "ietf-ip", NULL, NULL));
+ assert_non_null(ly_ctx_load_module(st->ctx, "iana-if-type", NULL, NULL));
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, data_xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->dt1));
assert_ptr_not_equal(st->dt1, NULL);
@@ -328,7 +328,7 @@
"</cont>";
assert_int_equal(LY_SUCCESS, lys_parse_mem(st->ctx, origin_yang, LYS_IN_YANG, NULL));
- lys_set_implemented(ly_ctx_get_module_latest(st->ctx, "ietf-origin"));
+ lys_set_implemented(ly_ctx_get_module_latest(st->ctx, "ietf-origin"), NULL);
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(st->ctx, data_xml, LYD_XML, LYD_PARSE_ONLY, 0, &st->dt1));
assert_ptr_not_equal(st->dt1, NULL);
diff --git a/tests/utests/data/test_parser_json.c b/tests/utests/data/test_parser_json.c
index 0c9e0a2..c22eb66 100644
--- a/tests/utests/data/test_parser_json.c
+++ b/tests/utests/data/test_parser_json.c
@@ -77,15 +77,15 @@
"leaf foo3 { type uint32; }"
"notification n2;}";
const struct lys_module *mod;
+ const char *feats[] = {"writable-running", NULL};
#if ENABLE_LOGGER_CHECKING
ly_set_log_clb(logger, 1);
#endif
assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &ctx));
- assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01"));
- assert_non_null((mod = ly_ctx_load_module(ctx, "ietf-netconf", "2011-06-01")));
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "writable-running"));
+ assert_non_null((mod = ly_ctx_load_module(ctx, "ietf-netconf", "2011-06-01", feats)));
+ assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01", NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL));
return 0;
diff --git a/tests/utests/data/test_parser_xml.c b/tests/utests/data/test_parser_xml.c
index 183e22f..baf4608 100644
--- a/tests/utests/data/test_parser_xml.c
+++ b/tests/utests/data/test_parser_xml.c
@@ -75,15 +75,15 @@
"leaf foo3 { type uint32; }"
"notification n2;}";
const struct lys_module *mod;
+ const char *feats[] = {"writable-running", NULL};
#if ENABLE_LOGGER_CHECKING
ly_set_log_clb(logger, 1);
#endif
assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &ctx));
- assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01"));
- assert_non_null((mod = ly_ctx_load_module(ctx, "ietf-netconf", "2011-06-01")));
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "writable-running"));
+ assert_non_null((mod = ly_ctx_load_module(ctx, "ietf-netconf", "2011-06-01", feats)));
+ assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01", NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL));
return 0;
diff --git a/tests/utests/data/test_printer_xml.c b/tests/utests/data/test_printer_xml.c
index b2bcd75..75cddd2 100644
--- a/tests/utests/data/test_printer_xml.c
+++ b/tests/utests/data/test_printer_xml.c
@@ -131,7 +131,7 @@
#endif
assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &s->ctx));
- assert_non_null(ly_ctx_load_module(s->ctx, "ietf-netconf-with-defaults", "2011-06-01"));
+ assert_non_null(ly_ctx_load_module(s->ctx, "ietf-netconf-with-defaults", "2011-06-01", NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(s->ctx, schema_a, LYS_IN_YANG, NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(s->ctx, schema_b, LYS_IN_YANG, NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(s->ctx, schema_c, LYS_IN_YANG, NULL));
diff --git a/tests/utests/data/test_types.c b/tests/utests/data/test_types.c
index 27e2338..e17118d 100644
--- a/tests/utests/data/test_types.c
+++ b/tests/utests/data/test_types.c
@@ -184,8 +184,7 @@
assert_string_equal("15", leaf->value.canonical);
assert_int_equal(15, leaf->value.int8);
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
assert_string_equal(leaf->value.canonical, value.canonical);
assert_int_equal(15, value.int8);
value.realtype->plugin->free(s->ctx, &value);
@@ -225,8 +224,7 @@
assert_string_equal("150", leaf->value.canonical);
assert_int_equal(150, leaf->value.uint8);
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
assert_string_equal(leaf->value.canonical, value.canonical);
assert_int_equal(150, value.uint8);
value.realtype->plugin->free(s->ctx, &value);
@@ -266,8 +264,7 @@
assert_string_equal("8.0", leaf->value.canonical);
assert_int_equal(80, leaf->value.dec64);
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
assert_string_equal(leaf->value.canonical, value.canonical);
assert_int_equal(80, value.dec64);
value.realtype->plugin->free(s->ctx, &value);
@@ -374,8 +371,7 @@
assert_string_equal("zero", leaf->value.bits_items[0]->name);
assert_string_equal("two", leaf->value.bits_items[1]->name);
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
assert_string_equal(leaf->value.canonical, value.canonical);
assert_int_equal(2, LY_ARRAY_COUNT(value.bits_items));
assert_string_equal("zero", value.bits_items[0]->name);
@@ -389,29 +385,17 @@
assert_string_equal("bits", tree->schema->name);
leaf = (struct lyd_node_term*)tree;
assert_string_equal("zero two", leaf->value.canonical);
+
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_string_equal(leaf->value.canonical, value.canonical);
+ assert_int_equal(2, LY_ARRAY_COUNT(value.bits_items));
+ assert_string_equal("zero", value.bits_items[0]->name);
+ value.realtype->plugin->free(s->ctx, &value);
lyd_free_all(tree);
/* disabled feature */
TEST_DATA("<bits xmlns=\"urn:tests:types\"> \t one \n\t </bits>", LY_EVALID, "Bit \"one\" is disabled by its 1. if-feature condition. /types:bits");
- /* enable that feature */
- assert_int_equal(LY_SUCCESS, lys_feature_enable(ly_ctx_get_module(s->ctx, "types", NULL), "f"));
- TEST_DATA("<bits xmlns=\"urn:tests:types\"> \t one \n\t </bits>", LY_SUCCESS, "");
- assert_int_equal(LYS_LEAF, tree->schema->nodetype);
- assert_string_equal("bits", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
- assert_string_equal("one", leaf->value.canonical);
- assert_int_equal(1, LY_ARRAY_COUNT(leaf->value.bits_items));
- assert_string_equal("one", leaf->value.bits_items[0]->name);
-
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
- assert_string_equal(leaf->value.canonical, value.canonical);
- assert_int_equal(1, LY_ARRAY_COUNT(value.bits_items));
- assert_string_equal("one", value.bits_items[0]->name);
- value.realtype->plugin->free(s->ctx, &value);
- lyd_free_all(tree);
-
/* multiple instances of the bit */
TEST_DATA("<bits xmlns=\"urn:tests:types\">one zero one</bits>", LY_EVALID, "Bit \"one\" used multiple times. /types:bits");
@@ -441,8 +425,7 @@
assert_string_equal("white", leaf->value.canonical);
assert_string_equal("white", leaf->value.enum_item->name);
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
assert_string_equal(leaf->value.canonical, value.canonical);
assert_string_equal("white", value.enum_item->name);
value.realtype->plugin->free(s->ctx, &value);
@@ -452,15 +435,6 @@
TEST_DATA("<enums xmlns=\"urn:tests:types\">yellow</enums>", LY_EVALID,
"Enumeration \"yellow\" is disabled by its 1. if-feature condition. /types:enums");
- /* enable that feature */
- assert_int_equal(LY_SUCCESS, lys_feature_enable(ly_ctx_get_module(s->ctx, "types", NULL), "f"));
- TEST_DATA("<enums xmlns=\"urn:tests:types\">yellow</enums>", LY_SUCCESS, "");
- assert_int_equal(LYS_LEAF, tree->schema->nodetype);
- assert_string_equal("enums", tree->schema->name);
- leaf = (struct lyd_node_term*)tree;
- assert_string_equal("yellow", leaf->value.canonical);
- lyd_free_all(tree);
-
/* leading/trailing whitespaces are not valid */
TEST_DATA("<enums xmlns=\"urn:tests:types\"> white</enums>", LY_EVALID, "Invalid enumeration value \" white\". /types:enums");
TEST_DATA("<enums xmlns=\"urn:tests:types\">white\n</enums>", LY_EVALID, "Invalid enumeration value \"white\n\". /types:enums");
@@ -495,8 +469,7 @@
leaf = (struct lyd_node_term*)tree;
assert_string_equal("TQ==", leaf->value.canonical);
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
assert_string_equal(leaf->value.canonical, value.canonical);
value.realtype->plugin->free(s->ctx, &value);
memset(&value, 0, sizeof value);
@@ -663,8 +636,7 @@
assert_string_equal("gigabit-ethernet", leaf->value.ident->name);
test_printed_value(&leaf->value, "t:gigabit-ethernet", LY_PREF_SCHEMA, s->mod_types->parsed);
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
assert_string_equal("types:gigabit-ethernet", value.canonical);
assert_string_equal("gigabit-ethernet", value.ident->name);
value.realtype->plugin->free(s->ctx, &value);
@@ -729,8 +701,7 @@
assert_string_equal("leaftarget", leaf->value.target[1].node->name);
assert_null(leaf->value.target[1].predicates);
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
assert_string_equal("/types:cont/leaftarget", value.canonical);
assert_true(LY_ARRAY_COUNT(leaf->value.target) == LY_ARRAY_COUNT(value.target));
assert_true(leaf->value.target[0].node == value.target[0].node);
@@ -776,8 +747,7 @@
test_printed_value(&leaf->value, "/t:list_inst[t:id=\"/t:leaflisttarget[.='b']\"]/t:value", LY_PREF_SCHEMA, s->mod_types->parsed);
test_printed_value(&leaf->value, "/types:list_inst[id=\"/types:leaflisttarget[.='b']\"]/value", LY_PREF_JSON, NULL);
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
assert_string_equal("/types:list_inst[id=\"/types:leaflisttarget[.='b']\"]/value", value.canonical);
assert_true(LY_ARRAY_COUNT(leaf->value.target) == LY_ARRAY_COUNT(value.target));
assert_true(leaf->value.target[0].node == value.target[0].node);
@@ -1115,8 +1085,7 @@
test_printed_value(&leaf->value, "12", LY_PREF_SCHEMA, NULL);
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
assert_string_equal("12", value.canonical);
assert_non_null(value.subvalue->prefix_data);
assert_int_equal(((struct ly_set *)leaf->value.subvalue->prefix_data)->count, 0);
@@ -1153,8 +1122,7 @@
test_printed_value(&leaf->value, "d:fast-ethernet", LY_PREF_SCHEMA, s->mod_defs->parsed);
test_printed_value(&leaf->value.subvalue->value, "d:fast-ethernet", LY_PREF_SCHEMA, s->mod_defs->parsed);
- value.realtype = leaf->value.realtype;
- assert_int_equal(LY_SUCCESS, value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
+ assert_int_equal(LY_SUCCESS, leaf->value.realtype->plugin->duplicate(s->ctx, &leaf->value, &value));
assert_string_equal("defs:fast-ethernet", value.canonical);
assert_string_equal("defs:fast-ethernet", value.subvalue->value.canonical);
assert_non_null(value.subvalue->prefix_data);
diff --git a/tests/utests/data/test_validation.c b/tests/utests/data/test_validation.c
index 072c375..66299f2 100644
--- a/tests/utests/data/test_validation.c
+++ b/tests/utests/data/test_validation.c
@@ -412,13 +412,15 @@
"type string;"
"}"
"}";
+ struct ly_in *in;
+ const char *feats[] = {"feat1", NULL};
#if ENABLE_LOGGER_CHECKING
ly_set_log_clb(logger, 1);
#endif
assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &ctx));
- assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01"));
+ assert_non_null(ly_ctx_load_module(ctx, "ietf-netconf-with-defaults", "2011-06-01", NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_a, LYS_IN_YANG, NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_b, LYS_IN_YANG, NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_c, LYS_IN_YANG, NULL));
@@ -428,7 +430,9 @@
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_g, LYS_IN_YANG, NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_h, LYS_IN_YANG, NULL));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_i, LYS_IN_YANG, NULL));
- assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_j, LYS_IN_YANG, NULL));
+ assert_int_equal(LY_SUCCESS, ly_in_new_memory(schema_j, &in));
+ assert_int_equal(LY_SUCCESS, lys_parse(ctx, in, LYS_IN_YANG, feats, NULL));
+ ly_in_free(in, 0);
return 0;
}
@@ -1225,112 +1229,6 @@
}
static void
-test_iffeature(void **state)
-{
- *state = test_iffeature;
-
- const char *data;
- struct lyd_node *tree;
- const struct lys_module *mod = ly_ctx_get_module_latest(ctx, "g");
-
- /* get empty data */
- tree = NULL;
- assert_int_equal(lyd_validate_module(&tree, mod, 0, NULL), LY_SUCCESS);
- assert_null(tree);
-
- /* disabled by f1 */
- data =
- "<cont xmlns=\"urn:tests:g\">"
- "<d>51</d>"
- "</cont>";
- assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
- assert_null(tree);
- logbuf_assert("Data are disabled by \"cont\" schema node if-feature. /g:cont");
-
- /* enable f1 */
- assert_int_equal(lys_feature_enable(mod, "f1"), LY_SUCCESS);
-
- /* get data with default container */
- assert_int_equal(lyd_validate_module(&tree, mod, 0, NULL), LY_SUCCESS);
- assert_non_null(tree);
- lyd_free_siblings(tree);
-
- /* disabled by f2 */
- data =
- "<cont xmlns=\"urn:tests:g\">"
- "<cont2>"
- "<e>val</e>"
- "</cont2>"
- "</cont>";
- assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
- assert_null(tree);
- logbuf_assert("Data are disabled by \"cont2\" schema node if-feature. /g:cont/cont2");
-
- data =
- "<cont xmlns=\"urn:tests:g\">"
- "<a>val</a>"
- "</cont>";
- assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
- assert_null(tree);
- logbuf_assert("Data are disabled by \"choic\" schema node if-feature. /g:cont/a");
-
- /* enable f3 */
- assert_int_equal(lys_feature_enable(mod, "f3"), LY_SUCCESS);
-
- assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
- assert_non_null(tree);
- lyd_free_siblings(tree);
-
- /* disabled by f2 */
- data =
- "<cont xmlns=\"urn:tests:g\">"
- "<l>val</l>"
- "</cont>";
- assert_int_equal(LY_EVALID, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
- assert_null(tree);
- logbuf_assert("Data are disabled by \"b\" schema node if-feature. /g:cont/l");
-
- /* enable f2 */
- assert_int_equal(lys_feature_enable(mod, "f2"), LY_SUCCESS);
-
- assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, 0, LYD_VALIDATE_PRESENT, &tree));
- assert_non_null(tree);
- lyd_free_siblings(tree);
-
- /* try separate validation */
- assert_int_equal(lys_feature_disable(mod, "f1"), LY_SUCCESS);
- assert_int_equal(lys_feature_disable(mod, "f2"), LY_SUCCESS);
- assert_int_equal(lys_feature_disable(mod, "f3"), LY_SUCCESS);
-
- data =
- "<cont xmlns=\"urn:tests:g\">"
- "<l>val</l>"
- "<d>51</d>"
- "<cont2>"
- "<e>val</e>"
- "</cont2>"
- "</cont>";
- assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY, 0, &tree));
- assert_non_null(tree);
-
- assert_int_equal(LY_EVALID, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT, NULL));
- logbuf_assert("Data are disabled by \"cont\" schema node if-feature. /g:cont");
-
- assert_int_equal(lys_feature_enable(mod, "f1"), LY_SUCCESS);
-
- assert_int_equal(LY_EVALID, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT, NULL));
- logbuf_assert("Data are disabled by \"b\" schema node if-feature. /g:cont/l");
-
- assert_int_equal(lys_feature_enable(mod, "f2"), LY_SUCCESS);
-
- assert_int_equal(LY_SUCCESS, lyd_validate_all(&tree, NULL, LYD_VALIDATE_PRESENT, NULL));
-
- lyd_free_siblings(tree);
-
- *state = NULL;
-}
-
-static void
test_state(void **state)
{
*state = test_state;
@@ -1400,7 +1298,6 @@
const char *data;
struct ly_in *in;
struct lyd_node *tree, *op_tree;
- const struct lys_module *mod;
data =
"<cont xmlns=\"urn:tests:j\">"
@@ -1429,14 +1326,6 @@
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
assert_non_null(tree);
- /* disabled if-feature */
- assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_RPC, NULL));
- logbuf_assert("Data are disabled by \"act\" schema node if-feature. /j:cont/l1[k='val1']/act");
-
- mod = ly_ctx_get_module_latest(ctx, "j");
- assert_non_null(mod);
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "feat1"));
-
/* input must false */
assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_RPC, NULL));
logbuf_assert("Must condition \"../../lf1 = 'true'\" not satisfied. /j:cont/l1[k='val1']/act");
@@ -1453,7 +1342,6 @@
/* success */
assert_int_equal(LY_SUCCESS, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_RPC, NULL));
- lys_feature_disable(mod, "feat1");
lyd_free_tree(op_tree);
lyd_free_siblings(tree);
@@ -1468,7 +1356,6 @@
const char *data;
struct ly_in *in;
struct lyd_node *tree, *op_tree, *request;
- const struct lys_module *mod;
data =
"<cont xmlns=\"urn:tests:j\">"
@@ -1504,14 +1391,6 @@
assert_int_equal(LY_SUCCESS, lyd_parse_data_mem(ctx, data, LYD_XML, LYD_PARSE_ONLY | LYD_PARSE_TRUSTED, 0, &tree));
assert_non_null(tree);
- /* disabled if-feature */
- assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_REPLY, NULL));
- logbuf_assert("Data are disabled by \"act\" schema node if-feature. /j:cont/l1[k='val1']/act");
-
- mod = ly_ctx_get_module_latest(ctx, "j");
- assert_non_null(mod);
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "feat1"));
-
/* input must false */
assert_int_equal(LY_EVALID, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_REPLY, NULL));
logbuf_assert("Must condition \"../../lf1 = 'true2'\" not satisfied. /j:cont/l1[k='val1']/act");
@@ -1528,7 +1407,6 @@
/* success */
assert_int_equal(LY_SUCCESS, lyd_validate_op(op_tree, tree, LYD_VALIDATE_OP_REPLY, NULL));
- lys_feature_disable(mod, "feat1");
lyd_free_tree(op_tree);
lyd_free_siblings(tree);
@@ -1545,7 +1423,6 @@
cmocka_unit_test_teardown(test_unique_nested, teardown_s),
cmocka_unit_test_teardown(test_dup, teardown_s),
cmocka_unit_test_teardown(test_defaults, teardown_s),
- cmocka_unit_test_teardown(test_iffeature, teardown_s),
cmocka_unit_test_teardown(test_state, teardown_s),
cmocka_unit_test_teardown(test_must, teardown_s),
cmocka_unit_test_teardown(test_action, teardown_s),
diff --git a/tests/utests/extensions/test_metadata.c b/tests/utests/extensions/test_metadata.c
index 523bcdc..4f1ac74 100644
--- a/tests/utests/extensions/test_metadata.c
+++ b/tests/utests/extensions/test_metadata.c
@@ -109,6 +109,7 @@
const struct lys_module *mod;
struct lysc_ext_instance *e;
struct lyext_metadata *ant;
+ struct ly_in *in;
const char *data = "module a {yang-version 1.1; namespace urn:tests:extensions:metadata:a; prefix a;"
"import ietf-yang-metadata {prefix md;}"
@@ -121,7 +122,10 @@
" type uint8;"
" units meters;"
"}}";
- assert_int_equal(LY_SUCCESS, lys_parse_mem(s->ctx, data, LYS_IN_YANG, &mod));
+ const char *feats[] = {"f", NULL};
+ assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
+ assert_int_equal(LY_SUCCESS, lys_parse(s->ctx, in, LYS_IN_YANG, feats, &mod));
+ ly_in_free(in, 0);
assert_int_equal(1, LY_ARRAY_COUNT(mod->compiled->exts));
e = &mod->compiled->exts[0];
assert_non_null(ant = (struct lyext_metadata*)e->data);
diff --git a/tests/utests/extensions/test_nacm.c b/tests/utests/extensions/test_nacm.c
index 86b2b80..04b4407 100644
--- a/tests/utests/extensions/test_nacm.c
+++ b/tests/utests/extensions/test_nacm.c
@@ -66,7 +66,7 @@
#endif
assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &s->ctx));
- assert_non_null(ly_ctx_load_module(s->ctx, "ietf-netconf-acm", "2018-02-14"));
+ assert_non_null(ly_ctx_load_module(s->ctx, "ietf-netconf-acm", "2018-02-14", NULL));
*state = s;
diff --git a/tests/utests/schema/test_printer_yang.c b/tests/utests/schema/test_printer_yang.c
index 52528eb..b59e6b2 100644
--- a/tests/utests/schema/test_printer_yang.c
+++ b/tests/utests/schema/test_printer_yang.c
@@ -171,17 +171,7 @@
compiled = "module b {\n"
" namespace \"urn:test:b\";\n"
" prefix b;\n\n"
- " revision 2019-04-16;\n\n"
- " feature f1 {\n"
- " status current;\n"
- " description\n"
- " \"text\";\n"
- " reference\n"
- " \"text\";\n"
- " }\n\n"
- " feature f2 {\n"
- " if-feature \"not f1\";\n"
- " }\n"
+ " revision 2019-04-16;\n"
"}\n";
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, orig, LYS_IN_YANG, &mod));
assert_int_equal(LY_SUCCESS, lys_print_module(out, mod, LYS_OUT_YANG, 0, 0));
@@ -193,7 +183,7 @@
assert_string_equal(printed, compiled);
ly_out_reset(out);
- orig = compiled = "module c {\n"
+ orig = "module c {\n"
" yang-version 1.1;\n"
" namespace \"urn:test:c\";\n"
" prefix c;\n\n"
@@ -210,12 +200,16 @@
" status obsolete;\n"
" }\n"
"}\n";
+ compiled = "module c {\n"
+ " namespace \"urn:test:c\";\n"
+ " prefix c;\n"
+ "}\n";
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, orig, LYS_IN_YANG, &mod));
assert_int_equal(LY_SUCCESS, lys_print_module(out, mod, LYS_OUT_YANG, 0, 0));
assert_int_equal(strlen(orig), ly_out_printed(out));
assert_string_equal(printed, orig);
ly_out_reset(out);
- assert_int_equal(LY_SUCCESS, lys_print_module(out, mod, LYS_OUT_YANG, 0, 0));
+ assert_int_equal(LY_SUCCESS, lys_print_module(out, mod, LYS_OUT_YANG_COMPILED, 0, 0));
assert_int_equal(strlen(compiled), ly_out_printed(out));
assert_string_equal(printed, compiled);
diff --git a/tests/utests/schema/test_schema_common.c b/tests/utests/schema/test_schema_common.c
index a43d6fc..dc50517 100644
--- a/tests/utests/schema/test_schema_common.c
+++ b/tests/utests/schema/test_schema_common.c
@@ -124,23 +124,15 @@
assert_string_equal("h-output", node->name);
assert_null(node = lys_getnext(node, (const struct lysc_node*)rpc, mod->compiled, LYS_GETNEXT_OUTPUT));
- assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b; feature f;"
- "leaf a {type string; if-feature f;}"
- "leaf b {type string;}}", LYS_IN_YANG, &mod));
- assert_non_null(node = lys_getnext(NULL, NULL, mod->compiled, 0));
- assert_string_equal("b", node->name);
- assert_non_null(node = lys_getnext(NULL, NULL, mod->compiled, LYS_GETNEXT_NOSTATECHECK));
- assert_string_equal("a", node->name);
-
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module c {namespace urn:c;prefix c; rpc c;}", LYS_IN_YANG, &mod));
assert_non_null(node = lys_getnext(NULL, NULL, mod->compiled, 0));
assert_string_equal("c", node->name);
- assert_null(node = lys_getnext(node, NULL, mod->compiled, LYS_GETNEXT_NOSTATECHECK));
+ assert_null(node = lys_getnext(node, NULL, mod->compiled, 0));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module d {namespace urn:d;prefix d; notification d;}", LYS_IN_YANG, &mod));
assert_non_null(node = lys_getnext(NULL, NULL, mod->compiled, 0));
assert_string_equal("d", node->name);
- assert_null(node = lys_getnext(node, NULL, mod->compiled, LYS_GETNEXT_NOSTATECHECK));
+ assert_null(node = lys_getnext(node, NULL, mod->compiled, 0));
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module e {namespace urn:e;prefix e; container c {container cc;} leaf a {type string;}}", LYS_IN_YANG, &mod));
assert_non_null(node = lys_getnext(NULL, NULL, mod->compiled, 0));
diff --git a/tests/utests/schema/test_schema_stmts.c b/tests/utests/schema/test_schema_stmts.c
index 11512ac..55400b4 100644
--- a/tests/utests/schema/test_schema_stmts.c
+++ b/tests/utests/schema/test_schema_stmts.c
@@ -116,11 +116,11 @@
assert_int_equal(1, LY_ARRAY_COUNT(mod->identities[1].derived));
assert_ptr_equal(mod->identities[1].derived[0], &mod->identities[0]);
- TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "identity i1;identity i1;", "Duplicate identifier \"i1\" of identity statement. /inv:{identity='i1'}");
+ TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "identity i1;identity i1;", "Duplicate identifier \"i1\" of identity statement. Line number 1.");
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "submodule inv_sub {belongs-to inv {prefix inv;} identity i1;}");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "include inv_sub;identity i1;",
- "Duplicate identifier \"i1\" of identity statement. /inv:{identity='i1'}");
+ "Duplicate identifier \"i1\" of identity statement. Line number 1.");
TEST_SCHEMA_ERR(ctx, 0, 0,"inv", "identity i1 {base i2;}", "Unable to find base (i2) of identity \"i1\". /inv:{identity='i1'}");
TEST_SCHEMA_ERR(ctx, 0, 0,"inv", "identity i1 {base i1;}", "Identity \"i1\" is derived from itself. /inv:{identity='i1'}");
TEST_SCHEMA_ERR(ctx, 0, 0,"inv", "identity i1 {base i2;}identity i2 {base i3;}identity i3 {base i1;}",
@@ -160,7 +160,7 @@
struct ly_ctx *ctx;
const struct lys_module *mod;
- const struct lysc_feature *f, *f1;
+ const struct lysp_feature *f;
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, 0, &ctx));
@@ -223,144 +223,51 @@
"feature f7 {if-feature \"(f2 and f3) or (not f1)\";}\n"
"feature f8 {if-feature \"f1 or f2 or f3 or orfeature or andfeature\";}\n"
"feature f9 {if-feature \"not not f1\";}", mod);
- assert_non_null(mod->features);
- assert_int_equal(9, LY_ARRAY_COUNT(mod->features));
+ assert_non_null(mod->parsed->features);
+ assert_int_equal(9, LY_ARRAY_COUNT(mod->parsed->features));
/* all features are disabled by default */
- LY_ARRAY_FOR(mod->features, struct lysc_feature, f) {
- assert_int_equal(LY_ENOT, lysc_feature_value(f));
+ LY_ARRAY_FOR(mod->parsed->features, struct lysp_feature, f) {
+ assert_false(f->flags & LYS_FENABLED);
}
- /* enable f1 */
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "f1"));
- f1 = &mod->features[0];
- assert_int_equal(LY_SUCCESS, lysc_feature_value(f1));
-
- /* enable orfeature */
- f = &mod->features[3];
- assert_int_equal(LY_ENOT, lysc_feature_value(f));
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "orfeature"));
- assert_int_equal(LY_SUCCESS, lysc_feature_value(f));
-
- /* enable andfeature - no possible since f2 is disabled */
- f = &mod->features[4];
- assert_int_equal(LY_ENOT, lysc_feature_value(f));
- assert_int_equal(LY_EDENIED, lys_feature_enable(mod, "andfeature"));
- logbuf_assert("Feature \"andfeature\" cannot be enabled since it is disabled by its if-feature condition(s).");
- assert_int_equal(LY_ENOT, lysc_feature_value(f));
-
- /* first enable f2, so f5 can be enabled then */
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "f2"));
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "andfeature"));
- assert_int_equal(LY_SUCCESS, lysc_feature_value(f));
-
- /* f1 is enabled, so f6 cannot be enabled */
- f = &mod->features[5];
- assert_int_equal(LY_ENOT, lysc_feature_value(f));
- assert_int_equal(LY_EDENIED, lys_feature_enable(mod, "f6"));
- logbuf_assert("Feature \"f6\" cannot be enabled since it is disabled by its if-feature condition(s).");
- assert_int_equal(LY_ENOT, lysc_feature_value(f));
-
- /* so disable f1 - andfeature will became also disabled */
- assert_int_equal(LY_SUCCESS, lysc_feature_value(f1));
- assert_int_equal(LY_SUCCESS, lys_feature_disable(mod, "f1"));
- assert_int_equal(LY_ENOT, lysc_feature_value(f1));
- assert_int_equal(LY_ENOT, lysc_feature_value(&mod->features[4]));
- /* while orfeature is stille enabled */
- assert_int_equal(LY_SUCCESS, lysc_feature_value(&mod->features[3]));
- /* and finally f6 can be enabled */
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "f6"));
- assert_int_equal(LY_SUCCESS, lysc_feature_value(&mod->features[5]));
-
- /* complex evaluation of f7: f1 and f3 are disabled, while f2 is enabled */
- assert_int_equal(LY_SUCCESS, lysc_iffeature_value(&mod->features[6].iffeatures[0]));
- /* long evaluation of f8 to need to reallocate internal stack for operators */
- assert_int_equal(LY_SUCCESS, lysc_iffeature_value(&mod->features[7].iffeatures[0]));
-
- /* double negation of disabled f1 -> disabled */
- assert_int_equal(LY_ENOT, lysc_iffeature_value(&mod->features[8].iffeatures[0]));
-
- /* disable all features */
- assert_int_equal(LY_SUCCESS, lys_feature_disable(mod, "*"));
- LY_ARRAY_FOR(mod->features, struct lysc_feature, f) {
- assert_int_equal(LY_ENOT, lys_feature_value(mod, f->name));
- }
- /* re-setting already set feature */
- assert_int_equal(LY_SUCCESS, lys_feature_disable(mod, "f1"));
- assert_int_equal(LY_ENOT, lys_feature_value(mod, "f1"));
-
- /* enabling feature that cannot be enabled due to its if-features */
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "f1"));
- assert_int_equal(LY_EDENIED, lys_feature_enable(mod, "andfeature"));
- logbuf_assert("Feature \"andfeature\" cannot be enabled since it is disabled by its if-feature condition(s).");
- assert_int_equal(LY_EDENIED, lys_feature_enable(mod, "*"));
- logbuf_assert("Feature \"f6\" cannot be enabled since it is disabled by its if-feature condition(s).");
- /* test if not changed */
- assert_int_equal(LY_SUCCESS, lys_feature_value(mod, "f1"));
- assert_int_equal(LY_ENOT, lys_feature_value(mod, "f2"));
-
- TEST_SCHEMA_OK(ctx, 0, 0, "b", "feature f1 {if-feature f2;}feature f2;", mod);
- assert_non_null(mod->features);
- assert_int_equal(2, LY_ARRAY_COUNT(mod->features));
- assert_non_null(mod->features[0].iffeatures);
- assert_int_equal(1, LY_ARRAY_COUNT(mod->features[0].iffeatures));
- assert_non_null(mod->features[0].iffeatures[0].features);
- assert_int_equal(1, LY_ARRAY_COUNT(mod->features[0].iffeatures[0].features));
- assert_ptr_equal(&mod->features[1], mod->features[0].iffeatures[0].features[0]);
- assert_non_null(mod->features);
- assert_int_equal(2, LY_ARRAY_COUNT(mod->features));
- assert_non_null(mod->features[1].depfeatures);
- assert_int_equal(1, LY_ARRAY_COUNT(mod->features[1].depfeatures));
- assert_ptr_equal(&mod->features[0], mod->features[1].depfeatures[0]);
-
- /* invalid reference */
- assert_int_equal(LY_ENOTFOUND, lys_feature_enable(mod, "xxx"));
- logbuf_assert("Feature \"xxx\" not found in module \"b\".");
/* some invalid expressions */
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f{if-feature f1;}",
- "Invalid value \"f1\" of if-feature - unable to find feature \"f1\". /inv:{feature='f'}");
+ "Invalid value \"f1\" of if-feature - unable to find feature \"f1\".");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f2{if-feature 'f and';}",
- "Invalid value \"f and\" of if-feature - unexpected end of expression. /inv:{feature='f2'}");
+ "Invalid value \"f and\" of if-feature - unexpected end of expression.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f{if-feature 'or';}",
- "Invalid value \"or\" of if-feature - unexpected end of expression. /inv:{feature='f'}");
+ "Invalid value \"or\" of if-feature - unexpected end of expression.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f2{if-feature '(f1';}",
- "Invalid value \"(f1\" of if-feature - non-matching opening and closing parentheses. /inv:{feature='f2'}");
+ "Invalid value \"(f1\" of if-feature - non-matching opening and closing parentheses.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f2{if-feature 'f1)';}",
- "Invalid value \"f1)\" of if-feature - non-matching opening and closing parentheses. /inv:{feature='f2'}");
+ "Invalid value \"f1)\" of if-feature - non-matching opening and closing parentheses.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f2{if-feature ---;}",
- "Invalid value \"---\" of if-feature - unable to find feature \"---\". /inv:{feature='f2'}");
+ "Invalid value \"---\" of if-feature - unable to find feature \"---\".");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "feature f1; feature f2{if-feature 'not f1';}",
- "Invalid value \"not f1\" of if-feature - YANG 1.1 expression in YANG 1.0 module. /inv:{feature='f2'}");
+ "Invalid value \"not f1\" of if-feature - YANG 1.1 expression in YANG 1.0 module.");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "feature f1; feature f1;",
- "Duplicate identifier \"f1\" of feature statement. /inv:{feature='f1'}");
+ "Duplicate identifier \"f1\" of feature statement. Line number 1.");
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "submodule inv_sub {belongs-to inv {prefix inv;} feature f1;}");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "include inv_sub;feature f1;",
- "Duplicate identifier \"f1\" of feature statement. /inv:{feature='f1'}");
+ "Duplicate identifier \"f1\" of feature statement. Line number 1.");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "feature f1 {if-feature f2;} feature f2 {if-feature f1;}",
- "Feature \"f1\" is indirectly referenced from itself. /inv:{feature='f2'}");
+ "Feature \"f1\" is indirectly referenced from itself.");
TEST_SCHEMA_ERR(ctx, 0, 0, "inv", "feature f1 {if-feature f1;}",
- "Feature \"f1\" is referenced from itself. /inv:{feature='f1'}");
+ "Feature \"f1\" is referenced from itself.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f {if-feature ();}",
- "Invalid value \"()\" of if-feature - number of features in expression does not match the required number of operands for the operations. /inv:{feature='f'}");
+ "Invalid value \"()\" of if-feature - number of features in expression does not match the required number of operands for the operations.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f {if-feature 'f1(';}",
- "Invalid value \"f1(\" of if-feature - non-matching opening and closing parentheses. /inv:{feature='f'}");
+ "Invalid value \"f1(\" of if-feature - non-matching opening and closing parentheses.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f {if-feature 'and f1';}",
- "Invalid value \"and f1\" of if-feature - missing feature/expression before \"and\" operation. /inv:{feature='f'}");
+ "Invalid value \"and f1\" of if-feature - missing feature/expression before \"and\" operation.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f {if-feature 'f1 not ';}",
- "Invalid value \"f1 not \" of if-feature - unexpected end of expression. /inv:{feature='f'}");
+ "Invalid value \"f1 not \" of if-feature - unexpected end of expression.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f {if-feature 'f1 not not ';}",
- "Invalid value \"f1 not not \" of if-feature - unexpected end of expression. /inv:{feature='f'}");
+ "Invalid value \"f1 not not \" of if-feature - unexpected end of expression.");
TEST_SCHEMA_ERR(ctx, 1, 0, "inv", "feature f1; feature f2; feature f {if-feature 'or f1 f2';}",
- "Invalid value \"or f1 f2\" of if-feature - missing feature/expression before \"or\" operation. /inv:{feature='f'}");
-
- /* import reference */
- assert_non_null(mod = ly_ctx_get_module(ctx, "a", NULL));
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "f1"));
- TEST_SCHEMA_OK(ctx, 0, 0, "c", "import a {prefix a;} feature f1; feature f2{if-feature 'a:f1';}", mod);
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "f2"));
- assert_int_equal(LY_ENOT, lys_feature_value(mod, "f1"));
- assert_int_equal(LY_SUCCESS, lys_feature_value(mod, "f2"));
+ "Invalid value \"or f1 f2\" of if-feature - missing feature/expression before \"or\" operation.");
/*
* printing
diff --git a/tests/utests/schema/test_tree_schema_compile.c b/tests/utests/schema/test_tree_schema_compile.c
index c1ea424..091ae9b 100644
--- a/tests/utests/schema/test_tree_schema_compile.c
+++ b/tests/utests/schema/test_tree_schema_compile.c
@@ -28,7 +28,6 @@
#include "schema_compile.h"
#include "xpath.h"
-void lysc_feature_free(struct ly_ctx *ctx, struct lysc_feature *feat);
void yang_parser_ctx_free(struct lys_yang_parser_ctx *ctx);
#define BUFSIZE 1024
@@ -104,7 +103,7 @@
struct ly_in *in;
struct ly_ctx *ctx = NULL;
struct lys_module *mod = NULL;
- struct lysc_feature *f;
+ struct lysp_feature *f;
struct lysc_iffeature *iff;
str = "module test {namespace urn:test; prefix t;"
@@ -114,7 +113,7 @@
assert_int_equal(LY_EINVAL, lys_compile(NULL, 0));
logbuf_assert("Invalid argument mod (lys_compile()).");
assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
- assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in, LYS_IN_YANG, 0, NULL, NULL, &mod));
+ assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in, LYS_IN_YANG, 0, NULL, NULL, NULL, &mod));
ly_in_free(in, 0);
assert_int_equal(0, mod->implemented);
assert_int_equal(LY_SUCCESS, lys_compile(mod, 0));
@@ -126,28 +125,28 @@
assert_string_equal("urn:test", mod->ns);
assert_string_equal("t", mod->prefix);
/* features */
- assert_non_null(mod->features);
- assert_int_equal(2, LY_ARRAY_COUNT(mod->features));
- f = &mod->features[1];
+ assert_non_null(mod->parsed->features);
+ assert_int_equal(2, LY_ARRAY_COUNT(mod->parsed->features));
+ f = &mod->parsed->features[1];
assert_non_null(f->iffeatures);
assert_int_equal(1, LY_ARRAY_COUNT(f->iffeatures));
- iff = &f->iffeatures[0];
+ iff = &f->iffeatures_c[0];
assert_non_null(iff->expr);
assert_non_null(iff->features);
assert_int_equal(1, LY_ARRAY_COUNT(iff->features));
- assert_ptr_equal(&mod->features[0], iff->features[0]);
+ assert_ptr_equal(&mod->parsed->features[0], iff->features[0]);
/* submodules cannot be compiled directly */
str = "submodule test {belongs-to xxx {prefix x;}}";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
- assert_int_equal(LY_EINVAL, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, NULL));
+ assert_int_equal(LY_EINVAL, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, NULL, NULL));
ly_in_free(in, 0);
logbuf_assert("Input data contains submodule which cannot be parsed directly without its main module.");
/* data definition name collision in top level */
str = "module aa {namespace urn:aa;prefix aa; leaf a {type string;} container a{presence x;}}";
assert_int_equal(LY_SUCCESS, ly_in_new_memory(str, &in));
- assert_int_equal(LY_EEXIST, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, &mod));
+ assert_int_equal(LY_EEXIST, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, NULL, &mod));
logbuf_assert("Duplicate identifier \"a\" of data definition/RPC/action/notification statement. /aa:a");
ly_in_free(in, 0);
@@ -399,12 +398,18 @@
const struct lys_module *mod;
struct lysc_node_list *list;
struct lysc_node *child;
+ struct ly_in *in;
+ const char *data =
+ "module a {namespace urn:a;prefix a;feature f;"
+ "list l1 {key \"x y\"; ordered-by user; leaf y{type string;if-feature f;} leaf x {type string; when 1;}}"
+ "list l2 {config false;leaf value {type string;}}}";
+ const char *feats[] = {"f", NULL};
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
- assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {namespace urn:a;prefix a;feature f;"
- "list l1 {key \"x y\"; ordered-by user; leaf y{type string;if-feature f;} leaf x {type string; when 1;}}"
- "list l2 {config false;leaf value {type string;}}}", LYS_IN_YANG, &mod));
+ assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
+ assert_int_equal(LY_SUCCESS, lys_parse(ctx, in, LYS_IN_YANG, feats, &mod));
+ ly_in_free(in, 0);
list = (struct lysc_node_list*)mod->compiled->data;
assert_non_null(list);
assert_non_null(list->child);
@@ -484,7 +489,7 @@
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module cc {yang-version 1.1;namespace urn:cc;prefix cc;feature f;"
"list l {key x; leaf x {type string; if-feature f;}}}", LYS_IN_YANG, NULL));
- logbuf_assert("List's key must not have any \"if-feature\" statement. /cc:l/x");
+ logbuf_assert("Key \"x\" is disabled by its if-features. /cc:l/x");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module dd {namespace urn:dd;prefix dd;"
"list l {key x; leaf x {type string; config false;}}}", LYS_IN_YANG, NULL));
@@ -1203,20 +1208,17 @@
assert_non_null(type);
assert_int_equal(LY_TYPE_ENUM, type->basetype);
assert_non_null(((struct lysc_type_enum*)type)->enums);
- assert_int_equal(6, LY_ARRAY_COUNT(((struct lysc_type_enum*)type)->enums));
- assert_non_null(((struct lysc_type_enum*)type)->enums[2].iffeatures);
+ assert_int_equal(5, LY_ARRAY_COUNT(((struct lysc_type_enum*)type)->enums));
assert_string_equal("automin", ((struct lysc_type_enum*)type)->enums[0].name);
assert_int_equal(0, ((struct lysc_type_enum*)type)->enums[0].value);
assert_string_equal("min", ((struct lysc_type_enum*)type)->enums[1].name);
assert_int_equal(-2147483648, ((struct lysc_type_enum*)type)->enums[1].value);
- assert_string_equal("one", ((struct lysc_type_enum*)type)->enums[2].name);
- assert_int_equal(1, ((struct lysc_type_enum*)type)->enums[2].value);
- assert_string_equal("two", ((struct lysc_type_enum*)type)->enums[3].name);
- assert_int_equal(2, ((struct lysc_type_enum*)type)->enums[3].value);
- assert_string_equal("seven", ((struct lysc_type_enum*)type)->enums[4].name);
- assert_int_equal(7, ((struct lysc_type_enum*)type)->enums[4].value);
- assert_string_equal("eight", ((struct lysc_type_enum*)type)->enums[5].name);
- assert_int_equal(8, ((struct lysc_type_enum*)type)->enums[5].value);
+ assert_string_equal("two", ((struct lysc_type_enum*)type)->enums[2].name);
+ assert_int_equal(2, ((struct lysc_type_enum*)type)->enums[2].value);
+ assert_string_equal("seven", ((struct lysc_type_enum*)type)->enums[3].name);
+ assert_int_equal(7, ((struct lysc_type_enum*)type)->enums[3].value);
+ assert_string_equal("eight", ((struct lysc_type_enum*)type)->enums[4].name);
+ assert_int_equal(8, ((struct lysc_type_enum*)type)->enums[4].value);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {yang-version 1.1; namespace urn:b;prefix b;feature f; typedef mytype {type enumeration {"
"enum 11; enum min {value -2147483648;}enum x$&;"
@@ -1307,18 +1309,15 @@
assert_non_null(type);
assert_int_equal(LY_TYPE_BITS, type->basetype);
assert_non_null(((struct lysc_type_bits*)type)->bits);
- assert_int_equal(5, LY_ARRAY_COUNT(((struct lysc_type_bits*)type)->bits));
- assert_non_null(((struct lysc_type_bits*)type)->bits[1].iffeatures);
+ assert_int_equal(4, LY_ARRAY_COUNT(((struct lysc_type_bits*)type)->bits));
assert_string_equal("automin", ((struct lysc_type_bits*)type)->bits[0].name);
assert_int_equal(0, ((struct lysc_type_bits*)type)->bits[0].position);
- assert_string_equal("one", ((struct lysc_type_bits*)type)->bits[1].name);
- assert_int_equal(1, ((struct lysc_type_bits*)type)->bits[1].position);
- assert_string_equal("two", ((struct lysc_type_bits*)type)->bits[2].name);
- assert_int_equal(2, ((struct lysc_type_bits*)type)->bits[2].position);
- assert_string_equal("seven", ((struct lysc_type_bits*)type)->bits[3].name);
- assert_int_equal(7, ((struct lysc_type_bits*)type)->bits[3].position);
- assert_string_equal("eight", ((struct lysc_type_bits*)type)->bits[4].name);
- assert_int_equal(8, ((struct lysc_type_bits*)type)->bits[4].position);
+ assert_string_equal("two", ((struct lysc_type_bits*)type)->bits[1].name);
+ assert_int_equal(2, ((struct lysc_type_bits*)type)->bits[1].position);
+ assert_string_equal("seven", ((struct lysc_type_bits*)type)->bits[2].name);
+ assert_int_equal(7, ((struct lysc_type_bits*)type)->bits[2].position);
+ assert_string_equal("eight", ((struct lysc_type_bits*)type)->bits[3].name);
+ assert_int_equal(8, ((struct lysc_type_bits*)type)->bits[3].position);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {yang-version 1.1;namespace urn:b;prefix b;feature f; typedef mytype {type bits {"
"bit automin; bit one;bit two; bit seven {position 7;}bit eight;}} leaf l { type mytype {bit eight;bit seven;bit automin;}}}",
@@ -1698,7 +1697,7 @@
assert_int_equal(1, ((struct lysc_type_leafref* )type)->require_instance);
/* conditional leafrefs */
- assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module e {yang-version 1.1;namespace urn:e;prefix e;feature f1; feature f2;"
+ /*assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module e {yang-version 1.1;namespace urn:e;prefix e;feature f1; feature f2;"
"leaf ref1 {if-feature 'f1 and f2';type leafref {path /target;}}"
"leaf target {if-feature f1; type boolean;}}", LYS_IN_YANG, &mod));
type = ((struct lysc_node_leaf*)mod->compiled->data)->type;
@@ -1708,7 +1707,7 @@
assert_string_equal("/target", ((struct lysc_type_leafref* )type)->path->expr);
assert_int_equal(0, LY_ARRAY_COUNT(((struct lysc_type_leafref*)type)->prefixes));
assert_non_null(((struct lysc_type_leafref*)type)->realtype);
- assert_int_equal(LY_TYPE_BOOL, ((struct lysc_type_leafref*)type)->realtype->basetype);
+ assert_int_equal(LY_TYPE_BOOL, ((struct lysc_type_leafref*)type)->realtype->basetype);*/
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module f {namespace urn:f;prefix f;"
"list interface{key name;leaf name{type string;}list address {key ip;leaf ip {type string;}}}"
@@ -1812,8 +1811,7 @@
logbuf_assert("Missing path substatement for leafref type mytype. /ii:ref1");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj {namespace urn:jj;prefix jj;feature f;"
"leaf ref {type leafref {path /target;}}leaf target {if-feature f;type string;}}", LYS_IN_YANG, &mod));
- logbuf_assert("Invalid leafref path \"/target\" - set of features applicable to the leafref target is not a subset of features "
- "applicable to the leafref itself. /jj:ref");
+ logbuf_assert("Not found node \"target\" in path. /jj:ref");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module kk {namespace urn:kk;prefix kk;"
"leaf ref {type leafref {path /target;}}leaf target {type string;config false;}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid leafref path \"/target\" - target is supposed to represent configuration data (as the leafref does), but it does not. /kk:ref");
@@ -2242,22 +2240,7 @@
assert_non_null((child = child->next));
assert_string_equal("x", child->name);
assert_ptr_equal(mod, child->module);
- assert_non_null((child = child->next));
- assert_string_equal("y", child->name);
- assert_non_null(child->iffeatures);
- assert_int_equal(1, LY_ARRAY_COUNT(child->iffeatures));
- assert_int_equal(1, LY_ARRAY_COUNT(child->iffeatures[0].features));
- assert_string_equal("f", child->iffeatures[0].features[0]->name);
- assert_int_equal(LY_EINVAL, lys_feature_enable(mod->parsed->imports[0].module, "f"));
- logbuf_assert("Module \"grp\" is not implemented so all its features are permanently disabled.");
- assert_int_equal(LY_ENOT, lysc_iffeature_value(&child->iffeatures[0]));
-
- /* make the imported module implemented and enable the feature */
- assert_non_null(mod = ly_ctx_get_module(ctx, "grp", NULL));
- assert_int_equal(LY_SUCCESS, lys_set_implemented((struct lys_module *)mod));
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "f"));
- assert_string_equal("f", child->iffeatures[0].features[0]->name);
- assert_int_equal(LY_SUCCESS, lysc_iffeature_value(&child->iffeatures[0]));
+ assert_null((child = child->next));
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "submodule bsub {belongs-to b {prefix b;} grouping grp {leaf b {when 1; type string;} leaf c {type string;}}}");
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module b {namespace urn:b;prefix b;include bsub;uses grp {when 2;}}", LYS_IN_YANG, &mod));
@@ -2415,25 +2398,33 @@
struct lysc_node_leaf *leaf;
struct lysc_node_leaflist *llist;
uint8_t dynamic;
+ struct ly_in *in;
+ const char *data, *feats1[] = {"f", NULL}, *feats2[] = {"fa", NULL};
assert_int_equal(LY_SUCCESS, ly_ctx_new(NULL, LY_CTX_DISABLE_SEARCHDIRS, &ctx));
- assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module grp {yang-version 1.1;namespace urn:grp;prefix g; feature f;typedef mytype {type string; default cheers!;}"
+ data = "module grp {yang-version 1.1;namespace urn:grp;prefix g; feature f;typedef mytype {type string; default cheers!;}"
"grouping grp {container c {leaf l {type mytype; default goodbye;}"
"leaf-list ll {type mytype; default goodbye; max-elements 6;}"
"choice ch {default ca; leaf ca {type int8;}leaf cb{type uint8;}}"
"leaf x {type mytype; mandatory true; must 1;}"
"anydata a {mandatory false; if-feature f; description original; reference original;}"
- "container c {config false; leaf l {type string;}}}}}", LYS_IN_YANG, NULL));
+ "container c {config false; leaf l {type string;}}}}}";
+ assert_int_equal(LY_SUCCESS, ly_in_new_memory(data, &in));
+ assert_int_equal(LY_SUCCESS, lys_parse(ctx, in, LYS_IN_YANG, feats1, NULL));
- assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, "module a {yang-version 1.1;namespace urn:a;prefix a;import grp {prefix g;}feature fa;"
+ data = "module a {yang-version 1.1;namespace urn:a;prefix a;import grp {prefix g;}feature fa;"
"uses g:grp {refine c/l {default hello; config false;}"
"refine c/ll {default hello;default world;}"
"refine c/ch {default cb;config true; if-feature fa;}"
"refine c/x {mandatory false; must ../ll;description refined; reference refined;}"
- "refine c/a {mandatory true; must 1; if-feature fa;description refined; reference refined;}"
+ "refine c/a {mandatory true; must 1; description refined; reference refined;}"
"refine c/ll {max-elements 5;}"
- "refine c/c {config true;presence indispensable;}}}", LYS_IN_YANG, &mod));
+ "refine c/c {config true;presence indispensable;}}}";
+ ly_in_memory(in, data);
+ assert_int_equal(LY_SUCCESS, lys_parse(ctx, in, LYS_IN_YANG, feats2, &mod));
+ ly_in_free(in, 0);
+
assert_non_null((parent = mod->compiled->data));
assert_int_equal(LYS_CONTAINER, parent->nodetype);
assert_string_equal("c", parent->name);
@@ -2458,8 +2449,6 @@
assert_string_equal("cb", ((struct lysc_node_choice*)child)->dflt->name);
assert_true(LYS_SET_DFLT & ((struct lysc_node_choice*)child)->dflt->flags);
assert_false(LYS_SET_DFLT & ((struct lysc_node_choice*)child)->cases[0].flags);
- assert_non_null(child->iffeatures);
- assert_int_equal(1, LY_ARRAY_COUNT(child->iffeatures));
assert_non_null(leaf = (struct lysc_node_leaf*)child->next);
assert_int_equal(LYS_LEAF, leaf->nodetype);
assert_string_equal("x", leaf->name);
@@ -2476,8 +2465,6 @@
assert_true(LYS_MAND_TRUE & child->flags);
assert_non_null(((struct lysc_node_anydata*)child)->musts);
assert_int_equal(1, LY_ARRAY_COUNT(((struct lysc_node_anydata*)child)->musts));
- assert_non_null(child->iffeatures);
- assert_int_equal(2, LY_ARRAY_COUNT(child->iffeatures));
assert_string_equal("refined", child->dsc);
assert_string_equal("refined", child->ref);
assert_non_null(child = child->next);
@@ -3201,7 +3188,7 @@
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj5 {namespace urn:jj5;prefix jj5; container top {leaf x {type string; config true;}}"
"deviation /top {deviate add {config false;}}}", LYS_IN_YANG, &mod));
/*logbuf_assert("Invalid deviation of config - configuration node cannot be child of any state data node. /jj5:{deviation='/top'}");*/
- logbuf_assert("Compilation of a deviated and/or refined node failed. /jj5:top/x");
+ logbuf_assert("Compilation of a deviated and/or refined node failed. /jj5:top");
assert_int_equal(LY_EVALID, lys_parse_mem(ctx, "module jj6 {namespace urn:jj6;prefix jj6; leaf x {config false; type string;}"
"deviation /x {deviate add {config true;}}}", LYS_IN_YANG, &mod));
logbuf_assert("Invalid deviation adding \"config\" property which already exists (with value \"config false\"). /jj6:{deviation='/x'}");
diff --git a/tests/utests/test_context.c b/tests/utests/test_context.c
index 35c9664..6526abc 100644
--- a/tests/utests/test_context.c
+++ b/tests/utests/test_context.c
@@ -286,7 +286,7 @@
assert_int_equal(ctx->module_set_id, ly_ctx_get_module_set_id(ctx));
assert_int_equal(LY_SUCCESS, ly_in_new_memory("module x {namespace urn:x;prefix x;}", &in));
- assert_int_equal(LY_EINVAL, lys_create_module(ctx, in, 4, 1, NULL, NULL, &mod1));
+ assert_int_equal(LY_EINVAL, lys_create_module(ctx, in, 4, 1, NULL, NULL, NULL, &mod1));
ly_in_free(in, 0);
logbuf_assert("Invalid schema input format.");
@@ -304,22 +304,22 @@
/* name collision of module and submodule */
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "submodule y {belongs-to a {prefix a;} revision 2018-10-30;}");
assert_int_equal(LY_SUCCESS, ly_in_new_memory("module y {namespace urn:y;prefix y;include y;}", &in));
- assert_int_equal(LY_EVALID, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, &mod1));
+ assert_int_equal(LY_EVALID, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, NULL, &mod1));
ly_in_free(in, 0);
logbuf_assert("Name collision between module and submodule of name \"y\". Line number 1.");
assert_int_equal(LY_SUCCESS, ly_in_new_memory("module a {namespace urn:a;prefix a;include y;revision 2018-10-30; }", &in));
- assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, &mod1));
+ assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, NULL, &mod1));
ly_in_free(in, 0);
assert_int_equal(LY_SUCCESS, ly_in_new_memory("module y {namespace urn:y;prefix y;}", &in));
- assert_int_equal(LY_EVALID, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, &mod1));
+ assert_int_equal(LY_EVALID, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, NULL, &mod1));
ly_in_free(in, 0);
logbuf_assert("Name collision between module and submodule of name \"y\". Line number 1.");
store = 1;
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "submodule y {belongs-to b {prefix b;}}");
assert_int_equal(LY_SUCCESS, ly_in_new_memory("module b {namespace urn:b;prefix b;include y;}", &in));
- assert_int_equal(LY_EVALID, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, &mod1));
+ assert_int_equal(LY_EVALID, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, NULL, &mod1));
ly_in_free(in, 0);
logbuf_assert("Name collision between submodules of name \"y\". Line number 1.");
store = -1;
@@ -328,13 +328,13 @@
ly_ctx_reset_latests(ctx);
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "submodule y {belongs-to a {prefix a;} revision 2018-10-31;}");
assert_int_equal(LY_SUCCESS, ly_in_new_memory("module a {namespace urn:a;prefix a;include y; revision 2018-10-31;}", &in));
- assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in, LYS_IN_YANG, 0, NULL, NULL, &mod2));
+ assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in, LYS_IN_YANG, 0, NULL, NULL, NULL, &mod2));
ly_in_free(in, 0);
assert_string_equal("2018-10-31", mod2->parsed->includes[0].submodule->revs[0].date);
/* reloading module in case only the compiled module resists in the context */
assert_int_equal(LY_SUCCESS, ly_in_new_memory("module w {namespace urn:w;prefix w;revision 2018-10-24;}", &in));
- assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in, LYS_IN_YANG, 0, NULL, NULL, &mod1));
+ assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in, LYS_IN_YANG, 0, NULL, NULL, NULL, &mod1));
ly_in_free(in, 0);
mod1->implemented = 1;
assert_int_equal(LY_SUCCESS, lys_compile(mod1, 0));
@@ -356,7 +356,7 @@
assert_int_equal(LY_SUCCESS, ly_in_new_memory("module z {namespace urn:z;prefix z;import w {prefix w;revision-date 2018-10-24;}}", &in));
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, "module w {namespace urn:w;prefix w;revision 2018-10-24;}");
- assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, &mod2));
+ assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in, LYS_IN_YANG, 1, NULL, NULL, NULL, &mod2));
ly_in_free(in, 0);
assert_non_null(mod2);
assert_non_null(mod1->parsed);
@@ -461,16 +461,16 @@
assert_non_null(ly_ctx_get_module_ns(ctx, "urn:ietf:params:xml:ns:yang:ietf-datastores", "2018-02-14"));
/* select module by revision */
- assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in1, LYS_IN_YANG, 1, NULL, NULL, &mod));
+ assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in1, LYS_IN_YANG, 1, NULL, NULL, NULL, &mod));
/* invalid attempts - implementing module of the same name and inserting the same module */
- assert_int_equal(LY_EDENIED, lys_create_module(ctx, in2, LYS_IN_YANG, 1, NULL, NULL, NULL));
+ assert_int_equal(LY_EDENIED, lys_create_module(ctx, in2, LYS_IN_YANG, 1, NULL, NULL, NULL, NULL));
logbuf_assert("Module \"a\" is already implemented in the context.");
ly_in_reset(in1);
- assert_int_equal(LY_EEXIST, lys_create_module(ctx, in1, LYS_IN_YANG, 0, NULL, NULL, NULL));
+ assert_int_equal(LY_EEXIST, lys_create_module(ctx, in1, LYS_IN_YANG, 0, NULL, NULL, NULL, NULL));
logbuf_assert("Module \"a\" of revision \"2018-10-23\" is already present in the context.");
/* insert the second module only as imported, not implemented */
ly_in_reset(in2);
- assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in2, LYS_IN_YANG, 0, NULL, NULL, &mod2));
+ assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in2, LYS_IN_YANG, 0, NULL, NULL, NULL, &mod2));
assert_non_null(mod2);
assert_ptr_not_equal(mod, mod2);
mod = ly_ctx_get_module_latest(ctx, "a");
@@ -478,14 +478,14 @@
mod2 = ly_ctx_get_module_latest_ns(ctx, mod->ns);
assert_ptr_equal(mod, mod2);
/* work with module with no revision */
- assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in0, LYS_IN_YANG, 0, NULL, NULL, &mod));
+ assert_int_equal(LY_SUCCESS, lys_create_module(ctx, in0, LYS_IN_YANG, 0, NULL, NULL, NULL, &mod));
assert_ptr_equal(mod, ly_ctx_get_module(ctx, "a", NULL));
assert_ptr_not_equal(mod, ly_ctx_get_module_latest(ctx, "a"));
str1 = "submodule b {belongs-to a {prefix a;}}";
ly_in_free(in1, 0);
assert_int_equal(LY_SUCCESS, ly_in_new_memory(str1, &in1));
- assert_int_equal(LY_EINVAL, lys_create_module(ctx, in1, LYS_IN_YANG, 1, NULL, NULL, &mod));
+ assert_int_equal(LY_EINVAL, lys_create_module(ctx, in1, LYS_IN_YANG, 1, NULL, NULL, NULL, &mod));
logbuf_assert("Input data contains submodule which cannot be parsed directly without its main module.");
while ((mod = (struct lys_module *)ly_ctx_get_module_iter(ctx, &index))) {
diff --git a/tests/utests/test_yanglib.c b/tests/utests/test_yanglib.c
index 8f72540..ae810a5 100644
--- a/tests/utests/test_yanglib.c
+++ b/tests/utests/test_yanglib.c
@@ -21,6 +21,7 @@
#include <cmocka.h>
#include "context.h"
+#include "in.h"
#include "log.h"
#include "set.h"
#include "tests/config.h"
@@ -137,6 +138,8 @@
"}"
"}";
const struct lys_module *mod;
+ const char *feats[] = {"feat1", NULL};
+ struct ly_in *in;
#if ENABLE_LOGGER_CHECKING
ly_set_log_clb(logger, 1);
@@ -145,8 +148,9 @@
assert_int_equal(LY_SUCCESS, ly_ctx_new(TESTS_DIR_MODULES_YANG, 0, &ctx));
ly_ctx_set_module_imp_clb(ctx, test_imp_clb, NULL);
- assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_a, LYS_IN_YANG, &mod));
- assert_int_equal(LY_SUCCESS, lys_feature_enable(mod, "feat1"));
+ assert_int_equal(LY_SUCCESS, ly_in_new_memory(schema_a, &in));
+ assert_int_equal(LY_SUCCESS, lys_parse(ctx, in, LYS_IN_YANG, feats, &mod));
+ ly_in_free(in, 0);
assert_int_equal(LY_SUCCESS, lys_parse_mem(ctx, schema_b, LYS_IN_YANG, NULL));
return 0;