2 test_cases_get_port.c -- Execution of specific meshlink black box test cases
3 Copyright (C) 2018 Guus Sliepen <guus@meshlink.io>
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.
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.
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.
24 #include "execute_tests.h"
25 #include "test_cases_get_self.h"
26 #include "../common/containers.h"
27 #include "../common/test_step.h"
28 #include "../common/common_handlers.h"
36 static void test_case_mesh_get_self_01(void **state);
37 static bool test_steps_mesh_get_self_01(void);
38 static void test_case_mesh_get_self_02(void **state);
39 static bool test_steps_mesh_get_self_02(void);
41 /* State structure for meshlink_get_self Test Case #1 */
42 static black_box_state_t test_mesh_get_self_01_state = {
43 .test_case_name = "test_case_mesh_get_self_01",
46 /* State structure for meshlink_get_self Test Case #2 */
47 static black_box_state_t test_mesh_get_self_02_state = {
48 .test_case_name = "test_case_mesh_get_self_02",
51 /* Execute meshlink_get_self Test Case # 1 */
52 static void test_case_mesh_get_self_01(void **state) {
53 execute_test(test_steps_mesh_get_self_01, state);
56 /* Test Steps for meshlink_get_self Test Case # 1
60 2. Get node's self handle
63 node handle of it's own is obtained
65 static bool test_steps_mesh_get_self_01(void) {
66 meshlink_handle_t *mesh = meshlink_open("self_conf", "foo", "test", DEV_CLASS_STATIONARY);
69 assert(meshlink_start(mesh));
70 meshlink_node_t *dest_node = meshlink_get_self(mesh);
71 assert_int_not_equal(dest_node, NULL);
73 if(strcmp(dest_node->name, "foo")) {
78 assert(meshlink_destroy("self_conf"));
83 /* Execute meshlink_get_self Test Case # 2 */
84 static void test_case_mesh_get_self_02(void **state) {
85 execute_test(test_steps_mesh_get_self_02, state);
88 /* Test Steps for meshlink_get_self Test Case # 2
91 1. Open NUT(Node Under Test) & bar meshes.
92 2. Export and Import mutually
95 Both the nodes imports successfully
97 static bool test_steps_mesh_get_self_02(void) {
98 meshlink_node_t *dest_node = meshlink_get_self(NULL);
99 assert_int_equal(dest_node, NULL);
104 int test_meshlink_get_self(void) {
105 const struct CMUnitTest blackbox_get_self_tests[] = {
106 cmocka_unit_test_prestate_setup_teardown(test_case_mesh_get_self_01, NULL, NULL,
107 (void *)&test_mesh_get_self_01_state),
108 cmocka_unit_test_prestate_setup_teardown(test_case_mesh_get_self_02, NULL, NULL,
109 (void *)&test_mesh_get_self_02_state)
112 total_tests += sizeof(blackbox_get_self_tests) / sizeof(blackbox_get_self_tests[0]);
114 return cmocka_run_group_tests(blackbox_get_self_tests, NULL, NULL);