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.
20 #include "execute_tests.h"
21 #include "test_cases_get_self.h"
22 #include "../common/containers.h"
23 #include "../common/test_step.h"
24 #include "../common/common_handlers.h"
32 static void test_case_mesh_get_self_01(void **state);
33 static bool test_steps_mesh_get_self_01(void);
34 static void test_case_mesh_get_self_02(void **state);
35 static bool test_steps_mesh_get_self_02(void);
37 /* State structure for meshlink_get_self Test Case #1 */
38 static black_box_state_t test_mesh_get_self_01_state = {
39 .test_case_name = "test_case_mesh_get_self_01",
42 /* State structure for meshlink_get_self Test Case #2 */
43 static black_box_state_t test_mesh_get_self_02_state = {
44 .test_case_name = "test_case_mesh_get_self_02",
47 /* Execute meshlink_get_self Test Case # 1 */
48 static void test_case_mesh_get_self_01(void **state) {
49 execute_test(test_steps_mesh_get_self_01, state);
52 /* Test Steps for meshlink_get_self Test Case # 1
56 2. Get node's self handle
59 node handle of it's own is obtained
61 static bool test_steps_mesh_get_self_01(void) {
62 meshlink_handle_t *mesh = meshlink_open("self_conf", "foo", "test", DEV_CLASS_STATIONARY);
65 assert(meshlink_start(mesh));
66 meshlink_node_t *dest_node = meshlink_get_self(mesh);
67 assert_int_not_equal(dest_node, NULL);
69 if(strcmp(dest_node->name, "foo")) {
74 meshlink_destroy("self_conf");
79 /* Execute meshlink_get_self Test Case # 2 */
80 static void test_case_mesh_get_self_02(void **state) {
81 execute_test(test_steps_mesh_get_self_02, state);
84 /* Test Steps for meshlink_get_self Test Case # 2
87 1. Open NUT(Node Under Test) & bar meshes.
88 2. Export and Import mutually
91 Both the nodes imports successfully
93 static bool test_steps_mesh_get_self_02(void) {
94 meshlink_node_t *dest_node = meshlink_get_self(NULL);
95 assert_int_equal(dest_node, NULL);
100 int test_meshlink_get_self(void) {
101 const struct CMUnitTest blackbox_get_self_tests[] = {
102 cmocka_unit_test_prestate_setup_teardown(test_case_mesh_get_self_01, NULL, NULL,
103 (void *)&test_mesh_get_self_01_state),
104 cmocka_unit_test_prestate_setup_teardown(test_case_mesh_get_self_02, NULL, NULL,
105 (void *)&test_mesh_get_self_02_state)
108 total_tests += sizeof(blackbox_get_self_tests) / sizeof(blackbox_get_self_tests[0]);
110 return cmocka_run_group_tests(blackbox_get_self_tests, NULL, NULL);