X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=test%2Fbasic.c;h=004e7186437fdc2b9fe8c3e64391eefb81523890;hb=4b6c01b1d5383b1a7417244a31ad4652aab2d5db;hp=bf8ff772af73db120cadbc2d54403fb36b512d26;hpb=a97a07d79c847d0b30c61a2589e7bde62f25d603;p=meshlink diff --git a/test/basic.c b/test/basic.c index bf8ff772..004e7186 100644 --- a/test/basic.c +++ b/test/basic.c @@ -13,13 +13,19 @@ #include "meshlink.h" #include "utils.h" -int main() { +int main(void) { meshlink_set_log_cb(NULL, MESHLINK_DEBUG, log_cb); - // Open a new meshlink instance. + // Check that the first time we need to supply a name assert(meshlink_destroy("basic_conf")); - meshlink_handle_t *mesh = meshlink_open("basic_conf", "foo", "basic", DEV_CLASS_BACKBONE); + + meshlink_handle_t *mesh = meshlink_open("basic_conf", NULL, "basic", DEV_CLASS_BACKBONE); + assert(!mesh); + + // Open a new meshlink instance. + + mesh = meshlink_open("basic_conf", "foo", "basic", DEV_CLASS_BACKBONE); assert(mesh); // Check that we can't open a second instance of the same node. @@ -74,10 +80,17 @@ int main() { meshlink_close(mesh); mesh = meshlink_open("basic_conf", "bar", "basic", DEV_CLASS_BACKBONE); + assert(!mesh); + + // Open it without providing a name + + mesh = meshlink_open("basic_conf", NULL, "basic", DEV_CLASS_BACKBONE); assert(mesh); self = meshlink_get_self(mesh); assert(self); + assert(!strcmp(mesh->name, "foo")); + assert(!strcmp(self->name, "foo")); // Check that we remembered we were reachable