From: Christian Grothoff Date: Fri, 18 May 2012 05:34:34 +0000 (+0000) Subject: -code cleanup X-Git-Tag: initial-import-from-subversion-38251~13445 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=45a6c8033e511e2d3dc3f20cb62248c77ee90725;p=oweals%2Fgnunet.git -code cleanup --- diff --git a/src/dht/test_dht_monitor.c b/src/dht/test_dht_monitor.c index 62d1dcbde..62210e85c 100644 --- a/src/dht/test_dht_monitor.c +++ b/src/dht/test_dht_monitor.c @@ -31,8 +31,6 @@ #include "gnunet_testing_lib.h" #include "gnunet_dht_service.h" -#define VERBOSE GNUNET_YES - #define REMOVE_DIR GNUNET_YES @@ -137,17 +135,14 @@ shutdown_callback (void *cls, const char *emsg) { if (emsg != NULL) { -#if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Shutdown of peers failed!\n"); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "test: Shutdown of peers failed: %s\n", + emsg); ok++; } else { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: All peers successfully shut down!\n"); -#endif } GNUNET_CONFIGURATION_destroy (testing_cfg); } @@ -156,16 +151,12 @@ shutdown_callback (void *cls, const char *emsg) static void shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Ending test.\n"); -#endif - if (disconnect_task != GNUNET_SCHEDULER_NO_TASK) { GNUNET_SCHEDULER_cancel (disconnect_task); disconnect_task = GNUNET_SCHEDULER_NO_TASK; } - if (data_file != NULL) GNUNET_DISK_file_close (data_file); GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); @@ -448,15 +439,9 @@ peergroup_ready (void *cls, const char *emsg) GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); return; } -#if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "************************************************************\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "test: Peer Group started successfully!\n"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Have %u connections\n", + "test: Peer Group started successfully with %u connections\n", total_connections); -#endif - if (data_file != NULL) { buf = NULL; @@ -564,19 +549,12 @@ run (void *cls, char *const *args, const char *cfgfile, testing_cfg = GNUNET_CONFIGURATION_dup (cfg); GNUNET_log_setup ("test_dht_monitor", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "test: Starting daemons.\n"); GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", "use_progressbars", "YES"); -#endif - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", "num_peers", &num_peers)) @@ -664,9 +642,6 @@ main (int xargc, char *xargv[]) char *const argv[] = { "test-dht-monitor", "-c", "test_dht_line.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c index a821b303c..9649405b1 100644 --- a/src/dht/test_dht_multipeer.c +++ b/src/dht/test_dht_multipeer.c @@ -27,9 +27,6 @@ #include "gnunet_core_service.h" #include "gnunet_dht_service.h" -/* DEFINES */ -#define VERBOSE GNUNET_NO - /* Timeout for entire testcase */ #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 30) @@ -658,10 +655,9 @@ start_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) unsigned long long j; struct TestGetContext *test_get; -#if VERBOSE - FPRINTF (stderr, "Issuing %llu GETs\n", - (unsigned long long) (num_peers * num_peers)); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Issuing %llu GETs\n", + (unsigned long long) (num_peers * num_peers)); for (i = 0; i < num_peers; i++) for (j = 0; j < num_peers; j++) { @@ -719,10 +715,9 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) test_put->dht_handle = GNUNET_DHT_connect (test_put->daemon->cfg, 10); GNUNET_assert (test_put->dht_handle != NULL); outstanding_puts++; -#if VERBOSE > 2 - FPRINTF (stderr, "PUT %u at `%s'\n", test_put->uid, - GNUNET_i2s (&test_put->daemon->id)); -#endif + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "PUT %u at `%s'\n", test_put->uid, + GNUNET_i2s (&test_put->daemon->id)); GNUNET_DHT_put (test_put->dht_handle, &key, 1, route_option, GNUNET_BLOCK_TYPE_TEST, sizeof (data), data, GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_REL, @@ -822,9 +817,6 @@ check () char *const argv[] = { "test-dht-multipeer", /* Name to give running binary */ "-c", "test_dht_multipeer_data.conf", /* Config file to use */ -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -848,13 +840,8 @@ main (int argc, char *argv[]) { int ret; - GNUNET_log_setup ("test-dht-multipeer", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); ret = check (); /** diff --git a/src/dht/test_dht_topo.c b/src/dht/test_dht_topo.c index cb0399da9..ed746a583 100644 --- a/src/dht/test_dht_topo.c +++ b/src/dht/test_dht_topo.c @@ -30,8 +30,6 @@ #include "gnunet_testing_lib.h" #include "gnunet_dht_service.h" -#define VERBOSE GNUNET_NO - #define REMOVE_DIR GNUNET_YES /** @@ -401,15 +399,9 @@ peergroup_ready (void *cls, const char *emsg) GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); return; } -#if VERBOSE - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "************************************************************\n"); GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Peer Group started successfully!\n"); - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %u connections\n", + "Peer Group started successfully with %u connections\n", total_connections); -#endif - if (data_file != NULL) { buf = NULL; @@ -493,19 +485,11 @@ run (void *cls, char *const *args, const char *cfgfile, testing_cfg = GNUNET_CONFIGURATION_dup (cfg); GNUNET_log_setup ("test_dht_topo", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); - -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", "use_progressbars", "YES"); -#endif - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", "num_peers", &num_peers)) @@ -593,17 +577,11 @@ main (int xargc, char *xargv[]) char *const argv_torus[] = { "test-dht-2dtorus", "-c", "test_dht_2dtorus.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; char *const argv_line[] = { "test-dht-line", "-c", "test_dht_line.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; char *const *argv; diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c index a3b6e4a54..6f2b0de18 100644 --- a/src/dht/test_dht_twopeer.c +++ b/src/dht/test_dht_twopeer.c @@ -306,7 +306,6 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, if (emsg == NULL) { total_connections++; -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s, distance %u\n", first_daemon->shortname, second_daemon->shortname, distance); @@ -314,19 +313,16 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, else { failed_connections++; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peer %s to peer %s with error :\n%s\n", first_daemon->shortname, second_daemon->shortname, emsg); -#endif } if (total_connections == expected_connections) { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created %d total connections, which is our target number! Starting next phase of testing.\n", total_connections); -#endif GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, @@ -409,10 +405,8 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, if (peers_left == 0) { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %d daemons started, now connecting peers!\n", num_peers); -#endif GNUNET_SCHEDULER_cancel (die_task); /* Set up task in case topology creation doesn't finish * within a reasonable amount of time */ @@ -466,9 +460,6 @@ check () char *const argv[] = { "test-dht-twopeer", "-c", "test_dht_twopeer_data.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -491,11 +482,7 @@ main (int argc, char *argv[]) int ret; GNUNET_log_setup ("test-dht-twopeer", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); ret = check (); /** diff --git a/src/dht/test_dht_twopeer_get_put.c b/src/dht/test_dht_twopeer_get_put.c index 4de4d6459..b32428bb4 100644 --- a/src/dht/test_dht_twopeer_get_put.c +++ b/src/dht/test_dht_twopeer_get_put.c @@ -391,29 +391,23 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, if (emsg == NULL) { total_connections++; -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s, distance %u\n", first_daemon->shortname, second_daemon->shortname, distance); -#endif } -#if VERBOSE else { failed_connections++; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peer %s to peer %s with error :\n%s\n", first_daemon->shortname, second_daemon->shortname, emsg); } -#endif if (total_connections == expected_connections) { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created %d total connections, which is our target number! Starting next phase of testing.\n", total_connections); -#endif GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets"); @@ -482,10 +476,8 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, if (peers_left == 0) /* Indicates all peers started */ { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %d daemons started, now connecting peers!\n", num_peers); -#endif expected_connections = -1; if ((pg != NULL)) /* Sanity check */ { @@ -556,9 +548,6 @@ check () char *const argv[] = { "test-dht-twopeer-get-put", /* Name to give running binary */ "-c", "test_dht_twopeer_data.conf", /* Config file to use */ -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -583,11 +572,7 @@ main (int argc, char *argv[]) int ret; GNUNET_log_setup ("test-dht-twopeer", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); ret = check (); /** diff --git a/src/dht/test_dht_twopeer_put_get.c b/src/dht/test_dht_twopeer_put_get.c index b2dd5a70b..e40848291 100644 --- a/src/dht/test_dht_twopeer_put_get.c +++ b/src/dht/test_dht_twopeer_put_get.c @@ -312,29 +312,23 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, if (emsg == NULL) { total_connections++; -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s, distance %u\n", first_daemon->shortname, second_daemon->shortname, distance); -#endif } -#if VERBOSE else { failed_connections++; - GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peer %s to peer %s with error :\n%s\n", first_daemon->shortname, second_daemon->shortname, emsg); } -#endif if (total_connections == expected_connections) { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created %d total connections, which is our target number! Starting next phase of testing.\n", total_connections); -#endif GNUNET_SCHEDULER_cancel (die_task); die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets"); @@ -402,10 +396,8 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, if (peers_left == 0) /* Indicates all peers started */ { -#if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All %d daemons started, now connecting peers!\n", num_peers); -#endif expected_connections = -1; if ((pg != NULL)) /* Sanity check */ { @@ -476,9 +468,6 @@ check () char *const argv[] = { "test-dht-twopeer-put-get", /* Name to give running binary */ "-c", "test_dht_twopeer_data.conf", /* Config file to use */ -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -503,11 +492,7 @@ main (int argc, char *argv[]) int ret; GNUNET_log_setup ("test-dht-twopeer", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); ret = check (); /**