X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=test%2Fbasic.c;h=46f86960cab377bb97f7517191560ec9c3258eb6;hb=be83b0af60449c7b35d17d97f2e6dc12f611e831;hp=f591df7b54df1e6271a9c868a80bcb78d6464e00;hpb=6c897377f68fc23ca9a8b23a6ca204517998b2e9;p=meshlink diff --git a/test/basic.c b/test/basic.c index f591df7b..46f86960 100644 --- a/test/basic.c +++ b/test/basic.c @@ -37,14 +37,24 @@ int main() { assert(self); assert(!strcmp(self->name, "foo")); + // Check that we are reachable. + + assert(meshlink_get_node_reachability(mesh, self, NULL, NULL)); + // Start and stop the mesh. assert(meshlink_start(mesh)); meshlink_stop(mesh); + // Check that we are still reachable. + + assert(meshlink_get_node_reachability(mesh, self, NULL, NULL)); + // Make sure we can start and stop the mesh again. assert(meshlink_start(mesh)); + assert(meshlink_start(mesh)); + meshlink_stop(mesh); meshlink_stop(mesh); // Close the mesh and open it again, now with a different name parameter. @@ -66,6 +76,28 @@ int main() { meshlink_stop(mesh); meshlink_close(mesh); + // Check that messing with the config directory will create a new instance. + + assert(unlink("basic_conf/current/meshlink.conf") == 0); + mesh = meshlink_open("basic_conf", "bar", "basic", DEV_CLASS_BACKBONE); + assert(mesh); + assert(!meshlink_get_node(mesh, "foo")); + self = meshlink_get_self(mesh); + assert(self); + assert(!strcmp(self->name, "bar")); + assert(access("basic_conf/new", X_OK) == -1 && errno == ENOENT); + meshlink_close(mesh); + + assert(rename("basic_conf/current", "basic_conf/new") == 0); + mesh = meshlink_open("basic_conf", "baz", "basic", DEV_CLASS_BACKBONE); + assert(mesh); + assert(!meshlink_get_node(mesh, "bar")); + self = meshlink_get_self(mesh); + assert(self); + assert(!strcmp(self->name, "baz")); + assert(access("basic_conf/new", X_OK) == -1 && errno == ENOENT); + meshlink_close(mesh); + // Destroy the mesh. assert(meshlink_destroy("basic_conf")); @@ -81,4 +113,8 @@ int main() { } closedir(dir); + + // Check that we can destroy it again. + + assert(meshlink_destroy("basic_conf")); }