Skip to content

Commit ddac622

Browse files
committed
test CHANGE augment leafref if-feature test also for yin
1 parent c47eebb commit ddac622

File tree

5 files changed

+137
-12
lines changed

5 files changed

+137
-12
lines changed

tests/schema/test_augment.c

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ char *yin_modules[2 * MOD_COUNT] = {0};
4343
static int
4444
setup_ctx_yin(void **state)
4545
{
46-
*state = malloc(strlen(TESTS_DIR) + 40);
46+
*state = malloc(strlen(TESTS_DIR) + 64);
4747
assert_non_null(*state);
4848
memcpy(*state, SCHEMA_FOLDER_YIN, strlen(SCHEMA_FOLDER_YIN) + 1);
4949

@@ -58,7 +58,7 @@ setup_ctx_yin(void **state)
5858
static int
5959
setup_ctx_yang(void **state)
6060
{
61-
*state = malloc(strlen(TESTS_DIR) + 40);
61+
*state = malloc(strlen(TESTS_DIR) + 64);
6262
assert_non_null(*state);
6363
memcpy(*state, SCHEMA_FOLDER_YANG, strlen(SCHEMA_FOLDER_YANG) + 1);
6464

@@ -154,11 +154,17 @@ test_leafref_w_feature1(void **state)
154154

155155
ly_ctx_set_searchdir(ctx, path);
156156
length = strlen(path);
157-
strcpy(path + length, "/leafref_w_feature1-mod3.yang");
158-
if (!(module = lys_parse_path(ctx, path, LYS_IN_YANG))) {
159-
fail();
157+
if (!strcmp(path, SCHEMA_FOLDER_YIN)) {
158+
strcpy(path + length, "/leafref_w_feature1-mod3.yin");
159+
if (!(module = lys_parse_path(ctx, path, LYS_IN_YIN))) {
160+
fail();
161+
}
162+
} else {
163+
strcpy(path + length, "/leafref_w_feature1-mod3.yang");
164+
if (!(module = lys_parse_path(ctx, path, LYS_IN_YANG))) {
165+
fail();
166+
}
160167
}
161-
lys_print_mem(&yang_modules[YANG_MOD_IDX(0)], module, LYS_OUT_YANG, NULL);
162168
}
163169

164170
static void
@@ -170,11 +176,17 @@ test_leafref_w_feature2(void **state)
170176

171177
ly_ctx_set_searchdir(ctx, path);
172178
length = strlen(path);
173-
strcpy(path + length, "/leafref_w_feature2-mod1.yang");
174-
if (!(module = lys_parse_path(ctx, path, LYS_IN_YANG))) {
175-
fail();
179+
if (!strcmp(path, SCHEMA_FOLDER_YIN)) {
180+
strcpy(path + length, "/leafref_w_feature2-mod1.yin");
181+
if (!(module = lys_parse_path(ctx, path, LYS_IN_YIN))) {
182+
fail();
183+
}
184+
} else {
185+
strcpy(path + length, "/leafref_w_feature2-mod1.yang");
186+
if (!(module = lys_parse_path(ctx, path, LYS_IN_YANG))) {
187+
fail();
188+
}
176189
}
177-
lys_print_mem(&yang_modules[YANG_MOD_IDX(0)], module, LYS_OUT_YANG, NULL);
178190
}
179191

180192
static void
@@ -323,15 +335,17 @@ main(void)
323335
cmocka_unit_test_setup_teardown(test_target_include_submodule, setup_ctx_yin, teardown_ctx),
324336
cmocka_unit_test_setup_teardown(test_leafref, setup_ctx_yin, teardown_ctx),
325337
cmocka_unit_test_setup_teardown(test_target_augment, setup_ctx_yin, teardown_ctx),
326-
cmocka_unit_test_setup_teardown(test_leafref_w_feature1, setup_ctx_yang, teardown_ctx),
327-
cmocka_unit_test_setup_teardown(test_leafref_w_feature2, setup_ctx_yang, teardown_ctx),
328338
cmocka_unit_test_setup_teardown(test_unres_augment, setup_ctx_yin, teardown_ctx),
329339
cmocka_unit_test_setup_teardown(test_import_augment_target, setup_ctx_yin, teardown_ctx),
340+
cmocka_unit_test_setup_teardown(test_leafref_w_feature1, setup_ctx_yin, teardown_ctx),
341+
cmocka_unit_test_setup_teardown(test_leafref_w_feature2, setup_ctx_yin, teardown_ctx),
330342
cmocka_unit_test_setup_teardown(test_target_include_submodule, setup_ctx_yang, teardown_ctx),
331343
cmocka_unit_test_setup_teardown(test_leafref, setup_ctx_yang, teardown_ctx),
332344
cmocka_unit_test_setup_teardown(test_target_augment, setup_ctx_yang, teardown_ctx),
333345
cmocka_unit_test_setup_teardown(test_unres_augment, setup_ctx_yang, teardown_ctx),
334346
cmocka_unit_test_setup_teardown(test_import_augment_target, setup_ctx_yang, teardown_ctx),
347+
cmocka_unit_test_setup_teardown(test_leafref_w_feature1, setup_ctx_yang, teardown_ctx),
348+
cmocka_unit_test_setup_teardown(test_leafref_w_feature2, setup_ctx_yang, teardown_ctx),
335349
cmocka_unit_test_teardown(compare_output, teardown_output),
336350
};
337351

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module name="leafref_w_feature1-mod1"
3+
xmlns="urn:ietf:params:xml:ns:yang:yin:1"
4+
xmlns:lr-w-ftr1-m1="urn:fri:params:xml:ns:yang:leafref_w_feature1-mod1">
5+
<namespace uri="urn:fri:params:xml:ns:yang:leafref_w_feature1-mod1"/>
6+
<prefix value="lr-w-ftr1-m1"/>
7+
<feature name="feature1"/>
8+
<container name="cont1">
9+
<if-feature name="feature1"/>
10+
</container>
11+
</module>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module name="leafref_w_feature1-mod2"
3+
xmlns="urn:ietf:params:xml:ns:yang:yin:1"
4+
xmlns:lr-w-ftr1-m2="urn:fri:params:xml:ns:yang:leafref_w_feature1-mod2"
5+
xmlns:lr-w-ftr1-m1="urn:fri:params:xml:ns:yang:leafref_w_feature1-mod1">
6+
<namespace uri="urn:fri:params:xml:ns:yang:leafref_w_feature1-mod2"/>
7+
<prefix value="lr-w-ftr1-m2"/>
8+
<import module="leafref_w_feature1-mod1">
9+
<prefix value="lr-w-ftr1-m1"/>
10+
</import>
11+
<typedef name="list2-ref">
12+
<type name="leafref">
13+
<path value="/lr-w-ftr1-m1:cont1/lr-w-ftr1-m2:cont2/lr-w-ftr1-m2:list2/lr-w-ftr1-m2:name"/>
14+
</type>
15+
</typedef>
16+
<augment target-node="/lr-w-ftr1-m1:cont1">
17+
<description>
18+
<text>mod2's cont1 augment</text>
19+
</description>
20+
<container name="cont2">
21+
<list name="list2">
22+
<key value="name"/>
23+
<leaf name="name">
24+
<type name="string"/>
25+
</leaf>
26+
</list>
27+
</container>
28+
</augment>
29+
</module>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module name="leafref_w_feature1-mod3"
3+
xmlns="urn:ietf:params:xml:ns:yang:yin:1"
4+
xmlns:lr-w-ftr1-m3="urn:fri:params:xml:ns:yang:leafref_w_feature1-mod3"
5+
xmlns:lr-w-ftr1-m1="urn:fri:params:xml:ns:yang:leafref_w_feature1-mod1"
6+
xmlns:lr-w-ftr1-m2="urn:fri:params:xml:ns:yang:leafref_w_feature1-mod2">
7+
<namespace uri="urn:fri:params:xml:ns:yang:leafref_w_feature1-mod3"/>
8+
<prefix value="lr-w-ftr1-m3"/>
9+
<import module="leafref_w_feature1-mod1">
10+
<prefix value="lr-w-ftr1-m1"/>
11+
</import>
12+
<import module="leafref_w_feature1-mod2">
13+
<prefix value="lr-w-ftr1-m2"/>
14+
</import>
15+
<augment target-node="/lr-w-ftr1-m1:cont1">
16+
<description>
17+
<text>mod3's cont1 augment</text>
18+
</description>
19+
<container name="cont3">
20+
<list name="list3">
21+
<key value="name"/>
22+
<leaf name="name">
23+
<type name="string"/>
24+
</leaf>
25+
<choice name="choice3">
26+
<case name="case3">
27+
<leaf-list name="llist3">
28+
<type name="lr-w-ftr1-m2:list2-ref"/>
29+
</leaf-list>
30+
</case>
31+
</choice>
32+
</list>
33+
</container>
34+
</augment>
35+
</module>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module name="leafref_w_feature2-mod1"
3+
xmlns="urn:ietf:params:xml:ns:yang:yin:1"
4+
xmlns:lr-w-ftr2-m1="urn:fri:params:xml:ns:yang:leafref_w_feature2-mod1">
5+
<namespace uri="urn:fri:params:xml:ns:yang:leafref_w_feature2-mod1"/>
6+
<prefix value="lr-w-ftr2-m1"/>
7+
<feature name="feature2"/>
8+
<container name="cont1">
9+
<if-feature name="feature2"/>
10+
</container>
11+
<augment target-node="/cont1">
12+
<container name="cont11">
13+
<list name="list11">
14+
<key value="name"/>
15+
<leaf name="name">
16+
<type name="string"/>
17+
</leaf>
18+
</list>
19+
</container>
20+
</augment>
21+
<augment target-node="/cont1">
22+
<container name="cont12">
23+
<list name="list12">
24+
<key value="name"/>
25+
<leaf name="name">
26+
<type name="string"/>
27+
</leaf>
28+
<leaf-list name="llist12">
29+
<type name="leafref">
30+
<path value="/cont1/cont11/list11/name"/>
31+
</type>
32+
</leaf-list>
33+
</list>
34+
</container>
35+
</augment>
36+
</module>

0 commit comments

Comments
 (0)