Skip to content

Commit 0829309

Browse files
authored
Merge pull request #140 from ADTRAN/hello_cap_w_empty_deviation_param
fix and testcase for empty deviation parameter
2 parents b4e6657 + cb9274f commit 0829309

5 files changed

Lines changed: 70 additions & 0 deletions

File tree

schemas/module-a-dv.yang

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module module-a-dv {
2+
3+
namespace "urn:jmu:params:xml:ns:yang:module-a-dv";
4+
prefix dv;
5+
6+
import module-a {
7+
prefix a;
8+
}
9+
10+
description
11+
"Contains some deviations to module-a";
12+
13+
deviation "/a:top/a:hidden" {
14+
deviate not-supported;
15+
}
16+
}

schemas/module-a-dv2.yang

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module module-a-dv2 {
2+
3+
namespace "urn:jmu:params:xml:ns:yang:module-a-dv2";
4+
prefix dv2;
5+
6+
import module-a {
7+
prefix a;
8+
}
9+
10+
description
11+
"Contains some deviations to module-a";
12+
13+
deviation "/a:top/a:type" {
14+
deviate add {
15+
default "admin";
16+
must "count(.) = 1";
17+
}
18+
}
19+
20+
}
21+

schemas/module-a.yang

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
module module-a {
2+
3+
namespace "urn:jmu:params:xml:ns:yang:module-a";
4+
prefix a;
5+
6+
description "This is a simple user module";
7+
8+
container top {
9+
10+
leaf name {
11+
type string;
12+
}
13+
14+
leaf type {
15+
type string;
16+
}
17+
18+
leaf hidden {
19+
type boolean;
20+
}
21+
22+
}
23+
}

src/session.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,7 @@ nc_server_get_cpblts_version(struct ly_ctx *ctx, LYS_VERSION version)
10521052
strcat(str, "&deviations=");
10531053
str_len += 12;
10541054
dev_count = 0;
1055+
v = 0;
10551056
while ((devmod = ly_ctx_get_module_iter(ctx, &v))) {
10561057
if (devmod == mod) {
10571058
continue;

tests/test_server_thread.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@ tls_client_thread(void *arg)
543543
session = nc_connect_tls("127.0.0.1", 6501, NULL);
544544
nc_assert(session);
545545

546+
/* verify some capabilities */
547+
nc_assert( nc_session_cpblt(session, "urn:jmu:params:xml:ns:yang:module-a?module=module-a&deviations=module-a-dv,module-a-dv2") );
548+
546549
nc_session_free(session, NULL);
547550

548551
fprintf(stdout, "TLS client finished.\n");
@@ -657,6 +660,12 @@ main(void)
657660
ctx = ly_ctx_new(TESTS_DIR"/../schemas", 0);
658661
nc_assert(ctx);
659662
ly_ctx_load_module(ctx, "ietf-netconf", NULL);
663+
664+
/* load some application models with deviations */
665+
nc_assert( ly_ctx_load_module(ctx, "module-a", NULL) );
666+
nc_assert( ly_ctx_load_module(ctx, "module-a-dv", NULL) );
667+
nc_assert( ly_ctx_load_module(ctx, "module-a-dv2", NULL) );
668+
660669
nc_server_init(ctx);
661670

662671
pthread_barrier_init(&barrier, NULL, thread_count);

0 commit comments

Comments
 (0)