]> git.meshlink.io Git - meshlink/blobdiff - test/basic.c
Add utility functions to create paired MeshLink instances.
[meshlink] / test / basic.c
index 626d06f6270e885a3133dd0b5819567a0b2d676a..d3ac13735e37e98726fbf68d80eb72aefb96d12a 100644 (file)
@@ -1,5 +1,7 @@
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
+#include <errno.h>
 
 #include "meshlink.h"
 
@@ -14,7 +16,7 @@ int main(int argc, char *argv[]) {
 
        // Check that our own node exists.
 
-       meshlink_node_t *self = meshlink_get_node(mesh, "foo");
+       meshlink_node_t *self = meshlink_get_self(mesh);
        if(!self) {
                fprintf(stderr, "Foo does not know about itself\n");
                return 1;
@@ -57,7 +59,7 @@ int main(int argc, char *argv[]) {
                return 1;
        }
 
-       self = meshlink_get_node(mesh, "foo");
+       self = meshlink_get_self(mesh);
        if(!self) {
                fprintf(stderr, "Foo doesn't know about itself the second time\n");
                return 1;
@@ -79,5 +81,17 @@ int main(int argc, char *argv[]) {
 
        meshlink_close(mesh);
 
+       // Destroy the mesh.
+
+       if(!meshlink_destroy("basic_conf")) {
+               fprintf(stderr, "Could not destroy configuration\n");
+               return 1;
+       }
+
+       if(!access("basic_conf", F_OK) || errno != ENOENT) {
+               fprintf(stderr, "Configuration not fully destroyed\n");
+               return 1;
+       }
+
        return 0;
 }