diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-08-10 15:17:00 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-08-10 15:17:00 +0000 |
commit | 49f3bd45e74b2723ef94f66ca5077e23c00685d5 (patch) | |
tree | d71009f020b61282c0f5fac1a8f3f4628538eea6 /src/testing/test_testing_topology.c | |
parent | 71cc9ab8f420c4724987647c11d679084269bc5a (diff) | |
download | gnunet-49f3bd45e74b2723ef94f66ca5077e23c00685d5.tar.gz gnunet-49f3bd45e74b2723ef94f66ca5077e23c00685d5.zip |
add statistics iteration to testing_group, test case for same.
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r-- | src/testing/test_testing_topology.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index f357862c5..3d03d7611 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c | |||
@@ -270,12 +270,40 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
270 | total_server_connections -= 2; | 270 | total_server_connections -= 2; |
271 | } | 271 | } |
272 | 272 | ||
273 | void topology_cb (void *cls, | 273 | static void stats_finished (void *cls, int result) |
274 | const struct GNUNET_PeerIdentity *first, | 274 | { |
275 | const struct GNUNET_PeerIdentity *second, | 275 | fprintf(stderr, "Finished getting all peers statistics!\n"); |
276 | struct GNUNET_TIME_Relative latency, | 276 | GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); |
277 | uint32_t distance, | 277 | } |
278 | const char *emsg) | 278 | |
279 | /** | ||
280 | * Callback function to process statistic values. | ||
281 | * | ||
282 | * @param cls closure | ||
283 | * @param peer the peer the statistics belong to | ||
284 | * @param subsystem name of subsystem that created the statistic | ||
285 | * @param name the name of the datum | ||
286 | * @param value the current value | ||
287 | * @param is_persistent GNUNET_YES if the value is persistent, GNUNET_NO if not | ||
288 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | ||
289 | */ | ||
290 | static int stats_print (void *cls, | ||
291 | const struct GNUNET_PeerIdentity *peer, | ||
292 | const char *subsystem, | ||
293 | const char *name, | ||
294 | uint64_t value, | ||
295 | int is_persistent) | ||
296 | { | ||
297 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s:%s:%s -- %llu\n", GNUNET_i2s(peer), subsystem, name, value); | ||
298 | return GNUNET_OK; | ||
299 | } | ||
300 | |||
301 | static void topology_cb (void *cls, | ||
302 | const struct GNUNET_PeerIdentity *first, | ||
303 | const struct GNUNET_PeerIdentity *second, | ||
304 | struct GNUNET_TIME_Relative latency, | ||
305 | uint32_t distance, | ||
306 | const char *emsg) | ||
279 | { | 307 | { |
280 | FILE *outfile; | 308 | FILE *outfile; |
281 | outfile = cls; | 309 | outfile = cls; |
@@ -295,7 +323,8 @@ void topology_cb (void *cls, | |||
295 | { | 323 | { |
296 | fprintf(outfile, "}\n"); | 324 | fprintf(outfile, "}\n"); |
297 | fclose(outfile); | 325 | fclose(outfile); |
298 | GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | 326 | GNUNET_TESTING_get_statistics(pg, &stats_finished, &stats_print, NULL); |
327 | //GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | ||
299 | } | 328 | } |
300 | } | 329 | } |
301 | } | 330 | } |