From cdb3dada645394bb1e0d0bf7816291fbd9a2a4a0 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Thu, 13 Jun 2019 23:30:12 +0200 Subject: [PATCH] Fix compiler warnings in the test suites. --- configure.ac | 2 +- test/basic.c | 1 + test/blackbox/common/common_handlers.c | 3 +- test/blackbox/common/containers.c | 64 +++++++++---------- test/blackbox/common/mesh_event_handler.c | 9 +-- .../common/network_namespace_framework.c | 27 ++++---- test/blackbox/common/tcpdump.c | 14 ++-- test/blackbox/common/test_step.c | 16 ++--- test/blackbox/run_blackbox_tests/test_cases.c | 22 ++++++- .../test_cases_autoconnect.c | 2 - .../run_blackbox_tests/test_cases_blacklist.c | 4 ++ .../test_cases_channel_blacklist.c | 10 ++- .../test_cases_channel_close.c | 5 -- .../test_cases_channel_conn.c | 34 +++++----- .../test_cases_channel_ex.c | 8 +-- .../test_cases_channel_get_flags.c | 6 +- .../test_cases_channel_open.c | 7 +- .../test_cases_channel_send.c | 6 +- .../test_cases_channel_set_accept_cb.c | 15 +++-- .../test_cases_channel_set_poll_cb.c | 7 ++ .../test_cases_channel_set_receive_cb.c | 19 +++--- .../test_cases_channel_shutdown.c | 22 ++----- .../test_cases_default_blacklist.c | 5 ++ .../test_cases_get_all_nodes.c | 8 +-- .../test_cases_get_all_nodes_by_dev_class.c | 4 +- .../run_blackbox_tests/test_cases_import.c | 11 ++-- .../run_blackbox_tests/test_cases_invite.c | 4 +- .../run_blackbox_tests/test_cases_join.c | 2 - .../test_cases_key_rotation.c | 2 + .../test_cases_random_port_bindings01.c | 6 -- .../test_cases_random_port_bindings02.c | 8 +++ .../run_blackbox_tests/test_cases_rec_cb.c | 5 +- .../run_blackbox_tests/test_cases_send.c | 18 +----- .../test_cases_set_connection_try_cb.c | 6 +- .../test_cases_set_log_cb.c | 5 +- .../run_blackbox_tests/test_cases_set_port.c | 2 + .../run_blackbox_tests/test_cases_sign.c | 2 - .../run_blackbox_tests/test_cases_status_cb.c | 6 +- .../run_blackbox_tests/test_cases_submesh01.c | 30 +++------ .../run_blackbox_tests/test_cases_submesh02.c | 30 +++------ .../run_blackbox_tests/test_cases_submesh03.c | 24 ++----- .../run_blackbox_tests/test_cases_submesh04.c | 24 ++----- .../run_blackbox_tests/test_cases_verify.c | 4 -- .../run_blackbox_tests/test_cases_whitelist.c | 7 +- .../run_blackbox_tests/test_optimal_pmtu.c | 12 +++- .../run_blackbox_tests/test_optimal_pmtu.h | 4 +- .../node_sim_nut_01.c | 8 ++- .../node_sim_peer_01.c | 2 - .../test_case_channel_conn_01/node_sim_nut.c | 18 +++--- .../test_case_channel_conn_01/node_sim_peer.c | 2 + .../test_case_channel_conn_02/node_sim_nut.c | 17 +++-- .../test_case_channel_conn_02/node_sim_peer.c | 9 +-- .../test_case_channel_conn_03/node_sim_nut.c | 18 +++--- .../test_case_channel_conn_03/node_sim_peer.c | 3 +- .../test_case_channel_conn_04/node_sim_nut.c | 11 ++-- .../test_case_channel_conn_04/node_sim_peer.c | 4 ++ .../test_case_channel_conn_05/node_sim_nut.c | 18 +++--- .../test_case_channel_conn_05/node_sim_peer.c | 2 + .../node_sim_relay.c | 2 + .../test_case_channel_conn_06/node_sim_nut.c | 17 +++-- .../test_case_channel_conn_06/node_sim_peer.c | 9 +-- .../node_sim_relay.c | 2 + .../test_case_channel_conn_07/node_sim_nut.c | 18 +++--- .../test_case_channel_conn_07/node_sim_peer.c | 3 +- .../node_sim_relay.c | 2 + .../test_case_channel_conn_08/node_sim_nut.c | 11 ++-- .../test_case_channel_conn_08/node_sim_peer.c | 4 ++ .../node_sim_relay.c | 2 + .../test_case_meta_conn_01/node_sim_nut.c | 10 +-- .../test_case_meta_conn_01/node_sim_peer.c | 2 + .../test_case_meta_conn_01/node_sim_relay.c | 2 + .../test_case_meta_conn_01/test/node_step.sh | 25 ++++++++ .../test_case_meta_conn_02/node_sim_nut.c | 10 +-- .../test_case_meta_conn_02/node_sim_peer.c | 2 + .../test_case_meta_conn_02/node_sim_relay.c | 2 + .../test_case_meta_conn_03/node_sim_nut.c | 8 ++- .../test_case_meta_conn_03/node_sim_peer.c | 2 + .../test_case_meta_conn_03/node_sim_relay.c | 2 + .../test_case_meta_conn_04/node_sim_nut.c | 12 ++-- .../test_case_meta_conn_04/node_sim_peer.c | 2 + .../test_case_meta_conn_04/node_sim_relay.c | 2 + .../test_case_meta_conn_05/node_sim_nut.c | 12 ++-- .../test_case_meta_conn_05/node_sim_peer.c | 2 + .../test_case_meta_conn_05/node_sim_relay.c | 2 + .../test_case_optimal_pmtu_01/node_sim_nut.c | 27 ++------ .../test_case_optimal_pmtu_01/node_sim_peer.c | 8 --- .../test_cases_submesh01/node_sim_app1node1.c | 13 ++-- .../test_cases_submesh01/node_sim_app1node2.c | 15 +++-- .../test_cases_submesh01/node_sim_app2node1.c | 13 ++-- .../test_cases_submesh01/node_sim_app2node2.c | 15 +++-- .../test_cases_submesh01/node_sim_corenode1.c | 20 +++--- .../test_cases_submesh01/node_sim_corenode2.c | 15 +++-- .../test_cases_submesh02/node_sim_app1node1.c | 13 ++-- .../test_cases_submesh02/node_sim_app1node2.c | 15 +++-- .../test_cases_submesh02/node_sim_app2node1.c | 13 ++-- .../test_cases_submesh02/node_sim_app2node2.c | 15 +++-- .../test_cases_submesh02/node_sim_corenode1.c | 20 +++--- .../test_cases_submesh02/node_sim_corenode2.c | 15 +++-- .../test_cases_submesh03/node_sim_app1node1.c | 13 ++-- .../test_cases_submesh03/node_sim_app1node2.c | 13 +++- .../test_cases_submesh03/node_sim_corenode1.c | 22 ++++--- .../test_cases_submesh04/node_sim_app1node1.c | 13 ++-- .../test_cases_submesh04/node_sim_app1node2.c | 14 ++-- .../test_cases_submesh04/node_sim_corenode1.c | 22 ++++--- test/import-export.c | 1 + test/invite-join.c | 1 + 106 files changed, 638 insertions(+), 489 deletions(-) create mode 100755 test/blackbox/test_case_meta_conn_01/test/node_step.sh diff --git a/configure.ac b/configure.ac index bc3d27fd..48694a70 100644 --- a/configure.ac +++ b/configure.ac @@ -57,7 +57,7 @@ dnl No -fstack-protector-all because it doesn't work on all platforms or archite AC_ARG_ENABLE([hardening], AS_HELP_STRING([--disable-hardening], [disable compiler and linker hardening flags])) AS_IF([test "x$enable_hardening" != "xno"], - [CPPFLAGS="$CPPFLAGS -W -pedantic" + [CPPFLAGS="$CPPFLAGS -Wall -W -pedantic" AX_CHECK_COMPILE_FLAG([-DFORTIFY_SOURCE=2], [CPPFLAGS="$CPPFLAGS -DFORITFY_SOURCE=2"]) AX_CHECK_COMPILE_FLAG([-fwrapv], [CPPFLAGS="$CPPFLAGS -fwrapv"], [AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CPPFLAGS="$CPPFLAGS -fno-strict-overflow"])] diff --git a/test/basic.c b/test/basic.c index 15bf7bf8..33d92974 100644 --- a/test/basic.c +++ b/test/basic.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "meshlink.h" diff --git a/test/blackbox/common/common_handlers.c b/test/blackbox/common/common_handlers.c index ad32a223..134fcc9f 100644 --- a/test/blackbox/common/common_handlers.c +++ b/test/blackbox/common/common_handlers.c @@ -53,7 +53,8 @@ static int meshlink_get_node_in_container(const char *name) { return -1; } -void mesh_close_signal_handler(int a) { +void mesh_close_signal_handler(int signum) { + (void)signum; test_running = false; exit(EXIT_SUCCESS); diff --git a/test/blackbox/common/containers.c b/test/blackbox/common/containers.c index ba4b393e..f99abde5 100644 --- a/test/blackbox/common/containers.c +++ b/test/blackbox/common/containers.c @@ -54,7 +54,7 @@ void rename_container(const char *old_name, const char *new_name) { struct lxc_container *old_container; /* Stop the old container if its still running */ - assert(old_container = find_container(old_name)); + assert((old_container = find_container(old_name))); old_container->shutdown(old_container, CONTAINER_SHUTDOWN_TIMEOUT); /* Call stop() in case shutdown() fails - one of these two will always succeed */ old_container->stop(old_container); @@ -77,7 +77,7 @@ char *run_in_container(const char *cmd, const char *container_name, bool daemoni assert(container_name); assert(snprintf(container_find_name, sizeof(container_find_name), "%s_%s", state_ptr->test_case_name, container_name) >= 0); - assert(container = find_container(container_find_name)); + assert((container = find_container(container_find_name))); return run_in_container_ex(cmd, container, daemonize); } @@ -87,7 +87,7 @@ char *execute_in_container(const char *cmd, const char *container_name, bool dae assert(cmd); assert(container_name); - assert(container = find_container(container_name)); + assert((container = find_container(container_name))); return run_in_container_ex(cmd, container, daemonize); } @@ -133,7 +133,7 @@ char *run_in_container_ex(const char *cmd, struct lxc_container *container, bool "%s/" LXC_UTIL_REL_PATH "/" LXC_RUN_SCRIPT " \"%s\" %s", meshlink_root_path, cmd, container->name) >= 0); FILE *attach_fp; - assert(attach_fp = popen(attach_command, "r")); + assert((attach_fp = popen(attach_command, "r"))); free(attach_command); /* If the command has an output, strip out any trailing carriage returns or newlines and return it, otherwise return NULL */ @@ -184,17 +184,17 @@ char *container_wait_ip_ex(const char *container_name) { int timeout; FILE *lxcls_fp; - assert(test_container = find_container(container_name)); + assert((test_container = find_container(container_name))); assert(snprintf(lxcls_command, sizeof(lxcls_command), "lxc-ls -f | grep %s | tr -s ' ' | cut -d ' ' -f 5", test_container->name) >= 0); PRINT_TEST_CASE_MSG("Waiting for Container '%s' to acquire IP\n", test_container->name); - assert(ip = malloc(20)); + assert((ip = malloc(20))); ip_len = sizeof(ip); ip_found = false; timeout = 60; while(!ip_found && timeout) { - assert(lxcls_fp = popen(lxcls_command, "r")); // Run command + assert((lxcls_fp = popen(lxcls_command, "r"))); // Run command assert(getline((char **)&ip, &ip_len, lxcls_fp) != -1); // Read its output /* Strip newlines and carriage returns from output */ i = strlen(ip) - 1; @@ -229,7 +229,7 @@ void create_containers(const char *node_names[], int num_nodes) { /* If this is the first Container, create it otherwise restore the snapshot saved for the first Container to create an additional Container */ if(i == 0) { - assert(first_container = lxc_container_new(container_name, NULL)); + assert((first_container = lxc_container_new(container_name, NULL))); assert(!first_container->is_defined(first_container)); create_status = first_container->createl(first_container, "download", NULL, NULL, LXC_CREATE_QUIET, "-d", "ubuntu", "-r", "trusty", "-a", choose_arch, NULL); @@ -256,7 +256,7 @@ void create_containers(const char *node_names[], int num_nodes) { after setting the state of the test case to an instance of black_box_state_t */ void setup_containers(void **state) { black_box_state_t *test_state = (black_box_state_t *)(*state); - int i, confbase_del_status; + int i; char build_command[200]; struct lxc_container *test_container, *new_container; char container_find_name[100]; @@ -271,7 +271,7 @@ void setup_containers(void **state) { test_state->node_names[i]) >= 0); if(!(test_container = find_container(container_find_name))) { - assert(test_container = lxc_container_new(container_find_name, NULL)); + assert((test_container = lxc_container_new(container_find_name, NULL))); assert(!test_container->is_defined(test_container)); create_status = test_container->createl(test_container, "download", NULL, NULL, LXC_CREATE_QUIET, "-d", "ubuntu", "-r", "trusty", "-a", choose_arch, NULL); @@ -292,7 +292,7 @@ void setup_containers(void **state) { if(!(new_container = find_container(container_new_name))) { rename_container(test_container->name, container_new_name); - assert(new_container = find_container(container_new_name)); + assert((new_container = find_container(container_new_name))); } /* Start the Container */ @@ -353,7 +353,7 @@ void restart_all_containers(void) { /* Shutdown, then start the Container, then wait for it to acquire an IP Address */ assert(snprintf(container_name, sizeof(container_name), "%s_%s", state_ptr->test_case_name, state_ptr->node_names[i]) >= 0); - assert(test_container = find_container(container_name)); + assert((test_container = find_container(container_name))); test_container->shutdown(test_container, CONTAINER_SHUTDOWN_TIMEOUT); test_container->stop(test_container); test_container->start(test_container, 0, NULL); @@ -370,7 +370,7 @@ char *invite_in_container(const char *inviter, const char *invitee) { assert(snprintf(invite_command, sizeof(invite_command), "LD_LIBRARY_PATH=/home/ubuntu/test/.libs /home/ubuntu/test/gen_invite %s %s " "2> gen_invite.log", inviter, invitee) >= 0); - assert(invite_url = run_in_container(invite_command, inviter, false)); + assert((invite_url = run_in_container(invite_command, inviter, false))); PRINT_TEST_CASE_MSG("Invite Generated from '%s' to '%s': %s\n", inviter, invitee, invite_url); @@ -387,7 +387,7 @@ char *submesh_invite_in_container(const char *inviter, const char *invitee, cons assert(snprintf(invite_command, sizeof(invite_command), "LD_LIBRARY_PATH=/home/ubuntu/test/.libs /home/ubuntu/test/gen_invite %s %s %s " "2> gen_invite.log", inviter, invitee, submesh) >= 0); - assert(invite_url = run_in_container(invite_command, inviter, false)); + assert((invite_url = run_in_container(invite_command, inviter, false))); PRINT_TEST_CASE_MSG("Invite Generated from '%s' to '%s': %s\n", inviter, invitee, invite_url); @@ -449,7 +449,7 @@ void node_step_in_container(const char *node, const char *sig) { Changes begin from X.X.X.254 and continue iteratively till an available address is found */ void change_ip(int node) { char *gateway_addr; - char new_ip[20]; + char new_ip[20] = ""; char *netmask; char *last_dot_in_ip; int last_ip_byte = 254; @@ -461,14 +461,14 @@ void change_ip(int node) { /* Get IP Address of LXC Bridge Interface - this will be set up as the Gateway Address of the Static IP assigned to the Container */ - assert(gateway_addr = get_ip(lxc_bridge)); + assert((gateway_addr = get_ip(lxc_bridge))); /* Get Netmask of LXC Brdige Interface */ - assert(netmask = get_netmask(lxc_bridge)); + assert((netmask = get_netmask(lxc_bridge))); /* Replace last byte of Container's IP with 254 to form the new Container IP */ assert(container_ips[node]); - strncpy(new_ip, container_ips[node], sizeof(new_ip)); - assert(last_dot_in_ip = strrchr(new_ip, '.')); + strncpy(new_ip, container_ips[node], sizeof(new_ip) - 1); + assert((last_dot_in_ip = strrchr(new_ip, '.'))); assert(snprintf(last_dot_in_ip + 1, 4, "%d", last_ip_byte) >= 0); /* Check that the new IP does not match the Container's existing IP @@ -480,7 +480,7 @@ void change_ip(int node) { } /* Create new 'interfaces' file for Container */ - assert(if_fp = fopen("interfaces", "w")); + assert((if_fp = fopen("interfaces", "w"))); fprintf(if_fp, "auto lo\n"); fprintf(if_fp, "iface lo inet loopback\n"); fprintf(if_fp, "\n"); @@ -503,14 +503,14 @@ void change_ip(int node) { /* Restart Container to apply new IP Address */ assert(snprintf(container_name, sizeof(container_name), "%s_%s", state_ptr->test_case_name, state_ptr->node_names[node]) >= 0); - assert(container = find_container(container_name)); + assert((container = find_container(container_name))); container->shutdown(container, CONTAINER_SHUTDOWN_TIMEOUT); /* Call stop() in case shutdown() fails One of these two calls with always succeed */ container->stop(container); assert(container->start(container, 0, NULL)); - strncpy(container_ips[node], new_ip, sizeof(new_ip)); // Save the new IP Address + strncpy(container_ips[node], new_ip, sizeof(container_ips[node])); // Save the new IP Address PRINT_TEST_CASE_MSG("Node '%s' IP Address changed to %s\n", state_ptr->node_names[node], container_ips[node]); } @@ -545,15 +545,14 @@ void install_in_container(const char *node, const char *app) { assert(snprintf(install_cmd, sizeof(install_cmd), "apt-get install %s -y >> /dev/null", app) >= 0); - char *ret = run_in_container(install_cmd, node, false); + run_in_container(install_cmd, node, false); // TODO: Check in container whether app has installed or not with a timeout sleep(10); } /* Return container's IP address */ char *get_container_ip(const char *node_name) { - char *ip; - int n, node = -1, i; + int node = -1, i; for(i = 0; i < state_ptr->num_nodes; i++) { if(!strcasecmp(state_ptr->node_names[i], node_name)) { @@ -566,10 +565,8 @@ char *get_container_ip(const char *node_name) { return NULL; } - n = strlen(container_ips[node]) + 1; - ip = malloc(n); + char *ip = strdup(container_ips[node]); assert(ip); - strncpy(ip, container_ips[node], n); return ip; } @@ -659,7 +656,6 @@ void flush_nat_rules(const char *container_name, const char *chain) { void add_full_cone_nat_rules(const char *container_name, const char *pub_interface, const char *priv_interface_listen_address) { char nat_cmd[500]; - char *ret; char **pub_interface_ips = get_container_interface_ips(container_name, pub_interface); assert(pub_interface_ips[0]); @@ -675,6 +671,8 @@ void add_full_cone_nat_rules(const char *container_name, const char *pub_interfa /* Create a NAT and a bridge, bridge connected to NAT and containers to be NATed can be switched to the NAT bridge from lxcbr0 */ void nat_create(const char *nat_name, const char *nat_bridge, int nat_type) { + (void)nat_type; + char build_command[200]; assert(snprintf(build_command, sizeof(build_command), "%s/" LXC_UTIL_REL_PATH "/" LXC_NAT_BUILD " %s %s %s >/dev/stderr", @@ -710,7 +708,6 @@ void container_switch_bridge(const char *container_name, char *lxc_conf_path, co FILE *fp_temp = fopen(".temp_file", "w"); assert(fp_temp); - char search_str[500]; int net_no; while((fgets(buffer, sizeof(buffer), fp)) != NULL) { @@ -798,7 +795,6 @@ void add_veth_pair(const char *vethName1, const char *vethName2) { /* Bring the interface up for the bridge created */ void bring_if_up(const char *bridgeName) { char command[300] = "ifconfig "; - char dhcommand[300] = "dhclient "; strcat(command, bridgeName); strcat(command, " up"); int if_up_status = system(command); @@ -913,7 +909,7 @@ void create_container_on_bridge(const char *containerName, const char *bridgeNam int container_create_status = system(command); assert(container_create_status == 0); sleep(3); - assert(fPtr = fopen(path, "a+")); + assert((fPtr = fopen(path, "a+"))); fprintf(fPtr, "lxc.net.0.name = eth0\n"); fprintf(fPtr, "\n"); fprintf(fPtr, "lxc.net.1.type = veth\n"); @@ -989,8 +985,8 @@ void config_nat(const char *containerName, const char *listenAddress) { char *last_dot_in_ip; int last_ip_byte = 0; char new_ip[300] = {0}; - strncpy(new_ip, listenAddress, sizeof(new_ip)); - assert(last_dot_in_ip = strrchr(new_ip, '.')); + strncpy(new_ip, listenAddress, sizeof(new_ip) - 1); + assert((last_dot_in_ip = strrchr(new_ip, '.'))); assert(snprintf(last_dot_in_ip + 1, 4, "%d", last_ip_byte) >= 0); char comd[300] = "echo \"iptables -t nat -A POSTROUTING -s "; strcat(comd, new_ip); diff --git a/test/blackbox/common/mesh_event_handler.c b/test/blackbox/common/mesh_event_handler.c index bb5faf1c..84ae63dd 100644 --- a/test/blackbox/common/mesh_event_handler.c +++ b/test/blackbox/common/mesh_event_handler.c @@ -83,6 +83,7 @@ static bool wait_cond_flag(struct cond_flag *s, int seconds) { // event_receive_handler running in a separate thread queues all the events received from the UDP port static void *event_receive_handler(void *arg) { + (void)arg; size_t recv_ret; char udp_buff[UDP_BUFF_MAX]; struct sockaddr client; @@ -120,7 +121,7 @@ static void *event_handler(void *argv) { bool callback_return = false; void *data; mesh_event_payload_t mesh_event_rec_packet; - mesh_event_callback_t callback = (mesh_event_callback_t)argv; + mesh_event_callback_t callback = *(mesh_event_callback_t *)argv; while(event_handle_thread_running) { @@ -173,7 +174,7 @@ char *mesh_event_sock_create(const char *if_name) { server.sin_port = htons(atoi(SERVER_LISTEN_PORT)); assert(bind(server_fd, (struct sockaddr *) &server, sizeof(struct sockaddr)) != -1); - assert(ip = malloc(30)); + assert((ip = malloc(30))); strncpy(ip, inet_ntoa(resp_if_addr->sin_addr), 20); strcat(ip, ":"); strcat(ip, SERVER_LISTEN_PORT); @@ -255,7 +256,7 @@ bool wait_for_event(mesh_event_callback_t callback, int seconds) { } set_cond_flag(&sync_event, false); - assert(!pthread_create(&event_handle_thread, NULL, event_handler, (void *)callback)); + assert(!pthread_create(&event_handle_thread, NULL, event_handler, (void *)&callback)); bool wait_ret = wait_cond_flag(&sync_event, seconds); event_handle_thread_running = false; pthread_cancel(event_handle_thread); @@ -279,4 +280,4 @@ void mesh_event_destroy(void) { mesh_events_flush(); event_receive_thread_running = false; pthread_cancel(event_receive_thread); -} \ No newline at end of file +} diff --git a/test/blackbox/common/network_namespace_framework.c b/test/blackbox/common/network_namespace_framework.c index 1c39bccc..8f652960 100644 --- a/test/blackbox/common/network_namespace_framework.c +++ b/test/blackbox/common/network_namespace_framework.c @@ -70,8 +70,9 @@ static int netns_delete_namespace(namespace_t *namespace_handle) { /* Create new network namespace using namespace handle */ static void netns_create_namespace(netns_state_t *test_state, namespace_t *namespace_handle) { + (void)test_state; + char cmd[200]; - int cmd_ret; // Add the network namespace @@ -83,8 +84,9 @@ static void netns_create_namespace(netns_state_t *test_state, namespace_t *names } static void netns_create_bridge(netns_state_t *test_state, namespace_t *namespace_handle) { + (void)test_state; + char cmd[200]; - int cmd_ret; sprintf(cmd, "ip link add name %s type bridge", namespace_handle->name); assert(system(cmd) == 0); @@ -94,6 +96,8 @@ static void netns_create_bridge(netns_state_t *test_state, namespace_t *namespac } interface_t *get_peer_interface_handle(netns_state_t *test_state, namespace_t *namespace, namespace_t *peer_namespace) { + (void)test_state; + int i; interface_t *interfaces = namespace->interfaces; int if_no = namespace->interfaces_no; @@ -126,8 +130,8 @@ bool check_interfaces_visited(netns_state_t *test_state, namespace_t *ns1, names } void netns_connect_namespaces(netns_state_t *test_state, namespace_t *ns1, namespace_t *ns2) { - char buff[20], cmd[200], ns_eth0[20], ns_peer0[20]; - int cmd_ret, if_no, i; + char buff[20], cmd[200]; + int i; char eth_pairs[2][20]; namespace_t *ns[2] = { ns1, ns2 }; interface_t *interface; @@ -144,7 +148,7 @@ void netns_connect_namespaces(netns_state_t *test_state, namespace_t *ns1, names // Delete veth pair if already exists for(i = 0; i < 2; i++) { assert(sprintf(cmd, "ip link del %s 2>/dev/null", eth_pairs[i]) >= 0); - cmd_ret = system(cmd); + system(cmd); } // Create veth pair @@ -193,7 +197,7 @@ void netns_connect_namespaces(netns_state_t *test_state, namespace_t *ns1, names } void netns_configure_ip_address(netns_state_t *test_state) { - int i, if_no, cmd_ret; + int i, if_no; namespace_t *namespace; interface_t *if_handle; char cmd[200]; @@ -262,9 +266,8 @@ void netns_enable_all_nats(netns_state_t *test_state) { } void netns_create_all_namespaces(netns_state_t *test_state) { - int i, j; - namespace_t *namespace, *peer_namespace; - interface_t *interfaces; + int i; + namespace_t *namespace; for(i = 0; i < test_state->num_namespaces; i++) { namespace = get_namespace_handle_by_index(test_state, i); @@ -330,7 +333,7 @@ void increment_ipv4_cidr_str(char *ip) { char *ptr = strchr(ip, '/'); *ptr = '\0'; increment_ipv4_str(ip, INET6_ADDRSTRLEN); - sprintf(ip, "%s/%d", ip, subnet); + sprintf(ip + strlen(ip), "/%d", subnet); } interface_t *netns_get_priv_addr(netns_state_t *test_state, const char *namespace_name) { @@ -384,9 +387,7 @@ void netns_add_default_route_addr(netns_state_t *test_state) { void netns_assign_ip_addresses(netns_state_t *test_state) { int ns, j; namespace_t *namespace_handle; - interface_t *interface_handle, *peer_interface_handle; - int sub_net; - + interface_t *interface_handle; char *addr = malloc(INET6_ADDRSTRLEN); assert(addr); diff --git a/test/blackbox/common/tcpdump.c b/test/blackbox/common/tcpdump.c index 422c397e..f33412de 100644 --- a/test/blackbox/common/tcpdump.c +++ b/test/blackbox/common/tcpdump.c @@ -17,25 +17,28 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ + #include #include #include #include #include +#include #include #include #include "common_handlers.h" #include "tcpdump.h" pid_t tcpdump_start(char *interface) { - pid_t tcpdump_pid; char *argv[] = { "tcpdump", "-i", interface, NULL }; // child process have a pipe to the parent process when parent process terminates SIGPIPE kills the tcpdump int pipes[2]; assert(pipe(pipes) != -1); PRINT_TEST_CASE_MSG("\x1b[32mLaunching TCP Dump ..\x1b[0m\n"); - if((tcpdump_pid = fork()) == 0) { + pid_t tcpdump_pid = fork(); + + if(tcpdump_pid == 0) { prctl(PR_SET_PDEATHSIG, SIGHUP); close(pipes[1]); // Open log file for TCP Dump @@ -45,13 +48,14 @@ pid_t tcpdump_start(char *interface) { assert(dup2(fd, STDOUT_FILENO) != -1); // Launch TCPDump with port numbers of sleepy, gateway & relay - int ret = execvp("/usr/sbin/tcpdump", argv); + execvp("/usr/sbin/tcpdump", argv); perror("execvp "); - assert(ret != -1); + exit(1); } else { close(pipes[0]); - return tcpdump_pid; } + + return tcpdump_pid; } void tcpdump_stop(pid_t tcpdump_pid) { diff --git a/test/blackbox/common/test_step.c b/test/blackbox/common/test_step.c index be0416d9..cda13150 100644 --- a/test/blackbox/common/test_step.c +++ b/test/blackbox/common/test_step.c @@ -89,18 +89,16 @@ void execute_close(void) { void execute_change_ip(void) { char *eth_if_ip; int last_byte; - char new_ip[20], gateway_ip[20]; + char new_ip[20] = "", gateway_ip[20] = ""; char *last_dot_in_ip; char *eth_if_netmask; - char route_chg_command[200]; - int route_chg_status; /* Get existing IP Address of Ethernet Bridge Interface */ - assert(eth_if_ip = get_ip(eth_if_name)); + assert((eth_if_ip = get_ip(eth_if_name))); /* Set new IP Address by replacing the last byte with last byte + 1 */ - strncpy(new_ip, eth_if_ip, sizeof(new_ip)); - assert(last_dot_in_ip = strrchr(new_ip, '.')); + strncpy(new_ip, eth_if_ip, sizeof(new_ip) - 1); + assert((last_dot_in_ip = strrchr(new_ip, '.'))); last_byte = atoi(last_dot_in_ip + 1); assert(snprintf(last_dot_in_ip + 1, 4, "%d", (last_byte > 253) ? 2 : (last_byte + 1)) >= 0); @@ -108,7 +106,7 @@ void execute_change_ip(void) { /* Bring the network interface down before making changes */ stop_nw_intf(eth_if_name); /* Save the netmask first, then restore it after setting the new IP Address */ - assert(eth_if_netmask = get_netmask(eth_if_name)); + assert((eth_if_netmask = get_netmask(eth_if_name))); set_ip(eth_if_name, new_ip); set_netmask(eth_if_name, eth_if_netmask); /* Bring the network interface back up again to apply changes */ @@ -116,8 +114,8 @@ void execute_change_ip(void) { /* Get Gateway's IP Address, by replacing the last byte with 1 in the current IP Address */ /* TO DO: Obtain the actual Gateway IP Address */ - strncpy(gateway_ip, eth_if_ip, sizeof(gateway_ip)); - assert(last_dot_in_ip = strrchr(gateway_ip, '.')); + strncpy(gateway_ip, eth_if_ip, sizeof(gateway_ip) - 1); + assert((last_dot_in_ip = strrchr(gateway_ip, '.'))); assert(snprintf(last_dot_in_ip + 1, 4, "%d", 1) >= 0); /* Add the default route back again, which would have been deleted when the diff --git a/test/blackbox/run_blackbox_tests/test_cases.c b/test/blackbox/run_blackbox_tests/test_cases.c index ee9171f6..7207eb60 100644 --- a/test/blackbox/run_blackbox_tests/test_cases.c +++ b/test/blackbox/run_blackbox_tests/test_cases.c @@ -85,6 +85,8 @@ static black_box_state_t test_meta_conn_5_state = { }; int black_box_group0_setup(void **state) { + (void)state; + const char *nodes[] = { "peer", "relay", "nut"}; int num_nodes = sizeof(nodes) / sizeof(nodes[0]); @@ -96,6 +98,8 @@ int black_box_group0_setup(void **state) { } int black_box_group0_teardown(void **state) { + (void)state; + PRINT_TEST_CASE_MSG("Destroying Containers\n"); destroy_containers(); @@ -103,6 +107,8 @@ int black_box_group0_teardown(void **state) { } int black_box_all_nodes_setup(void **state) { + (void)state; + const char *nodes[] = { "peer" }; int num_nodes = sizeof(nodes) / sizeof(nodes[0]); @@ -137,6 +143,9 @@ static bool meta_conn01_cb(mesh_event_payload_t payload) { case META_RECONN_SUCCESSFUL : meta_conn01_reconn = true; break; + + default: + break; } return true; @@ -161,7 +170,6 @@ static void test_case_meta_conn_01(void **state) { */ static bool test_steps_meta_conn_01(void) { char *invite_peer, *invite_nut; - int i; char *import; import = mesh_event_sock_create(eth_if_name); @@ -214,6 +222,9 @@ static bool meta_conn02_cb(mesh_event_payload_t payload) { case NODE_STARTED : fprintf(stderr, "Node started\n"); break; + + default: + break; } return true; @@ -235,7 +246,6 @@ static void test_case_meta_conn_02(void **state) { */ static bool test_steps_meta_conn_02(void) { char *invite_peer, *invite_nut; - int i; char *import; import = mesh_event_sock_create(eth_if_name); @@ -296,6 +306,9 @@ static bool meta_conn03_cb(mesh_event_payload_t payload) { fprintf(stderr, "Reconnected\n"); meta_conn03_result = true; break; + + default: + break; } return true; @@ -317,7 +330,6 @@ static void test_case_meta_conn_03(void **state) { */ static bool test_steps_meta_conn_03(void) { char *invite_peer, *invite_nut; - int i; char *import; import = mesh_event_sock_create(eth_if_name); @@ -376,6 +388,7 @@ static bool meta_conn04_cb(mesh_event_payload_t payload) { default : fprintf(stderr, "Undefined mesh event\n"); + break; } return true; @@ -460,6 +473,9 @@ static bool meta_conn05_cb(mesh_event_payload_t payload) { case NODE_STARTED : fprintf(stderr, "Node started\n"); break; + + default: + break; } return true; diff --git a/test/blackbox/run_blackbox_tests/test_cases_autoconnect.c b/test/blackbox/run_blackbox_tests/test_cases_autoconnect.c index 18991279..6be5fa13 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_autoconnect.c +++ b/test/blackbox/run_blackbox_tests/test_cases_autoconnect.c @@ -72,8 +72,6 @@ static void receive(meshlink_handle_t *mesh, meshlink_node_t *src, const void *d assert(len); } -static bool bar_reachable; - static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { (void)mesh; fprintf(stderr, "Status of node {%s} is %d\n", node->name, reachable); diff --git a/test/blackbox/run_blackbox_tests/test_cases_blacklist.c b/test/blackbox/run_blackbox_tests/test_cases_blacklist.c index 15f1131a..7324a19e 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_blacklist.c +++ b/test/blackbox/run_blackbox_tests/test_cases_blacklist.c @@ -62,6 +62,8 @@ void test_case_mesh_blacklist_01(void **state) { static bool received; static void receive(meshlink_handle_t *mesh, meshlink_node_t *src, const void *data, size_t len) { + (void)mesh; + const char *msg = data; assert(len); @@ -73,6 +75,8 @@ static void receive(meshlink_handle_t *mesh, meshlink_node_t *src, const void *d static bool bar_reachable; static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcmp(node->name, "bar") && reachable) { bar_reachable = true; } diff --git a/test/blackbox/run_blackbox_tests/test_cases_channel_blacklist.c b/test/blackbox/run_blackbox_tests/test_cases_channel_blacklist.c index d6e9d744..05594bce 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_channel_blacklist.c +++ b/test/blackbox/run_blackbox_tests/test_cases_channel_blacklist.c @@ -47,10 +47,8 @@ static mesh_arg_t peer_arg = {.node_name = "peer", .confbase = "peer", .app_name static mesh_arg_t nut_arg = {.node_name = "nut", .confbase = "nut", .app_name = "nut", .dev_class = 1 }; static mesh_invite_arg_t relay_nut_invite_arg = {.mesh_arg = &relay_arg, .invitee_name = "nut" }; static mesh_invite_arg_t relay_peer_invite_arg = {.mesh_arg = &relay_arg, .invitee_name = "peer" }; -static mesh_invite_arg_t peer_nut_invite_arg = {.mesh_arg = &peer_arg, .invitee_name = "nut" }; static netns_thread_t netns_relay_nut_invite = {.namespace_name = "relay", .netns_thread = gen_inv, .arg = &relay_nut_invite_arg}; static netns_thread_t netns_relay_peer_invite = {.namespace_name = "relay", .netns_thread = gen_inv, .arg = &relay_peer_invite_arg}; -static netns_thread_t netns_peer_nut_invite = {.namespace_name = "peer", .netns_thread = gen_inv, .arg = &peer_nut_invite_arg}; static netns_thread_t netns_relay_handle = {.namespace_name = "relay", .netns_thread = test_channel_blacklist_disonnection_relay_01, .arg = &relay_arg}; static netns_thread_t netns_peer_handle = {.namespace_name = "peer", .netns_thread = test_channel_blacklist_disonnection_peer_01, .arg = &peer_arg}; static netns_thread_t netns_nut_handle = {.namespace_name = "nut", .netns_thread = test_channel_blacklist_disonnection_nut_01, .arg = &nut_arg}; @@ -58,6 +56,8 @@ static netns_thread_t netns_nut_handle = {.namespace_name = "nut", .netns_thread struct sync_flag test_channel_discon_nut_close = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static int setup_test(void **state) { + (void)state; + netns_create_topology(test_channel_disconnection_state); fprintf(stderr, "\nCreated topology\n"); @@ -74,6 +74,8 @@ static int setup_test(void **state) { } static int teardown_test(void **state) { + (void)state; + meshlink_destroy("nut"); meshlink_destroy("peer"); meshlink_destroy("relay"); @@ -83,6 +85,8 @@ static int teardown_test(void **state) { } 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(); @@ -102,6 +106,8 @@ static void *gen_inv(void *arg) { assert(invitation); mesh_invite_arg->invite_str = invitation; meshlink_close(mesh); + + return NULL; } static void launch_3_nodes(void) { diff --git a/test/blackbox/run_blackbox_tests/test_cases_channel_close.c b/test/blackbox/run_blackbox_tests/test_cases_channel_close.c index bc32256d..6017da2c 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_channel_close.c +++ b/test/blackbox/run_blackbox_tests/test_cases_channel_close.c @@ -52,11 +52,6 @@ static void test_case_mesh_channel_close_01(void **state) { /* Test Steps for meshlink_channel_close Test Case # 1*/ static bool test_steps_mesh_channel_close_01(void) { - bool result = false; - char *msg = NULL; - char buf[] = "bar"; - msg = buf; - size_t len = sizeof(buf); meshlink_destroy("chan_close_conf.3"); meshlink_destroy("chan_close_conf.4"); diff --git a/test/blackbox/run_blackbox_tests/test_cases_channel_conn.c b/test/blackbox/run_blackbox_tests/test_cases_channel_conn.c index bbe2948f..4d497e66 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_channel_conn.c +++ b/test/blackbox/run_blackbox_tests/test_cases_channel_conn.c @@ -752,6 +752,8 @@ static bool test_steps_channel_conn_08(void) { } static int black_box_group_setup(void **state) { + (void)state; + const char *nodes[] = { "peer", "nut", "relay" }; int num_nodes = sizeof(nodes) / sizeof(nodes[0]); @@ -763,6 +765,8 @@ static int black_box_group_setup(void **state) { } static int black_box_group_teardown(void **state) { + (void)state; + printf("Destroying Containers\n"); destroy_containers(); @@ -772,21 +776,21 @@ static int black_box_group_teardown(void **state) { int test_meshlink_channel_conn(void) { const struct CMUnitTest blackbox_group0_tests[] = { cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_01, setup_test, teardown_test, - (void *)&test_case_channel_conn_01_state),/* - cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_02, setup_test, teardown_test, - (void *)&test_case_channel_conn_02_state), - cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_03, setup_test, teardown_test, - (void *)&test_case_channel_conn_03_state), - cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_04, setup_test, teardown_test, - (void *)&test_case_channel_conn_04_state), - cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_05, setup_test, teardown_test, - (void *)&test_case_channel_conn_05_state), - cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_06, setup_test, teardown_test, - (void *)&test_case_channel_conn_06_state), - cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_07, setup_test, teardown_test, - (void *)&test_case_channel_conn_07_state), - cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_08, setup_test, teardown_test, - (void *)&test_case_channel_conn_08_state)*/ + (void *)&test_case_channel_conn_01_state), + cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_02, setup_test, teardown_test, + (void *)&test_case_channel_conn_02_state), + cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_03, setup_test, teardown_test, + (void *)&test_case_channel_conn_03_state), + cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_04, setup_test, teardown_test, + (void *)&test_case_channel_conn_04_state), + cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_05, setup_test, teardown_test, + (void *)&test_case_channel_conn_05_state), + cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_06, setup_test, teardown_test, + (void *)&test_case_channel_conn_06_state), + cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_07, setup_test, teardown_test, + (void *)&test_case_channel_conn_07_state), + cmocka_unit_test_prestate_setup_teardown(test_case_channel_conn_08, setup_test, teardown_test, + (void *)&test_case_channel_conn_08_state), }; total_tests += sizeof(blackbox_group0_tests) / sizeof(blackbox_group0_tests[0]); diff --git a/test/blackbox/run_blackbox_tests/test_cases_channel_ex.c b/test/blackbox/run_blackbox_tests/test_cases_channel_ex.c index aa6fa23d..dc626c89 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_channel_ex.c +++ b/test/blackbox/run_blackbox_tests/test_cases_channel_ex.c @@ -73,10 +73,6 @@ static black_box_state_t test_case_channel_ex_05_state = { static black_box_state_t test_case_channel_ex_06_state = { .test_case_name = "test_case_channel_ex_06", }; -static black_box_state_t test_case_channel_ex_07_state = { - .test_case_name = "test_case_channel_ex_07", -}; - /* mutex for the common variable */ static pthread_mutex_t accept_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t accept_cond = PTHREAD_COND_INITIALIZER; @@ -94,9 +90,11 @@ static void cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void } static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len) { + (void)mesh; + (void)channel; (void)dat; (void)len; - char *data = (char *) dat; + assert_int_equal(port, PORT); pthread_mutex_lock(&accept_lock); diff --git a/test/blackbox/run_blackbox_tests/test_cases_channel_get_flags.c b/test/blackbox/run_blackbox_tests/test_cases_channel_get_flags.c index 266b3150..f83c39f5 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_channel_get_flags.c +++ b/test/blackbox/run_blackbox_tests/test_cases_channel_get_flags.c @@ -43,16 +43,14 @@ static bool test_steps_channel_get_flags_03(void); static black_box_state_t test_case_channel_get_flags_01_state = { .test_case_name = "test_case_channel_get_flags_01", }; + static black_box_state_t test_case_channel_get_flags_02_state = { .test_case_name = "test_case_channel_get_flags_02", }; + static black_box_state_t test_case_channel_get_flags_03_state = { .test_case_name = "test_case_channel_get_flags_03", }; -static black_box_state_t test_case_channel_get_flags_04_state = { - .test_case_name = "test_case_channel_get_flags_04", -}; - /* Execute meshlink_channel_get_flags Test Case # 1 - Valid case*/ static void test_case_channel_get_flags_01(void **state) { diff --git a/test/blackbox/run_blackbox_tests/test_cases_channel_open.c b/test/blackbox/run_blackbox_tests/test_cases_channel_open.c index 0d5728f6..289f2eca 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_channel_open.c +++ b/test/blackbox/run_blackbox_tests/test_cases_channel_open.c @@ -63,11 +63,6 @@ static void test_case_mesh_channel_open_01(void **state) { execute_test(test_steps_mesh_channel_open_01, state); } -static void receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *data, size_t len) { - (void)mesh; - (void)channel; -} - /* Test Steps for meshlink_channel_open Test Case # 1 Test Steps: @@ -106,7 +101,7 @@ static bool test_steps_mesh_channel_open_01(void) { // Open a channel from foo to bar. meshlink_node_t *bar = meshlink_get_node(mesh1, "bar"); assert(bar != NULL); - meshlink_channel_t *channel = meshlink_channel_open(mesh1, bar, 7000, receive_cb, NULL, 0); + meshlink_channel_t *channel = meshlink_channel_open(mesh1, bar, 7000, NULL, NULL, 0); assert_int_not_equal(channel, NULL); // Clean up. diff --git a/test/blackbox/run_blackbox_tests/test_cases_channel_send.c b/test/blackbox/run_blackbox_tests/test_cases_channel_send.c index 651e16ed..1e30739e 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_channel_send.c +++ b/test/blackbox/run_blackbox_tests/test_cases_channel_send.c @@ -101,6 +101,8 @@ static bool reject_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint } static bool accept_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) { + (void)data; + assert(port == 7); assert(!len); @@ -111,6 +113,9 @@ static bool accept_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint /* channel receive callback */ static void receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + (void)channel; + if(len == 5 && !memcmp(dat, "Hello", 5)) { pthread_mutex_lock(& bar_responded_lock); bar_responded = true; @@ -268,7 +273,6 @@ static void test_case_mesh_channel_send_03(void **state) { /* Test Steps for meshlink_channel_send Test Case # 3*/ static bool test_steps_mesh_channel_send_03(void) { - struct timespec timeout = {0}; meshlink_destroy("chan_send_conf.7"); // Open new meshlink instance. diff --git a/test/blackbox/run_blackbox_tests/test_cases_channel_set_accept_cb.c b/test/blackbox/run_blackbox_tests/test_cases_channel_set_accept_cb.c index 77d2c9cf..c8e4cbcc 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_channel_set_accept_cb.c +++ b/test/blackbox/run_blackbox_tests/test_cases_channel_set_accept_cb.c @@ -43,18 +43,15 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, static bool channel_reject(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len); static bool channel_acc; -static bool channel_rej; static bool polled; static bool rejected; /* mutex for the common variable */ static pthread_mutex_t accept_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_mutex_t reject_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t poll_lock = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t lock_receive = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t accept_cond = PTHREAD_COND_INITIALIZER; -static pthread_cond_t reject_cond = PTHREAD_COND_INITIALIZER; static pthread_cond_t poll_cond = PTHREAD_COND_INITIALIZER; static pthread_cond_t receive_cond = PTHREAD_COND_INITIALIZER; @@ -67,12 +64,16 @@ static black_box_state_t test_case_channel_set_accept_cb_02_state = { /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + (void)channel; + (void)dat; + if(!len) { if(!meshlink_errno) { - pthread_mutex_lock(& lock_receive); + pthread_mutex_lock(&lock_receive); rejected = true; assert(!pthread_cond_broadcast(&receive_cond)); - pthread_mutex_unlock(& lock_receive); + pthread_mutex_unlock(&lock_receive); } } } @@ -88,9 +89,11 @@ static bool channel_reject(meshlink_handle_t *mesh, meshlink_channel_t *channel, } static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len) { + (void)mesh; + (void)channel; (void)dat; (void)len; - char *data = (char *) dat; + assert_int_equal(port, PORT); pthread_mutex_lock(&accept_lock); diff --git a/test/blackbox/run_blackbox_tests/test_cases_channel_set_poll_cb.c b/test/blackbox/run_blackbox_tests/test_cases_channel_set_poll_cb.c index 5e1d63ed..33ce2473 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_channel_set_poll_cb.c +++ b/test/blackbox/run_blackbox_tests/test_cases_channel_set_poll_cb.c @@ -80,6 +80,13 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *source, bool reach) { + (void)mesh; + (void)source; + + if(!reach) { + return; + } + pthread_mutex_lock(&reachable_lock); reachable = true; assert(!pthread_cond_broadcast(&reachable_cond)); diff --git a/test/blackbox/run_blackbox_tests/test_cases_channel_set_receive_cb.c b/test/blackbox/run_blackbox_tests/test_cases_channel_set_receive_cb.c index d1854428..2986b3af 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_channel_set_receive_cb.c +++ b/test/blackbox/run_blackbox_tests/test_cases_channel_set_receive_cb.c @@ -45,11 +45,6 @@ static void test_case_set_channel_receive_cb_02(void **state); static bool test_steps_set_channel_receive_cb_02(void); static void test_case_set_channel_receive_cb_03(void **state); static bool test_steps_set_channel_receive_cb_03(void); -static void test_case_set_channel_receive_cb_04(void **state); -static bool test_steps_set_channel_receive_cb_04(void); - -static void channel_poll(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len); -static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len); static bool rec_stat = false; static bool accept_stat = false; @@ -63,18 +58,22 @@ static pthread_cond_t receive_cond = PTHREAD_COND_INITIALIZER; static black_box_state_t test_case_channel_set_receive_cb_01_state = { .test_case_name = "test_case_channel_set_receive_cb_01", }; + static black_box_state_t test_case_channel_set_receive_cb_02_state = { .test_case_name = "test_case_channel_set_receive_cb_02", }; + static black_box_state_t test_case_channel_set_receive_cb_03_state = { .test_case_name = "test_case_channel_set_receive_cb_03", }; -static black_box_state_t test_case_channel_set_receive_cb_04_state = { - .test_case_name = "test_case_channel_set_receive_cb_04", -}; /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + (void)channel; + (void)dat; + (void)len; + pthread_mutex_lock(& lock_receive); rec_stat = true; assert(!pthread_cond_broadcast(&receive_cond)); @@ -82,6 +81,10 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } static bool accept_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) { + (void)port; + (void)data; + (void)len; + meshlink_set_channel_receive_cb(mesh, channel, channel_receive_cb); pthread_mutex_lock(& lock_accept); diff --git a/test/blackbox/run_blackbox_tests/test_cases_channel_shutdown.c b/test/blackbox/run_blackbox_tests/test_cases_channel_shutdown.c index f17266fb..b344df52 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_channel_shutdown.c +++ b/test/blackbox/run_blackbox_tests/test_cases_channel_shutdown.c @@ -39,13 +39,8 @@ static void test_case_mesh_channel_shutdown_02(void **state); static bool test_steps_mesh_channel_shutdown_02(void); static void test_case_mesh_channel_shutdown_03(void **state); static bool test_steps_mesh_channel_shutdown_03(void); -static void test_case_mesh_channel_shutdown_04(void **state); -static bool test_steps_mesh_channel_shutdown_04(void); -static void test_case_mesh_channel_shutdown_05(void **state); -static bool test_steps_mesh_channel_shutdown_05(void); static void receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len); -static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable); static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len); /* State structure for meshlink_channel_shutdown Test Case #1 */ @@ -63,16 +58,6 @@ static black_box_state_t test_mesh_channel_shutdown_03_state = { .test_case_name = "test_case_mesh_channel_shutdown_03", }; -/* State structure for meshlink_channel_shutdown Test Case #4 */ -static black_box_state_t test_mesh_channel_shutdown_04_state = { - .test_case_name = "test_case_mesh_channel_shutdown_04", -}; - -/* State structure for meshlink_channel_shutdown Test Case #5 */ -static black_box_state_t test_mesh_channel_shutdown_05_state = { - .test_case_name = "test_case_mesh_channel_shutdown_05", -}; - static bool channel_acc; static bool polled; static bool foo_responded; @@ -90,6 +75,8 @@ static pthread_cond_t foo_cond = PTHREAD_COND_INITIALIZER; static pthread_cond_t bar_cond = PTHREAD_COND_INITIALIZER; static bool accept_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *data, size_t len) { + (void)data; + assert(port == 7); assert(!len); @@ -105,6 +92,9 @@ static bool accept_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint /* channel receive callback */ static void receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)dat; + (void)len; + if(!strcmp(mesh->name, "foo")) { pthread_mutex_lock(& foo_responded_lock); foo_responded = true; @@ -207,8 +197,6 @@ static bool test_steps_mesh_channel_shutdown_01(void) { pthread_mutex_unlock(&accept_lock); - meshlink_channel_t *channel2 = bar->priv; - // Sending to bar and testing the echo assert(meshlink_channel_send(mesh1, channel1, "echo", 4) >= 0); diff --git a/test/blackbox/run_blackbox_tests/test_cases_default_blacklist.c b/test/blackbox/run_blackbox_tests/test_cases_default_blacklist.c index bf21ed84..bf53b597 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_default_blacklist.c +++ b/test/blackbox/run_blackbox_tests/test_cases_default_blacklist.c @@ -57,6 +57,9 @@ static void test_case_mesh_default_blacklist_01(void **state) { static bool received = false; static void receive(meshlink_handle_t *mesh, meshlink_node_t *src, const void *data, size_t len) { + (void)mesh; + (void)data; + assert(len); if(!strcmp(src->name, "bar") || !strcmp(src->name, "foz")) { @@ -68,6 +71,8 @@ static bool bar_reachable = false; static bool foz_reachable = false; void status_cb1(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcmp(node->name, "bar")) { bar_reachable = reachable; } else if(!strcmp(node->name, "foz")) { diff --git a/test/blackbox/run_blackbox_tests/test_cases_get_all_nodes.c b/test/blackbox/run_blackbox_tests/test_cases_get_all_nodes.c index 8b885a73..56a31398 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_get_all_nodes.c +++ b/test/blackbox/run_blackbox_tests/test_cases_get_all_nodes.c @@ -40,8 +40,6 @@ static void test_case_get_all_nodes_02(void **state); static bool test_get_all_nodes_02(void); static void test_case_get_all_nodes_03(void **state); static bool test_get_all_nodes_03(void); -static void test_case_get_all_nodes_04(void **state); -static bool test_get_all_nodes_04(void); /* State structure for get_all_nodes Test Case #1 */ static black_box_state_t test_case_get_all_nodes_01_state = { @@ -128,11 +126,11 @@ static void test_case_get_all_nodes_02(void **state) { Error reported correctly by returning NULL */ static bool test_get_all_nodes_02(void) { - meshlink_node_t **nodes = NULL; size_t nmemb = 0; - meshlink_node_t **node = meshlink_get_all_nodes(NULL, nodes, &nmemb); - assert_int_equal(nodes, NULL); + meshlink_node_t **nodes = meshlink_get_all_nodes(NULL, NULL, &nmemb); + assert_null(nodes); + assert_int_equal(nmemb, NULL); return true; } diff --git a/test/blackbox/run_blackbox_tests/test_cases_get_all_nodes_by_dev_class.c b/test/blackbox/run_blackbox_tests/test_cases_get_all_nodes_by_dev_class.c index e32fb36c..6f4badf6 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_get_all_nodes_by_dev_class.c +++ b/test/blackbox/run_blackbox_tests/test_cases_get_all_nodes_by_dev_class.c @@ -208,7 +208,7 @@ static void test_case_mesh_get_node_by_dev_class_02(void **state) { static bool test_steps_mesh_get_node_by_dev_class_02(void) { meshlink_node_t **nodes; size_t nnodes = 0; - int i; + meshlink_destroy("getnodeconf.1"); /* Create meshlink instance for NUT */ @@ -308,6 +308,8 @@ static bool test_steps_mesh_get_node_dev_class_02(void) { } static int black_box_setup_test_case(void **state) { + (void)state; + fprintf(stderr, "Destroying confbases\n"); meshlink_destroy("getnodeconf.1"); meshlink_destroy("getnodeconf.2"); diff --git a/test/blackbox/run_blackbox_tests/test_cases_import.c b/test/blackbox/run_blackbox_tests/test_cases_import.c index 0ab6c042..6b5dfa60 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_import.c +++ b/test/blackbox/run_blackbox_tests/test_cases_import.c @@ -42,34 +42,31 @@ static void test_case_import_04(void **state); static bool test_import_04(void); static void test_case_import_05(void **state); static bool test_import_05(void); -static void test_case_import_06(void **state); -static bool test_import_06(void); /* State structure for import API Test Case #1 */ static black_box_state_t test_case_import_01_state = { .test_case_name = "test_case_import_01", }; + /* State structure for import API Test Case #2 */ static black_box_state_t test_case_import_02_state = { .test_case_name = "test_case_import_02", }; + /* State structure for import API Test Case #3 */ static black_box_state_t test_case_import_03_state = { .test_case_name = "test_case_import_03", }; + /* State structure for import API Test Case #4 */ static black_box_state_t test_case_import_04_state = { .test_case_name = "test_case_import_04", }; + /* State structure for import API Test Case #5 */ static black_box_state_t test_case_import_05_state = { .test_case_name = "test_case_import_05", }; -/* State structure for import API Test Case #6 */ -static black_box_state_t test_case_import_06_state = { - .test_case_name = "test_case_import_06", -}; - /* Execute import Test Case # 1 - valid case*/ static void test_case_import_01(void **state) { diff --git a/test/blackbox/run_blackbox_tests/test_cases_invite.c b/test/blackbox/run_blackbox_tests/test_cases_invite.c index af02cb47..cd5b7faf 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_invite.c +++ b/test/blackbox/run_blackbox_tests/test_cases_invite.c @@ -164,12 +164,12 @@ static bool test_invite_04(void) { meshlink_set_log_cb(mesh_handle, TEST_MESHLINK_LOG_LEVEL, meshlink_callback_logger); char *hostname1 = "127.1.1.1"; - bool ret = meshlink_add_address(mesh_handle, hostname1); + meshlink_add_address(mesh_handle, hostname1); char *invitation = meshlink_invite(mesh_handle, NULL, "foo"); assert_int_not_equal(strstr(invitation, hostname1), NULL); char *hostname2 = "127.1.2.3"; - ret = meshlink_add_address(mesh_handle, hostname2); + meshlink_add_address(mesh_handle, hostname2); invitation = meshlink_invite(mesh_handle, NULL, "bar"); // Verify we have both the added addresses diff --git a/test/blackbox/run_blackbox_tests/test_cases_join.c b/test/blackbox/run_blackbox_tests/test_cases_join.c index e91c163c..39c08ac2 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_join.c +++ b/test/blackbox/run_blackbox_tests/test_cases_join.c @@ -39,8 +39,6 @@ static void test_case_meshlink_join_02(void **state); static bool test_meshlink_join_02(void); static void test_case_meshlink_join_03(void **state); static bool test_meshlink_join_03(void); -static void test_case_meshlink_join_04(void **state); -static bool test_meshlink_join_04(void); /* State structure for join Test Case #1 */ static black_box_state_t test_case_join_01_state = { diff --git a/test/blackbox/run_blackbox_tests/test_cases_key_rotation.c b/test/blackbox/run_blackbox_tests/test_cases_key_rotation.c index a42a54d5..e1fae3c3 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_key_rotation.c +++ b/test/blackbox/run_blackbox_tests/test_cases_key_rotation.c @@ -334,6 +334,8 @@ static void test_case_key_rotation_05(void **state) { static int break_stage; static void nop_stage(int stage) { + (void)stage; + return; } diff --git a/test/blackbox/run_blackbox_tests/test_cases_random_port_bindings01.c b/test/blackbox/run_blackbox_tests/test_cases_random_port_bindings01.c index 24a7e409..d39d2dc6 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_random_port_bindings01.c +++ b/test/blackbox/run_blackbox_tests/test_cases_random_port_bindings01.c @@ -138,7 +138,6 @@ void test_case_mesh_random_port_bindings_01(void **state) { of the instance should be unchanged. */ bool test_steps_mesh_random_port_bindings_01(void) { - struct sockaddr_in servaddr; meshlink_handle_t *relay = NULL; meshlink_destroy("relay_conf"); @@ -189,7 +188,6 @@ void test_case_mesh_random_port_bindings_02(void **state) { The meshlink_set_port() API should fail. */ bool test_steps_mesh_random_port_bindings_02(void) { - int port = -1; meshlink_handle_t *relay = NULL; meshlink_destroy("relay_conf"); @@ -205,7 +203,6 @@ bool test_steps_mesh_random_port_bindings_02(void) { assert_true(meshlink_start(relay)); sleep(1); - port = meshlink_get_port(relay); devtool_trybind_probe = occupy_trybind_port; meshlink_stop(relay); @@ -241,10 +238,7 @@ void test_case_mesh_random_port_bindings_03(void **state) { previous port number. */ bool test_steps_mesh_random_port_bindings_03(void) { - int mode = 1; int port, new_port; - struct sockaddr_in servaddr; - struct sockaddr_in6 ipv6addr; meshlink_handle_t *relay = NULL; meshlink_destroy("relay_conf"); diff --git a/test/blackbox/run_blackbox_tests/test_cases_random_port_bindings02.c b/test/blackbox/run_blackbox_tests/test_cases_random_port_bindings02.c index 2d24c3af..b1a6259c 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_random_port_bindings02.c +++ b/test/blackbox/run_blackbox_tests/test_cases_random_port_bindings02.c @@ -51,6 +51,8 @@ static netns_state_t *test_random_port_bindings_state; static bool localnode = false; static int setup_test(void **state) { + (void)state; + netns_create_topology(test_random_port_bindings_state); fprintf(stderr, "\nCreated topology\n"); @@ -70,6 +72,8 @@ static int setup_test(void **state) { } static int teardown_test(void **state) { + (void)state; + meshlink_destroy("nut"); meshlink_destroy("peer"); meshlink_destroy("relay"); @@ -79,6 +83,8 @@ static int teardown_test(void **state) { } 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(); @@ -89,6 +95,8 @@ static void execute_test(test_step_func_t step_func, void **state) { } static void message_log(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) { + (void)level; + char *levelstr = "\x1b[32mRELAY"; if(strcmp(mesh->name, "peer") == 0) { diff --git a/test/blackbox/run_blackbox_tests/test_cases_rec_cb.c b/test/blackbox/run_blackbox_tests/test_cases_rec_cb.c index f9ec4770..2f22d7e6 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_rec_cb.c +++ b/test/blackbox/run_blackbox_tests/test_cases_rec_cb.c @@ -40,8 +40,6 @@ static void test_case_set_rec_cb_02(void **state); static bool test_set_rec_cb_02(void); static void test_case_set_rec_cb_03(void **state); static bool test_set_rec_cb_03(void); -static void test_case_set_rec_cb_04(void **state); -static bool test_set_rec_cb_04(void); /* Test Steps for meshlink_set_receive_cb Test Case #1 */ static black_box_state_t test_case_set_rec_cb_01_state = { @@ -65,6 +63,9 @@ pthread_mutex_t lock; /* receive callback function */ static void rec_cb(meshlink_handle_t *mesh, meshlink_node_t *source, const void *data, size_t len) { + (void)mesh; + (void)source; + assert(len); pthread_mutex_lock(&lock); diff --git a/test/blackbox/run_blackbox_tests/test_cases_send.c b/test/blackbox/run_blackbox_tests/test_cases_send.c index 82c494d5..6bb39da3 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_send.c +++ b/test/blackbox/run_blackbox_tests/test_cases_send.c @@ -51,21 +51,6 @@ static black_box_state_t test_mesh_send_03_state = { .test_case_name = "test_case_mesh_send_03", }; -/* State structure for meshlink_send Test Case #4 */ -static black_box_state_t test_mesh_send_04_state = { - .test_case_name = "test_case_mesh_send_04", -}; - -/* State structure for meshlink_send Test Case #5 */ -static black_box_state_t test_mesh_send_05_state = { - .test_case_name = "test_case_mesh_send_05", -}; - -/* State structure for meshlink_send Test Case #6 */ -static black_box_state_t test_mesh_send_06_state = { - .test_case_name = "test_case_mesh_send_06", -}; - /* Execute meshlink_send Test Case # 1 */ static void test_case_mesh_send_01(void **state) { execute_test(test_steps_mesh_send_01, state); @@ -73,7 +58,8 @@ static void test_case_mesh_send_01(void **state) { static bool receive_data = false; static void receive(meshlink_handle_t *mesh, meshlink_node_t *dest_node, const void *data, size_t len) { - const char *msg = data; + (void)mesh; + (void)dest_node; assert(len); diff --git a/test/blackbox/run_blackbox_tests/test_cases_set_connection_try_cb.c b/test/blackbox/run_blackbox_tests/test_cases_set_connection_try_cb.c index 42ac08f5..e610beb6 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_set_connection_try_cb.c +++ b/test/blackbox/run_blackbox_tests/test_cases_set_connection_try_cb.c @@ -44,6 +44,8 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *source, boo /* Meta-connection try callback handler */ static void connection_try_cb(meshlink_handle_t *mesh, meshlink_node_t *source) { + (void)source; + if(!strcmp(mesh->name, "foo")) { ++connection_attempts; @@ -89,8 +91,8 @@ static bool test_set_connection_try_cb_01(void) { assert(exp1 != NULL); char *exp2 = meshlink_export(mesh2); assert(exp2 != NULL); - bool imp1 = meshlink_import(mesh1, exp2); - bool imp2 = meshlink_import(mesh2, exp1); + meshlink_import(mesh1, exp2); + meshlink_import(mesh2, exp1); free(exp1); free(exp2); diff --git a/test/blackbox/run_blackbox_tests/test_cases_set_log_cb.c b/test/blackbox/run_blackbox_tests/test_cases_set_log_cb.c index 71019a13..14129017 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_set_log_cb.c +++ b/test/blackbox/run_blackbox_tests/test_cases_set_log_cb.c @@ -38,8 +38,6 @@ static void test_case_set_log_cb_01(void **state); static bool test_set_log_cb_01(void); static void test_case_set_log_cb_02(void **state); static bool test_set_log_cb_02(void); -static void test_case_set_log_cb_03(void **state); -static bool test_set_log_cb_03(void); /* log variable gives access to the log callback to know whether invoked or not */ static bool log; @@ -57,6 +55,9 @@ static black_box_state_t test_case_set_log_cb_02_state = { /* log callback */ static void log_cb(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) { + (void)mesh; + (void)level; + fprintf(stderr, "Received log text : %s\n", text); log = true; } diff --git a/test/blackbox/run_blackbox_tests/test_cases_set_port.c b/test/blackbox/run_blackbox_tests/test_cases_set_port.c index 48129def..b01bc6d8 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_set_port.c +++ b/test/blackbox/run_blackbox_tests/test_cases_set_port.c @@ -150,6 +150,8 @@ static bool test_set_port_03(void) { meshlink_close(mesh_handle); meshlink_destroy("getportconf"); + + return false; } diff --git a/test/blackbox/run_blackbox_tests/test_cases_sign.c b/test/blackbox/run_blackbox_tests/test_cases_sign.c index 11494549..6ecbeccd 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_sign.c +++ b/test/blackbox/run_blackbox_tests/test_cases_sign.c @@ -269,7 +269,6 @@ static bool test_sign_05(void) { // Signing data char *data = "Test"; - char sig[MESHLINK_SIGLEN]; size_t ssize = MESHLINK_SIGLEN; bool ret = meshlink_sign(mesh_handle, data, strlen(data) + 1, NULL, &ssize); @@ -315,7 +314,6 @@ static bool test_sign_06(void) { char *data = "Test"; char sig[MESHLINK_SIGLEN]; - size_t ssize = MESHLINK_SIGLEN; bool ret = meshlink_sign(mesh_handle, data, strlen(data) + 1, sig, NULL); // Clean up diff --git a/test/blackbox/run_blackbox_tests/test_cases_status_cb.c b/test/blackbox/run_blackbox_tests/test_cases_status_cb.c index 9bfb4c63..044781b5 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_status_cb.c +++ b/test/blackbox/run_blackbox_tests/test_cases_status_cb.c @@ -53,6 +53,8 @@ static black_box_state_t test_case_set_status_cb_02_state = { static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *source, bool reach) { + (void)mesh; + fprintf(stderr, "In status callback\n"); if(reach) { @@ -98,8 +100,8 @@ static bool test_set_status_cb_01(void) { assert(exp1 != NULL); char *exp2 = meshlink_export(mesh2); assert(exp2 != NULL); - bool imp1 = meshlink_import(mesh1, exp2); - bool imp2 = meshlink_import(mesh2, exp1); + meshlink_import(mesh1, exp2); + meshlink_import(mesh2, exp1); assert(meshlink_start(mesh1)); assert(meshlink_start(mesh2)); diff --git a/test/blackbox/run_blackbox_tests/test_cases_submesh01.c b/test/blackbox/run_blackbox_tests/test_cases_submesh01.c index c9854a12..0ce3112e 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_submesh01.c +++ b/test/blackbox/run_blackbox_tests/test_cases_submesh01.c @@ -71,6 +71,8 @@ static black_box_state_t test_case_submesh_1_state = { }; static int black_box_group0_setup(void **state) { + (void)state; + const char *nodes[] = { "corenode1", "app1node1", "app2node1", "corenode2", "app1node2", "app2node2" }; int num_nodes = sizeof(nodes) / sizeof(nodes[0]); @@ -82,31 +84,22 @@ static int black_box_group0_setup(void **state) { } static int black_box_group0_teardown(void **state) { + (void)state; + PRINT_TEST_CASE_MSG("Destroying Containers\n"); destroy_containers(); return 0; } -static int black_box_all_nodes_setup(void **state) { - const char *nodes[] = { "corenode1" }; - int num_nodes = sizeof(nodes) / sizeof(nodes[0]); - - PRINT_TEST_CASE_MSG("Creating Containers\n"); - destroy_containers(); - create_containers(nodes, num_nodes); - PRINT_TEST_CASE_MSG("Created Containers\n"); - return 0; -} - static bool event_cb(mesh_event_payload_t payload) { static node_status_t node_status[6] = { - {core_node1, 0, 3, false}, - {app1_node1, 0, 4, false}, - {app2_node1, 0, 4, false}, - {core_node2, 0, 4, false}, - {app1_node2, 0, 7, false}, - {app2_node2, 0, 7, false} + {core_node1, 0, 3}, + {app1_node1, 0, 4}, + {app2_node1, 0, 4}, + {core_node2, 0, 4}, + {app1_node2, 0, 7}, + {app2_node2, 0, 7}, }; fprintf(stderr, "%s(%lu) : %s\n", event_node_name[payload.client_id], time(NULL), event_status[payload.mesh_event]); @@ -145,10 +138,7 @@ static void test_case_submesh_01(void **state) { */ static bool test_steps_submesh_01(void) { char *invite_corenode2, *invite_app1node1, *invite_app2node1, *invite_app1node2, *invite_app2node2; - bool result = false; - int i; char *import; - pthread_t thread1, thread2; import = mesh_event_sock_create(eth_if_name); invite_corenode2 = invite_in_container("corenode1", "corenode2"); diff --git a/test/blackbox/run_blackbox_tests/test_cases_submesh02.c b/test/blackbox/run_blackbox_tests/test_cases_submesh02.c index da475749..4a59e23f 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_submesh02.c +++ b/test/blackbox/run_blackbox_tests/test_cases_submesh02.c @@ -71,6 +71,8 @@ static black_box_state_t test_case_submesh_2_state = { }; static int black_box_group0_setup(void **state) { + (void)state; + const char *nodes[] = { "corenode1", "app1node1", "app2node1", "corenode2", "app1node2", "app2node2" }; int num_nodes = sizeof(nodes) / sizeof(nodes[0]); @@ -82,31 +84,22 @@ static int black_box_group0_setup(void **state) { } static int black_box_group0_teardown(void **state) { + (void)state; + PRINT_TEST_CASE_MSG("Destroying Containers\n"); destroy_containers(); return 0; } -static int black_box_all_nodes_setup(void **state) { - const char *nodes[] = { "corenode1" }; - int num_nodes = sizeof(nodes) / sizeof(nodes[0]); - - PRINT_TEST_CASE_MSG("Creating Containers\n"); - destroy_containers(); - create_containers(nodes, num_nodes); - PRINT_TEST_CASE_MSG("Created Containers\n"); - return 0; -} - static bool event_cb(mesh_event_payload_t payload) { static node_status_t node_status[6] = { - {core_node1, 0, 3, false}, - {app1_node1, 0, 4, false}, - {app2_node1, 0, 4, false}, - {core_node2, 0, 4, false}, - {app1_node2, 0, 7, false}, - {app2_node2, 0, 7, false} + {core_node1, 0, 3}, + {app1_node1, 0, 4}, + {app2_node1, 0, 4}, + {core_node2, 0, 4}, + {app1_node2, 0, 7}, + {app2_node2, 0, 7}, }; fprintf(stderr, "%s(%lu) : %s\n", event_node_name[payload.client_id], time(NULL), event_status[payload.mesh_event]); @@ -148,10 +141,7 @@ static void test_case_submesh_02(void **state) { */ static bool test_steps_submesh_02(void) { char *invite_corenode2, *invite_app1node1, *invite_app2node1, *invite_app1node2, *invite_app2node2; - bool result = false; - int i; char *import; - pthread_t thread1, thread2; import = mesh_event_sock_create(eth_if_name); invite_corenode2 = invite_in_container("corenode1", "corenode2"); diff --git a/test/blackbox/run_blackbox_tests/test_cases_submesh03.c b/test/blackbox/run_blackbox_tests/test_cases_submesh03.c index 1f51479f..eecd539d 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_submesh03.c +++ b/test/blackbox/run_blackbox_tests/test_cases_submesh03.c @@ -50,9 +50,9 @@ static mesh_event_t app1_node1[] = { NODE_STARTED, NODE_JOINED, CHANNEL_OPENED, static mesh_event_t app1_node2[] = { NODE_STARTED, NODE_JOINED, CHANNEL_OPENED, CHANNEL_DATA_RECIEVED, CHANNEL_OPENED, CHANNEL_DATA_RECIEVED, MESH_EVENT_COMPLETED}; static node_status_t node_status[3] = { - {core_node1, 0, 3, false}, - {app1_node1, 0, 4, false}, - {app1_node2, 0, 7, false} + {core_node1, 0, 3}, + {app1_node1, 0, 4}, + {app1_node2, 0, 7}, }; /* State structure for SubMesh Test Case #3 */ @@ -64,6 +64,8 @@ static black_box_state_t test_case_submesh_3_state = { }; static int black_box_group0_setup(void **state) { + (void)state; + const char *nodes[] = { "corenode1", "app1node1", "app1node2" }; int num_nodes = sizeof(nodes) / sizeof(nodes[0]); @@ -75,23 +77,14 @@ static int black_box_group0_setup(void **state) { } static int black_box_group0_teardown(void **state) { + (void)state; + PRINT_TEST_CASE_MSG("Destroying Containers\n"); destroy_containers(); return 0; } -static int black_box_all_nodes_setup(void **state) { - const char *nodes[] = { "corenode1" }; - int num_nodes = sizeof(nodes) / sizeof(nodes[0]); - - PRINT_TEST_CASE_MSG("Creating Containers\n"); - destroy_containers(); - create_containers(nodes, num_nodes); - PRINT_TEST_CASE_MSG("Created Containers\n"); - return 0; -} - static void restart_all_nodes(char *import) { int i; @@ -144,10 +137,7 @@ static void test_case_submesh_03(void **state) { */ static bool test_steps_submesh_03(void) { char *invite_app1node1, *invite_app1node2; - bool result = false; - int i; char *import; - pthread_t thread1, thread2; import = mesh_event_sock_create(eth_if_name); invite_app1node1 = invite_in_container("corenode1", "app1node1"); diff --git a/test/blackbox/run_blackbox_tests/test_cases_submesh04.c b/test/blackbox/run_blackbox_tests/test_cases_submesh04.c index 1f37071b..2cdf9216 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_submesh04.c +++ b/test/blackbox/run_blackbox_tests/test_cases_submesh04.c @@ -58,6 +58,8 @@ static black_box_state_t test_case_submesh_4_state = { }; static int black_box_group0_setup(void **state) { + (void)state; + const char *nodes[] = { "corenode1", "app1node1", "app1node2" }; int num_nodes = sizeof(nodes) / sizeof(nodes[0]); @@ -69,28 +71,19 @@ static int black_box_group0_setup(void **state) { } static int black_box_group0_teardown(void **state) { + (void)state; + PRINT_TEST_CASE_MSG("Destroying Containers\n"); destroy_containers(); return 0; } -static int black_box_all_nodes_setup(void **state) { - const char *nodes[] = { "corenode1" }; - int num_nodes = sizeof(nodes) / sizeof(nodes[0]); - - PRINT_TEST_CASE_MSG("Creating Containers\n"); - destroy_containers(); - create_containers(nodes, num_nodes); - PRINT_TEST_CASE_MSG("Created Containers\n"); - return 0; -} - static bool event_cb(mesh_event_payload_t payload) { static node_status_t node_status[3] = { - {core_node1, 0, 3, false}, - {app1_node1, 0, 4, false}, - {app1_node2, 0, 7, false} + {core_node1, 0, 3}, + {app1_node1, 0, 4}, + {app1_node2, 0, 7}, }; fprintf(stderr, "%s(%lu) : %s\n", event_node_name[payload.client_id], time(NULL), event_status[payload.mesh_event]); @@ -131,10 +124,7 @@ static void test_case_submesh_04(void **state) { */ static bool test_steps_submesh_04(void) { char *invite_app1node1, *invite_app1node2; - bool result = false; - int i; char *import; - pthread_t thread1, thread2; import = mesh_event_sock_create(eth_if_name); invite_app1node1 = invite_in_container("corenode1", "app1node1"); diff --git a/test/blackbox/run_blackbox_tests/test_cases_verify.c b/test/blackbox/run_blackbox_tests/test_cases_verify.c index ad84563e..4040c33e 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_verify.c +++ b/test/blackbox/run_blackbox_tests/test_cases_verify.c @@ -44,10 +44,6 @@ static void test_case_verify_05(void **state); static bool test_verify_05(void); static void test_case_verify_06(void **state); static bool test_verify_06(void); -static void test_case_verify_07(void **state); -static bool test_verify_07(void); -static void test_case_verify_08(void **state); -static bool test_verify_08(void); /* State structure for verify API Test Case #1 */ static black_box_state_t test_case_verify_01_state = { diff --git a/test/blackbox/run_blackbox_tests/test_cases_whitelist.c b/test/blackbox/run_blackbox_tests/test_cases_whitelist.c index 0ee8636e..dc306d83 100644 --- a/test/blackbox/run_blackbox_tests/test_cases_whitelist.c +++ b/test/blackbox/run_blackbox_tests/test_cases_whitelist.c @@ -70,7 +70,10 @@ static void test_case_mesh_whitelist_01(void **state) { static void receive(meshlink_handle_t *mesh, meshlink_node_t *src, const void *data, size_t len) { - const char *msg = data; + (void)mesh; + (void)src; + (void)data; + assert(len); pthread_mutex_lock(& lock_receive); @@ -81,6 +84,8 @@ static void receive(meshlink_handle_t *mesh, meshlink_node_t *src, const void *d } static void status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reach) { + (void)mesh; + if(!strcmp(node->name, "bar")) { pthread_mutex_lock(&reachable_lock); reachable = reach; diff --git a/test/blackbox/run_blackbox_tests/test_optimal_pmtu.c b/test/blackbox/run_blackbox_tests/test_optimal_pmtu.c index 2cb605ae..51fc808c 100644 --- a/test/blackbox/run_blackbox_tests/test_optimal_pmtu.c +++ b/test/blackbox/run_blackbox_tests/test_optimal_pmtu.c @@ -61,6 +61,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,7 +70,7 @@ 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"); @@ -78,6 +80,8 @@ static int setup_test(void **state) { } static int teardown_test(void **state) { + (void)state; + meshlink_destroy("nut"); meshlink_destroy("peer"); meshlink_destroy("relay"); @@ -87,6 +91,8 @@ static int teardown_test(void **state) { } 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(); @@ -106,6 +112,8 @@ static void *gen_inv(void *arg) { assert(invitation); mesh_invite_arg->invite_str = invitation; meshlink_close(mesh); + + return NULL; } /* Test Steps for optimal PMTU discovery Test Case # 1 - @@ -417,6 +425,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) { diff --git a/test/blackbox/run_blackbox_tests/test_optimal_pmtu.h b/test/blackbox/run_blackbox_tests/test_optimal_pmtu.h index fa241a29..3ee68f7d 100644 --- a/test/blackbox/run_blackbox_tests/test_optimal_pmtu.h +++ b/test/blackbox/run_blackbox_tests/test_optimal_pmtu.h @@ -45,8 +45,8 @@ typedef struct pmtu_attr { int mtu_size; } pmtu_attr_t; -#define NODE_PMTU_RELAY 1 -#define NODE_PMTU_PEER 2 +#define NODE_PMTU_RELAY 0 +#define NODE_PMTU_PEER 1 #define find_node_index(i, node_name) if(!strcasecmp(node_name, "peer")) { \ i = NODE_PMTU_PEER; \ diff --git a/test/blackbox/test_case_channel_blacklist_01/node_sim_nut_01.c b/test/blackbox/test_case_channel_blacklist_01/node_sim_nut_01.c index fca20715..cb140a04 100644 --- a/test/blackbox/test_case_channel_blacklist_01/node_sim_nut_01.c +++ b/test/blackbox/test_case_channel_blacklist_01/node_sim_nut_01.c @@ -47,8 +47,8 @@ static struct sync_flag peer_unreachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static struct sync_flag channels_closed = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; fprintf(stderr, "Node %s %s\n", node->name, reachable ? "reachable" : "unreachable"); @@ -80,6 +80,8 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + if(len == 0) { fprintf(stderr, "Closed channel with %s\n", (char *)channel->priv); @@ -103,6 +105,8 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } static void log_message(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) { + (void)level; + (void)mesh; fprintf(stderr, "\x1b[32m nut:\x1b[0m %s\n", text); diff --git a/test/blackbox/test_case_channel_blacklist_01/node_sim_peer_01.c b/test/blackbox/test_case_channel_blacklist_01/node_sim_peer_01.c index 4f1c9395..3d880948 100644 --- a/test/blackbox/test_case_channel_blacklist_01/node_sim_peer_01.c +++ b/test/blackbox/test_case_channel_blacklist_01/node_sim_peer_01.c @@ -36,8 +36,6 @@ bool test_case_signal_peer_restart_01; static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len); static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len); -static int client_id = -1; - static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len) { (void)dat; (void)len; diff --git a/test/blackbox/test_case_channel_conn_01/node_sim_nut.c b/test/blackbox/test_case_channel_conn_01/node_sim_nut.c index 057faaca..8e819085 100644 --- a/test/blackbox/test_case_channel_conn_01/node_sim_nut.c +++ b/test/blackbox/test_case_channel_conn_01/node_sim_nut.c @@ -41,14 +41,13 @@ static int client_id = -1; static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; -static struct sync_flag channel_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static void send_event(mesh_event_t event); -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable); -static void mesh_siguser1_signal_handler(int sig_num); +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable); static void mesh_siguser1_signal_handler(int sig_num) { + (void)sig_num; + set_sync_flag(&sigusr_received, true); return; @@ -68,8 +67,9 @@ static void send_event(mesh_event_t event) { return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "peer") && reachable) { set_sync_flag(&peer_reachable, true); } @@ -85,6 +85,8 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + if(len == 0) { send_event(ERR_NETWORK); assert(false); @@ -100,9 +102,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; - struct timespec timeout = {0}; - int i; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_01/node_sim_peer.c b/test/blackbox/test_case_channel_conn_01/node_sim_peer.c index 7cc095d7..a6e82b09 100644 --- a/test/blackbox/test_case_channel_conn_01/node_sim_peer.c +++ b/test/blackbox/test_case_channel_conn_01/node_sim_peer.c @@ -81,6 +81,8 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_02/node_sim_nut.c b/test/blackbox/test_case_channel_conn_02/node_sim_nut.c index d8af0923..f15148ae 100644 --- a/test/blackbox/test_case_channel_conn_02/node_sim_nut.c +++ b/test/blackbox/test_case_channel_conn_02/node_sim_nut.c @@ -45,11 +45,11 @@ static struct sync_flag channel_closed = {.mutex = PTHREAD_MUTEX_INITIALIZER, . static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static void send_event(mesh_event_t event); -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable); -static void mesh_siguser1_signal_handler(int sig_num); +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable); static void mesh_siguser1_signal_handler(int sig_num) { + (void)sig_num; + set_sync_flag(&sigusr_received, true); return; } @@ -69,8 +69,9 @@ static void send_event(mesh_event_t event) { return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "peer") && reachable) { set_sync_flag(&peer_reachable, true); } @@ -86,6 +87,8 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + if(len == 0) { set_sync_flag(&channel_closed, true); send_event(ERR_NETWORK); @@ -102,9 +105,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; - struct timespec timeout = {0}; - int i; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_02/node_sim_peer.c b/test/blackbox/test_case_channel_conn_02/node_sim_peer.c index ac94066f..c86dd7d7 100644 --- a/test/blackbox/test_case_channel_conn_02/node_sim_peer.c +++ b/test/blackbox/test_case_channel_conn_02/node_sim_peer.c @@ -35,12 +35,6 @@ #define CHANNEL_PORT 1234 static int client_id = -1; -static bool channel_rec; -static bool channel_reply; -static pthread_mutex_t reply_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t reply_cond = PTHREAD_COND_INITIALIZER; -static pthread_mutex_t recv_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t recv_cond = PTHREAD_COND_INITIALIZER; static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len); @@ -76,8 +70,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; - struct timespec timeout = {0}; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_03/node_sim_nut.c b/test/blackbox/test_case_channel_conn_03/node_sim_nut.c index 2f1e7e60..421542b9 100644 --- a/test/blackbox/test_case_channel_conn_03/node_sim_nut.c +++ b/test/blackbox/test_case_channel_conn_03/node_sim_nut.c @@ -44,17 +44,16 @@ static struct sync_flag peer_unreachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static void send_event(mesh_event_t event); -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable); -static void mesh_siguser1_signal_handler(int sig_num); +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable); static void mesh_siguser1_signal_handler(int sig_num) { + (void)sig_num; + set_sync_flag(&sigusr_received, true); return; } static void send_event(mesh_event_t event) { - bool send_ret = false; int attempts; for(attempts = 0; attempts < 5; attempts += 1) { @@ -68,8 +67,9 @@ static void send_event(mesh_event_t event) { return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "peer")) { if(reachable) { set_sync_flag(&peer_reachable, true); @@ -89,6 +89,8 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + if(!strcmp(channel->node->name, "peer")) { if(len == 5 && !memcmp(dat, "reply", 5)) { set_sync_flag(&channel_opened, true); @@ -99,9 +101,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; - struct timespec timeout = {0}; - int i; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_03/node_sim_peer.c b/test/blackbox/test_case_channel_conn_03/node_sim_peer.c index ae8dadcc..32d3753c 100644 --- a/test/blackbox/test_case_channel_conn_03/node_sim_peer.c +++ b/test/blackbox/test_case_channel_conn_03/node_sim_peer.c @@ -72,8 +72,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; - struct timespec timeout = {0}; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_04/node_sim_nut.c b/test/blackbox/test_case_channel_conn_04/node_sim_nut.c index fe338704..3522da2c 100644 --- a/test/blackbox/test_case_channel_conn_04/node_sim_nut.c +++ b/test/blackbox/test_case_channel_conn_04/node_sim_nut.c @@ -40,7 +40,6 @@ static int client_id = -1; static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; -static struct sync_flag channel_closed = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static void send_event(mesh_event_t event); static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, @@ -60,8 +59,9 @@ static void send_event(mesh_event_t event) { return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "peer")) { if(reachable) { set_sync_flag(&peer_reachable, true); @@ -82,6 +82,8 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + if(len == 0) { //send_event(ERR_NETWORK); return; @@ -99,8 +101,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; - int i; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_04/node_sim_peer.c b/test/blackbox/test_case_channel_conn_04/node_sim_peer.c index 01289786..f2847130 100644 --- a/test/blackbox/test_case_channel_conn_04/node_sim_peer.c +++ b/test/blackbox/test_case_channel_conn_04/node_sim_peer.c @@ -43,6 +43,8 @@ static struct sync_flag sigusr = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = P static int client_id = -1; static void mesh_siguser1_signal_handler(int sig_num) { + (void)sig_num; + set_sync_flag(&sigusr, true); return; @@ -84,6 +86,8 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_05/node_sim_nut.c b/test/blackbox/test_case_channel_conn_05/node_sim_nut.c index bded500a..193d554a 100644 --- a/test/blackbox/test_case_channel_conn_05/node_sim_nut.c +++ b/test/blackbox/test_case_channel_conn_05/node_sim_nut.c @@ -41,14 +41,13 @@ static int client_id = -1; static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; -static struct sync_flag channel_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static void send_event(mesh_event_t event); -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable); -static void mesh_siguser1_signal_handler(int sig_num); +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable); static void mesh_siguser1_signal_handler(int sig_num) { + (void)sig_num; + set_sync_flag(&sigusr_received, true); return; @@ -68,8 +67,9 @@ static void send_event(mesh_event_t event) { return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "peer") && reachable) { set_sync_flag(&peer_reachable, true); } @@ -85,6 +85,8 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + if(len == 0) { send_event(ERR_NETWORK); assert(false); @@ -100,9 +102,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; - struct timespec timeout = {0}; - int i; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_05/node_sim_peer.c b/test/blackbox/test_case_channel_conn_05/node_sim_peer.c index 7cc095d7..a6e82b09 100644 --- a/test/blackbox/test_case_channel_conn_05/node_sim_peer.c +++ b/test/blackbox/test_case_channel_conn_05/node_sim_peer.c @@ -81,6 +81,8 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_05/node_sim_relay.c b/test/blackbox/test_case_channel_conn_05/node_sim_relay.c index 46fbf163..c4fd1e4c 100644 --- a/test/blackbox/test_case_channel_conn_05/node_sim_relay.c +++ b/test/blackbox/test_case_channel_conn_05/node_sim_relay.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; // Setup required signals diff --git a/test/blackbox/test_case_channel_conn_06/node_sim_nut.c b/test/blackbox/test_case_channel_conn_06/node_sim_nut.c index 643028ab..8e75bb76 100644 --- a/test/blackbox/test_case_channel_conn_06/node_sim_nut.c +++ b/test/blackbox/test_case_channel_conn_06/node_sim_nut.c @@ -45,11 +45,11 @@ static struct sync_flag channel_closed = {.mutex = PTHREAD_MUTEX_INITIALIZER, . static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static void send_event(mesh_event_t event); -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable); -static void mesh_siguser1_signal_handler(int sig_num); +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable); static void mesh_siguser1_signal_handler(int sig_num) { + (void)sig_num; + set_sync_flag(&sigusr_received, true); return; } @@ -69,8 +69,9 @@ static void send_event(mesh_event_t event) { return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "peer") && reachable) { set_sync_flag(&peer_reachable, true); @@ -87,6 +88,8 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + if(len == 0) { set_sync_flag(&channel_closed, true); @@ -104,9 +107,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; - struct timespec timeout = {0}; - int i; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_06/node_sim_peer.c b/test/blackbox/test_case_channel_conn_06/node_sim_peer.c index 24c8d7d7..c1a5b91a 100644 --- a/test/blackbox/test_case_channel_conn_06/node_sim_peer.c +++ b/test/blackbox/test_case_channel_conn_06/node_sim_peer.c @@ -35,12 +35,6 @@ #define CHANNEL_PORT 1234 static int client_id = -1; -static bool channel_rec; -static bool channel_reply; -static pthread_mutex_t reply_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t reply_cond = PTHREAD_COND_INITIALIZER; -static pthread_mutex_t recv_lock = PTHREAD_MUTEX_INITIALIZER; -static pthread_cond_t recv_cond = PTHREAD_COND_INITIALIZER; static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len); @@ -77,8 +71,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; - struct timespec timeout = {0}; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_06/node_sim_relay.c b/test/blackbox/test_case_channel_conn_06/node_sim_relay.c index 46fbf163..c4fd1e4c 100644 --- a/test/blackbox/test_case_channel_conn_06/node_sim_relay.c +++ b/test/blackbox/test_case_channel_conn_06/node_sim_relay.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; // Setup required signals diff --git a/test/blackbox/test_case_channel_conn_07/node_sim_nut.c b/test/blackbox/test_case_channel_conn_07/node_sim_nut.c index 7bab5226..5590064f 100644 --- a/test/blackbox/test_case_channel_conn_07/node_sim_nut.c +++ b/test/blackbox/test_case_channel_conn_07/node_sim_nut.c @@ -44,17 +44,16 @@ static struct sync_flag peer_unreachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, static struct sync_flag sigusr_received = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static void send_event(mesh_event_t event); -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable); -static void mesh_siguser1_signal_handler(int sig_num); +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable); static void mesh_siguser1_signal_handler(int sig_num) { + (void)sig_num; + set_sync_flag(&sigusr_received, true); return; } static void send_event(mesh_event_t event) { - bool send_ret = false; int attempts; for(attempts = 0; attempts < 5; attempts += 1) { @@ -68,8 +67,9 @@ static void send_event(mesh_event_t event) { return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "peer")) { if(reachable) { @@ -90,6 +90,8 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + if(len == 0) { send_event(ERR_NETWORK); return; @@ -105,9 +107,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; - struct timespec timeout = {0}; - int i; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_07/node_sim_peer.c b/test/blackbox/test_case_channel_conn_07/node_sim_peer.c index ae8dadcc..32d3753c 100644 --- a/test/blackbox/test_case_channel_conn_07/node_sim_peer.c +++ b/test/blackbox/test_case_channel_conn_07/node_sim_peer.c @@ -72,8 +72,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; - struct timespec timeout = {0}; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_07/node_sim_relay.c b/test/blackbox/test_case_channel_conn_07/node_sim_relay.c index 46fbf163..c4fd1e4c 100644 --- a/test/blackbox/test_case_channel_conn_07/node_sim_relay.c +++ b/test/blackbox/test_case_channel_conn_07/node_sim_relay.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; // Setup required signals diff --git a/test/blackbox/test_case_channel_conn_08/node_sim_nut.c b/test/blackbox/test_case_channel_conn_08/node_sim_nut.c index fe338704..3522da2c 100644 --- a/test/blackbox/test_case_channel_conn_08/node_sim_nut.c +++ b/test/blackbox/test_case_channel_conn_08/node_sim_nut.c @@ -40,7 +40,6 @@ static int client_id = -1; static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; -static struct sync_flag channel_closed = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static void send_event(mesh_event_t event); static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, @@ -60,8 +59,9 @@ static void send_event(mesh_event_t event) { return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "peer")) { if(reachable) { set_sync_flag(&peer_reachable, true); @@ -82,6 +82,8 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + if(len == 0) { //send_event(ERR_NETWORK); return; @@ -99,8 +101,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; - int i; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_08/node_sim_peer.c b/test/blackbox/test_case_channel_conn_08/node_sim_peer.c index 01289786..f2847130 100644 --- a/test/blackbox/test_case_channel_conn_08/node_sim_peer.c +++ b/test/blackbox/test_case_channel_conn_08/node_sim_peer.c @@ -43,6 +43,8 @@ static struct sync_flag sigusr = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = P static int client_id = -1; static void mesh_siguser1_signal_handler(int sig_num) { + (void)sig_num; + set_sync_flag(&sigusr, true); return; @@ -84,6 +86,8 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; // Import mesh event handler diff --git a/test/blackbox/test_case_channel_conn_08/node_sim_relay.c b/test/blackbox/test_case_channel_conn_08/node_sim_relay.c index 46fbf163..c4fd1e4c 100644 --- a/test/blackbox/test_case_channel_conn_08/node_sim_relay.c +++ b/test/blackbox/test_case_channel_conn_08/node_sim_relay.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; // Setup required signals diff --git a/test/blackbox/test_case_meta_conn_01/node_sim_nut.c b/test/blackbox/test_case_meta_conn_01/node_sim_nut.c index 86f94207..77ff2b80 100644 --- a/test/blackbox/test_case_meta_conn_01/node_sim_nut.c +++ b/test/blackbox/test_case_meta_conn_01/node_sim_nut.c @@ -34,8 +34,10 @@ static bool conn_status = false; -static void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, - const char *text) { +static void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) { + (void)mesh; + (void)level; + char connection_match_msg[100]; fprintf(stderr, "meshlink>> %s\n", text); @@ -78,9 +80,9 @@ static void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, } int main(int argc, char *argv[]) { + (void)argc; + int client_id = -1; - bool result = false; - int i; if((argv[3]) && (argv[4])) { client_id = atoi(argv[3]); diff --git a/test/blackbox/test_case_meta_conn_01/node_sim_peer.c b/test/blackbox/test_case_meta_conn_01/node_sim_peer.c index 6fc3dbf5..8b242038 100644 --- a/test/blackbox/test_case_meta_conn_01/node_sim_peer.c +++ b/test/blackbox/test_case_meta_conn_01/node_sim_peer.c @@ -25,6 +25,8 @@ #include "../common/mesh_event_handler.h" int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; int client_id = -1; diff --git a/test/blackbox/test_case_meta_conn_01/node_sim_relay.c b/test/blackbox/test_case_meta_conn_01/node_sim_relay.c index 2cf948ed..3c6c548c 100644 --- a/test/blackbox/test_case_meta_conn_01/node_sim_relay.c +++ b/test/blackbox/test_case_meta_conn_01/node_sim_relay.c @@ -25,6 +25,8 @@ #include "../common/mesh_event_handler.h" int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; int client_id = -1; diff --git a/test/blackbox/test_case_meta_conn_01/test/node_step.sh b/test/blackbox/test_case_meta_conn_01/test/node_step.sh new file mode 100755 index 00000000..fe28423a --- /dev/null +++ b/test/blackbox/test_case_meta_conn_01/test/node_step.sh @@ -0,0 +1,25 @@ +# node_step.sh -- Script to send signal to control Mesh Node Simulation +# Copyright (C) 2018 Guus Sliepen +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Read command-line arguments +prog_name=$1 +signal=$2 + +# Find instance of running program and send the named signal to it +pid=`/bin/pidof -s ${prog_name}` +kill -${signal} ${pid} +exit $? diff --git a/test/blackbox/test_case_meta_conn_02/node_sim_nut.c b/test/blackbox/test_case_meta_conn_02/node_sim_nut.c index bba685ae..d56124dd 100644 --- a/test/blackbox/test_case_meta_conn_02/node_sim_nut.c +++ b/test/blackbox/test_case_meta_conn_02/node_sim_nut.c @@ -34,8 +34,10 @@ static bool conn_status = false; -static void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, - const char *text) { +static void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) { + (void)mesh; + (void)level; + char connection_match_msg[100]; fprintf(stderr, "meshlink>> %s\n", text); @@ -78,9 +80,9 @@ static void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, } int main(int argc, char *argv[]) { + (void)argc; + int client_id = -1; - bool result = false; - int i; if((argv[3]) && (argv[4])) { client_id = atoi(argv[3]); diff --git a/test/blackbox/test_case_meta_conn_02/node_sim_peer.c b/test/blackbox/test_case_meta_conn_02/node_sim_peer.c index b7dbd659..429ca333 100644 --- a/test/blackbox/test_case_meta_conn_02/node_sim_peer.c +++ b/test/blackbox/test_case_meta_conn_02/node_sim_peer.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; int client_id = -1; diff --git a/test/blackbox/test_case_meta_conn_02/node_sim_relay.c b/test/blackbox/test_case_meta_conn_02/node_sim_relay.c index 9d0636d1..20fd8373 100644 --- a/test/blackbox/test_case_meta_conn_02/node_sim_relay.c +++ b/test/blackbox/test_case_meta_conn_02/node_sim_relay.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; int client_id = -1; diff --git a/test/blackbox/test_case_meta_conn_03/node_sim_nut.c b/test/blackbox/test_case_meta_conn_03/node_sim_nut.c index f8a6aa22..cdffb6ea 100644 --- a/test/blackbox/test_case_meta_conn_03/node_sim_nut.c +++ b/test/blackbox/test_case_meta_conn_03/node_sim_nut.c @@ -28,8 +28,10 @@ static bool conn_status = false; -void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, - const char *text) { +void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) { + (void)mesh; + (void)level; + char connection_match_msg[100]; fprintf(stderr, "meshlink>> %s\n", text); @@ -72,6 +74,8 @@ void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, } int main(int argc, char *argv[]) { + (void)argc; + int client_id = -1; bool result = false; int i; diff --git a/test/blackbox/test_case_meta_conn_03/node_sim_peer.c b/test/blackbox/test_case_meta_conn_03/node_sim_peer.c index b7dbd659..429ca333 100644 --- a/test/blackbox/test_case_meta_conn_03/node_sim_peer.c +++ b/test/blackbox/test_case_meta_conn_03/node_sim_peer.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; int client_id = -1; diff --git a/test/blackbox/test_case_meta_conn_03/node_sim_relay.c b/test/blackbox/test_case_meta_conn_03/node_sim_relay.c index 4a4de245..f24037d9 100644 --- a/test/blackbox/test_case_meta_conn_03/node_sim_relay.c +++ b/test/blackbox/test_case_meta_conn_03/node_sim_relay.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; int client_id = -1; diff --git a/test/blackbox/test_case_meta_conn_04/node_sim_nut.c b/test/blackbox/test_case_meta_conn_04/node_sim_nut.c index 04b6d9c9..e16dee39 100644 --- a/test/blackbox/test_case_meta_conn_04/node_sim_nut.c +++ b/test/blackbox/test_case_meta_conn_04/node_sim_nut.c @@ -34,8 +34,10 @@ static bool conn_status = false; -void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, - const char *text) { +void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) { + (void)mesh; + (void)level; + char connection_match_msg[100]; fprintf(stderr, "meshlink>> %s\n", text); @@ -78,9 +80,9 @@ void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, } int main(int argc, char *argv[]) { - struct timeval main_loop_wait = { 5, 0 }; - int i, clientId = -1; - bool result; + (void)argc; + + int clientId = -1; char *invite_peer; if((argv[3]) && (argv[4])) { diff --git a/test/blackbox/test_case_meta_conn_04/node_sim_peer.c b/test/blackbox/test_case_meta_conn_04/node_sim_peer.c index b619f77e..ef0cfcbb 100644 --- a/test/blackbox/test_case_meta_conn_04/node_sim_peer.c +++ b/test/blackbox/test_case_meta_conn_04/node_sim_peer.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; int client_id = -1; diff --git a/test/blackbox/test_case_meta_conn_04/node_sim_relay.c b/test/blackbox/test_case_meta_conn_04/node_sim_relay.c index c0009b6c..3e4299dc 100644 --- a/test/blackbox/test_case_meta_conn_04/node_sim_relay.c +++ b/test/blackbox/test_case_meta_conn_04/node_sim_relay.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; int clientid = -1; diff --git a/test/blackbox/test_case_meta_conn_05/node_sim_nut.c b/test/blackbox/test_case_meta_conn_05/node_sim_nut.c index 0a014e83..b6d90c93 100644 --- a/test/blackbox/test_case_meta_conn_05/node_sim_nut.c +++ b/test/blackbox/test_case_meta_conn_05/node_sim_nut.c @@ -34,8 +34,10 @@ static bool conn_status = false; -void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, - const char *text) { +void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, const char *text) { + (void)mesh; + (void)level; + char connection_match_msg[100]; fprintf(stderr, "meshlink>> %s\n", text); @@ -78,9 +80,9 @@ void callback_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, } int main(int argc, char *argv[]) { - struct timeval main_loop_wait = { 5, 0 }; - int i, clientId = -1; - bool result; + (void)argc; + + int clientId = -1; char *invite_peer; if((argv[3]) && (argv[4])) { diff --git a/test/blackbox/test_case_meta_conn_05/node_sim_peer.c b/test/blackbox/test_case_meta_conn_05/node_sim_peer.c index b7dbd659..429ca333 100644 --- a/test/blackbox/test_case_meta_conn_05/node_sim_peer.c +++ b/test/blackbox/test_case_meta_conn_05/node_sim_peer.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; int client_id = -1; diff --git a/test/blackbox/test_case_meta_conn_05/node_sim_relay.c b/test/blackbox/test_case_meta_conn_05/node_sim_relay.c index c0009b6c..3e4299dc 100644 --- a/test/blackbox/test_case_meta_conn_05/node_sim_relay.c +++ b/test/blackbox/test_case_meta_conn_05/node_sim_relay.c @@ -31,6 +31,8 @@ #define CMD_LINE_ARG_INVITEURL 5 int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; int clientid = -1; diff --git a/test/blackbox/test_case_optimal_pmtu_01/node_sim_nut.c b/test/blackbox/test_case_optimal_pmtu_01/node_sim_nut.c index 40c9a031..5d8975d3 100644 --- a/test/blackbox/test_case_optimal_pmtu_01/node_sim_nut.c +++ b/test/blackbox/test_case_optimal_pmtu_01/node_sim_nut.c @@ -43,7 +43,6 @@ static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, . static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable); static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len); -static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len); pmtu_attr_t node_pmtu[2]; static time_t node_shutdown_time = 0; @@ -68,8 +67,9 @@ static void print_mtu_calc(pmtu_attr_t node_pmtu) { } // Node status callback -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + // Signal pthread_cond_wait if peer is reachable if(!strcasecmp(node->name, "peer") && reachable) { set_sync_flag(&peer_reachable, true); @@ -88,23 +88,6 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t return; } -static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, uint16_t port, const void *dat, size_t len) { - (void)dat; - (void)len; - - assert(port == CHANNEL_PORT); - - // If the channel is from peer node set receive callback for it else reject the channel - if(!strcmp(channel->node->name, "peer")) { - meshlink_set_channel_receive_cb(mesh, channel, channel_receive_cb); - mesh->priv = channel; - - return true; - } - - return false; -} - /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { if(len == 0) { @@ -140,8 +123,6 @@ static void meshlink_logger(meshlink_handle_t *mesh, meshlink_log_level_t level, cur_time = time(NULL); assert(cur_time != -1); - bool mtu_probe = false; - if(node_shutdown_time && cur_time >= node_shutdown_time) { test_pmtu_nut_running = false; } @@ -313,4 +294,6 @@ void *node_sim_pmtu_nut_01(void *arg) { print_mtu_calc(node_pmtu[NODE_PMTU_PEER]); fprintf(stderr, "\nNODE_PMTU_RELAY :\n"); print_mtu_calc(node_pmtu[NODE_PMTU_RELAY]); + + return NULL; } diff --git a/test/blackbox/test_case_optimal_pmtu_01/node_sim_peer.c b/test/blackbox/test_case_optimal_pmtu_01/node_sim_peer.c index 678c009b..1768ecae 100644 --- a/test/blackbox/test_case_optimal_pmtu_01/node_sim_peer.c +++ b/test/blackbox/test_case_optimal_pmtu_01/node_sim_peer.c @@ -33,7 +33,6 @@ extern bool test_pmtu_peer_running; -static struct sync_flag nut_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER}; static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len); @@ -55,13 +54,6 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, return false; } -static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) { - (void)len; - meshlink_set_channel_poll_cb(mesh, channel, NULL); - assert(meshlink_channel_send(mesh, channel, "test", 5) >= 0); - return; -} - /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { if(len == 0) { diff --git a/test/blackbox/test_cases_submesh01/node_sim_app1node1.c b/test/blackbox/test_cases_submesh01/node_sim_app1node1.c index 50cf4fe1..2bf19a94 100644 --- a/test/blackbox/test_cases_submesh01/node_sim_app1node1.c +++ b/test/blackbox/test_cases_submesh01/node_sim_app1node1.c @@ -136,8 +136,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -148,12 +149,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app1node1\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; meshlink_node_t *core_node = NULL; @@ -218,4 +223,4 @@ int main(int argc, char *argv[]) { meshlink_close(mesh); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/test/blackbox/test_cases_submesh01/node_sim_app1node2.c b/test/blackbox/test_cases_submesh01/node_sim_app1node2.c index bb8697bf..2cc7b5cb 100644 --- a/test/blackbox/test_cases_submesh01/node_sim_app1node2.c +++ b/test/blackbox/test_cases_submesh01/node_sim_app1node2.c @@ -83,6 +83,8 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -126,8 +128,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -143,12 +146,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app1node2\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; meshlink_node_t *core_node = NULL; @@ -240,4 +247,4 @@ int main(int argc, char *argv[]) { meshlink_close(mesh); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/test/blackbox/test_cases_submesh01/node_sim_app2node1.c b/test/blackbox/test_cases_submesh01/node_sim_app2node1.c index ced45aeb..059850d0 100644 --- a/test/blackbox/test_cases_submesh01/node_sim_app2node1.c +++ b/test/blackbox/test_cases_submesh01/node_sim_app2node1.c @@ -135,8 +135,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -147,12 +148,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app2node1\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; meshlink_node_t *core_node = NULL; @@ -217,4 +222,4 @@ int main(int argc, char *argv[]) { meshlink_close(mesh); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/test/blackbox/test_cases_submesh01/node_sim_app2node2.c b/test/blackbox/test_cases_submesh01/node_sim_app2node2.c index 4323988b..db65032d 100644 --- a/test/blackbox/test_cases_submesh01/node_sim_app2node2.c +++ b/test/blackbox/test_cases_submesh01/node_sim_app2node2.c @@ -83,6 +83,8 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -126,8 +128,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -143,12 +146,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app2node2\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; meshlink_node_t *core_node = NULL; @@ -240,4 +247,4 @@ int main(int argc, char *argv[]) { meshlink_close(mesh); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/test/blackbox/test_cases_submesh01/node_sim_corenode1.c b/test/blackbox/test_cases_submesh01/node_sim_corenode1.c index 842e5d71..8c8eb7c1 100644 --- a/test/blackbox/test_cases_submesh01/node_sim_corenode1.c +++ b/test/blackbox/test_cases_submesh01/node_sim_corenode1.c @@ -35,16 +35,14 @@ #define CMD_LINE_ARG_INVITEURL 5 #define CHANNEL_PORT 1234 -static bool conn_status = false; static int client_id = -1; -static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static struct sync_flag channel_data_recieved = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static meshlink_handle_t *mesh = NULL; -static void mesh_send_message_handler(char *destination); +static void mesh_send_message_handler(const char *destination); static void send_event(mesh_event_t event) { int attempts; @@ -62,6 +60,8 @@ static void send_event(mesh_event_t event) { /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -86,8 +86,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(reachable) { fprintf(stderr, "Node %s became reachable\n", node->name); } else { @@ -98,8 +99,8 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, } static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) { - char *message = "Channel Message"; - char *node = channel->node->name; + const char *message = "Channel Message"; + const char *node = channel->node->name; (void)len; meshlink_set_channel_poll_cb(mesh, channel, NULL); fprintf(stderr, "corenode1's Channel request has been accepted by %s at : %lu\n", node, time(NULL)); @@ -125,7 +126,7 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, return true; } -void mesh_send_message_handler(char *destination) { +static void mesh_send_message_handler(const char *destination) { meshlink_channel_t *channel = NULL; meshlink_node_t *target_node = NULL; @@ -139,8 +140,9 @@ void mesh_send_message_handler(char *destination) { } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; - int i; // Import mesh event handler diff --git a/test/blackbox/test_cases_submesh01/node_sim_corenode2.c b/test/blackbox/test_cases_submesh01/node_sim_corenode2.c index a7b4760b..222a27ce 100644 --- a/test/blackbox/test_cases_submesh01/node_sim_corenode2.c +++ b/test/blackbox/test_cases_submesh01/node_sim_corenode2.c @@ -82,6 +82,8 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -115,8 +117,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "Node corenode2 became reachable"); @@ -127,12 +130,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in corenode2\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; meshlink_node_t *core_node = NULL; @@ -197,4 +204,4 @@ int main(int argc, char *argv[]) { meshlink_close(mesh); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/test/blackbox/test_cases_submesh02/node_sim_app1node1.c b/test/blackbox/test_cases_submesh02/node_sim_app1node1.c index d5423578..169520f7 100644 --- a/test/blackbox/test_cases_submesh02/node_sim_app1node1.c +++ b/test/blackbox/test_cases_submesh02/node_sim_app1node1.c @@ -136,8 +136,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -148,12 +149,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app1node1\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; meshlink_node_t *core_node = NULL; @@ -218,4 +223,4 @@ int main(int argc, char *argv[]) { meshlink_close(mesh); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/test/blackbox/test_cases_submesh02/node_sim_app1node2.c b/test/blackbox/test_cases_submesh02/node_sim_app1node2.c index 77aa8b37..1429745b 100644 --- a/test/blackbox/test_cases_submesh02/node_sim_app1node2.c +++ b/test/blackbox/test_cases_submesh02/node_sim_app1node2.c @@ -83,6 +83,8 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -126,8 +128,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -143,12 +146,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app1node2\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + size_t num_nodes, i; struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; @@ -227,7 +234,7 @@ int main(int argc, char *argv[]) { num_nodes = 0; node_handles = meshlink_get_all_nodes(mesh, NULL, &num_nodes); - fprintf(stderr, "\tGot %d nodes in list with error : %s\n", num_nodes, meshlink_strerror(meshlink_errno)); + fprintf(stderr, "\tGot %d nodes in list with error : %s\n", (int)num_nodes, meshlink_strerror(meshlink_errno)); assert(node_handles); assert((num_nodes == 4)); diff --git a/test/blackbox/test_cases_submesh02/node_sim_app2node1.c b/test/blackbox/test_cases_submesh02/node_sim_app2node1.c index ced45aeb..059850d0 100644 --- a/test/blackbox/test_cases_submesh02/node_sim_app2node1.c +++ b/test/blackbox/test_cases_submesh02/node_sim_app2node1.c @@ -135,8 +135,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -147,12 +148,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app2node1\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; meshlink_node_t *core_node = NULL; @@ -217,4 +222,4 @@ int main(int argc, char *argv[]) { meshlink_close(mesh); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/test/blackbox/test_cases_submesh02/node_sim_app2node2.c b/test/blackbox/test_cases_submesh02/node_sim_app2node2.c index b480f6a0..2bf43dee 100644 --- a/test/blackbox/test_cases_submesh02/node_sim_app2node2.c +++ b/test/blackbox/test_cases_submesh02/node_sim_app2node2.c @@ -83,6 +83,8 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -126,8 +128,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -143,12 +146,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app2node2\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + size_t num_nodes, i; struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; @@ -227,7 +234,7 @@ int main(int argc, char *argv[]) { num_nodes = 0; node_handles = meshlink_get_all_nodes(mesh, NULL, &num_nodes); - fprintf(stderr, "\tGot %d nodes in list with error : %s\n", num_nodes, meshlink_strerror(meshlink_errno)); + fprintf(stderr, "\tGot %d nodes in list with error : %s\n", (int)num_nodes, meshlink_strerror(meshlink_errno)); assert(node_handles); assert((num_nodes == 4)); diff --git a/test/blackbox/test_cases_submesh02/node_sim_corenode1.c b/test/blackbox/test_cases_submesh02/node_sim_corenode1.c index 842e5d71..8c8eb7c1 100644 --- a/test/blackbox/test_cases_submesh02/node_sim_corenode1.c +++ b/test/blackbox/test_cases_submesh02/node_sim_corenode1.c @@ -35,16 +35,14 @@ #define CMD_LINE_ARG_INVITEURL 5 #define CHANNEL_PORT 1234 -static bool conn_status = false; static int client_id = -1; -static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static struct sync_flag channel_data_recieved = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static meshlink_handle_t *mesh = NULL; -static void mesh_send_message_handler(char *destination); +static void mesh_send_message_handler(const char *destination); static void send_event(mesh_event_t event) { int attempts; @@ -62,6 +60,8 @@ static void send_event(mesh_event_t event) { /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -86,8 +86,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(reachable) { fprintf(stderr, "Node %s became reachable\n", node->name); } else { @@ -98,8 +99,8 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, } static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) { - char *message = "Channel Message"; - char *node = channel->node->name; + const char *message = "Channel Message"; + const char *node = channel->node->name; (void)len; meshlink_set_channel_poll_cb(mesh, channel, NULL); fprintf(stderr, "corenode1's Channel request has been accepted by %s at : %lu\n", node, time(NULL)); @@ -125,7 +126,7 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, return true; } -void mesh_send_message_handler(char *destination) { +static void mesh_send_message_handler(const char *destination) { meshlink_channel_t *channel = NULL; meshlink_node_t *target_node = NULL; @@ -139,8 +140,9 @@ void mesh_send_message_handler(char *destination) { } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; - int i; // Import mesh event handler diff --git a/test/blackbox/test_cases_submesh02/node_sim_corenode2.c b/test/blackbox/test_cases_submesh02/node_sim_corenode2.c index a7b4760b..222a27ce 100644 --- a/test/blackbox/test_cases_submesh02/node_sim_corenode2.c +++ b/test/blackbox/test_cases_submesh02/node_sim_corenode2.c @@ -82,6 +82,8 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -115,8 +117,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "Node corenode2 became reachable"); @@ -127,12 +130,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in corenode2\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; meshlink_node_t *core_node = NULL; @@ -197,4 +204,4 @@ int main(int argc, char *argv[]) { meshlink_close(mesh); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/test/blackbox/test_cases_submesh03/node_sim_app1node1.c b/test/blackbox/test_cases_submesh03/node_sim_app1node1.c index d5423578..169520f7 100644 --- a/test/blackbox/test_cases_submesh03/node_sim_app1node1.c +++ b/test/blackbox/test_cases_submesh03/node_sim_app1node1.c @@ -136,8 +136,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -148,12 +149,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app1node1\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; meshlink_node_t *core_node = NULL; @@ -218,4 +223,4 @@ int main(int argc, char *argv[]) { meshlink_close(mesh); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/test/blackbox/test_cases_submesh03/node_sim_app1node2.c b/test/blackbox/test_cases_submesh03/node_sim_app1node2.c index 39d998e1..450d5338 100644 --- a/test/blackbox/test_cases_submesh03/node_sim_app1node2.c +++ b/test/blackbox/test_cases_submesh03/node_sim_app1node2.c @@ -83,6 +83,8 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -126,8 +128,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -143,12 +146,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app1node2\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + size_t num_nodes, i; struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; diff --git a/test/blackbox/test_cases_submesh03/node_sim_corenode1.c b/test/blackbox/test_cases_submesh03/node_sim_corenode1.c index 5648d280..6d6c94d7 100644 --- a/test/blackbox/test_cases_submesh03/node_sim_corenode1.c +++ b/test/blackbox/test_cases_submesh03/node_sim_corenode1.c @@ -35,16 +35,14 @@ #define CMD_LINE_ARG_INVITEURL 5 #define CHANNEL_PORT 1234 -static bool conn_status = false; static int client_id = -1; -static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static struct sync_flag channel_data_recieved = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static meshlink_handle_t *mesh = NULL; -static void mesh_send_message_handler(char *destination); +static void mesh_send_message_handler(const char *destination); static void send_event(mesh_event_t event) { int attempts; @@ -62,6 +60,8 @@ static void send_event(mesh_event_t event) { /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -74,7 +74,7 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan fprintf(stderr, "corenode1 got message from %s as %s\n", channel->node->name, data); if(!memcmp(dat, "Channel Message", len)) { - mesh_send_message_handler((char *)channel->node->name); + mesh_send_message_handler(channel->node->name); if(0 == strcmp("app1node1", channel->node->name)) { set_sync_flag(&channel_data_recieved, true); @@ -86,8 +86,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(reachable) { fprintf(stderr, "Node %s became reachable\n", node->name); } else { @@ -98,8 +99,8 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, } static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) { - char *message = "Channel Message"; - char *node = (char *)channel->node->name; + const char *message = "Channel Message"; + const char *node = channel->node->name; (void)len; meshlink_set_channel_poll_cb(mesh, channel, NULL); fprintf(stderr, "corenode1's Channel request has been accepted by %s at : %lu\n", node, time(NULL)); @@ -125,7 +126,7 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, return true; } -void mesh_send_message_handler(char *destination) { +static void mesh_send_message_handler(const char *destination) { meshlink_channel_t *channel = NULL; meshlink_node_t *target_node = NULL; @@ -139,8 +140,9 @@ void mesh_send_message_handler(char *destination) { } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; - int i; // Import mesh event handler diff --git a/test/blackbox/test_cases_submesh04/node_sim_app1node1.c b/test/blackbox/test_cases_submesh04/node_sim_app1node1.c index d5423578..169520f7 100644 --- a/test/blackbox/test_cases_submesh04/node_sim_app1node1.c +++ b/test/blackbox/test_cases_submesh04/node_sim_app1node1.c @@ -136,8 +136,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -148,12 +149,16 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app1node1\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; meshlink_node_t *core_node = NULL; @@ -218,4 +223,4 @@ int main(int argc, char *argv[]) { meshlink_close(mesh); return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/test/blackbox/test_cases_submesh04/node_sim_app1node2.c b/test/blackbox/test_cases_submesh04/node_sim_app1node2.c index 14729f5e..28bbaa19 100644 --- a/test/blackbox/test_cases_submesh04/node_sim_app1node2.c +++ b/test/blackbox/test_cases_submesh04/node_sim_app1node2.c @@ -84,6 +84,8 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -128,8 +130,9 @@ static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(!strcasecmp(node->name, "corenode1")) { if(reachable) { fprintf(stderr, "\tNode corenode1 became reachable\n"); @@ -145,18 +148,21 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, return; } -void mesh_start_test_handler(int a) { +void mesh_start_test_handler(int signum) { + (void)signum; + fprintf(stderr, "Starting test in app1node2\n"); set_sync_flag(&start_test, true); } int main(int argc, char *argv[]) { + (void)argc; + size_t num_nodes, i; struct timeval main_loop_wait = { 2, 0 }; meshlink_channel_t *channel = NULL; meshlink_node_t *core_node = NULL; meshlink_node_t **node_handles = NULL; - ssize_t retvalue = -1; fprintf(stderr, "\tMesh node 'app1node2' starting up........\n"); diff --git a/test/blackbox/test_cases_submesh04/node_sim_corenode1.c b/test/blackbox/test_cases_submesh04/node_sim_corenode1.c index d37c54a9..a2ff3ce3 100644 --- a/test/blackbox/test_cases_submesh04/node_sim_corenode1.c +++ b/test/blackbox/test_cases_submesh04/node_sim_corenode1.c @@ -35,16 +35,14 @@ #define CMD_LINE_ARG_INVITEURL 5 #define CHANNEL_PORT 1234 -static bool conn_status = false; static int client_id = -1; -static struct sync_flag peer_reachable = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static struct sync_flag channel_opened = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static struct sync_flag channel_data_recieved = {.mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .flag = false}; static meshlink_handle_t *mesh = NULL; -static void mesh_send_message_handler(char *destination); +static void mesh_send_message_handler(const char *destination); static void send_event(mesh_event_t event) { int attempts; @@ -62,6 +60,8 @@ static void send_event(mesh_event_t event) { /* channel receive callback */ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, const void *dat, size_t len) { + (void)mesh; + char data[100] = {0}; if(len == 0) { @@ -74,7 +74,7 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan fprintf(stderr, "corenode1 got message from %s as %s\n", channel->node->name, data); if(!memcmp(dat, "Channel Message", len)) { - mesh_send_message_handler((char *)channel->node->name); + mesh_send_message_handler(channel->node->name); if(0 == strcmp("app1node2", channel->node->name)) { set_sync_flag(&channel_data_recieved, true); @@ -86,8 +86,9 @@ static void channel_receive_cb(meshlink_handle_t *mesh, meshlink_channel_t *chan return; } -static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, - bool reachable) { +static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool reachable) { + (void)mesh; + if(reachable) { fprintf(stderr, "Node %s became reachable\n", node->name); } else { @@ -98,8 +99,8 @@ static void node_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, } static void poll_cb(meshlink_handle_t *mesh, meshlink_channel_t *channel, size_t len) { - char *message = "Channel Message"; - char *node = (char *)channel->node->name; + const char *message = "Channel Message"; + const char *node = channel->node->name; (void)len; meshlink_set_channel_poll_cb(mesh, channel, NULL); fprintf(stderr, "corenode1's Channel request has been accepted by %s at : %lu\n", node, time(NULL)); @@ -125,7 +126,7 @@ static bool channel_accept(meshlink_handle_t *mesh, meshlink_channel_t *channel, return true; } -void mesh_send_message_handler(char *destination) { +static void mesh_send_message_handler(const char *destination) { meshlink_channel_t *channel = NULL; meshlink_node_t *target_node = NULL; @@ -139,8 +140,9 @@ void mesh_send_message_handler(char *destination) { } int main(int argc, char *argv[]) { + (void)argc; + struct timeval main_loop_wait = { 5, 0 }; - int i; // Import mesh event handler diff --git a/test/import-export.c b/test/import-export.c index eaa94497..0671cf47 100644 --- a/test/import-export.c +++ b/test/import-export.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "meshlink.h" diff --git a/test/invite-join.c b/test/invite-join.c index c9ebea60..b69eb3d8 100644 --- a/test/invite-join.c +++ b/test/invite-join.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "meshlink.h" -- 2.39.5