]> git.meshlink.io Git - meshlink/blobdiff - test/basicpp.cpp
Use new version of UTCP which also return errors via the poll callback.
[meshlink] / test / basicpp.cpp
index 34c0bacbf2a7b45d13b227a99378d3bbb0af67a9..02d4cb61e4b7d70c286b3a77a085d78a9ffb148e 100644 (file)
@@ -1,5 +1,7 @@
 #include <cstring>
 #include <iostream>
+#include <unistd.h>
+#include <cerrno>
 
 #include "meshlink++.h"
 
@@ -13,7 +15,7 @@ int main(int argc, char *argv[]) {
 
        // Check that our own node exists.
 
-       meshlink::node *self = mesh.get_node("foo");
+       meshlink::node *self = mesh.get_self();
        if(!self) {
                cerr << "Foo does not know about itself\n";
                return 1;
@@ -45,14 +47,14 @@ int main(int argc, char *argv[]) {
 
        // Check that the name is ignored now, and that we still are "foo".
 
-       mesh.open("basic_conf", "bar", "basicpp", DEV_CLASS_BACKBONE);
+       mesh.open("basicpp_conf", "bar", "basicpp", DEV_CLASS_BACKBONE);
 
        if(mesh.get_node("bar")) {
                cerr << "Foo knows about bar, it shouldn't\n";
                return 1;
        }
 
-       self = mesh.get_node("foo");
+       self = mesh.get_self();
        if(!self) {
                cerr << "Foo doesn't know about itself the second time\n";
                return 1;
@@ -71,5 +73,15 @@ int main(int argc, char *argv[]) {
 
        mesh.stop();
 
+       if(!meshlink::destroy("basicpp_conf")) {
+               cerr << "Could not destroy configuration\n";
+               return 1;
+       }
+
+       if(!access("basic.conf", F_OK) || errno != ENOENT) {
+               cerr << "Configuration not fully destroyed\n";
+               return 1;
+       }
+
        return 0;
 }