diff options
Diffstat (limited to 'src/mesh/test_mesh_api.c')
-rw-r--r-- | src/mesh/test_mesh_api.c | 79 |
1 files changed, 32 insertions, 47 deletions
diff --git a/src/mesh/test_mesh_api.c b/src/mesh/test_mesh_api.c index 4383d3133..00212eb49 100644 --- a/src/mesh/test_mesh_api.c +++ b/src/mesh/test_mesh_api.c | |||
@@ -7,6 +7,7 @@ static struct GNUNET_MESH_MessageHandler handlers[] = { | |||
7 | {NULL, 0, 0} | 7 | {NULL, 0, 0} |
8 | }; | 8 | }; |
9 | 9 | ||
10 | |||
10 | static void | 11 | static void |
11 | run (void *cls, | 12 | run (void *cls, |
12 | char *const *args, | 13 | char *const *args, |
@@ -14,37 +15,30 @@ run (void *cls, | |||
14 | struct GNUNET_OS_Process *arm_pid; | 15 | struct GNUNET_OS_Process *arm_pid; |
15 | struct GNUNET_MESH_Handle *mesh; | 16 | struct GNUNET_MESH_Handle *mesh; |
16 | struct GNUNET_DHT_Handle *dht; | 17 | struct GNUNET_DHT_Handle *dht; |
17 | // struct GNUNET_MESH_Tunnel *t; | 18 | GNUNET_MESH_ApplicationType app; |
19 | char buffer[2048]; | ||
18 | 20 | ||
19 | 21 | ||
20 | arm_pid = GNUNET_OS_start_process (NULL, NULL, | 22 | arm_pid = GNUNET_OS_start_process (NULL, NULL, |
21 | "gnunet-service-arm", | 23 | "gnunet-service-arm", |
22 | "gnunet-service-arm", | 24 | "gnunet-service-arm", |
23 | "-L", "DEBUG", | 25 | "-L", "DEBUG", |
24 | "-c", "test_dht_api_data.conf", | 26 | "-c", "test_mesh.conf", |
25 | NULL); | 27 | NULL); |
26 | // sleep(1); | ||
27 | // printf("%d\n", fopen( "test_mesh.conf", "r")); | ||
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); | 28 | dht = GNUNET_DHT_connect(cfg, 100); |
32 | if(NULL == dht) { | 29 | if(NULL == dht) { |
33 | // fprintf(stderr, "Couldn't connect to dht :(\n"); | 30 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Couldn't connect to dht :(\n"); |
34 | // return 1; // succeed anyway | 31 | } else { |
32 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "YAY! CONNECTED TO DHT :D\n"); | ||
33 | } | ||
34 | |||
35 | app = 0; | ||
36 | mesh = GNUNET_MESH_connect(cfg, NULL, NULL, handlers, &app); | ||
37 | if(NULL == mesh) { | ||
38 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Couldn't connect to mesh :(\n"); | ||
35 | } else { | 39 | } else { |
36 | // fprintf(stderr, "YAY! CONNECTED TO DHT :D\n"); | 40 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "YAY! CONNECTED TO MESH :D\n"); |
37 | } | 41 | } |
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 | ||
46 | // printf("MESH TEST\n"); | ||
47 | // t = GNUNET_MESH_tunnel_create(mesh, ); | ||
48 | 42 | ||
49 | /* do real test work here */ | 43 | /* do real test work here */ |
50 | if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM)) | 44 | if (0 != GNUNET_OS_process_kill (arm_pid, SIGTERM)) |
@@ -55,33 +49,24 @@ run (void *cls, | |||
55 | return; | 49 | return; |
56 | } | 50 | } |
57 | 51 | ||
58 | static int | 52 | |
59 | check () | ||
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 | 53 | ||
83 | int main (int argc, char *argv[]) { | 54 | int main (int argc, char *argv[]) { |
84 | if(GNUNET_OK == check()) | 55 | int ret; |
85 | return 0; | 56 | char *const argv2[] = {"test-mesh-api", |
86 | else return 1; | 57 | "-c", "test_mesh.conf", |
58 | "-L", "DEBUG", | ||
59 | NULL | ||
60 | }; | ||
61 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
62 | GNUNET_GETOPT_OPTION_END | ||
63 | }; | ||
64 | GNUNET_log_setup ("test-dht-api","DEBUG", NULL); | ||
65 | ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, | ||
66 | argv2, "test-mesh-api", "nohelp", | ||
67 | options, &run, NULL); | ||
68 | if (ret != GNUNET_OK) { | ||
69 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "test-mesh-api': Failed with error code %d\n", ret); | ||
70 | } | ||
71 | return 0; | ||
87 | } | 72 | } |