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_client.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 client |
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 | |
Michal Vasko | ba9f358 | 2023-02-22 10:26:32 +0100 | [diff] [blame] | 15 | #define _GNU_SOURCE |
| 16 | |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 17 | #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 Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 25 | #include <string.h> |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 26 | #include <sys/socket.h> |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 27 | #include <sys/stat.h> |
| 28 | #include <sys/types.h> |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 29 | #include <unistd.h> |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 30 | |
| 31 | #include <cmocka.h> |
| 32 | #include <libyang/libyang.h> |
| 33 | |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 34 | #include <session_client.h> |
Michal Vasko | b83a3fa | 2021-05-26 09:53:42 +0200 | [diff] [blame] | 35 | #include "tests/config.h" |
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_client(void **state) |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 39 | { |
| 40 | (void)state; |
| 41 | |
Roytak | b279485 | 2023-10-18 14:30:22 +0200 | [diff] [blame] | 42 | nc_client_init(); |
| 43 | |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | static int |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 48 | teardown_client(void **state) |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 49 | { |
| 50 | (void)state; |
| 51 | |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 52 | nc_client_destroy(); |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | static void |
| 58 | test_dummy(void **state) |
| 59 | { |
| 60 | (void)state; |
| 61 | } |
| 62 | |
| 63 | int |
| 64 | main(void) |
| 65 | { |
| 66 | const struct CMUnitTest init_destroy[] = { |
Michal Vasko | a7b8ca5 | 2016-03-01 12:09:29 +0100 | [diff] [blame] | 67 | cmocka_unit_test_setup_teardown(test_dummy, setup_client, teardown_client) |
Michal Vasko | 77fad15 | 2016-02-03 15:36:15 +0100 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | return cmocka_run_group_tests(init_destroy, NULL, NULL); |
| 71 | } |