blob: 6e58da408a30f497b754370415c9a588c8458e16 [file] [log] [blame]
Michal Vasko77fad152016-02-03 15:36:15 +01001/**
Michal Vaskoa7b8ca52016-03-01 12:09:29 +01002 * \file test_init_destroy_server.c
Michal Vasko77fad152016-02-03 15:36:15 +01003 * \author Michal Vasko <mvasko@cesnet.cz>
Michal Vaskoa7b8ca52016-03-01 12:09:29 +01004 * \brief libnetconf2 tests - init/destroy server
Michal Vasko77fad152016-02-03 15:36:15 +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 Vasko77fad152016-02-03 15:36:15 +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>
Michal Vasko77fad152016-02-03 15:36:15 +010023#include <string.h>
Michal Vaskob83a3fa2021-05-26 09:53:42 +020024#include <sys/socket.h>
Michal Vasko77fad152016-02-03 15:36:15 +010025#include <sys/stat.h>
26#include <sys/types.h>
Michal Vaskob83a3fa2021-05-26 09:53:42 +020027#include <unistd.h>
Michal Vasko77fad152016-02-03 15:36:15 +010028
29#include <cmocka.h>
30#include <libyang/libyang.h>
31
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010032#include <session_server.h>
Michal Vaskob83a3fa2021-05-26 09:53:42 +020033#include "tests/config.h"
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010034
35struct ly_ctx *ctx;
Michal Vasko77fad152016-02-03 15:36:15 +010036
37static int
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010038setup_server(void **state)
Michal Vasko77fad152016-02-03 15:36:15 +010039{
40 (void)state;
41
Michal Vasko77367452021-02-16 16:32:18 +010042 ly_ctx_new(NULL, 0, &ctx);
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010043 assert_non_null(ctx);
44
45 nc_server_init(ctx);
Michal Vasko77fad152016-02-03 15:36:15 +010046
47 return 0;
48}
49
50static int
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010051teardown_server(void **state)
Michal Vasko77fad152016-02-03 15:36:15 +010052{
53 (void)state;
54
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010055 nc_server_destroy();
Michal Vasko1dcb7642021-04-14 15:28:23 +020056 ly_ctx_destroy(ctx);
Michal Vasko77fad152016-02-03 15:36:15 +010057
58 return 0;
59}
60
61static void
62test_dummy(void **state)
63{
64 (void)state;
65}
66
67int
68main(void)
69{
70 const struct CMUnitTest init_destroy[] = {
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010071 cmocka_unit_test_setup_teardown(test_dummy, setup_server, teardown_server)
Michal Vasko77fad152016-02-03 15:36:15 +010072 };
73
74 return cmocka_run_group_tests(init_destroy, NULL, NULL);
75}