diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-08-04 07:54:55 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-08-04 07:54:55 +0000 |
commit | 69ddb299086bc6e4190cd4d4fdefac625e12b7be (patch) | |
tree | d4a8a50a26a6e0c00cd0e3429cead24a79ea7d11 /src/testing/test_testing_topology.c | |
parent | f7cbc0da90fbd616475073ac3b908a5be8c492b0 (diff) | |
download | gnunet-69ddb299086bc6e4190cd4d4fdefac625e12b7be.tar.gz gnunet-69ddb299086bc6e4190cd4d4fdefac625e12b7be.zip |
test printing connected topology
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r-- | src/testing/test_testing_topology.c | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c index 4701d2c84..a2bb350f0 100644 --- a/src/testing/test_testing_topology.c +++ b/src/testing/test_testing_topology.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include "gnunet_core_service.h" | 26 | #include "gnunet_core_service.h" |
27 | #include "gnunet_os_lib.h" | 27 | #include "gnunet_os_lib.h" |
28 | 28 | ||
29 | #define VERBOSE GNUNET_NO | 29 | #define VERBOSE GNUNET_YES |
30 | 30 | ||
31 | #define DELAY_FOR_LOGGING GNUNET_NO | 31 | #define DELAY_FOR_LOGGING GNUNET_NO |
32 | 32 | ||
@@ -44,7 +44,7 @@ | |||
44 | 44 | ||
45 | #define DEFAULT_NUM_PEERS 4 | 45 | #define DEFAULT_NUM_PEERS 4 |
46 | 46 | ||
47 | #define MAX_OUTSTANDING_CONNECTIONS 300 | 47 | #define MAX_OUTSTANDING_CONNECTIONS 100 |
48 | 48 | ||
49 | static float fail_percentage = 0.05; | 49 | static float fail_percentage = 0.05; |
50 | 50 | ||
@@ -265,6 +265,37 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) | |||
265 | total_server_connections -= 2; | 265 | total_server_connections -= 2; |
266 | } | 266 | } |
267 | 267 | ||
268 | void topology_cb (void *cls, | ||
269 | const struct GNUNET_PeerIdentity *first, | ||
270 | const struct GNUNET_PeerIdentity *second, | ||
271 | struct GNUNET_TIME_Relative latency, | ||
272 | uint32_t distance, | ||
273 | const char *emsg) | ||
274 | { | ||
275 | FILE *outfile; | ||
276 | outfile = cls; | ||
277 | if (first != NULL) | ||
278 | { | ||
279 | if (outfile == NULL) | ||
280 | fprintf(stderr, "Peer %s connected to %s\n", GNUNET_i2s(first), GNUNET_h2s(&second->hashPubKey)); | ||
281 | else | ||
282 | { | ||
283 | fprintf(outfile, "\t\"%s\" -- ", GNUNET_i2s(first)); | ||
284 | fprintf(outfile, "\"%s\";\n", GNUNET_i2s(second)); | ||
285 | } | ||
286 | } | ||
287 | else | ||
288 | { | ||
289 | fprintf(stderr, "Finished iterating over topology!\n"); | ||
290 | if (outfile != NULL) | ||
291 | { | ||
292 | fprintf(outfile, "}\n"); | ||
293 | fclose(outfile); | ||
294 | } | ||
295 | GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | ||
296 | } | ||
297 | } | ||
298 | |||
268 | static int | 299 | static int |
269 | process_mtype (void *cls, | 300 | process_mtype (void *cls, |
270 | const struct GNUNET_PeerIdentity *peer, | 301 | const struct GNUNET_PeerIdentity *peer, |
@@ -272,6 +303,8 @@ process_mtype (void *cls, | |||
272 | struct GNUNET_TIME_Relative latency, | 303 | struct GNUNET_TIME_Relative latency, |
273 | uint32_t distance) | 304 | uint32_t distance) |
274 | { | 305 | { |
306 | char *dotOutFileNameFinished; | ||
307 | FILE *dotOutFileFinished; | ||
275 | struct TestMessageContext *pos = cls; | 308 | struct TestMessageContext *pos = cls; |
276 | struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message; | 309 | struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *)message; |
277 | if (pos->uid != ntohl(msg->uid)) | 310 | if (pos->uid != ntohl(msg->uid)) |
@@ -309,7 +342,14 @@ process_mtype (void *cls, | |||
309 | fprintf(stdout, "100%%]\n"); | 342 | fprintf(stdout, "100%%]\n"); |
310 | #endif | 343 | #endif |
311 | GNUNET_SCHEDULER_cancel (sched, die_task); | 344 | GNUNET_SCHEDULER_cancel (sched, die_task); |
312 | GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | 345 | GNUNET_asprintf(&dotOutFileNameFinished, "%s.dot", "final_topology"); |
346 | dotOutFileFinished = fopen (dotOutFileNameFinished, "w"); | ||
347 | if (dotOutFileFinished != NULL) | ||
348 | { | ||
349 | fprintf(dotOutFileFinished, "strict graph G {\n"); | ||
350 | } | ||
351 | GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished); | ||
352 | //GNUNET_SCHEDULER_add_now (sched, &finish_testing, NULL); | ||
313 | } | 353 | } |
314 | else | 354 | else |
315 | { | 355 | { |