]> git.meshlink.io Git - meshlink/blob - test/blackbox/run_blackbox_tests/test_cases_stop_close.c
Ensure NDEBUG is not set in the test suite.
[meshlink] / test / blackbox / run_blackbox_tests / test_cases_stop_close.c
1 /*
2     test_cases_stop_close.c -- Execution of specific meshlink black box test cases
3     Copyright (C) 2018  Guus Sliepen <guus@meshlink.io>
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License along
16     with this program; if not, write to the Free Software Foundation, Inc.,
17     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #ifdef NDEBUG
21 #undef NDEBUG
22 #endif
23
24 #include "execute_tests.h"
25 #include "test_cases_stop_close.h"
26 #include "../common/containers.h"
27 #include "../common/test_step.h"
28 #include "../common/common_handlers.h"
29 #include <stdlib.h>
30 #include <stdarg.h>
31 #include <setjmp.h>
32 #include <cmocka.h>
33 #include <assert.h>
34 #include <string.h>
35 #include <sys/wait.h>
36
37 #define CLOSE_FILE_PATH "/home/sairoop/meshlink/test/blackbox/test_case_close/mesh_close"
38 #define VALGRIND_LOG "valgrind.log"
39
40 static void test_case_mesh_close_01(void **state);
41 static bool test_steps_mesh_close_01(void);
42 static void test_case_mesh_stop_01(void **state);
43 static bool test_steps_mesh_stop_01(void);
44
45 /* State structure for meshlink_close Test Case #1 */
46 static black_box_state_t test_mesh_close_01_state = {
47         .test_case_name = "test_case_mesh_close_01",
48 };
49
50 /* State structure for meshlink_close Test Case #1 */
51 static black_box_state_t test_mesh_stop_01_state = {
52         .test_case_name = "test_case_mesh_stop_01",
53 };
54
55 /* Execute meshlink_close Test Case # 1*/
56 static void test_case_mesh_close_01(void **state) {
57         execute_test(test_steps_mesh_close_01, state);
58 }
59
60 /* Test Steps for meshlink_close Test Case # 1*/
61
62 static bool test_steps_mesh_close_01(void) {
63         meshlink_close(NULL);
64         assert_int_equal(meshlink_errno, MESHLINK_EINVAL);
65
66         return true;
67 }
68
69 /* Execute meshlink_stop Test Case # 1*/
70 static void test_case_mesh_stop_01(void **state) {
71         execute_test(test_steps_mesh_stop_01, state);
72 }
73
74 /* Test Steps for meshlink_stop Test Case # 1*/
75 static bool test_steps_mesh_stop_01(void) {
76         meshlink_stop(NULL);
77         assert_int_equal(meshlink_errno, MESHLINK_EINVAL);
78
79         return true;
80 }
81
82 int test_meshlink_stop_close(void) {
83         const struct CMUnitTest blackbox_stop_close_tests[] = {
84                 cmocka_unit_test_prestate_setup_teardown(test_case_mesh_stop_01, NULL, NULL,
85                                 (void *)&test_mesh_stop_01_state),
86                 cmocka_unit_test_prestate_setup_teardown(test_case_mesh_close_01, NULL, NULL,
87                                 (void *)&test_mesh_close_01_state)
88         };
89
90         total_tests += sizeof(blackbox_stop_close_tests) / sizeof(blackbox_stop_close_tests[0]);
91
92         return cmocka_run_group_tests(blackbox_stop_close_tests, NULL, NULL);
93 }
94