Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 1 | /** |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 2 | * \file test_init_destroy_server.c |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 3 | * \author Michal Vasko <mvasko@cesnet.cz> |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 4 | * \brief libnetconf2 tests - init/destroy server |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 5 | * |
| 6 | * Copyright (c) 2015 CESNET, z.s.p.o. |
| 7 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 8 | * 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 Vasko | ad1cc6a | 2016-02-26 15:06:06 +0100 | [diff] [blame] | 11 | * |
Radek Krejci | 9b81f5b | 2016-02-24 13:14:49 +0100 | [diff] [blame] | 12 | * https://opensource.org/licenses/BSD-3-Clause |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 13 | */ |
| 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 | |
Jan Kundrát | cf15d6c | 2017-10-26 18:07:56 +0200 | [diff] [blame^] | 32 | #include "tests/config.h" |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 33 | #include <session_server.h> |
| 34 | |
| 35 | struct ly_ctx *ctx; |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 36 | |
| 37 | static int |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 38 | setup_server(void **state) |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 39 | { |
| 40 | (void)state; |
| 41 | |
Radek Krejci | 3222b7d | 2017-09-21 16:04:30 +0200 | [diff] [blame] | 42 | ctx = ly_ctx_new(NULL, 0); |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 43 | assert_non_null(ctx); |
| 44 | |
| 45 | nc_server_init(ctx); |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 46 | |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | static int |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 51 | teardown_server(void **state) |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 52 | { |
| 53 | (void)state; |
| 54 | |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 55 | nc_server_destroy(); |
| 56 | ly_ctx_destroy(ctx, NULL); |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 57 | |
| 58 | return 0; |
| 59 | } |
| 60 | |
| 61 | static void |
| 62 | test_dummy(void **state) |
| 63 | { |
| 64 | (void)state; |
| 65 | } |
| 66 | |
| 67 | int |
| 68 | main(void) |
| 69 | { |
| 70 | const struct CMUnitTest init_destroy[] = { |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 71 | cmocka_unit_test_setup_teardown(test_dummy, setup_server, teardown_server) |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 72 | }; |
| 73 | |
| 74 | return cmocka_run_group_tests(init_destroy, NULL, NULL); |
| 75 | } |
| 76 | |