]> git.meshlink.io Git - meshlink/blobdiff - test/blacklist.c
Don't use assert() to check the results of pthread_*() calls.
[meshlink] / test / blacklist.c
index d504460207fc38439f62cb9a1487220aaa7bcfdf..1f5cd605e936fafb9d7c076c68c6de8d34f72f89 100644 (file)
@@ -44,7 +44,11 @@ static void baz_status_cb(meshlink_handle_t *mesh, meshlink_node_t *node, bool r
        }
 }
 
-int main() {
+int main(void) {
+       init_sync_flag(&bar_connected);
+       init_sync_flag(&bar_disconnected);
+       init_sync_flag(&baz_connected);
+
        meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_cb);
 
        // Create three instances.
@@ -58,11 +62,11 @@ int main() {
                assert(asprintf(&path, "blacklist_conf.%d", i) != -1 && path);
 
                assert(meshlink_destroy(path));
-               mesh[i] = meshlink_open(path, name[i], "trio", DEV_CLASS_BACKBONE);
+               mesh[i] = meshlink_open(path, name[i], "blacklist", DEV_CLASS_BACKBONE);
                assert(mesh[i]);
                free(path);
 
-               assert(meshlink_add_address(mesh[i], "localhost"));
+               assert(meshlink_set_canonical_address(mesh[i], meshlink_get_self(mesh[i]), "localhost", NULL));
 
                data[i] = meshlink_export(mesh[i]);
                assert(data[i]);
@@ -177,4 +181,12 @@ int main() {
        // Check that bar has no config file for baz
        assert(access("blacklist_conf.2/current/hosts/bar", F_OK) == 0);
        assert(access("blacklist_conf.1/current/hosts/baz", F_OK) != 0 && errno == ENOENT);
+
+       // Check that we remember xyzzy but not quux after reopening the mesh
+       mesh[0] = meshlink_open("blacklist_conf.0", "foo", "blacklist", DEV_CLASS_BACKBONE);
+       assert(mesh[0]);
+       assert(meshlink_get_node(mesh[0], "xyzzy"));
+       assert(!meshlink_get_node(mesh[0], "quux"));
+
+       meshlink_close(mesh[0]);
 }