blob: 59a787ba590591f70999121b5b1ddfa0f90fd66c [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) {
102 sess->opts.server.rpc_lock = malloc(sizeof *sess->opts.server.rpc_lock);
103 sess->opts.server.rpc_cond = malloc(sizeof *sess->opts.server.rpc_cond);
104 sess->opts.server.rpc_inuse = malloc(sizeof *sess->opts.server.rpc_inuse);
105 if (!sess->opts.server.rpc_lock || !sess->opts.server.rpc_cond || !sess->opts.server.rpc_inuse) {
106 goto error;
107 }
108 pthread_mutex_init(sess->opts.server.rpc_lock, NULL);
109 pthread_cond_init(sess->opts.server.rpc_cond, NULL);
110 *sess->opts.server.rpc_inuse = 0;
111 }
112
113 sess->io_lock = malloc(sizeof *sess->io_lock);
114 if (!sess->io_lock) {
115 goto error;
116 }
117 pthread_mutex_init(sess->io_lock, NULL);
118
119 return sess;
120
121error:
122 if (side == NC_SERVER) {
123 free(sess->opts.server.rpc_lock);
124 free(sess->opts.server.rpc_cond);
125 free((int *)sess->opts.server.rpc_inuse);
126 }
127 free(sess);
128 return NULL;
129}
130
Michal Vasko294d4c62016-02-01 10:10:27 +0100131static int
132setup_sessions(void **state)
133{
134 (void)state;
Michal Vasko294d4c62016-02-01 10:10:27 +0100135 int sock[2];
136
Michal Vasko294d4c62016-02-01 10:10:27 +0100137 /* create communication channel */
138 socketpair(AF_UNIX, SOCK_STREAM, 0, sock);
139
Michal Vasko294d4c62016-02-01 10:10:27 +0100140 /* create server session */
Michal Vasko131120a2018-05-29 15:44:02 +0200141 server_session = test_new_session(NC_SERVER);
Michal Vasko294d4c62016-02-01 10:10:27 +0100142 server_session->status = NC_STATUS_RUNNING;
Michal Vasko294d4c62016-02-01 10:10:27 +0100143 server_session->id = 1;
Michal Vasko294d4c62016-02-01 10:10:27 +0100144 server_session->ti_type = NC_TI_FD;
Michal Vasko294d4c62016-02-01 10:10:27 +0100145 server_session->ti.fd.in = sock[0];
146 server_session->ti.fd.out = sock[0];
147 server_session->ctx = ctx;
148 server_session->flags = NC_SESSION_SHAREDCTX;
149
150 /* create client session */
Michal Vasko131120a2018-05-29 15:44:02 +0200151 client_session = test_new_session(NC_CLIENT);
Michal Vasko294d4c62016-02-01 10:10:27 +0100152 client_session->status = NC_STATUS_RUNNING;
Michal Vasko294d4c62016-02-01 10:10:27 +0100153 client_session->id = 1;
Michal Vasko294d4c62016-02-01 10:10:27 +0100154 client_session->ti_type = NC_TI_FD;
Michal Vasko294d4c62016-02-01 10:10:27 +0100155 client_session->ti.fd.in = sock[1];
156 client_session->ti.fd.out = sock[1];
157 client_session->ctx = ctx;
158 client_session->flags = NC_SESSION_SHAREDCTX;
Michal Vasko338f8472016-10-13 15:01:27 +0200159 client_session->opts.client.msgid = 50;
Michal Vasko294d4c62016-02-01 10:10:27 +0100160
161 return 0;
162}
163
164static int
165teardown_sessions(void **state)
166{
167 (void)state;
168
Michal Vasko294d4c62016-02-01 10:10:27 +0100169 close(server_session->ti.fd.in);
Michal Vasko131120a2018-05-29 15:44:02 +0200170 nc_session_free(server_session, NULL);
Michal Vasko294d4c62016-02-01 10:10:27 +0100171
172 close(client_session->ti.fd.in);
Michal Vasko131120a2018-05-29 15:44:02 +0200173 nc_session_free(client_session, NULL);
Michal Vasko294d4c62016-02-01 10:10:27 +0100174
175 return 0;
176}
177
178static void
Michal Vasko58d152f2016-02-01 11:44:49 +0100179test_send_recv_ok(void)
Michal Vasko294d4c62016-02-01 10:10:27 +0100180{
Michal Vasko294d4c62016-02-01 10:10:27 +0100181 int ret;
182 uint64_t msgid;
183 NC_MSG_TYPE msgtype;
184 struct nc_rpc *rpc;
185 struct nc_reply *reply;
186 struct nc_pollsession *ps;
187
188 /* client RPC */
189 rpc = nc_rpc_get(NULL, 0, 0);
190 assert_non_null(rpc);
191
192 msgtype = nc_send_rpc(client_session, rpc, 0, &msgid);
193 assert_int_equal(msgtype, NC_MSG_RPC);
194
195 /* server RPC, send reply */
196 ps = nc_ps_new();
197 assert_non_null(ps);
198 nc_ps_add_session(ps, server_session);
199
Michal Vasko71090fc2016-05-24 16:37:28 +0200200 ret = nc_ps_poll(ps, 0, NULL);
201 assert_int_equal(ret, NC_PSPOLL_RPC);
Michal Vasko294d4c62016-02-01 10:10:27 +0100202
203 /* server finished */
204 nc_ps_free(ps);
205
206 /* client reply */
Michal Vaskoeb7080e2016-02-18 13:27:05 +0100207 msgtype = nc_recv_reply(client_session, rpc, msgid, 0, 0, &reply);
Michal Vasko294d4c62016-02-01 10:10:27 +0100208 assert_int_equal(msgtype, NC_MSG_REPLY);
209
210 nc_rpc_free(rpc);
211 assert_int_equal(reply->type, NC_RPL_OK);
212 nc_reply_free(reply);
213}
214
215static void
Michal Vasko58d152f2016-02-01 11:44:49 +0100216test_send_recv_ok_10(void **state)
Michal Vasko294d4c62016-02-01 10:10:27 +0100217{
218 (void)state;
Michal Vasko58d152f2016-02-01 11:44:49 +0100219
220 server_session->version = NC_VERSION_10;
221 client_session->version = NC_VERSION_10;
222
223 test_send_recv_ok();
224}
225
226static void
227test_send_recv_ok_11(void **state)
228{
229 (void)state;
230
231 server_session->version = NC_VERSION_11;
232 client_session->version = NC_VERSION_11;
233
234 test_send_recv_ok();
235}
236
237static void
238test_send_recv_error(void)
239{
Michal Vasko294d4c62016-02-01 10:10:27 +0100240 int ret;
241 uint64_t msgid;
242 NC_MSG_TYPE msgtype;
243 struct nc_rpc *rpc;
244 struct nc_reply *reply;
245 struct nc_pollsession *ps;
246
247 /* client RPC */
248 rpc = nc_rpc_kill(1);
249 assert_non_null(rpc);
250
251 msgtype = nc_send_rpc(client_session, rpc, 0, &msgid);
252 assert_int_equal(msgtype, NC_MSG_RPC);
253
254 /* server RPC, send reply */
255 ps = nc_ps_new();
256 assert_non_null(ps);
257 nc_ps_add_session(ps, server_session);
258
Michal Vasko71090fc2016-05-24 16:37:28 +0200259 ret = nc_ps_poll(ps, 0, NULL);
260 assert_int_equal(ret, NC_PSPOLL_RPC | NC_PSPOLL_REPLY_ERROR);
Michal Vasko294d4c62016-02-01 10:10:27 +0100261
262 /* server finished */
263 nc_ps_free(ps);
264
265 /* client reply */
Michal Vaskoeb7080e2016-02-18 13:27:05 +0100266 msgtype = nc_recv_reply(client_session, rpc, msgid, 0, 0, &reply);
Michal Vasko294d4c62016-02-01 10:10:27 +0100267 assert_int_equal(msgtype, NC_MSG_REPLY);
268
269 nc_rpc_free(rpc);
270 assert_int_equal(reply->type, NC_RPL_ERROR);
271 assert_string_equal(((struct nc_reply_error *)reply)->err->tag, "operation-not-supported");
272 nc_reply_free(reply);
273}
274
275static void
Michal Vasko58d152f2016-02-01 11:44:49 +0100276test_send_recv_error_10(void **state)
Michal Vasko294d4c62016-02-01 10:10:27 +0100277{
278 (void)state;
Michal Vasko58d152f2016-02-01 11:44:49 +0100279
280 server_session->version = NC_VERSION_10;
281 client_session->version = NC_VERSION_10;
282
283 test_send_recv_error();
284}
285
286static void
287test_send_recv_error_11(void **state)
288{
289 (void)state;
290
291 server_session->version = NC_VERSION_11;
292 client_session->version = NC_VERSION_11;
293
294 test_send_recv_error();
295}
296
297static void
298test_send_recv_data(void)
299{
Michal Vasko294d4c62016-02-01 10:10:27 +0100300 int ret;
301 uint64_t msgid;
302 NC_MSG_TYPE msgtype;
303 struct nc_rpc *rpc;
304 struct nc_reply *reply;
305 struct nc_pollsession *ps;
306
307 /* client RPC */
308 rpc = nc_rpc_getconfig(NC_DATASTORE_RUNNING, NULL, 0, 0);
309 assert_non_null(rpc);
310
311 msgtype = nc_send_rpc(client_session, rpc, 0, &msgid);
312 assert_int_equal(msgtype, NC_MSG_RPC);
313
314 /* server RPC, send reply */
315 ps = nc_ps_new();
316 assert_non_null(ps);
317 nc_ps_add_session(ps, server_session);
318
Michal Vasko71090fc2016-05-24 16:37:28 +0200319 ret = nc_ps_poll(ps, 0, NULL);
320 assert_int_equal(ret, NC_PSPOLL_RPC);
Michal Vasko294d4c62016-02-01 10:10:27 +0100321
322 /* server finished */
323 nc_ps_free(ps);
324
325 /* client reply */
Radek Krejci8c8e1242016-09-07 16:43:54 +0200326 msgtype = nc_recv_reply(client_session, rpc, msgid, 0, 0, &reply);
Michal Vasko294d4c62016-02-01 10:10:27 +0100327 assert_int_equal(msgtype, NC_MSG_REPLY);
328
329 nc_rpc_free(rpc);
330 assert_int_equal(reply->type, NC_RPL_DATA);
331 nc_reply_free(reply);
332}
333
Michal Vasko58d152f2016-02-01 11:44:49 +0100334static void
335test_send_recv_data_10(void **state)
336{
337 (void)state;
338
339 server_session->version = NC_VERSION_10;
340 client_session->version = NC_VERSION_10;
341
342 test_send_recv_data();
343}
344
345static void
346test_send_recv_data_11(void **state)
347{
348 (void)state;
349
350 server_session->version = NC_VERSION_11;
351 client_session->version = NC_VERSION_11;
352
353 test_send_recv_data();
354}
355
Michal Vasko131120a2018-05-29 15:44:02 +0200356static void
357test_notif_clb(struct nc_session *session, const struct nc_notif *notif)
358{
359 assert_ptr_equal(session, client_session);
360 assert_string_equal(notif->tree->schema->name, "notificationComplete");
361
362 /* client notification received, update state */
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100363 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200364 while (glob_state != 2) {
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100365 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200366 usleep(1000);
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100367 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200368 }
369 glob_state = 3;
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100370 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200371}
372
373static void *
374server_send_notif_thread(void *arg)
375{
376 NC_MSG_TYPE msg_type;
377 struct lyd_node *notif_tree;
378 struct nc_server_notif *notif;
379 char *buf;
380 (void)arg;
381
382 /* wait for the RPC callback to be called */
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100383 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200384 while (glob_state != 1) {
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100385 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200386 usleep(1000);
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100387 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200388 }
389
390 /* create notif */
391 notif_tree = lyd_new_path(NULL, ctx, "/nc-notifications:notificationComplete", NULL, 0, 0);
392 assert_non_null(notif_tree);
393 buf = malloc(64);
394 assert_non_null(buf);
395 notif = nc_server_notif_new(notif_tree, nc_time2datetime(time(NULL), NULL, buf), NC_PARAMTYPE_FREE);
396 assert_non_null(notif);
397
398 /* send notif */
399 nc_session_set_notif_status(server_session, 1);
400 msg_type = nc_server_notif_send(server_session, notif, 100);
401 nc_server_notif_free(notif);
402 assert_int_equal(msg_type, NC_MSG_NOTIF);
403
404 /* update state */
405 glob_state = 2;
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100406 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200407
408 return NULL;
409}
410
Michal Vasko294d4c62016-02-01 10:10:27 +0100411static void
Michal Vasko58d152f2016-02-01 11:44:49 +0100412test_send_recv_notif(void)
Michal Vasko294d4c62016-02-01 10:10:27 +0100413{
Michal Vasko131120a2018-05-29 15:44:02 +0200414 int ret;
415 pthread_t tid;
416 uint64_t msgid;
417 NC_MSG_TYPE msgtype;
418 struct nc_rpc *rpc;
419 struct nc_reply *reply;
420 struct nc_pollsession *ps;
Michal Vasko294d4c62016-02-01 10:10:27 +0100421
Michal Vasko131120a2018-05-29 15:44:02 +0200422 /* client RPC */
423 rpc = nc_rpc_commit(0, 0, NULL, NULL, 0);
424 assert_non_null(rpc);
425
426 msgtype = nc_send_rpc(client_session, rpc, 0, &msgid);
427 assert_int_equal(msgtype, NC_MSG_RPC);
428
429 /* client subscription */
430 ret = nc_recv_notif_dispatch(client_session, test_notif_clb);
431 assert_int_equal(ret, 0);
432
433 /* create server */
434 ps = nc_ps_new();
435 assert_non_null(ps);
436 nc_ps_add_session(ps, server_session);
437
438 /* server will send a notification */
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100439 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200440 glob_state = 0;
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100441 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200442 ret = pthread_create(&tid, NULL, server_send_notif_thread, NULL);
443 assert_int_equal(ret, 0);
444
445 /* server blocked on RPC */
446 ret = nc_ps_poll(ps, 0, NULL);
447 assert_int_equal(ret, NC_PSPOLL_RPC);
448
449 /* RPC, notification finished fine */
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100450 pthread_mutex_lock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200451 assert_int_equal(glob_state, 3);
Michal Vaskobbaa9b22019-03-14 12:35:43 +0100452 pthread_mutex_unlock(&state_lock);
Michal Vasko131120a2018-05-29 15:44:02 +0200453
454 /* server finished */
455 ret = pthread_join(tid, NULL);
456 assert_int_equal(ret, 0);
457 nc_ps_free(ps);
458
459 /* client reply */
460 msgtype = nc_recv_reply(client_session, rpc, msgid, 0, 0, &reply);
461 assert_int_equal(msgtype, NC_MSG_REPLY);
462
463 nc_rpc_free(rpc);
464 assert_int_equal(reply->type, NC_RPL_OK);
465 nc_reply_free(reply);
466}
467
468static void
469test_send_recv_notif_10(void **state)
470{
471 (void)state;
472
473 server_session->version = NC_VERSION_10;
474 client_session->version = NC_VERSION_10;
475
476 test_send_recv_notif();
477}
478
479static void
480test_send_recv_notif_11(void **state)
481{
482 (void)state;
483
484 server_session->version = NC_VERSION_11;
485 client_session->version = NC_VERSION_11;
486
487 test_send_recv_notif();
488}
Michal Vasko294d4c62016-02-01 10:10:27 +0100489
490int
491main(void)
492{
Michal Vasko8c5518b2016-03-01 12:35:13 +0100493 int ret;
494 const struct lys_module *module;
Michal Vasko88639e92017-08-03 14:38:10 +0200495 const struct lys_node *node;
Michal Vasko8c5518b2016-03-01 12:35:13 +0100496
497 /* create ctx */
Michal Vasko3c37b4f2020-01-03 05:11:39 -0500498 ctx = ly_ctx_new(TESTS_DIR"/../schemas", 0);
Michal Vasko8c5518b2016-03-01 12:35:13 +0100499 assert_non_null(ctx);
500
501 /* load modules */
502 module = ly_ctx_load_module(ctx, "ietf-netconf-acm", NULL);
503 assert_non_null(module);
504
505 module = ly_ctx_load_module(ctx, "ietf-netconf", NULL);
506 assert_non_null(module);
Michal Vasko131120a2018-05-29 15:44:02 +0200507 ret = lys_features_enable(module, "candidate");
508 assert_int_equal(ret, 0);
509
510 module = ly_ctx_load_module(ctx, "nc-notifications", NULL);
511 assert_non_null(module);
Michal Vasko8c5518b2016-03-01 12:35:13 +0100512
513 /* set RPC callbacks */
Michal Vasko88639e92017-08-03 14:38:10 +0200514 node = ly_ctx_get_node(module->ctx, NULL, "/ietf-netconf:get", 0);
515 assert_non_null(node);
516 lys_set_private(node, my_get_rpc_clb);
517
518 node = ly_ctx_get_node(module->ctx, NULL, "/ietf-netconf:get-config", 0);
519 assert_non_null(node);
520 lys_set_private(node, my_getconfig_rpc_clb);
Michal Vasko8c5518b2016-03-01 12:35:13 +0100521
Michal Vasko131120a2018-05-29 15:44:02 +0200522 node = ly_ctx_get_node(module->ctx, NULL, "/ietf-netconf:commit", 0);
523 assert_non_null(node);
524 lys_set_private(node, my_commit_rpc_clb);
525
Michal Vasko8c5518b2016-03-01 12:35:13 +0100526 nc_server_init(ctx);
527
Michal Vasko294d4c62016-02-01 10:10:27 +0100528 const struct CMUnitTest comm[] = {
Michal Vasko58d152f2016-02-01 11:44:49 +0100529 cmocka_unit_test_setup_teardown(test_send_recv_ok_10, setup_sessions, teardown_sessions),
530 cmocka_unit_test_setup_teardown(test_send_recv_error_10, setup_sessions, teardown_sessions),
531 cmocka_unit_test_setup_teardown(test_send_recv_data_10, setup_sessions, teardown_sessions),
Michal Vasko131120a2018-05-29 15:44:02 +0200532 cmocka_unit_test_setup_teardown(test_send_recv_notif_10, setup_sessions, teardown_sessions),
Michal Vasko58d152f2016-02-01 11:44:49 +0100533 cmocka_unit_test_setup_teardown(test_send_recv_ok_11, setup_sessions, teardown_sessions),
534 cmocka_unit_test_setup_teardown(test_send_recv_error_11, setup_sessions, teardown_sessions),
Michal Vasko131120a2018-05-29 15:44:02 +0200535 cmocka_unit_test_setup_teardown(test_send_recv_data_11, setup_sessions, teardown_sessions),
536 cmocka_unit_test_setup_teardown(test_send_recv_notif_11, setup_sessions, teardown_sessions),
Michal Vasko294d4c62016-02-01 10:10:27 +0100537 };
538
Michal Vasko8c5518b2016-03-01 12:35:13 +0100539 ret = cmocka_run_group_tests(comm, NULL, NULL);
540
541 nc_server_destroy();
542 ly_ctx_destroy(ctx, NULL);
543
544 return ret;
Michal Vasko294d4c62016-02-01 10:10:27 +0100545}