X-Git-Url: http://git.meshlink.io/?p=meshlink;a=blobdiff_plain;f=test%2Fbasic.c;h=bc93de09c68e32508dab5ce5bb27391dec875bca;hp=bf8ff772af73db120cadbc2d54403fb36b512d26;hb=fec95d1221c2d7e2059d6ba2fe244211ccee95ad;hpb=a97a07d79c847d0b30c61a2589e7bde62f25d603 diff --git a/test/basic.c b/test/basic.c index bf8ff772..bc93de09 100644 --- a/test/basic.c +++ b/test/basic.c @@ -16,10 +16,16 @@ int main() { 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