6 #include "meshlink++.h"
10 int main(int argc, char *argv[]) {
11 // Open a new meshlink instance.
14 mesh.open("basicpp_conf", "foo", "basicpp", DEV_CLASS_BACKBONE);
16 // Check that our own node exists.
18 meshlink::node *self = mesh.get_self();
20 cerr << "Foo does not know about itself\n";
23 if(strcmp(self->name, "foo")) {
24 cerr << "Foo thinks its name is " << self->name << "\n";
28 // Start and stop the mesh.
31 cerr << "Foo could not start\n";
36 // Make sure we can start and stop the mesh again.
39 cerr << "Foo could not start twice\n";
44 // Close the mesh and open it again, now with a different name parameter.
48 // Check that the name is ignored now, and that we still are "foo".
50 mesh.open("basicpp_conf", "bar", "basicpp", DEV_CLASS_BACKBONE);
52 if(mesh.get_node("bar")) {
53 cerr << "Foo knows about bar, it shouldn't\n";
57 self = mesh.get_self();
59 cerr << "Foo doesn't know about itself the second time\n";
62 if(strcmp(self->name, "foo")) {
63 cerr << "Foo thinks its name is " << self->name << " the second time\n";
67 // Start and stop the mesh.
70 cerr << "Foo could not start a third time\n";
76 if(!meshlink::destroy("basicpp_conf")) {
77 cerr << "Could not destroy configuration\n";
81 if(!access("basic.conf", F_OK) || errno != ENOENT) {
82 cerr << "Configuration not fully destroyed\n";