aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_multipeer.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-10-04 11:09:39 +0000
committerChristian Grothoff <christian@grothoff.org>2011-10-04 11:09:39 +0000
commite305c764722394c18d55e084c7be4b64ff799fa4 (patch)
tree24f9dd8cc6f5393a9084d8149e53af5e850b25e7 /src/dht/test_dht_multipeer.c
parentba59bf06eefaefa447fbca9059adefe9ac0ef167 (diff)
downloadgnunet-e305c764722394c18d55e084c7be4b64ff799fa4.tar.gz
gnunet-e305c764722394c18d55e084c7be4b64ff799fa4.zip
LRN's big logging rewrite (#1805):
* GNUNET_BOTTOM_LOGLEVEL and GNUNET_TOP_LOGLEVEL set global levels Use bottom level to force logging to be more verbose than configured Use top level to force logging to be less verbose than configured Obviously, bottom <= top * GNUNET_LOG sets per-component levels GNUNET_LOG looks like this: name[/bottom[/top]]/... name starts with a non-digit character, must not include '/' bottom and top must consist only of digits, or be empty a description is only used if it matches the component exactly as a special exception (for now) the name '*' matches any component per-component loglevels override global loglevels global levels override whatever is given via arguments or in config Examples: test_client/8/8/ run test_client with DEBUG level (usually leads to a timeout, by the way) */2/2/core/8/8/transport/4/4 run everything with WARNING, core - with DEBUG, transport - with INFO *//1/peerinfo/4/ run everything with top loglevel ERROR, global/configured bottom loglevel, and peerinfo - with bottom loglevel INFO and global/configured top loglevel statistics/ does nothing * Added GNUNET_ERROR_TYPE_UNSPECIFIED enum value, to hold -1. Its corresponding string is NULL. * Changed the logger calls as Grothoff suggested - to use static int to hold the result of runtime evaluation of logability. Logging can be unconditionally disabled in advance by defining GNUNET_LOG_CALL_STATUS to 0, and enabled in advance by defining it to 1. * Added GNUNET_CULL_LOGGING, which, if defined, completely culls out all logging calls at compile time. * Log definition parsing is only done once, results are cached. * Changed definition format, now it looks like this: [component|*|];[file|*|];[function|*|];[from_line[-to_line]];level/[component...] All field separators are mandatory (but some fields could be empty or be '*'). Line definition must be either empty or "number" or "number-number" Level definition must not be empty, and is a string representation of the level (i.e. DEBUG, WARNING, INFO, etc). Definition entry must end with a slash, whether or not there's another entry after it. File name is matched to the end of __FILE__, which allows file name to match not only the base name, but also directories leading to it. * Removed default WARNING loglevel from program and service utility code. Now they default to NULL (UNSPECIFIED) level, which can be overriden by GNUNET_LOG definition, if no level is specified via config or commandline. Log levels from config or commandline are overriden by GNUNET_FORCE_LOG. If GNUNET_*LOG are undefined, and no levels came from config or commandline, logger internally defaults to WARNING level. Add --enable-logging configure option
Diffstat (limited to 'src/dht/test_dht_multipeer.c')
-rw-r--r--src/dht/test_dht_multipeer.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c
index 2fc439ecb..eb70424a3 100644
--- a/src/dht/test_dht_multipeer.c
+++ b/src/dht/test_dht_multipeer.c
@@ -250,19 +250,23 @@ struct StatValues
250{ 250{
251 const char *subsystem; 251 const char *subsystem;
252 const char *name; 252 const char *name;
253 unsigned long long total;
253}; 254};
254 255
255/** 256/**
256 * Statistics we print out. 257 * Statistics we print out.
257 */ 258 */
258static struct StatValues stats[] = { 259static struct StatValues stats[] = {
259 {"core", "# bytes decrypted"}, 260 {"core", "# bytes decrypted", 0},
260 {"core", "# bytes encrypted"}, 261 {"core", "# bytes encrypted", 0},
261 {"core", "# discarded CORE_SEND requests"}, 262 {"transport", "# bytes received via TCP", 0},
262 {"core", "# discarded lower priority CORE_SEND requests"}, 263 {"transport", "# bytes transmitted via TCP", 0},
263 {"transport", "# bytes received via TCP"}, 264 {"dht", "# PUT messages queued for transmission"},
264 {"transport", "# bytes transmitted via TCP"}, 265 {"dht", "# P2P PUT requests received"},
265 {"dht", "# FIXME"}, 266 {"dht", "# GET messages queued for transmission"},
267 {"dht", "# P2P GET requests received"},
268 {"dht", "# RESULT messages queued for transmission"},
269 {"dht", "# P2P RESULTS received"},
266 {NULL, NULL} 270 {NULL, NULL}
267}; 271};
268 272
@@ -283,6 +287,7 @@ print_stat (void *cls, const char *subsystem, const char *name, uint64_t value,
283{ 287{
284 struct StatMaster *sm = cls; 288 struct StatMaster *sm = cls;
285 289
290 stats[sm->value].total += value;
286 fprintf (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem, 291 fprintf (stderr, "Peer %2u: %12s/%50s = %12llu\n", sm->daemon, subsystem,
287 name, (unsigned long long) value); 292 name, (unsigned long long) value);
288 return GNUNET_OK; 293 return GNUNET_OK;
@@ -317,7 +322,9 @@ static void
317stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 322stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
318{ 323{
319 struct StatMaster *sm = cls; 324 struct StatMaster *sm = cls;
325 unsigned int i;
320 326
327 die_task = GNUNET_SCHEDULER_NO_TASK;
321 if (stats[sm->value].name != NULL) 328 if (stats[sm->value].name != NULL)
322 { 329 {
323 GNUNET_STATISTICS_get (sm->stat, 330 GNUNET_STATISTICS_get (sm->stat,
@@ -336,14 +343,21 @@ stat_run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
336 if (sm->daemon == num_peers) 343 if (sm->daemon == num_peers)
337 { 344 {
338 GNUNET_free (sm); 345 GNUNET_free (sm);
339 GNUNET_SCHEDULER_add_now (&do_stop, NULL); 346 i = 0;
347 while (stats[i].name != NULL)
348 {
349 fprintf (stderr, "Total : %12s/%50s = %12llu\n", stats[i].subsystem,
350 stats[i].name, (unsigned long long) stats[i].total);
351 i++;
352 }
353 die_task = GNUNET_SCHEDULER_add_now (&do_stop, NULL);
340 return; 354 return;
341 } 355 }
342 sm->stat = 356 sm->stat =
343 GNUNET_STATISTICS_create ("<driver>", 357 GNUNET_STATISTICS_create ("<driver>",
344 GNUNET_TESTING_daemon_get (pg, 358 GNUNET_TESTING_daemon_get (pg,
345 sm->daemon)->cfg); 359 sm->daemon)->cfg);
346 GNUNET_SCHEDULER_add_now (&stat_run, sm); 360 die_task = GNUNET_SCHEDULER_add_now (&stat_run, sm);
347} 361}
348 362
349 363
@@ -384,13 +398,12 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
384 test_get); 398 test_get);
385 GNUNET_free (test_get); 399 GNUNET_free (test_get);
386 } 400 }
387 ok = 0;
388 sm = GNUNET_malloc (sizeof (struct StatMaster)); 401 sm = GNUNET_malloc (sizeof (struct StatMaster));
389 sm->stat = 402 sm->stat =
390 GNUNET_STATISTICS_create ("<driver>", 403 GNUNET_STATISTICS_create ("<driver>",
391 GNUNET_TESTING_daemon_get (pg, 404 GNUNET_TESTING_daemon_get (pg,
392 sm->daemon)->cfg); 405 sm->daemon)->cfg);
393 GNUNET_SCHEDULER_add_now (&stat_run, sm); 406 die_task = GNUNET_SCHEDULER_add_now (&stat_run, sm);
394} 407}
395 408
396 409
@@ -474,21 +487,25 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
474 all_gets_tail, 487 all_gets_tail,
475 test_get); 488 test_get);
476 GNUNET_free (test_get); 489 GNUNET_free (test_get);
477 490 if ((gets_failed > 10) && (outstanding_gets == 0))
478 if ((gets_failed > 0) && (outstanding_gets == 0)) /* Had some failures */
479 { 491 {
492 /* Had more than 10% failures */
480 fprintf (stderr, 493 fprintf (stderr,
481 "%llu gets succeeded, %llu gets failed!\n", 494 "%llu gets succeeded, %llu gets failed!\n",
482 gets_completed, gets_failed); 495 gets_completed, gets_failed);
483 GNUNET_SCHEDULER_cancel (die_task); 496 GNUNET_SCHEDULER_cancel (die_task);
484 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "not all gets succeeded"); 497 ok = 1;
498 die_task = GNUNET_SCHEDULER_add_now (&finish_testing, "not all gets succeeded");
485 return; 499 return;
486 } 500 }
487 501 if ( (gets_completed + gets_failed == num_peers * num_peers) &&
488 if ( (gets_completed == num_peers * num_peers) &&
489 (outstanding_gets == 0) ) /* All gets successful */ 502 (outstanding_gets == 0) ) /* All gets successful */
490 { 503 {
504 fprintf (stderr,
505 "%llu gets succeeded, %llu gets failed!\n",
506 gets_completed, gets_failed);
491 GNUNET_SCHEDULER_cancel (die_task); 507 GNUNET_SCHEDULER_cancel (die_task);
508 ok = 0;
492 die_task = GNUNET_SCHEDULER_add_now (&finish_testing, NULL); 509 die_task = GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
493 } 510 }
494} 511}