]> git.meshlink.io Git - meshlink/blob - test/blackbox/test_case_optimal_pmtu_01/node_sim_relay.c
Fix __warn_unused_result__, add more of it and fix the resulting warnings.
[meshlink] / test / blackbox / test_case_optimal_pmtu_01 / node_sim_relay.c
1 /*
2     node_sim_relay.c -- Implementation of Node Simulation for Meshlink Testing
3     Copyright (C) 2019  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 <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <pthread.h>
28 #include <assert.h>
29 #include <signal.h>
30 #include <time.h>
31 #include "../common/common_handlers.h"
32 #include "../common/test_step.h"
33 #include "../common/network_namespace_framework.h"
34 #include "../../utils.h"
35 #include "../run_blackbox_tests/test_optimal_pmtu.h"
36
37 extern bool test_pmtu_relay_running;
38
39 void *node_sim_pmtu_relay_01(void *arg) {
40         mesh_arg_t *mesh_arg = (mesh_arg_t *)arg;
41         struct timeval main_loop_wait = { 5, 0 };
42
43         // Run relay node instance
44
45
46         meshlink_handle_t *mesh;
47         mesh = meshlink_open(mesh_arg->node_name, mesh_arg->confbase, mesh_arg->app_name, mesh_arg->dev_class);
48         assert(mesh);
49
50         //meshlink_set_log_cb(mesh, MESHLINK_DEBUG, meshlink_callback_logger);
51         meshlink_enable_discovery(mesh, false);
52
53         assert(meshlink_start(mesh));
54         //send_event(NODE_STARTED);
55
56         /* All test steps executed - wait for signals to stop/start or close the mesh */
57         while(test_pmtu_relay_running) {
58                 select(1, NULL, NULL, NULL, &main_loop_wait);
59         }
60
61         meshlink_close(mesh);
62
63         return 0;
64 }