blob: 376c705eaa0f9da6df2f5b0b966dd6b07dfdce49 [file] [log] [blame]
Michal Vasko294d4c62016-02-01 10:10:27 +01001/**
Michal Vasko7227f352016-02-01 12:11:40 +01002 * \file test_fd_comm.c
Michal Vasko294d4c62016-02-01 10:10:27 +01003 * \author Michal Vasko <mvasko@cesnet.cz>
Michal Vasko7227f352016-02-01 12:11:40 +01004 * \brief libnetconf2 tests - file descriptor basic RPC communication
Michal Vasko294d4c62016-02-01 10:10:27 +01005 *
6 * Copyright (c) 2015 CESNET, z.s.p.o.
7 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +01008 * This source code is licensed under BSD 3-Clause License (the "License").
9 * You may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
Michal Vaskoad1cc6a2016-02-26 15:06:06 +010011 *
Radek Krejci9b81f5b2016-02-24 13:14:49 +010012 * https://opensource.org/licenses/BSD-3-Clause
Michal Vasko294d4c62016-02-01 10:10:27 +010013 */
14
15#include <errno.h>
16#include <fcntl.h>
17#include <pthread.h>
18#include <setjmp.h>
19#include <stdarg.h>
20#include <stddef.h>
21#include <stdint.h>
22#include <stdlib.h>
23#include <unistd.h>
24#include <string.h>
25#include <sys/stat.h>
26#include <sys/types.h>
27#include <sys/socket.h>
28
29#include <cmocka.h>
30#include <libyang/libyang.h>
31
32#include <session_client.h>
33#include <session_server.h>
34#include <session_p.h>
35#include <messages_p.h>
Jan Kundrátcf15d6c2017-10-26 18:07:56 +020036#include "tests/config.h"
Michal Vasko294d4c62016-02-01 10:10:27 +010037
38struct nc_session *server_session;
39struct nc_session *client_session;
Michal Vasko8c5518b2016-03-01 12:35:13 +010040struct ly_ctx *ctx;
Michal Vaskobbaa9b22019-03-14 12:35:43 +010041pthread_mutex_t state_lock = PTHREAD_MUTEX_INITIALIZER;
42int glob_state;
Michal Vasko294d4c62016-02-01 10:10:27 +010043
44struct nc_server_reply *
45my_get_rpc_clb(struct lyd_node *rpc, struct nc_session *session)
46{
47 assert_string_equal(rpc->schema->name, "get");
48 assert_ptr_equal(session, server_session);
49
50 return nc_server_reply_ok();
51}
52
53struct nc_server_reply *
54my_getconfig_rpc_clb(struct lyd_node *rpc, struct nc_session *session)
55{
56 struct lyd_node *data;
Michal Vasko294d4c62016-02-01 10:10:27 +010057
58 assert_string_equal(rpc->schema->name, "get-config");
59 assert_ptr_equal(session, server_session);
60
Radek Krejci539efb62016-08-24 15:05:16 +020061 data = lyd_new_path(NULL, session->ctx, "/ietf-netconf:get-config/data", NULL, LYD_ANYDATA_CONSTSTRING,
62 LYD_PATH_OPT_OUTPUT);
Michal Vasko294d4c62016-02-01 10:10:27 +010063 assert_non_null(data);
64
Radek Krejci36dfdb32016-09-01 16:56:35 +020065 return nc_server_reply_data(data, NC_WD_EXPLICIT, NC_PARAMTYPE_FREE);
Michal Vasko294d4c62016-02-01 10:10:27 +010066}
67
Michal Vasko131120a2018-05-29 15:44:02 +020068struct nc_server_reply *
69my_commit_rpc_clb(struct lyd_node *rpc, struct nc_session *session)
70{
71 assert_string_equal(rpc->schema->name, "commit");
72 assert_ptr_equal(session, server_session);
73
74 /* update state */
Michal Vaskobbaa9b22019-03-14 12:35:43 +010075 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +020076 glob_state = 1;
77
78 /* wait until the client receives the notification */
79 while (glob_state != 3) {
Michal Vaskobbaa9b22019-03-14 12:35:43 +010080 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +020081 usleep(100000);
Michal Vaskobbaa9b22019-03-14 12:35:43 +010082 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +020083 }
Michal Vaskobbaa9b22019-03-14 12:35:43 +010084 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +020085
86 return nc_server_reply_ok();
87}
88
89static struct nc_session *
90test_new_session(NC_SIDE side)
91{
92 struct nc_session *sess;
93
94 sess = calloc(1, sizeof *sess);
95 if (!sess) {
96 return NULL;
97 }
98
99 sess->side = side;
100
101 if (side == NC_SERVER) {
Michal Vaskoacf98472021-02-04 15:33:57 +0100102 pthread_mutex_init(&sess->opts.server.rpc_lock, NULL);
103 pthread_cond_init(&sess->opts.server.rpc_cond, NULL);
104 sess->opts.server.rpc_inuse = 0;
Michal Vasko131120a2018-05-29 15:44:02 +0200105 }
106
107 sess->io_lock = malloc(sizeof *sess->io_lock);
108 if (!sess->io_lock) {
109 goto error;
110 }
111 pthread_mutex_init(sess->io_lock, NULL);
112
113 return sess;
114
115error:
Michal Vasko131120a2018-05-29 15:44:02 +0200116 free(sess);
117 return NULL;
118}
119
Michal Vasko294d4c62016-02-01 10:10:27 +0100120static int
121setup_sessions(void **state)
122{
123 (void)state;
Michal Vasko294d4c62016-02-01 10:10:27 +0100124 int sock[2];
125
Michal Vasko294d4c62016-02-01 10:10:27 +0100126 /* create communication channel */
127 socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
128
Michal Vasko294d4c62016-02-01 10:10:27 +0100129 /* create server session */
Michal Vasko131120a2018-05-29 15:44:02 +0200130 server_session = test_new_session(NC_SERVER);
Michal Vasko294d4c62016-02-01 10:10:27 +0100131 server_session->status = NC_STATUS_RUNNING;
Michal Vasko294d4c62016-02-01 10:10:27 +0100132 server_session->id = 1;
Michal Vasko294d4c62016-02-01 10:10:27 +0100133 server_session->ti_type = NC_TI_FD;
Michal Vasko294d4c62016-02-01 10:10:27 +0100134 server_session->ti.fd.in = sock[0];
135 server_session->ti.fd.out = sock[0];
136 server_session->ctx = ctx;
137 server_session->flags = NC_SESSION_SHAREDCTX;
138
139 /* create client session */
Michal Vasko131120a2018-05-29 15:44:02 +0200140 client_session = test_new_session(NC_CLIENT);
Michal Vasko294d4c62016-02-01 10:10:27 +0100141 client_session->status = NC_STATUS_RUNNING;
Michal Vasko294d4c62016-02-01 10:10:27 +0100142 client_session->id = 1;
Michal Vasko294d4c62016-02-01 10:10:27 +0100143 client_session->ti_type = NC_TI_FD;
Michal Vasko294d4c62016-02-01 10:10:27 +0100144 client_session->ti.fd.in = sock[1];
145 client_session->ti.fd.out = sock[1];
146 client_session->ctx = ctx;
147 client_session->flags = NC_SESSION_SHAREDCTX;
Michal Vasko338f8472016-10-13 15:01:27 +0200148 client_session->opts.client.msgid = 50;
Michal Vasko294d4c62016-02-01 10:10:27 +0100149
150 return 0;
151}
152
153static int
154teardown_sessions(void **state)
155{
156 (void)state;
157
Michal Vasko294d4c62016-02-01 10:10:27 +0100158 close(server_session->ti.fd.in);
Michal Vasko131120a2018-05-29 15:44:02 +0200159 nc_session_free(server_session, NULL);
Michal Vasko294d4c62016-02-01 10:10:27 +0100160
161 close(client_session->ti.fd.in);
Michal Vasko131120a2018-05-29 15:44:02 +0200162 nc_session_free(client_session, NULL);
Michal Vasko294d4c62016-02-01 10:10:27 +0100163
164 return 0;
165}
166
167static void
Michal Vasko58d152f2016-02-01 11:44:49 +0100168test_send_recv_ok(void)
Michal Vasko294d4c62016-02-01 10:10:27 +0100169{
Michal Vasko294d4c62016-02-01 10:10:27 +0100170 int ret;
171 uint64_t msgid;
172 NC_MSG_TYPE msgtype;
173 struct nc_rpc *rpc;
174 struct nc_reply *reply;
175 struct nc_pollsession *ps;
176
177 /* client RPC */
178 rpc = nc_rpc_get(NULL, 0, 0);
179 assert_non_null(rpc);
180
181 msgtype = nc_send_rpc(client_session, rpc, 0, &msgid);
182 assert_int_equal(msgtype, NC_MSG_RPC);
183
184 /* server RPC, send reply */
185 ps = nc_ps_new();
186 assert_non_null(ps);
187 nc_ps_add_session(ps, server_session);
188
Michal Vasko71090fc2016-05-24 16:37:28 +0200189 ret = nc_ps_poll(ps, 0, NULL);
190 assert_int_equal(ret, NC_PSPOLL_RPC);
Michal Vasko294d4c62016-02-01 10:10:27 +0100191
192 /* server finished */
193 nc_ps_free(ps);
194
195 /* client reply */
Michal Vaskoeb7080e2016-02-18 13:27:05 +0100196 msgtype = nc_recv_reply(client_session, rpc, msgid, 0, 0, &reply);
Michal Vasko294d4c62016-02-01 10:10:27 +0100197 assert_int_equal(msgtype, NC_MSG_REPLY);
198
199 nc_rpc_free(rpc);
200 assert_int_equal(reply->type, NC_RPL_OK);
201 nc_reply_free(reply);
202}
203
204static void
Michal Vasko58d152f2016-02-01 11:44:49 +0100205test_send_recv_ok_10(void **state)
Michal Vasko294d4c62016-02-01 10:10:27 +0100206{
207 (void)state;
Michal Vasko58d152f2016-02-01 11:44:49 +0100208
209 server_session->version = NC_VERSION_10;
210 client_session->version = NC_VERSION_10;
211
212 test_send_recv_ok();
213}
214
215static void
216test_send_recv_ok_11(void **state)
217{
218 (void)state;
219
220 server_session->version = NC_VERSION_11;
221 client_session->version = NC_VERSION_11;
222
223 test_send_recv_ok();
224}
225
226static void
227test_send_recv_error(void)
228{
Michal Vasko294d4c62016-02-01 10:10:27 +0100229 int ret;
230 uint64_t msgid;
231 NC_MSG_TYPE msgtype;
232 struct nc_rpc *rpc;
233 struct nc_reply *reply;
234 struct nc_pollsession *ps;
235
236 /* client RPC */
237 rpc = nc_rpc_kill(1);
238 assert_non_null(rpc);
239
240 msgtype = nc_send_rpc(client_session, rpc, 0, &msgid);
241 assert_int_equal(msgtype, NC_MSG_RPC);
242
243 /* server RPC, send reply */
244 ps = nc_ps_new();
245 assert_non_null(ps);
246 nc_ps_add_session(ps, server_session);
247
Michal Vasko71090fc2016-05-24 16:37:28 +0200248 ret = nc_ps_poll(ps, 0, NULL);
249 assert_int_equal(ret, NC_PSPOLL_RPC | NC_PSPOLL_REPLY_ERROR);
Michal Vasko294d4c62016-02-01 10:10:27 +0100250
251 /* server finished */
252 nc_ps_free(ps);
253
254 /* client reply */
Michal Vaskoeb7080e2016-02-18 13:27:05 +0100255 msgtype = nc_recv_reply(client_session, rpc, msgid, 0, 0, &reply);
Michal Vasko294d4c62016-02-01 10:10:27 +0100256 assert_int_equal(msgtype, NC_MSG_REPLY);
257
258 nc_rpc_free(rpc);
259 assert_int_equal(reply->type, NC_RPL_ERROR);
260 assert_string_equal(((struct nc_reply_error *)reply)->err->tag, "operation-not-supported");
261 nc_reply_free(reply);
262}
263
264static void
Michal Vasko58d152f2016-02-01 11:44:49 +0100265test_send_recv_error_10(void **state)
Michal Vasko294d4c62016-02-01 10:10:27 +0100266{
267 (void)state;
Michal Vasko58d152f2016-02-01 11:44:49 +0100268
269 server_session->version = NC_VERSION_10;
270 client_session->version = NC_VERSION_10;
271
272 test_send_recv_error();
273}
274
275static void
276test_send_recv_error_11(void **state)
277{
278 (void)state;
279
280 server_session->version = NC_VERSION_11;
281 client_session->version = NC_VERSION_11;
282
283 test_send_recv_error();
284}
285
286static void
287test_send_recv_data(void)
288{
Michal Vasko294d4c62016-02-01 10:10:27 +0100289 int ret;
290 uint64_t msgid;
291 NC_MSG_TYPE msgtype;
292 struct nc_rpc *rpc;
293 struct nc_reply *reply;
294 struct nc_pollsession *ps;
295
296 /* client RPC */
297 rpc = nc_rpc_getconfig(NC_DATASTORE_RUNNING, NULL, 0, 0);
298 assert_non_null(rpc);
299
300 msgtype = nc_send_rpc(client_session, rpc, 0, &msgid);
301 assert_int_equal(msgtype, NC_MSG_RPC);
302
303 /* server RPC, send reply */
304 ps = nc_ps_new();
305 assert_non_null(ps);
306 nc_ps_add_session(ps, server_session);
307
Michal Vasko71090fc2016-05-24 16:37:28 +0200308 ret = nc_ps_poll(ps, 0, NULL);
309 assert_int_equal(ret, NC_PSPOLL_RPC);
Michal Vasko294d4c62016-02-01 10:10:27 +0100310
311 /* server finished */
312 nc_ps_free(ps);
313
314 /* client reply */
Radek Krejci8c8e1242016-09-07 16:43:54 +0200315 msgtype = nc_recv_reply(client_session, rpc, msgid, 0, 0, &reply);
Michal Vasko294d4c62016-02-01 10:10:27 +0100316 assert_int_equal(msgtype, NC_MSG_REPLY);
317
318 nc_rpc_free(rpc);
319 assert_int_equal(reply->type, NC_RPL_DATA);
320 nc_reply_free(reply);
321}
322
Michal Vasko58d152f2016-02-01 11:44:49 +0100323static void
324test_send_recv_data_10(void **state)
325{
326 (void)state;
327
328 server_session->version = NC_VERSION_10;
329 client_session->version = NC_VERSION_10;
330
331 test_send_recv_data();
332}
333
334static void
335test_send_recv_data_11(void **state)
336{
337 (void)state;
338
339 server_session->version = NC_VERSION_11;
340 client_session->version = NC_VERSION_11;
341
342 test_send_recv_data();
343}
344
Michal Vasko131120a2018-05-29 15:44:02 +0200345static void
346test_notif_clb(struct nc_session *session, const struct nc_notif *notif)
347{
348 assert_ptr_equal(session, client_session);
349 assert_string_equal(notif->tree->schema->name, "notificationComplete");
350
351 /* client notification received, update state */
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100352 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200353 while (glob_state != 2) {
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100354 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200355 usleep(1000);
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100356 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200357 }
358 glob_state = 3;
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100359 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200360}
361
362static void *
363server_send_notif_thread(void *arg)
364{
365 NC_MSG_TYPE msg_type;
366 struct lyd_node *notif_tree;
367 struct nc_server_notif *notif;
368 char *buf;
369 (void)arg;
370
371 /* wait for the RPC callback to be called */
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100372 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200373 while (glob_state != 1) {
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100374 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200375 usleep(1000);
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100376 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200377 }
378
379 /* create notif */
380 notif_tree = lyd_new_path(NULL, ctx, "/nc-notifications:notificationComplete", NULL, 0, 0);
381 assert_non_null(notif_tree);
382 buf = malloc(64);
383 assert_non_null(buf);
384 notif = nc_server_notif_new(notif_tree, nc_time2datetime(time(NULL), NULL, buf), NC_PARAMTYPE_FREE);
385 assert_non_null(notif);
386
387 /* send notif */
388 nc_session_set_notif_status(server_session, 1);
389 msg_type = nc_server_notif_send(server_session, notif, 100);
390 nc_server_notif_free(notif);
391 assert_int_equal(msg_type, NC_MSG_NOTIF);
392
393 /* update state */
394 glob_state = 2;
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100395 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200396
397 return NULL;
398}
399
Michal Vasko294d4c62016-02-01 10:10:27 +0100400static void
Michal Vasko58d152f2016-02-01 11:44:49 +0100401test_send_recv_notif(void)
Michal Vasko294d4c62016-02-01 10:10:27 +0100402{
Michal Vasko131120a2018-05-29 15:44:02 +0200403 int ret;
404 pthread_t tid;
405 uint64_t msgid;
406 NC_MSG_TYPE msgtype;
407 struct nc_rpc *rpc;
408 struct nc_reply *reply;
409 struct nc_pollsession *ps;
Michal Vasko294d4c62016-02-01 10:10:27 +0100410
Michal Vasko131120a2018-05-29 15:44:02 +0200411 /* client RPC */
412 rpc = nc_rpc_commit(0, 0, NULL, NULL, 0);
413 assert_non_null(rpc);
414
415 msgtype = nc_send_rpc(client_session, rpc, 0, &msgid);
416 assert_int_equal(msgtype, NC_MSG_RPC);
417
418 /* client subscription */
419 ret = nc_recv_notif_dispatch(client_session, test_notif_clb);
420 assert_int_equal(ret, 0);
421
422 /* create server */
423 ps = nc_ps_new();
424 assert_non_null(ps);
425 nc_ps_add_session(ps, server_session);
426
427 /* server will send a notification */
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100428 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200429 glob_state = 0;
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100430 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200431 ret = pthread_create(&tid, NULL, server_send_notif_thread, NULL);
432 assert_int_equal(ret, 0);
433
434 /* server blocked on RPC */
435 ret = nc_ps_poll(ps, 0, NULL);
436 assert_int_equal(ret, NC_PSPOLL_RPC);
437
438 /* RPC, notification finished fine */
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100439 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200440 assert_int_equal(glob_state, 3);
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100441 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200442
443 /* server finished */
444 ret = pthread_join(tid, NULL);
445 assert_int_equal(ret, 0);
446 nc_ps_free(ps);
447
448 /* client reply */
449 msgtype = nc_recv_reply(client_session, rpc, msgid, 0, 0, &reply);
450 assert_int_equal(msgtype, NC_MSG_REPLY);
451
452 nc_rpc_free(rpc);
453 assert_int_equal(reply->type, NC_RPL_OK);
454 nc_reply_free(reply);
455}
456
457static void
458test_send_recv_notif_10(void **state)
459{
460 (void)state;
461
462 server_session->version = NC_VERSION_10;
463 client_session->version = NC_VERSION_10;
464
465 test_send_recv_notif();
466}
467
468static void
469test_send_recv_notif_11(void **state)
470{
471 (void)state;
472
473 server_session->version = NC_VERSION_11;
474 client_session->version = NC_VERSION_11;
475
476 test_send_recv_notif();
477}
Michal Vasko294d4c62016-02-01 10:10:27 +0100478
479int
480main(void)
481{
Michal Vasko8c5518b2016-03-01 12:35:13 +0100482 int ret;
483 const struct lys_module *module;
Michal Vasko88639e92017-08-03 14:38:10 +0200484 const struct lys_node *node;
Michal Vasko8c5518b2016-03-01 12:35:13 +0100485
486 /* create ctx */
Michal Vasko5a446472020-05-06 12:43:42 +0200487 ctx = ly_ctx_new(TESTS_DIR"/data/modules", 0);
Michal Vasko8c5518b2016-03-01 12:35:13 +0100488 assert_non_null(ctx);
489
490 /* load modules */
491 module = ly_ctx_load_module(ctx, "ietf-netconf-acm", NULL);
492 assert_non_null(module);
493
494 module = ly_ctx_load_module(ctx, "ietf-netconf", NULL);
495 assert_non_null(module);
Michal Vasko131120a2018-05-29 15:44:02 +0200496 ret = lys_features_enable(module, "candidate");
497 assert_int_equal(ret, 0);
498
499 module = ly_ctx_load_module(ctx, "nc-notifications", NULL);
500 assert_non_null(module);
Michal Vasko8c5518b2016-03-01 12:35:13 +0100501
502 /* set RPC callbacks */
Michal Vasko88639e92017-08-03 14:38:10 +0200503 node = ly_ctx_get_node(module->ctx, NULL, "/ietf-netconf:get", 0);
504 assert_non_null(node);
505 lys_set_private(node, my_get_rpc_clb);
506
507 node = ly_ctx_get_node(module->ctx, NULL, "/ietf-netconf:get-config", 0);
508 assert_non_null(node);
509 lys_set_private(node, my_getconfig_rpc_clb);
Michal Vasko8c5518b2016-03-01 12:35:13 +0100510
Michal Vasko131120a2018-05-29 15:44:02 +0200511 node = ly_ctx_get_node(module->ctx, NULL, "/ietf-netconf:commit", 0);
512 assert_non_null(node);
513 lys_set_private(node, my_commit_rpc_clb);
514
Michal Vasko8c5518b2016-03-01 12:35:13 +0100515 nc_server_init(ctx);
516
Michal Vasko294d4c62016-02-01 10:10:27 +0100517 const struct CMUnitTest comm[] = {
Michal Vasko58d152f2016-02-01 11:44:49 +0100518 cmocka_unit_test_setup_teardown(test_send_recv_ok_10, setup_sessions, teardown_sessions),
519 cmocka_unit_test_setup_teardown(test_send_recv_error_10, setup_sessions, teardown_sessions),
520 cmocka_unit_test_setup_teardown(test_send_recv_data_10, setup_sessions, teardown_sessions),
Michal Vasko131120a2018-05-29 15:44:02 +0200521 cmocka_unit_test_setup_teardown(test_send_recv_notif_10, setup_sessions, teardown_sessions),
Michal Vasko58d152f2016-02-01 11:44:49 +0100522 cmocka_unit_test_setup_teardown(test_send_recv_ok_11, setup_sessions, teardown_sessions),
523 cmocka_unit_test_setup_teardown(test_send_recv_error_11, setup_sessions, teardown_sessions),
Michal Vasko131120a2018-05-29 15:44:02 +0200524 cmocka_unit_test_setup_teardown(test_send_recv_data_11, setup_sessions, teardown_sessions),
525 cmocka_unit_test_setup_teardown(test_send_recv_notif_11, setup_sessions, teardown_sessions),
Michal Vasko294d4c62016-02-01 10:10:27 +0100526 };
527
Michal Vasko8c5518b2016-03-01 12:35:13 +0100528 ret = cmocka_run_group_tests(comm, NULL, NULL);
529
530 nc_server_destroy();
531 ly_ctx_destroy(ctx, NULL);
532
533 return ret;
Michal Vasko294d4c62016-02-01 10:10:27 +0100534}