blob: 082710c149779ea97f8599b484d93fd8d8107531 [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
Michal Vaskoba9f3582023-02-22 10:26:32 +010015#define _GNU_SOURCE
16
Michal Vasko77fad152016-02-03 15:36:15 +010017#include <errno.h>
18#include <fcntl.h>
19#include <pthread.h>
20#include <setjmp.h>
21#include <stdarg.h>
22#include <stddef.h>
23#include <stdint.h>
24#include <stdlib.h>
Michal Vasko77fad152016-02-03 15:36:15 +010025#include <string.h>
Michal Vaskob83a3fa2021-05-26 09:53:42 +020026#include <sys/socket.h>
Michal Vasko77fad152016-02-03 15:36:15 +010027#include <sys/stat.h>
28#include <sys/types.h>
Michal Vaskob83a3fa2021-05-26 09:53:42 +020029#include <unistd.h>
Michal Vasko77fad152016-02-03 15:36:15 +010030
31#include <cmocka.h>
32#include <libyang/libyang.h>
33
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010034#include <session_server.h>
Michal Vaskob83a3fa2021-05-26 09:53:42 +020035#include "tests/config.h"
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010036
Michal Vasko77fad152016-02-03 15:36:15 +010037static 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 Vasko93224072021-11-09 12:14:28 +010042 nc_server_init();
Michal Vasko77fad152016-02-03 15:36:15 +010043
44 return 0;
45}
46
47static int
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010048teardown_server(void **state)
Michal Vasko77fad152016-02-03 15:36:15 +010049{
50 (void)state;
51
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010052 nc_server_destroy();
Michal Vasko77fad152016-02-03 15:36:15 +010053
54 return 0;
55}
56
57static void
58test_dummy(void **state)
59{
60 (void)state;
61}
62
63int
64main(void)
65{
66 const struct CMUnitTest init_destroy[] = {
Michal Vaskoa7b8ca52016-03-01 12:09:29 +010067 cmocka_unit_test_setup_teardown(test_dummy, setup_server, teardown_server)
Michal Vasko77fad152016-02-03 15:36:15 +010068 };
69
70 return cmocka_run_group_tests(init_destroy, NULL, NULL);
71}