X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=test%2Fbasicpp.cpp;h=4d126cf58dde2e2af42c0beb02317b375e3e8caf;hb=f73f697142bd5ce32d9b7273ed73ea798594854d;hp=34c0bacbf2a7b45d13b227a99378d3bbb0af67a9;hpb=6b21c4293b372e17b2468529a901b8a521acd670;p=meshlink diff --git a/test/basicpp.cpp b/test/basicpp.cpp index 34c0bacb..4d126cf5 100644 --- a/test/basicpp.cpp +++ b/test/basicpp.cpp @@ -1,11 +1,13 @@ #include #include +#include +#include #include "meshlink++.h" using namespace std; -int main(int argc, char *argv[]) { +int main() { // Open a new meshlink instance. meshlink::mesh mesh; @@ -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; @@ -23,6 +25,10 @@ int main(int argc, char *argv[]) { return 1; } + // Disable local discovery. + + mesh.enable_discovery(false); + // Start and stop the mesh. if(!mesh.start()) { @@ -45,14 +51,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; @@ -64,6 +70,8 @@ int main(int argc, char *argv[]) { // Start and stop the mesh. + mesh.enable_discovery(false); + if(!mesh.start()) { cerr << "Foo could not start a third time\n"; return 1; @@ -71,5 +79,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; }