diff options
Diffstat (limited to 'src/core/test_core_api.c')
-rw-r--r-- | src/core/test_core_api.c | 27 |
1 files changed, 3 insertions, 24 deletions
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index 11fd14504..68ae39df2 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c | |||
@@ -31,10 +31,6 @@ | |||
31 | #include "gnunet_scheduler_lib.h" | 31 | #include "gnunet_scheduler_lib.h" |
32 | #include "gnunet_transport_service.h" | 32 | #include "gnunet_transport_service.h" |
33 | 33 | ||
34 | #define VERBOSE GNUNET_NO | ||
35 | |||
36 | #define START_ARM GNUNET_YES | ||
37 | |||
38 | #define MTYPE 12345 | 34 | #define MTYPE 12345 |
39 | 35 | ||
40 | struct PeerContext | 36 | struct PeerContext |
@@ -46,9 +42,7 @@ struct PeerContext | |||
46 | struct GNUNET_TRANSPORT_GetHelloHandle *ghh; | 42 | struct GNUNET_TRANSPORT_GetHelloHandle *ghh; |
47 | struct GNUNET_MessageHeader *hello; | 43 | struct GNUNET_MessageHeader *hello; |
48 | int connect_status; | 44 | int connect_status; |
49 | #if START_ARM | ||
50 | struct GNUNET_OS_Process *arm_proc; | 45 | struct GNUNET_OS_Process *arm_proc; |
51 | #endif | ||
52 | }; | 46 | }; |
53 | 47 | ||
54 | static struct PeerContext p1; | 48 | static struct PeerContext p1; |
@@ -61,11 +55,7 @@ static GNUNET_SCHEDULER_TaskIdentifier con_task; | |||
61 | 55 | ||
62 | static int ok; | 56 | static int ok; |
63 | 57 | ||
64 | #if VERBOSE | ||
65 | #define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) | 58 | #define OKPP do { ok++; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) |
66 | #else | ||
67 | #define OKPP do { ok++; } while (0) | ||
68 | #endif | ||
69 | 59 | ||
70 | 60 | ||
71 | static void | 61 | static void |
@@ -111,9 +101,8 @@ terminate_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
111 | static void | 101 | static void |
112 | terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 102 | terminate_task_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
113 | { | 103 | { |
114 | #if VERBOSE | 104 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
115 | FPRINTF (stderr, "ENDING ANGRILY %u\n", ok); | 105 | "ENDING ANGRILY %u\n", ok); |
116 | #endif | ||
117 | GNUNET_break (0); | 106 | GNUNET_break (0); |
118 | if (NULL != p1.ch) | 107 | if (NULL != p1.ch) |
119 | { | 108 | { |
@@ -320,14 +309,12 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
320 | 309 | ||
321 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); | 310 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); |
322 | p->cfg = GNUNET_CONFIGURATION_create (); | 311 | p->cfg = GNUNET_CONFIGURATION_create (); |
323 | #if START_ARM | ||
324 | p->arm_proc = | 312 | p->arm_proc = |
325 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | 313 | GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
326 | NULL, NULL, | 314 | NULL, NULL, |
327 | binary, | 315 | binary, |
328 | "gnunet-service-arm", | 316 | "gnunet-service-arm", |
329 | "-c", cfgname, NULL); | 317 | "-c", cfgname, NULL); |
330 | #endif | ||
331 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 318 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
332 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); | 319 | p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); |
333 | GNUNET_assert (p->th != NULL); | 320 | GNUNET_assert (p->th != NULL); |
@@ -358,7 +345,6 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
358 | static void | 345 | static void |
359 | stop_arm (struct PeerContext *p) | 346 | stop_arm (struct PeerContext *p) |
360 | { | 347 | { |
361 | #if START_ARM | ||
362 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) | 348 | if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM)) |
363 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 349 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); |
364 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) | 350 | if (GNUNET_OS_process_wait (p->arm_proc) != GNUNET_OK) |
@@ -367,19 +353,16 @@ stop_arm (struct PeerContext *p) | |||
367 | GNUNET_OS_process_get_pid (p->arm_proc)); | 353 | GNUNET_OS_process_get_pid (p->arm_proc)); |
368 | GNUNET_OS_process_destroy (p->arm_proc); | 354 | GNUNET_OS_process_destroy (p->arm_proc); |
369 | p->arm_proc = NULL; | 355 | p->arm_proc = NULL; |
370 | #endif | ||
371 | GNUNET_CONFIGURATION_destroy (p->cfg); | 356 | GNUNET_CONFIGURATION_destroy (p->cfg); |
372 | } | 357 | } |
373 | 358 | ||
359 | |||
374 | static int | 360 | static int |
375 | check () | 361 | check () |
376 | { | 362 | { |
377 | char *const argv[] = { "test-core-api", | 363 | char *const argv[] = { "test-core-api", |
378 | "-c", | 364 | "-c", |
379 | "test_core_api_data.conf", | 365 | "test_core_api_data.conf", |
380 | #if VERBOSE | ||
381 | "-L", "DEBUG", | ||
382 | #endif | ||
383 | NULL | 366 | NULL |
384 | }; | 367 | }; |
385 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 368 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -399,11 +382,7 @@ main (int argc, char *argv[]) | |||
399 | int ret; | 382 | int ret; |
400 | 383 | ||
401 | GNUNET_log_setup ("test-core-api", | 384 | GNUNET_log_setup ("test-core-api", |
402 | #if VERBOSE | ||
403 | "DEBUG", | ||
404 | #else | ||
405 | "WARNING", | 385 | "WARNING", |
406 | #endif | ||
407 | NULL); | 386 | NULL); |
408 | ret = check (); | 387 | ret = check (); |
409 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); | 388 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1"); |