]> git.meshlink.io Git - meshlink/blobdiff - test/blackbox/run_blackbox_tests/test_optimal_pmtu.c
Fix __warn_unused_result__, add more of it and fix the resulting warnings.
[meshlink] / test / blackbox / run_blackbox_tests / test_optimal_pmtu.c
index c5638c6ebc1a312849bf795ed7e5c805585960af..1d7408957ef90a20c052170c54fd4eef3377ac27 100644 (file)
     with this program; if not, write to the Free Software Foundation, Inc.,
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
+
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+
 #include <stdlib.h>
 #include <stdarg.h>
 #include <setjmp.h>
@@ -61,6 +66,8 @@ struct sync_flag test_pmtu_nut_closed = {.mutex  = PTHREAD_MUTEX_INITIALIZER, .c
 static netns_state_t *test_pmtu_state;
 
 static int setup_test(void **state) {
+       (void)state;
+
        netns_create_topology(test_pmtu_state);
        fprintf(stderr, "\nCreated topology\n");
 
@@ -68,25 +75,29 @@ static int setup_test(void **state) {
        test_pmtu_peer_running = true;
        test_pmtu_nut_running = true;
        ping_channel_enable_07 = false;
-       memset(node_pmtu, 2, sizeof(node_pmtu[0]));
+       memset(node_pmtu, 0, sizeof(node_pmtu));
        set_sync_flag(&test_pmtu_nut_closed, false);
-       meshlink_destroy("nut");
-       meshlink_destroy("peer");
-       meshlink_destroy("relay");
+       assert(meshlink_destroy("nut"));
+       assert(meshlink_destroy("peer"));
+       assert(meshlink_destroy("relay"));
 
        return EXIT_SUCCESS;
 }
 
 static int teardown_test(void **state) {
-       meshlink_destroy("nut");
-       meshlink_destroy("peer");
-       meshlink_destroy("relay");
+       (void)state;
+
+       assert(meshlink_destroy("nut"));
+       assert(meshlink_destroy("peer"));
+       assert(meshlink_destroy("relay"));
        netns_destroy_topology(test_pmtu_state);
 
        return EXIT_SUCCESS;
 }
 
 static void execute_test(test_step_func_t step_func, void **state) {
+       (void)state;
+
 
        fprintf(stderr, "\n\x1b[32mRunning Test\x1b[0m\n");
        bool test_result = step_func();
@@ -99,13 +110,15 @@ static void execute_test(test_step_func_t step_func, void **state) {
 static void *gen_inv(void *arg) {
        mesh_invite_arg_t *mesh_invite_arg = (mesh_invite_arg_t *)arg;
        meshlink_handle_t *mesh;
-       mesh = meshlink_open(mesh_invite_arg->mesh_arg->node_name , mesh_invite_arg->mesh_arg->confbase, mesh_invite_arg->mesh_arg->app_name, mesh_invite_arg->mesh_arg->dev_class);
+       mesh = meshlink_open(mesh_invite_arg->mesh_arg->node_name, mesh_invite_arg->mesh_arg->confbase, mesh_invite_arg->mesh_arg->app_name, mesh_invite_arg->mesh_arg->dev_class);
        assert(mesh);
 
        char *invitation = meshlink_invite(mesh, NULL, mesh_invite_arg->invitee_name);
        assert(invitation);
        mesh_invite_arg->invite_str = invitation;
        meshlink_close(mesh);
+
+       return NULL;
 }
 
 /* Test Steps for optimal PMTU discovery Test Case # 1 -
@@ -417,6 +430,8 @@ static void test_case_optimal_pmtu_06(void **state) {
 static bool run_conntrack;
 static pthread_t pmtu_test_case_conntrack_thread;
 static void *conntrack_flush(void *arg) {
+       (void)arg;
+
        // flushes mappings for every 60 seconds
 
        while(run_conntrack) {
@@ -616,19 +631,19 @@ int test_optimal_pmtu(void) {
 
        const struct CMUnitTest blackbox_group0_tests[] = {
                cmocka_unit_test_prestate_setup_teardown(test_case_optimal_pmtu_01, setup_test, teardown_test,
-               (void *)&test_pmtu_state),
+                               (void *)&test_pmtu_state),
                cmocka_unit_test_prestate_setup_teardown(test_case_optimal_pmtu_02, setup_test, teardown_test,
-               (void *)&test_pmtu_state),
+                               (void *)&test_pmtu_state),
                cmocka_unit_test_prestate_setup_teardown(test_case_optimal_pmtu_03, setup_test, teardown_test,
-               (void *)&test_pmtu_state),
+                               (void *)&test_pmtu_state),
                cmocka_unit_test_prestate_setup_teardown(test_case_optimal_pmtu_04, setup_test, teardown_test,
-               (void *)&test_pmtu_state),
+                               (void *)&test_pmtu_state),
                cmocka_unit_test_prestate_setup_teardown(test_case_optimal_pmtu_05, setup_test, teardown_test,
-               (void *)&test_pmtu_state),
+                               (void *)&test_pmtu_state),
                cmocka_unit_test_prestate_setup_teardown(test_case_optimal_pmtu_06, setup_test, teardown_test,
-               (void *)&test_pmtu_state),
+                               (void *)&test_pmtu_state),
                cmocka_unit_test_prestate_setup_teardown(test_case_optimal_pmtu_07, setup_test, teardown_test,
-               (void *)&test_pmtu_state),
+                               (void *)&test_pmtu_state),
        };
        total_tests += sizeof(blackbox_group0_tests) / sizeof(blackbox_group0_tests[0]);