]> git.meshlink.io Git - meshlink/blobdiff - test/blackbox/run_blackbox_tests/test_cases_whitelist.c
Fix __warn_unused_result__, add more of it and fix the resulting warnings.
[meshlink] / test / blackbox / run_blackbox_tests / test_cases_whitelist.c
index 0ee8636efaa3ba8d5ac49d1d6a0c7c0a21e962dd..68283a96f0fca27b699dc3af4ce2477c81e2ae55 100644 (file)
     51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
+#ifdef NDEBUG
+#undef NDEBUG
+#endif
+
 #include "execute_tests.h"
 #include "test_cases_whitelist.h"
 #include "../common/containers.h"
@@ -70,7 +74,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 +88,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;
@@ -104,8 +113,8 @@ static bool test_steps_mesh_whitelist_01(void) {
 
        // Open two new meshlink instance.
 
-       meshlink_destroy("whitelist_conf.1");
-       meshlink_destroy("whitelist_conf.2");
+       assert(meshlink_destroy("whitelist_conf.1"));
+       assert(meshlink_destroy("whitelist_conf.2"));
        meshlink_handle_t *mesh1 = meshlink_open("whitelist_conf.1", "foo", "test", DEV_CLASS_BACKBONE);
        assert(mesh1);
        meshlink_set_log_cb(mesh1, MESHLINK_DEBUG, meshlink_callback_logger);
@@ -161,7 +170,7 @@ static bool test_steps_mesh_whitelist_01(void) {
        pthread_mutex_unlock(& lock_receive);
 
 
-       meshlink_blacklist(mesh1, foo);
+       assert(meshlink_blacklist(mesh1, foo));
 
        rec_stat = false;
        assert(meshlink_send(mesh1, bar, "test", 5));
@@ -174,7 +183,7 @@ static bool test_steps_mesh_whitelist_01(void) {
        }
 
        pthread_mutex_unlock(& lock_receive);
-       meshlink_whitelist(mesh1, foo);
+       assert(meshlink_whitelist(mesh1, foo));
 
        rec_stat = false;
        bool result = meshlink_send(mesh2, foo, "test", 5);
@@ -191,8 +200,8 @@ static bool test_steps_mesh_whitelist_01(void) {
 
        meshlink_close(mesh2);
        meshlink_close(mesh1);
-       meshlink_destroy("whitelist_conf.1");
-       meshlink_destroy("whitelist_conf.2");
+       assert(meshlink_destroy("whitelist_conf.1"));
+       assert(meshlink_destroy("whitelist_conf.2"));
 
        return result;
 }
@@ -215,8 +224,8 @@ static bool test_steps_mesh_whitelist_02(void) {
 
        // Open two new meshlink instance.
 
-       meshlink_destroy("whitelist_conf.3");
-       meshlink_destroy("whitelist_conf.4");
+       assert(meshlink_destroy("whitelist_conf.3"));
+       assert(meshlink_destroy("whitelist_conf.4"));
        meshlink_handle_t *mesh1 = meshlink_open("whitelist_conf.3", "foo", "test", DEV_CLASS_BACKBONE);
        assert(mesh1);
        meshlink_handle_t *mesh2 = meshlink_open("whitelist_conf.4", "bar", "test", DEV_CLASS_BACKBONE);
@@ -257,19 +266,19 @@ static bool test_steps_mesh_whitelist_02(void) {
 
        assert(meshlink_send(mesh1, bar, "test", 5));
 
-       meshlink_blacklist(mesh1, foo);
+       assert(meshlink_blacklist(mesh1, foo));
 
        // Passing NULL as mesh handle but with valid node handle 'foo'
 
-       meshlink_whitelist(NULL, foo);
+       assert(!meshlink_whitelist(NULL, foo));
        assert_int_equal(meshlink_errno, MESHLINK_EINVAL);
 
        // Clean up.
 
        meshlink_close(mesh2);
        meshlink_close(mesh1);
-       meshlink_destroy("whitelist_conf.3");
-       meshlink_destroy("whitelist_conf.4");
+       assert(meshlink_destroy("whitelist_conf.3"));
+       assert(meshlink_destroy("whitelist_conf.4"));
 
        return true;
 }
@@ -290,20 +299,20 @@ static void test_case_mesh_whitelist_03(void **state) {
 static bool test_steps_mesh_whitelist_03(void) {
        // Open meshlink instance.
 
-       meshlink_destroy("whitelist_conf");
+       assert(meshlink_destroy("whitelist_conf"));
        meshlink_handle_t *mesh = meshlink_open("whitelist_conf", "foo", "test", DEV_CLASS_BACKBONE);
        assert(mesh);
 
        // Start instance
        assert(meshlink_start(mesh));
 
-       meshlink_whitelist(mesh, NULL);
+       assert(!meshlink_whitelist(mesh, NULL));
        assert_int_equal(meshlink_errno, MESHLINK_EINVAL);
 
        // Clean up.
 
        meshlink_close(mesh);
-       meshlink_destroy("whitelist_conf");
+       assert(meshlink_destroy("whitelist_conf"));
        return true;
 }