tests ADD test case with augments from multiple modules
this test is supposed to cause fatal hash collision
diff --git a/tests/data/files/augment-target.yang b/tests/data/files/augment-target.yang
new file mode 100644
index 0000000..e32cddf
--- /dev/null
+++ b/tests/data/files/augment-target.yang
@@ -0,0 +1,11 @@
+module augment-target {
+ yang-version 1.1;
+ namespace "urn:augment";
+ prefix aug;
+
+ container cont {
+ leaf cont-leaf {
+ type string;
+ }
+ }
+}
diff --git a/tests/data/files/augment.xml b/tests/data/files/augment.xml
new file mode 100644
index 0000000..1a1927c
--- /dev/null
+++ b/tests/data/files/augment.xml
@@ -0,0 +1,6 @@
+<cont xmlns="urn:augment">
+ <cont-leaf>string</cont-leaf>
+ <augmented-leaf xmlns="urn:test-augment0">str</augmented-leaf>
+ <another-augmented-leaf xmlns="urn:test-augment1">stri</another-augmented-leaf>
+ <a21 xmlns="urn:test-augment1">string</a21>
+</cont>
diff --git a/tests/data/files/augment0.yang b/tests/data/files/augment0.yang
new file mode 100644
index 0000000..9fcbde6
--- /dev/null
+++ b/tests/data/files/augment0.yang
@@ -0,0 +1,15 @@
+module augment0 {
+ yang-version 1.1;
+ namespace "urn:test-augment0";
+ prefix au0;
+
+ import augment-target {
+ prefix aug;
+ }
+
+ augment "/aug:cont" {
+ leaf augmented-leaf {
+ type string;
+ }
+ }
+}
diff --git a/tests/data/files/augment1.yang b/tests/data/files/augment1.yang
new file mode 100644
index 0000000..26e81b2
--- /dev/null
+++ b/tests/data/files/augment1.yang
@@ -0,0 +1,19 @@
+module augment1 {
+ yang-version 1.1;
+ namespace "urn:test-augment1";
+ prefix au1;
+
+ import augment-target {
+ prefix aug;
+ }
+
+ augment "/aug:cont" {
+ leaf another-augmented-leaf {
+ type string;
+ }
+
+ leaf a21 {
+ type string;
+ }
+ }
+}
diff --git a/tests/data/test_lyb.c b/tests/data/test_lyb.c
index 503a3c9..290ed4c 100644
--- a/tests/data/test_lyb.c
+++ b/tests/data/test_lyb.c
@@ -613,6 +613,29 @@
check_data_tree(st->dt1, st->dt2);
}
+static void
+test_coliding_augments(void **state)
+{
+ struct state *st = (*state);
+ int ret;
+
+ ly_ctx_set_searchdir(st->ctx, TESTS_DIR"/data/files");
+ assert_non_null(ly_ctx_load_module(st->ctx, "augment-target", NULL));
+ assert_non_null(ly_ctx_load_module(st->ctx, "augment0", NULL));
+ assert_non_null(ly_ctx_load_module(st->ctx, "augment1", NULL));
+
+ st->dt1 = lyd_parse_path(st->ctx, TESTS_DIR"/data/files/augment.xml", LYD_XML, LYD_OPT_CONFIG);
+ assert_ptr_not_equal(st->dt1, NULL);
+
+ ret = lyd_print_mem(&st->mem, st->dt1, LYD_LYB, LYP_WITHSIBLINGS);
+ assert_int_equal(ret, 0);
+
+ st->dt2 = lyd_parse_mem(st->ctx, st->mem, LYD_LYB, LYD_OPT_CONFIG | LYD_OPT_STRICT);
+ assert_ptr_not_equal(st->dt2, NULL);
+
+ check_data_tree(st->dt1, st->dt2);
+}
+
int
main(void)
{
@@ -629,6 +652,7 @@
cmocka_unit_test_setup_teardown(test_collisions, setup_f, teardown_f),
cmocka_unit_test_setup_teardown(test_anydata, setup_f, teardown_f),
cmocka_unit_test_setup_teardown(test_submodule_feature, setup_f, teardown_f),
+ cmocka_unit_test_setup_teardown(test_coliding_augments, setup_f, teardown_f),
};
return cmocka_run_group_tests(tests, NULL, NULL);