]> git.meshlink.io Git - meshlink/blob - test/blackbox/run_blackbox_tests/test_cases_stop_close.c
Add the blackbox container based 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 #include "execute_tests.h"
21 #include "test_cases_stop_close.h"
22 #include "../common/containers.h"
23 #include "../common/test_step.h"
24 #include "../common/common_handlers.h"
25 #include <stdlib.h>
26 #include <stdarg.h>
27 #include <setjmp.h>
28 #include <cmocka.h>
29 #include <assert.h>
30 #include <string.h>
31 #include <sys/wait.h>
32
33 #define CLOSE_FILE_PATH "/home/sairoop/meshlink/test/blackbox/test_case_close/mesh_close"
34 #define VALGRIND_LOG "valgrind.log"
35
36 static void test_case_mesh_close_01(void **state);
37 static bool test_steps_mesh_close_01(void);
38 static void test_case_mesh_stop_01(void **state);
39 static bool test_steps_mesh_stop_01(void);
40
41 /* State structure for meshlink_close Test Case #1 */
42 static black_box_state_t test_mesh_close_01_state = {
43         .test_case_name = "test_case_mesh_close_01",
44 };
45
46 /* State structure for meshlink_close Test Case #1 */
47 static black_box_state_t test_mesh_stop_01_state = {
48         .test_case_name = "test_case_mesh_stop_01",
49 };
50
51 /* Execute meshlink_close Test Case # 1*/
52 static void test_case_mesh_close_01(void **state) {
53         execute_test(test_steps_mesh_close_01, state);
54 }
55
56 /* Test Steps for meshlink_close Test Case # 1*/
57
58 static bool test_steps_mesh_close_01(void) {
59         meshlink_close(NULL);
60         assert_int_equal(meshlink_errno, MESHLINK_EINVAL);
61
62         return true;
63 }
64
65 /* Execute meshlink_stop Test Case # 1*/
66 static void test_case_mesh_stop_01(void **state) {
67         execute_test(test_steps_mesh_stop_01, state);
68 }
69
70 /* Test Steps for meshlink_stop Test Case # 1*/
71 static bool test_steps_mesh_stop_01(void) {
72         meshlink_stop(NULL);
73         assert_int_equal(meshlink_errno, MESHLINK_EINVAL);
74
75         return true;
76 }
77
78 int test_meshlink_stop_close(void) {
79         const struct CMUnitTest blackbox_stop_close_tests[] = {
80                 cmocka_unit_test_prestate_setup_teardown(test_case_mesh_stop_01, NULL, NULL,
81                                 (void *)&test_mesh_stop_01_state),
82                 cmocka_unit_test_prestate_setup_teardown(test_case_mesh_close_01, NULL, NULL,
83                                 (void *)&test_mesh_close_01_state)
84         };
85
86         total_tests += sizeof(blackbox_stop_close_tests) / sizeof(blackbox_stop_close_tests[0]);
87
88         return cmocka_run_group_tests(blackbox_stop_close_tests, NULL, NULL);
89 }
90