diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-05-16 13:22:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-05-16 13:22:52 +0000 |
commit | 0e711c15d015f2270c240765ebe9c1268eee70e8 (patch) | |
tree | f06b8a25f0137c210bb0f8250dd5f49ad7ee6300 /src | |
parent | fceae1fb62128bf030a577e8811fc2d2a1bdd265 (diff) | |
download | gnunet-0e711c15d015f2270c240765ebe9c1268eee70e8.tar.gz gnunet-0e711c15d015f2270c240765ebe9c1268eee70e8.zip |
-fixing testcases, cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/test_transport_api_restart_1peer.c | 47 | ||||
-rw-r--r-- | src/transport/test_transport_api_restart_2peers.c | 43 |
2 files changed, 23 insertions, 67 deletions
diff --git a/src/transport/test_transport_api_restart_1peer.c b/src/transport/test_transport_api_restart_1peer.c index d01d9e432..b7fc7ab30 100644 --- a/src/transport/test_transport_api_restart_1peer.c +++ b/src/transport/test_transport_api_restart_1peer.c | |||
@@ -36,8 +36,6 @@ | |||
36 | #include "transport.h" | 36 | #include "transport.h" |
37 | #include "transport-testing.h" | 37 | #include "transport-testing.h" |
38 | 38 | ||
39 | #define VERBOSE GNUNET_NO | ||
40 | #define VERBOSE_ARM GNUNET_NO | ||
41 | 39 | ||
42 | #define START_ARM GNUNET_YES | 40 | #define START_ARM GNUNET_YES |
43 | 41 | ||
@@ -63,32 +61,26 @@ static GNUNET_SCHEDULER_TaskIdentifier send_task; | |||
63 | 61 | ||
64 | static GNUNET_SCHEDULER_TaskIdentifier reconnect_task; | 62 | static GNUNET_SCHEDULER_TaskIdentifier reconnect_task; |
65 | 63 | ||
66 | struct PeerContext *p1; | 64 | static struct PeerContext *p1; |
67 | 65 | ||
68 | int p1_connected; | 66 | static int p1_connected; |
69 | 67 | ||
70 | struct PeerContext *p2; | 68 | static struct PeerContext *p2; |
71 | 69 | ||
72 | int p2_connected; | 70 | static int p2_connected; |
73 | 71 | ||
74 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 72 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; |
75 | 73 | ||
76 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 74 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
77 | 75 | ||
78 | struct GNUNET_TRANSPORT_TESTING_handle *tth; | 76 | static struct GNUNET_TRANSPORT_TESTING_handle *tth; |
79 | 77 | ||
80 | char *cfg_file_p1; | 78 | static char *cfg_file_p1; |
81 | 79 | ||
82 | char *cfg_file_p2; | 80 | static char *cfg_file_p2; |
83 | 81 | ||
84 | static int restarted; | 82 | static int restarted; |
85 | 83 | ||
86 | #if VERBOSE | ||
87 | #define OKPP do { ok++; FPRINTF (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) | ||
88 | #else | ||
89 | #define OKPP do { ok++; } while (0) | ||
90 | #endif | ||
91 | |||
92 | 84 | ||
93 | static void | 85 | static void |
94 | end () | 86 | end () |
@@ -350,8 +342,6 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
350 | { | 342 | { |
351 | p2_connected = GNUNET_NO; | 343 | p2_connected = GNUNET_NO; |
352 | } | 344 | } |
353 | |||
354 | |||
355 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 345 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
356 | 346 | ||
357 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 347 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -362,6 +352,9 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
362 | if (th != NULL) | 352 | if (th != NULL) |
363 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 353 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
364 | th = NULL; | 354 | th = NULL; |
355 | if (GNUNET_SCHEDULER_NO_TASK != send_task) | ||
356 | GNUNET_SCHEDULER_cancel (send_task); | ||
357 | send_task = GNUNET_SCHEDULER_NO_TASK; | ||
365 | } | 358 | } |
366 | 359 | ||
367 | static void | 360 | static void |
@@ -379,7 +372,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
379 | 372 | ||
380 | 373 | ||
381 | 374 | ||
382 | void | 375 | static void |
383 | start_cb (struct PeerContext *p, void *cls) | 376 | start_cb (struct PeerContext *p, void *cls) |
384 | { | 377 | { |
385 | static int started; | 378 | static int started; |
@@ -438,9 +431,6 @@ check () | |||
438 | static char *const argv[] = { "test-transport-api", | 431 | static char *const argv[] = { "test-transport-api", |
439 | "-c", | 432 | "-c", |
440 | "test_transport_api_data.conf", | 433 | "test_transport_api_data.conf", |
441 | #if VERBOSE | ||
442 | "-L", "DEBUG", | ||
443 | #endif | ||
444 | NULL | 434 | NULL |
445 | }; | 435 | }; |
446 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 436 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -465,30 +455,17 @@ main (int argc, char *argv[]) | |||
465 | int ret; | 455 | int ret; |
466 | 456 | ||
467 | GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); | 457 | GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); |
468 | |||
469 | |||
470 | GNUNET_log_setup (test_name, | 458 | GNUNET_log_setup (test_name, |
471 | #if VERBOSE | ||
472 | "DEBUG", | ||
473 | #else | ||
474 | "WARNING", | 459 | "WARNING", |
475 | #endif | ||
476 | NULL); | 460 | NULL); |
477 | |||
478 | tth = GNUNET_TRANSPORT_TESTING_init (); | 461 | tth = GNUNET_TRANSPORT_TESTING_init (); |
479 | |||
480 | GNUNET_asprintf (&cfg_file_p1, "test_transport_api_tcp_peer1.conf"); | 462 | GNUNET_asprintf (&cfg_file_p1, "test_transport_api_tcp_peer1.conf"); |
481 | GNUNET_asprintf (&cfg_file_p2, "test_transport_api_tcp_peer2.conf"); | 463 | GNUNET_asprintf (&cfg_file_p2, "test_transport_api_tcp_peer2.conf"); |
482 | |||
483 | ret = check (); | 464 | ret = check (); |
484 | |||
485 | GNUNET_free (cfg_file_p1); | 465 | GNUNET_free (cfg_file_p1); |
486 | GNUNET_free (cfg_file_p2); | 466 | GNUNET_free (cfg_file_p2); |
487 | |||
488 | GNUNET_free (test_name); | 467 | GNUNET_free (test_name); |
489 | |||
490 | GNUNET_TRANSPORT_TESTING_done (tth); | 468 | GNUNET_TRANSPORT_TESTING_done (tth); |
491 | |||
492 | return ret; | 469 | return ret; |
493 | } | 470 | } |
494 | 471 | ||
diff --git a/src/transport/test_transport_api_restart_2peers.c b/src/transport/test_transport_api_restart_2peers.c index 86758dfe6..9fd9c0da6 100644 --- a/src/transport/test_transport_api_restart_2peers.c +++ b/src/transport/test_transport_api_restart_2peers.c | |||
@@ -36,9 +36,6 @@ | |||
36 | #include "transport.h" | 36 | #include "transport.h" |
37 | #include "transport-testing.h" | 37 | #include "transport-testing.h" |
38 | 38 | ||
39 | #define VERBOSE GNUNET_NO | ||
40 | #define VERBOSE_ARM GNUNET_NO | ||
41 | |||
42 | #define START_ARM GNUNET_YES | 39 | #define START_ARM GNUNET_YES |
43 | 40 | ||
44 | /** | 41 | /** |
@@ -63,28 +60,22 @@ static GNUNET_SCHEDULER_TaskIdentifier send_task; | |||
63 | 60 | ||
64 | static GNUNET_SCHEDULER_TaskIdentifier reconnect_task; | 61 | static GNUNET_SCHEDULER_TaskIdentifier reconnect_task; |
65 | 62 | ||
66 | struct PeerContext *p1; | 63 | static struct PeerContext *p1; |
67 | 64 | ||
68 | struct PeerContext *p2; | 65 | static struct PeerContext *p2; |
69 | 66 | ||
70 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; | 67 | static GNUNET_TRANSPORT_TESTING_ConnectRequest cc; |
71 | 68 | ||
72 | struct GNUNET_TRANSPORT_TransmitHandle *th; | 69 | static struct GNUNET_TRANSPORT_TransmitHandle *th; |
73 | 70 | ||
74 | struct GNUNET_TRANSPORT_TESTING_handle *tth; | 71 | static struct GNUNET_TRANSPORT_TESTING_handle *tth; |
75 | 72 | ||
76 | char *cfg_file_p1; | 73 | static char *cfg_file_p1; |
77 | 74 | ||
78 | char *cfg_file_p2; | 75 | static char *cfg_file_p2; |
79 | 76 | ||
80 | static int restarted; | 77 | static int restarted; |
81 | 78 | ||
82 | #if VERBOSE | ||
83 | #define OKPP do { ok++; FPRINTF (stderr, "Now at stage %u at %s:%u\n", ok, __FILE__, __LINE__); } while (0) | ||
84 | #else | ||
85 | #define OKPP do { ok++; } while (0) | ||
86 | #endif | ||
87 | |||
88 | 79 | ||
89 | static void | 80 | static void |
90 | end () | 81 | end () |
@@ -345,8 +336,12 @@ notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
345 | if (th != NULL) | 336 | if (th != NULL) |
346 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); | 337 | GNUNET_TRANSPORT_notify_transmit_ready_cancel (th); |
347 | th = NULL; | 338 | th = NULL; |
339 | if (GNUNET_SCHEDULER_NO_TASK != send_task) | ||
340 | GNUNET_SCHEDULER_cancel (send_task); | ||
341 | send_task = GNUNET_SCHEDULER_NO_TASK; | ||
348 | } | 342 | } |
349 | 343 | ||
344 | |||
350 | static void | 345 | static void |
351 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | 346 | testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) |
352 | { | 347 | { |
@@ -362,7 +357,7 @@ testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls) | |||
362 | 357 | ||
363 | 358 | ||
364 | 359 | ||
365 | void | 360 | static void |
366 | start_cb (struct PeerContext *p, void *cls) | 361 | start_cb (struct PeerContext *p, void *cls) |
367 | { | 362 | { |
368 | static int started; | 363 | static int started; |
@@ -420,9 +415,6 @@ check () | |||
420 | static char *const argv[] = { "test-transport-api", | 415 | static char *const argv[] = { "test-transport-api", |
421 | "-c", | 416 | "-c", |
422 | "test_transport_api_data.conf", | 417 | "test_transport_api_data.conf", |
423 | #if VERBOSE | ||
424 | "-L", "DEBUG", | ||
425 | #endif | ||
426 | NULL | 418 | NULL |
427 | }; | 419 | }; |
428 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | 420 | static struct GNUNET_GETOPT_CommandLineOption options[] = { |
@@ -447,30 +439,17 @@ main (int argc, char *argv[]) | |||
447 | int ret; | 439 | int ret; |
448 | 440 | ||
449 | GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); | 441 | GNUNET_TRANSPORT_TESTING_get_test_name (argv[0], &test_name); |
450 | |||
451 | |||
452 | GNUNET_log_setup (test_name, | 442 | GNUNET_log_setup (test_name, |
453 | #if VERBOSE | ||
454 | "DEBUG", | ||
455 | #else | ||
456 | "WARNING", | 443 | "WARNING", |
457 | #endif | ||
458 | NULL); | 444 | NULL); |
459 | |||
460 | tth = GNUNET_TRANSPORT_TESTING_init (); | 445 | tth = GNUNET_TRANSPORT_TESTING_init (); |
461 | |||
462 | GNUNET_asprintf (&cfg_file_p1, "test_transport_api_tcp_peer1.conf"); | 446 | GNUNET_asprintf (&cfg_file_p1, "test_transport_api_tcp_peer1.conf"); |
463 | GNUNET_asprintf (&cfg_file_p2, "test_transport_api_tcp_peer2.conf"); | 447 | GNUNET_asprintf (&cfg_file_p2, "test_transport_api_tcp_peer2.conf"); |
464 | |||
465 | ret = check (); | 448 | ret = check (); |
466 | |||
467 | GNUNET_free (cfg_file_p1); | 449 | GNUNET_free (cfg_file_p1); |
468 | GNUNET_free (cfg_file_p2); | 450 | GNUNET_free (cfg_file_p2); |
469 | |||
470 | GNUNET_free (test_name); | 451 | GNUNET_free (test_name); |
471 | |||
472 | GNUNET_TRANSPORT_TESTING_done (tth); | 452 | GNUNET_TRANSPORT_TESTING_done (tth); |
473 | |||
474 | return ret; | 453 | return ret; |
475 | } | 454 | } |
476 | 455 | ||