aboutsummaryrefslogtreecommitdiff
path: root/src/mesh/test_mesh_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesh/test_mesh_api.c')
-rw-r--r--src/mesh/test_mesh_api.c65
1 files changed, 57 insertions, 8 deletions
diff --git a/src/mesh/test_mesh_api.c b/src/mesh/test_mesh_api.c
index 04e3a4388..4383d3133 100644
--- a/src/mesh/test_mesh_api.c
+++ b/src/mesh/test_mesh_api.c
@@ -1,30 +1,48 @@
1#include "platform.h" 1#include "platform.h"
2#include "gnunet_util_lib.h" 2#include "gnunet_util_lib.h"
3#include "gnunet_dht_service.h"
3#include "gnunet_mesh_service_new.h" 4#include "gnunet_mesh_service_new.h"
4 5
5static struct GNUNET_MESH_MessageHandler handlers[] = { 6static struct GNUNET_MESH_MessageHandler handlers[] = {
6 {NULL, 0, 0} 7 {NULL, 0, 0}
7}; 8};
8 9
9int main (int argc, char *argv[]) { 10static void
11run (void *cls,
12 char *const *args,
13 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) {
10 struct GNUNET_OS_Process *arm_pid; 14 struct GNUNET_OS_Process *arm_pid;
11 struct GNUNET_MESH_Handle *mesh; 15 struct GNUNET_MESH_Handle *mesh;
16 struct GNUNET_DHT_Handle *dht;
12// struct GNUNET_MESH_Tunnel *t; 17// struct GNUNET_MESH_Tunnel *t;
13 struct GNUNET_CONFIGURATION_Handle *cfg;
14 18
15 cfg = GNUNET_CONFIGURATION_create();
16 19
17 arm_pid = GNUNET_OS_start_process (NULL, NULL, 20 arm_pid = GNUNET_OS_start_process (NULL, NULL,
18 "gnunet-service-arm", 21 "gnunet-service-arm",
19 "gnunet-service-arm", 22 "gnunet-service-arm",
20 "-L", "DEBUG", 23 "-L", "DEBUG",
24 "-c", "test_dht_api_data.conf",
21 NULL); 25 NULL);
22 mesh = GNUNET_MESH_connect(cfg, NULL, NULL, handlers, NULL); 26// sleep(1);
23 if(NULL == mesh) { 27// printf("%d\n", fopen( "test_mesh.conf", "r"));
24 fprintf(stderr, "Couldn't connect to mesh :(\n"); 28// GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (cfg, "test_mesh.conf"));
29 //printf("%d\n", GNUNET_CONFIGURATION_load (cfg, NULL));
30// printf("%d\n", GNUNET_CONFIGURATION_load (cfg, "test_dht_api_data.conf"));
31 dht = GNUNET_DHT_connect(cfg, 100);
32 if(NULL == dht) {
33// fprintf(stderr, "Couldn't connect to dht :(\n");
25// return 1; // succeed anyway 34// return 1; // succeed anyway
35 } else {
36// fprintf(stderr, "YAY! CONNECTED TO DHT :D\n");
26 } 37 }
27 mesh = realloc(mesh, 0); // don't complain about *mesh 38// mesh = GNUNET_MESH_connect(cfg, NULL, NULL, handlers, NULL);
39// if(NULL == mesh) {
40// fprintf(stderr, "Couldn't connect to mesh :(\n");
41// return 1; // succeed anyway
42// } else {
43// fprintf(stderr, "YAY! CONNECTED TO MESH :D\n");
44// }
45// mesh = realloc(mesh, 0); // don't complain about *mesh
28// printf("MESH TEST\n"); 46// printf("MESH TEST\n");
29// t = GNUNET_MESH_tunnel_create(mesh, ); 47// t = GNUNET_MESH_tunnel_create(mesh, );
30 48
@@ -34,5 +52,36 @@ int main (int argc, char *argv[]) {
34 GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid)); 52 GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (arm_pid));
35 GNUNET_OS_process_close (arm_pid); 53 GNUNET_OS_process_close (arm_pid);
36 54
37 return 0; 55 return;
56}
57
58static int
59check ()
60{
61 int ret;
62 char *const argv[] = {"test-mesh-api",
63 "-c",
64 "test_dht_api_data.conf",
65#if VERBOSE
66 "-L", "DEBUG",
67#endif
68 NULL
69 };
70 struct GNUNET_GETOPT_CommandLineOption options[] = {
71 GNUNET_GETOPT_OPTION_END
72 };
73 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
74 argv, "test-mesh-api", "nohelp",
75 options, &run, NULL);
76 if (ret != GNUNET_OK)
77 {
78 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "test-mesh-api': Failed with error code %d\n", ret);
79 }
80 return GNUNET_OK;
81}
82
83int main (int argc, char *argv[]) {
84 if(GNUNET_OK == check())
85 return 0;
86 else return 1;
38} 87}