diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:46:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:46:35 +0000 |
commit | 502af2167f7c218366666ca4944bd7cc54b5b19a (patch) | |
tree | a91fec5cc9769d260640bd91c6633cb9cf395524 /src/testing/test_testing_large_topology.c | |
parent | 03af5a603b7cc53432249d5854cd412aa90dde0d (diff) | |
download | gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.tar.gz gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.zip |
indentation
Diffstat (limited to 'src/testing/test_testing_large_topology.c')
-rw-r--r-- | src/testing/test_testing_large_topology.c | 826 |
1 files changed, 420 insertions, 406 deletions
diff --git a/src/testing/test_testing_large_topology.c b/src/testing/test_testing_large_topology.c index f9f4ff6fd..62922e9e8 100644 --- a/src/testing/test_testing_large_topology.c +++ b/src/testing/test_testing_large_topology.c | |||
@@ -99,7 +99,7 @@ static enum GNUNET_TESTING_Topology blacklist_topology = GNUNET_TESTING_TOPOLOGY | |||
99 | static enum GNUNET_TESTING_Topology connection_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* NONE actually means connect all allowed peers */ | 99 | static enum GNUNET_TESTING_Topology connection_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* NONE actually means connect all allowed peers */ |
100 | 100 | ||
101 | static enum GNUNET_TESTING_TopologyOption connect_topology_option = | 101 | static enum GNUNET_TESTING_TopologyOption connect_topology_option = |
102 | GNUNET_TESTING_TOPOLOGY_OPTION_ALL; | 102 | GNUNET_TESTING_TOPOLOGY_OPTION_ALL; |
103 | 103 | ||
104 | static double connect_topology_option_modifier = 0.0; | 104 | static double connect_topology_option_modifier = 0.0; |
105 | 105 | ||
@@ -160,20 +160,19 @@ void | |||
160 | shutdown_callback (void *cls, const char *emsg) | 160 | shutdown_callback (void *cls, const char *emsg) |
161 | { | 161 | { |
162 | if (emsg != NULL) | 162 | if (emsg != NULL) |
163 | { | 163 | { |
164 | #if VERBOSE | 164 | #if VERBOSE |
165 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); | 165 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); |
166 | #endif | 166 | #endif |
167 | if (ok == 0) | 167 | if (ok == 0) |
168 | ok = 666; | 168 | ok = 666; |
169 | } | 169 | } |
170 | else | 170 | else |
171 | { | 171 | { |
172 | #if VERBOSE | 172 | #if VERBOSE |
173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers successfully shut down!\n"); |
174 | "All peers successfully shut down!\n"); | ||
175 | #endif | 174 | #endif |
176 | } | 175 | } |
177 | } | 176 | } |
178 | 177 | ||
179 | #if DELAY_FOR_LOGGING | 178 | #if DELAY_FOR_LOGGING |
@@ -183,6 +182,7 @@ gather_log_data () | |||
183 | char *peer_number; | 182 | char *peer_number; |
184 | char *connect_number; | 183 | char *connect_number; |
185 | struct GNUNET_OS_Process *mem_process; | 184 | struct GNUNET_OS_Process *mem_process; |
185 | |||
186 | GNUNET_asprintf (&peer_number, "%llu", num_peers); | 186 | GNUNET_asprintf (&peer_number, "%llu", num_peers); |
187 | GNUNET_asprintf (&connect_number, "%llu", expected_connections); | 187 | GNUNET_asprintf (&connect_number, "%llu", expected_connections); |
188 | mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", | 188 | mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", |
@@ -201,6 +201,7 @@ finish_testing () | |||
201 | GNUNET_assert (pg != NULL); | 201 | GNUNET_assert (pg != NULL); |
202 | struct TestMessageContext *pos; | 202 | struct TestMessageContext *pos; |
203 | struct TestMessageContext *free_pos; | 203 | struct TestMessageContext *free_pos; |
204 | |||
204 | #if VERBOSE | 205 | #if VERBOSE |
205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 206 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
206 | "Called finish testing, stopping daemons.\n"); | 207 | "Called finish testing, stopping daemons.\n"); |
@@ -208,25 +209,25 @@ finish_testing () | |||
208 | 209 | ||
209 | pos = test_messages; | 210 | pos = test_messages; |
210 | while (pos != NULL) | 211 | while (pos != NULL) |
212 | { | ||
213 | if (pos->peer1handle != NULL) | ||
214 | { | ||
215 | GNUNET_CORE_disconnect (pos->peer1handle); | ||
216 | pos->peer1handle = NULL; | ||
217 | } | ||
218 | if (pos->peer2handle != NULL) | ||
211 | { | 219 | { |
212 | if (pos->peer1handle != NULL) | 220 | GNUNET_CORE_disconnect (pos->peer2handle); |
213 | { | 221 | pos->peer2handle = NULL; |
214 | GNUNET_CORE_disconnect (pos->peer1handle); | ||
215 | pos->peer1handle = NULL; | ||
216 | } | ||
217 | if (pos->peer2handle != NULL) | ||
218 | { | ||
219 | GNUNET_CORE_disconnect (pos->peer2handle); | ||
220 | pos->peer2handle = NULL; | ||
221 | } | ||
222 | free_pos = pos; | ||
223 | pos = pos->next; | ||
224 | if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) | ||
225 | { | ||
226 | GNUNET_SCHEDULER_cancel (free_pos->disconnect_task); | ||
227 | } | ||
228 | GNUNET_free (free_pos); | ||
229 | } | 222 | } |
223 | free_pos = pos; | ||
224 | pos = pos->next; | ||
225 | if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK) | ||
226 | { | ||
227 | GNUNET_SCHEDULER_cancel (free_pos->disconnect_task); | ||
228 | } | ||
229 | GNUNET_free (free_pos); | ||
230 | } | ||
230 | #if VERBOSE | 231 | #if VERBOSE |
231 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
232 | "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", | 233 | "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", |
@@ -240,10 +241,10 @@ finish_testing () | |||
240 | GNUNET_TESTING_daemons_stop (pg, timeout, &shutdown_callback, NULL); | 241 | GNUNET_TESTING_daemons_stop (pg, timeout, &shutdown_callback, NULL); |
241 | 242 | ||
242 | if (dotOutFile != NULL) | 243 | if (dotOutFile != NULL) |
243 | { | 244 | { |
244 | fprintf (dotOutFile, "}"); | 245 | fprintf (dotOutFile, "}"); |
245 | fclose (dotOutFile); | 246 | fclose (dotOutFile); |
246 | } | 247 | } |
247 | 248 | ||
248 | ok = 0; | 249 | ok = 0; |
249 | } | 250 | } |
@@ -284,27 +285,28 @@ topology_cb (void *cls, | |||
284 | const struct GNUNET_PeerIdentity *second, const char *emsg) | 285 | const struct GNUNET_PeerIdentity *second, const char *emsg) |
285 | { | 286 | { |
286 | FILE *outfile = cls; | 287 | FILE *outfile = cls; |
288 | |||
287 | if (first != NULL) | 289 | if (first != NULL) |
290 | { | ||
291 | if (outfile != NULL) | ||
288 | { | 292 | { |
289 | if (outfile != NULL) | 293 | fprintf (outfile, "\t\"%s\" -- ", GNUNET_i2s (first)); |
290 | { | 294 | fprintf (outfile, "\"%s\";\n", GNUNET_i2s (second)); |
291 | fprintf (outfile, "\t\"%s\" -- ", GNUNET_i2s (first)); | ||
292 | fprintf (outfile, "\"%s\";\n", GNUNET_i2s (second)); | ||
293 | } | ||
294 | topology_connections++; | ||
295 | } | 295 | } |
296 | topology_connections++; | ||
297 | } | ||
296 | else | 298 | else |
299 | { | ||
300 | fprintf (stderr, | ||
301 | "Finished iterating over topology, %d total connections!\n", | ||
302 | topology_connections); | ||
303 | if (outfile != NULL) | ||
297 | { | 304 | { |
298 | fprintf (stderr, | 305 | fprintf (outfile, "}\n"); |
299 | "Finished iterating over topology, %d total connections!\n", | 306 | fclose (outfile); |
300 | topology_connections); | 307 | GNUNET_SCHEDULER_add_now (&finish_testing, NULL); |
301 | if (outfile != NULL) | ||
302 | { | ||
303 | fprintf (outfile, "}\n"); | ||
304 | fclose (outfile); | ||
305 | GNUNET_SCHEDULER_add_now (&finish_testing, NULL); | ||
306 | } | ||
307 | } | 308 | } |
309 | } | ||
308 | } | 310 | } |
309 | 311 | ||
310 | static int | 312 | static int |
@@ -317,24 +319,25 @@ process_mtype (void *cls, | |||
317 | FILE *dotOutFileFinished; | 319 | FILE *dotOutFileFinished; |
318 | struct TestMessageContext *pos = cls; | 320 | struct TestMessageContext *pos = cls; |
319 | struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *) message; | 321 | struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *) message; |
322 | |||
320 | if (pos->uid != ntohl (msg->uid)) | 323 | if (pos->uid != ntohl (msg->uid)) |
321 | return GNUNET_OK; | 324 | return GNUNET_OK; |
322 | 325 | ||
323 | #if VERBOSE | 326 | #if VERBOSE |
324 | if ((total_messages_received) % modnum == 0) | 327 | if ((total_messages_received) % modnum == 0) |
325 | { | 328 | { |
326 | if (total_messages_received == 0) | 329 | if (total_messages_received == 0) |
327 | fprintf (stdout, "0%%"); | 330 | fprintf (stdout, "0%%"); |
328 | else | 331 | else |
329 | fprintf (stdout, "%d%%", | 332 | fprintf (stdout, "%d%%", |
330 | (int) (((float) total_messages_received / | 333 | (int) (((float) total_messages_received / |
331 | expected_messages) * 100)); | 334 | expected_messages) * 100)); |
332 | 335 | ||
333 | } | 336 | } |
334 | else if (total_messages_received % dotnum == 0) | 337 | else if (total_messages_received % dotnum == 0) |
335 | { | 338 | { |
336 | fprintf (stdout, "."); | 339 | fprintf (stdout, "."); |
337 | } | 340 | } |
338 | fflush (stdout); | 341 | fflush (stdout); |
339 | #endif | 342 | #endif |
340 | 343 | ||
@@ -350,27 +353,26 @@ process_mtype (void *cls, | |||
350 | #endif | 353 | #endif |
351 | 354 | ||
352 | if (total_messages_received == expected_messages) | 355 | if (total_messages_received == expected_messages) |
353 | { | 356 | { |
354 | #if VERBOSE | 357 | #if VERBOSE |
355 | fprintf (stdout, "100%%]\n"); | 358 | fprintf (stdout, "100%%]\n"); |
356 | #endif | 359 | #endif |
357 | GNUNET_SCHEDULER_cancel (die_task); | 360 | GNUNET_SCHEDULER_cancel (die_task); |
358 | GNUNET_asprintf (&dotOutFileNameFinished, "%s.dot", "final_topology"); | 361 | GNUNET_asprintf (&dotOutFileNameFinished, "%s.dot", "final_topology"); |
359 | dotOutFileFinished = fopen (dotOutFileNameFinished, "w"); | 362 | dotOutFileFinished = fopen (dotOutFileNameFinished, "w"); |
360 | GNUNET_free (dotOutFileNameFinished); | 363 | GNUNET_free (dotOutFileNameFinished); |
361 | if (dotOutFileFinished != NULL) | 364 | if (dotOutFileFinished != NULL) |
362 | { | ||
363 | fprintf (dotOutFileFinished, "strict graph G {\n"); | ||
364 | } | ||
365 | topology_connections = 0; | ||
366 | GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished); | ||
367 | //GNUNET_SCHEDULER_add_now (&finish_testing, NULL); | ||
368 | } | ||
369 | else | ||
370 | { | 365 | { |
371 | pos->disconnect_task = | 366 | fprintf (dotOutFileFinished, "strict graph G {\n"); |
372 | GNUNET_SCHEDULER_add_now (&disconnect_cores, pos); | ||
373 | } | 367 | } |
368 | topology_connections = 0; | ||
369 | GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished); | ||
370 | //GNUNET_SCHEDULER_add_now (&finish_testing, NULL); | ||
371 | } | ||
372 | else | ||
373 | { | ||
374 | pos->disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cores, pos); | ||
375 | } | ||
374 | 376 | ||
375 | return GNUNET_OK; | 377 | return GNUNET_OK; |
376 | } | 378 | } |
@@ -379,6 +381,7 @@ static void | |||
379 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 381 | end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
380 | { | 382 | { |
381 | char *msg = cls; | 383 | char *msg = cls; |
384 | |||
382 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 385 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
383 | "End badly was called (%s)... stopping daemons.\n", msg); | 386 | "End badly was called (%s)... stopping daemons.\n", msg); |
384 | struct TestMessageContext *pos; | 387 | struct TestMessageContext *pos; |
@@ -386,21 +389,21 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
386 | 389 | ||
387 | pos = test_messages; | 390 | pos = test_messages; |
388 | while (pos != NULL) | 391 | while (pos != NULL) |
392 | { | ||
393 | if (pos->peer1handle != NULL) | ||
389 | { | 394 | { |
390 | if (pos->peer1handle != NULL) | 395 | GNUNET_CORE_disconnect (pos->peer1handle); |
391 | { | 396 | pos->peer1handle = NULL; |
392 | GNUNET_CORE_disconnect (pos->peer1handle); | ||
393 | pos->peer1handle = NULL; | ||
394 | } | ||
395 | if (pos->peer2handle != NULL) | ||
396 | { | ||
397 | GNUNET_CORE_disconnect (pos->peer2handle); | ||
398 | pos->peer2handle = NULL; | ||
399 | } | ||
400 | free_pos = pos; | ||
401 | pos = pos->next; | ||
402 | GNUNET_free (free_pos); | ||
403 | } | 397 | } |
398 | if (pos->peer2handle != NULL) | ||
399 | { | ||
400 | GNUNET_CORE_disconnect (pos->peer2handle); | ||
401 | pos->peer2handle = NULL; | ||
402 | } | ||
403 | free_pos = pos; | ||
404 | pos = pos->next; | ||
405 | GNUNET_free (free_pos); | ||
406 | } | ||
404 | 407 | ||
405 | #if VERBOSE | 408 | #if VERBOSE |
406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 409 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -413,18 +416,18 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
413 | #endif | 416 | #endif |
414 | 417 | ||
415 | if (pg != NULL) | 418 | if (pg != NULL) |
416 | { | 419 | { |
417 | GNUNET_TESTING_daemons_stop (pg, timeout, &shutdown_callback, NULL); | 420 | GNUNET_TESTING_daemons_stop (pg, timeout, &shutdown_callback, NULL); |
418 | ok = 7331; /* Opposite of leet */ | 421 | ok = 7331; /* Opposite of leet */ |
419 | } | 422 | } |
420 | else | 423 | else |
421 | ok = 401; /* Never got peers started */ | 424 | ok = 401; /* Never got peers started */ |
422 | 425 | ||
423 | if (dotOutFile != NULL) | 426 | if (dotOutFile != NULL) |
424 | { | 427 | { |
425 | fprintf (dotOutFile, "}"); | 428 | fprintf (dotOutFile, "}"); |
426 | fclose (dotOutFile); | 429 | fclose (dotOutFile); |
427 | } | 430 | } |
428 | } | 431 | } |
429 | 432 | ||
430 | static size_t | 433 | static size_t |
@@ -471,30 +474,31 @@ init_notify_peer2 (void *cls, | |||
471 | 474 | ||
472 | pos->peer2connected = GNUNET_YES; | 475 | pos->peer2connected = GNUNET_YES; |
473 | if (pos->peer1notified == GNUNET_YES) /* Peer 1 has been notified of connection to peer 2 */ | 476 | if (pos->peer1notified == GNUNET_YES) /* Peer 1 has been notified of connection to peer 2 */ |
474 | { | 477 | { |
475 | #if VERBOSE > 1 | 478 | #if VERBOSE > 1 |
476 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 479 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
477 | "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", | 480 | "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", |
478 | GNUNET_i2s (my_identity), GNUNET_h2s(&pos->peer1->id.hashPubKey)); | 481 | GNUNET_i2s (my_identity), |
482 | GNUNET_h2s (&pos->peer1->id.hashPubKey)); | ||
479 | #endif | 483 | #endif |
480 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, | 484 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, |
481 | 0, | 485 | 0, |
482 | timeout, | 486 | timeout, |
483 | &pos->peer2->id, | 487 | &pos->peer2->id, |
484 | sizeof (struct | 488 | sizeof (struct |
485 | GNUNET_TestMessage), | 489 | GNUNET_TestMessage), |
486 | &transmit_ready, pos)) | 490 | &transmit_ready, pos)) |
487 | { | 491 | { |
488 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 492 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
489 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | 493 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", |
490 | GNUNET_i2s (&pos->peer2->id)); | 494 | GNUNET_i2s (&pos->peer2->id)); |
491 | transmit_ready_failed++; | 495 | transmit_ready_failed++; |
492 | } | 496 | } |
493 | else | 497 | else |
494 | { | 498 | { |
495 | transmit_ready_scheduled++; | 499 | transmit_ready_scheduled++; |
496 | } | ||
497 | } | 500 | } |
501 | } | ||
498 | } | 502 | } |
499 | 503 | ||
500 | /** | 504 | /** |
@@ -504,50 +508,52 @@ init_notify_peer2 (void *cls, | |||
504 | * @param peer peer identity this notification is about | 508 | * @param peer peer identity this notification is about |
505 | * @param atsi performance data for the connection | 509 | * @param atsi performance data for the connection |
506 | */ | 510 | */ |
507 | static void connect_notify_peers (void *cls, | 511 | static void |
508 | const struct | 512 | connect_notify_peers (void *cls, |
509 | GNUNET_PeerIdentity *peer, | 513 | const struct |
510 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 514 | GNUNET_PeerIdentity *peer, |
515 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | ||
511 | { | 516 | { |
512 | struct TestMessageContext *pos = cls; | 517 | struct TestMessageContext *pos = cls; |
513 | 518 | ||
514 | if (0 == memcmp(peer, &pos->peer2->id, sizeof(struct GNUNET_PeerIdentity))) | 519 | if (0 == memcmp (peer, &pos->peer2->id, sizeof (struct GNUNET_PeerIdentity))) |
515 | { | 520 | { |
516 | pos->peer1notified = GNUNET_YES; | 521 | pos->peer1notified = GNUNET_YES; |
517 | #if VERBOSE > 1 | 522 | #if VERBOSE > 1 |
518 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 523 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
519 | "Peer `%s' notified of connection to peer `%s'\n", | 524 | "Peer `%s' notified of connection to peer `%s'\n", |
520 | GNUNET_i2s (&pos->peer1->id), GNUNET_h2s(&peer->hashPubKey)); | 525 | GNUNET_i2s (&pos->peer1->id), GNUNET_h2s (&peer->hashPubKey)); |
521 | #endif | 526 | #endif |
522 | } | 527 | } |
523 | else | 528 | else |
524 | return; | 529 | return; |
525 | 530 | ||
526 | if (pos->peer2connected == GNUNET_YES) /* Already connected and notified of connection, send message! */ | 531 | if (pos->peer2connected == GNUNET_YES) /* Already connected and notified of connection, send message! */ |
527 | { | 532 | { |
528 | #if VERBOSE > 1 | 533 | #if VERBOSE > 1 |
529 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 534 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
530 | "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", | 535 | "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", |
531 | GNUNET_i2s (&pos->peer2->id), GNUNET_h2s(&pos->peer1->id.hashPubKey)); | 536 | GNUNET_i2s (&pos->peer2->id), |
537 | GNUNET_h2s (&pos->peer1->id.hashPubKey)); | ||
532 | #endif | 538 | #endif |
533 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, | 539 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, |
534 | 0, | 540 | 0, |
535 | timeout, | 541 | timeout, |
536 | &pos->peer2->id, | 542 | &pos->peer2->id, |
537 | sizeof (struct | 543 | sizeof (struct |
538 | GNUNET_TestMessage), | 544 | GNUNET_TestMessage), |
539 | &transmit_ready, pos)) | 545 | &transmit_ready, pos)) |
540 | { | 546 | { |
541 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 547 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
542 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", | 548 | "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", |
543 | GNUNET_i2s (&pos->peer2->id)); | 549 | GNUNET_i2s (&pos->peer2->id)); |
544 | transmit_ready_failed++; | 550 | transmit_ready_failed++; |
545 | } | 551 | } |
546 | else | 552 | else |
547 | { | 553 | { |
548 | transmit_ready_scheduled++; | 554 | transmit_ready_scheduled++; |
549 | } | ||
550 | } | 555 | } |
556 | } | ||
551 | } | 557 | } |
552 | 558 | ||
553 | static void | 559 | static void |
@@ -558,6 +564,7 @@ init_notify_peer1 (void *cls, | |||
558 | *publicKey) | 564 | *publicKey) |
559 | { | 565 | { |
560 | struct TestMessageContext *pos = cls; | 566 | struct TestMessageContext *pos = cls; |
567 | |||
561 | total_server_connections++; | 568 | total_server_connections++; |
562 | 569 | ||
563 | #if VERBOSE > 1 | 570 | #if VERBOSE > 1 |
@@ -588,27 +595,27 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
588 | struct TestMessageContext *pos = cls; | 595 | struct TestMessageContext *pos = cls; |
589 | 596 | ||
590 | if ((pos == test_messages) && (settle_time.rel_value > 0)) | 597 | if ((pos == test_messages) && (settle_time.rel_value > 0)) |
591 | { | 598 | { |
592 | topology_connections = 0; | 599 | topology_connections = 0; |
593 | GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); | 600 | GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); |
594 | } | 601 | } |
595 | if (( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)|| (cls == NULL)) | 602 | if (((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) || (cls == NULL)) |
596 | return; | 603 | return; |
597 | 604 | ||
598 | if (die_task == GNUNET_SCHEDULER_NO_TASK) | 605 | if (die_task == GNUNET_SCHEDULER_NO_TASK) |
599 | { | 606 | { |
600 | die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, | 607 | die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, |
601 | &end_badly, | 608 | &end_badly, |
602 | "from send test messages (timeout)"); | 609 | "from send test messages (timeout)"); |
603 | } | 610 | } |
604 | 611 | ||
605 | if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) | 612 | if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) |
606 | { | 613 | { |
607 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 614 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
608 | (GNUNET_TIME_UNIT_SECONDS, 1), | 615 | (GNUNET_TIME_UNIT_SECONDS, 1), |
609 | &send_test_messages, pos); | 616 | &send_test_messages, pos); |
610 | return; /* Otherwise we'll double schedule messages here! */ | 617 | return; /* Otherwise we'll double schedule messages here! */ |
611 | } | 618 | } |
612 | 619 | ||
613 | /* | 620 | /* |
614 | * Connect to the sending peer | 621 | * Connect to the sending peer |
@@ -626,15 +633,15 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
626 | GNUNET_assert (pos->peer1handle != NULL); | 633 | GNUNET_assert (pos->peer1handle != NULL); |
627 | 634 | ||
628 | if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) | 635 | if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) |
629 | { | 636 | { |
630 | GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next); | 637 | GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next); |
631 | } | 638 | } |
632 | else | 639 | else |
633 | { | 640 | { |
634 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 641 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
635 | (GNUNET_TIME_UNIT_SECONDS, 1), | 642 | (GNUNET_TIME_UNIT_SECONDS, 1), |
636 | &send_test_messages, pos->next); | 643 | &send_test_messages, pos->next); |
637 | } | 644 | } |
638 | } | 645 | } |
639 | 646 | ||
640 | 647 | ||
@@ -650,113 +657,114 @@ topology_callback (void *cls, | |||
650 | const char *emsg) | 657 | const char *emsg) |
651 | { | 658 | { |
652 | struct TestMessageContext *temp_context; | 659 | struct TestMessageContext *temp_context; |
660 | |||
653 | if (emsg == NULL) | 661 | if (emsg == NULL) |
654 | { | 662 | { |
655 | #if VERBOSE | 663 | #if VERBOSE |
656 | if ((total_connections) % modnum == 0) | 664 | if ((total_connections) % modnum == 0) |
657 | { | 665 | { |
658 | if (total_connections == 0) | 666 | if (total_connections == 0) |
659 | fprintf (stdout, "0%%"); | 667 | fprintf (stdout, "0%%"); |
660 | else | 668 | else |
661 | fprintf (stdout, "%d%%", | 669 | fprintf (stdout, "%d%%", |
662 | (int) (((float) total_connections / | 670 | (int) (((float) total_connections / |
663 | expected_connections) * 100)); | 671 | expected_connections) * 100)); |
664 | 672 | ||
665 | } | 673 | } |
666 | else if (total_connections % dotnum == 0) | 674 | else if (total_connections % dotnum == 0) |
667 | { | 675 | { |
668 | fprintf (stdout, "."); | 676 | fprintf (stdout, "."); |
669 | } | 677 | } |
670 | fflush (stdout); | 678 | fflush (stdout); |
671 | #endif | 679 | #endif |
672 | total_connections++; | 680 | total_connections++; |
673 | #if VERBOSE > 1 | 681 | #if VERBOSE > 1 |
674 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "connected peer %s to peer %s\n", | 682 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "connected peer %s to peer %s\n", |
675 | first_daemon->shortname, second_daemon->shortname); | 683 | first_daemon->shortname, second_daemon->shortname); |
676 | #endif | 684 | #endif |
677 | temp_context = GNUNET_malloc (sizeof (struct TestMessageContext)); | 685 | temp_context = GNUNET_malloc (sizeof (struct TestMessageContext)); |
678 | temp_context->peer1 = first_daemon; | 686 | temp_context->peer1 = first_daemon; |
679 | temp_context->peer2 = second_daemon; | 687 | temp_context->peer2 = second_daemon; |
680 | temp_context->next = test_messages; | 688 | temp_context->next = test_messages; |
681 | temp_context->uid = total_connections; | 689 | temp_context->uid = total_connections; |
682 | temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK; | 690 | temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK; |
683 | test_messages = temp_context; | 691 | test_messages = temp_context; |
684 | 692 | ||
685 | expected_messages++; | 693 | expected_messages++; |
686 | if (dotOutFile != NULL) | 694 | if (dotOutFile != NULL) |
687 | fprintf (dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname, | 695 | fprintf (dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname, |
688 | second_daemon->shortname); | 696 | second_daemon->shortname); |
689 | } | 697 | } |
690 | #if VERBOSE | 698 | #if VERBOSE |
691 | else | 699 | else |
692 | { | 700 | { |
693 | failed_connections++; | 701 | failed_connections++; |
694 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 702 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
695 | "Failed to connect peer %s to peer %s with error :\n%s\n", | 703 | "Failed to connect peer %s to peer %s with error :\n%s\n", |
696 | first_daemon->shortname, second_daemon->shortname, emsg); | 704 | first_daemon->shortname, second_daemon->shortname, emsg); |
697 | } | 705 | } |
698 | #endif | 706 | #endif |
699 | 707 | ||
700 | if (total_connections == expected_connections) | 708 | if (total_connections == expected_connections) |
701 | { | 709 | { |
702 | #if VERBOSE | 710 | #if VERBOSE |
703 | fprintf (stdout, "100%%]\n"); | 711 | fprintf (stdout, "100%%]\n"); |
704 | #endif | 712 | #endif |
705 | #if VERBOSE | 713 | #if VERBOSE |
706 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 714 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
707 | "Created %d total connections, which is our target number! Calling send messages.\n", | 715 | "Created %d total connections, which is our target number! Calling send messages.\n", |
708 | total_connections); | 716 | total_connections); |
709 | #endif | 717 | #endif |
710 | modnum = expected_messages / 4; | 718 | modnum = expected_messages / 4; |
711 | dotnum = (expected_messages / 50) + 1; | 719 | dotnum = (expected_messages / 50) + 1; |
712 | GNUNET_SCHEDULER_cancel (die_task); | 720 | GNUNET_SCHEDULER_cancel (die_task); |
713 | die_task = GNUNET_SCHEDULER_NO_TASK; | 721 | die_task = GNUNET_SCHEDULER_NO_TASK; |
714 | #if DELAY_FOR_LOGGING | 722 | #if DELAY_FOR_LOGGING |
715 | fprintf (stdout, "Sending test messages in 10 seconds.\n"); | 723 | fprintf (stdout, "Sending test messages in 10 seconds.\n"); |
716 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 724 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
717 | (GNUNET_TIME_UNIT_SECONDS, 10), | 725 | (GNUNET_TIME_UNIT_SECONDS, 10), |
718 | &send_test_messages, test_messages); | 726 | &send_test_messages, test_messages); |
719 | gather_log_data (); | 727 | gather_log_data (); |
720 | #else | 728 | #else |
721 | if (settle_time.rel_value > 0) | 729 | if (settle_time.rel_value > 0) |
722 | { | 730 | { |
723 | GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); | 731 | GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); |
724 | } | 732 | } |
725 | GNUNET_SCHEDULER_add_delayed (settle_time, &send_test_messages, | 733 | GNUNET_SCHEDULER_add_delayed (settle_time, &send_test_messages, |
726 | test_messages); | 734 | test_messages); |
727 | #endif | 735 | #endif |
728 | #if VERBOSE | 736 | #if VERBOSE |
729 | fprintf (stdout, "Test message progress: ["); | 737 | fprintf (stdout, "Test message progress: ["); |
730 | #endif | 738 | #endif |
731 | 739 | ||
732 | } | 740 | } |
733 | else if (total_connections + failed_connections == expected_connections) | 741 | else if (total_connections + failed_connections == expected_connections) |
742 | { | ||
743 | if (failed_connections < | ||
744 | (unsigned int) (fail_percentage * total_connections)) | ||
734 | { | 745 | { |
735 | if (failed_connections < | 746 | GNUNET_SCHEDULER_cancel (die_task); |
736 | (unsigned int) (fail_percentage * total_connections)) | 747 | die_task = GNUNET_SCHEDULER_NO_TASK; |
737 | { | 748 | GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages); |
738 | GNUNET_SCHEDULER_cancel (die_task); | ||
739 | die_task = GNUNET_SCHEDULER_NO_TASK; | ||
740 | GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages); | ||
741 | } | ||
742 | else | ||
743 | { | ||
744 | GNUNET_SCHEDULER_cancel (die_task); | ||
745 | die_task = | ||
746 | GNUNET_SCHEDULER_add_now (&end_badly, | ||
747 | "from topology_callback (too many failed connections)"); | ||
748 | } | ||
749 | } | 749 | } |
750 | else | 750 | else |
751 | { | 751 | { |
752 | GNUNET_SCHEDULER_cancel (die_task); | ||
753 | die_task = | ||
754 | GNUNET_SCHEDULER_add_now (&end_badly, | ||
755 | "from topology_callback (too many failed connections)"); | ||
756 | } | ||
757 | } | ||
758 | else | ||
759 | { | ||
752 | #if VERBOSE > 1 | 760 | #if VERBOSE > 1 |
753 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 761 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
754 | "Have %d total connections, %d failed connections, Want %d (at least %d)\n", | 762 | "Have %d total connections, %d failed connections, Want %d (at least %d)\n", |
755 | total_connections, failed_connections, expected_connections, | 763 | total_connections, failed_connections, expected_connections, |
756 | expected_connections - | 764 | expected_connections - |
757 | (unsigned int) (fail_percentage * expected_connections)); | 765 | (unsigned int) (fail_percentage * expected_connections)); |
758 | #endif | 766 | #endif |
759 | } | 767 | } |
760 | } | 768 | } |
761 | 769 | ||
762 | static void | 770 | static void |
@@ -774,8 +782,8 @@ connect_topology () | |||
774 | { | 782 | { |
775 | expected_connections = -1; | 783 | expected_connections = -1; |
776 | if ((pg != NULL) && (peers_left == 0)) | 784 | if ((pg != NULL) && (peers_left == 0)) |
777 | { | 785 | { |
778 | expected_connections = | 786 | expected_connections = |
779 | GNUNET_TESTING_connect_topology (pg, connection_topology, | 787 | GNUNET_TESTING_connect_topology (pg, connection_topology, |
780 | connect_topology_option, | 788 | connect_topology_option, |
781 | connect_topology_option_modifier, | 789 | connect_topology_option_modifier, |
@@ -783,18 +791,18 @@ connect_topology () | |||
783 | connect_attempts, | 791 | connect_attempts, |
784 | &topology_creation_finished, NULL); | 792 | &topology_creation_finished, NULL); |
785 | #if VERBOSE > 1 | 793 | #if VERBOSE > 1 |
786 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 794 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
787 | "Have %d expected connections\n", expected_connections); | 795 | "Have %d expected connections\n", expected_connections); |
788 | #endif | 796 | #endif |
789 | } | 797 | } |
790 | 798 | ||
791 | GNUNET_SCHEDULER_cancel (die_task); | 799 | GNUNET_SCHEDULER_cancel (die_task); |
792 | if (expected_connections == GNUNET_SYSERR) | 800 | if (expected_connections == GNUNET_SYSERR) |
793 | { | 801 | { |
794 | die_task = | 802 | die_task = |
795 | GNUNET_SCHEDULER_add_now (&end_badly, | 803 | GNUNET_SCHEDULER_add_now (&end_badly, |
796 | "from connect topology (bad return)"); | 804 | "from connect topology (bad return)"); |
797 | } | 805 | } |
798 | 806 | ||
799 | die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, | 807 | die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, |
800 | &end_badly, | 808 | &end_badly, |
@@ -811,23 +819,22 @@ create_topology () | |||
811 | { | 819 | { |
812 | peers_left = num_peers; /* Reset counter */ | 820 | peers_left = num_peers; /* Reset counter */ |
813 | if (GNUNET_TESTING_create_topology | 821 | if (GNUNET_TESTING_create_topology |
814 | (pg, topology, blacklist_topology, | 822 | (pg, topology, blacklist_topology, blacklist_transports) != GNUNET_SYSERR) |
815 | blacklist_transports) != GNUNET_SYSERR) | 823 | { |
816 | { | ||
817 | #if VERBOSE | 824 | #if VERBOSE |
818 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 825 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
819 | "Topology set up, now starting peers!\n"); | 826 | "Topology set up, now starting peers!\n"); |
820 | fprintf (stdout, "Daemon start progress ["); | 827 | fprintf (stdout, "Daemon start progress ["); |
821 | #endif | 828 | #endif |
822 | GNUNET_TESTING_daemons_continue_startup (pg); | 829 | GNUNET_TESTING_daemons_continue_startup (pg); |
823 | } | 830 | } |
824 | else | 831 | else |
825 | { | 832 | { |
826 | GNUNET_SCHEDULER_cancel (die_task); | 833 | GNUNET_SCHEDULER_cancel (die_task); |
827 | die_task = | 834 | die_task = |
828 | GNUNET_SCHEDULER_add_now (&end_badly, | 835 | GNUNET_SCHEDULER_add_now (&end_badly, |
829 | "from create topology (bad return)"); | 836 | "from create topology (bad return)"); |
830 | } | 837 | } |
831 | GNUNET_SCHEDULER_cancel (die_task); | 838 | GNUNET_SCHEDULER_cancel (die_task); |
832 | die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, | 839 | die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, |
833 | &end_badly, | 840 | &end_badly, |
@@ -842,11 +849,11 @@ peers_started_callback (void *cls, | |||
842 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 849 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
843 | { | 850 | { |
844 | if (emsg != NULL) | 851 | if (emsg != NULL) |
845 | { | 852 | { |
846 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 853 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
847 | "Failed to start daemon with error: `%s'\n", emsg); | 854 | "Failed to start daemon with error: `%s'\n", emsg); |
848 | return; | 855 | return; |
849 | } | 856 | } |
850 | GNUNET_assert (id != NULL); | 857 | GNUNET_assert (id != NULL); |
851 | #if VERBOSE > 1 | 858 | #if VERBOSE > 1 |
852 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n", | 859 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n", |
@@ -854,49 +861,47 @@ peers_started_callback (void *cls, | |||
854 | #endif | 861 | #endif |
855 | #if VERBOSE | 862 | #if VERBOSE |
856 | if ((num_peers - peers_left) % modnum == 0) | 863 | if ((num_peers - peers_left) % modnum == 0) |
857 | { | 864 | { |
858 | if (num_peers - peers_left == 0) | 865 | if (num_peers - peers_left == 0) |
859 | fprintf (stdout, "0%%"); | 866 | fprintf (stdout, "0%%"); |
860 | else | 867 | else |
861 | fprintf (stdout, "%d%%", | 868 | fprintf (stdout, "%d%%", |
862 | (int) (((float) (num_peers - peers_left) / | 869 | (int) (((float) (num_peers - peers_left) / num_peers) * 100)); |
863 | num_peers) * 100)); | 870 | |
864 | 871 | } | |
865 | } | ||
866 | else if ((num_peers - peers_left) % dotnum == 0) | 872 | else if ((num_peers - peers_left) % dotnum == 0) |
867 | { | 873 | { |
868 | fprintf (stdout, "."); | 874 | fprintf (stdout, "."); |
869 | } | 875 | } |
870 | fflush (stdout); | 876 | fflush (stdout); |
871 | #endif | 877 | #endif |
872 | peers_left--; | 878 | peers_left--; |
873 | if (peers_left == 0) | 879 | if (peers_left == 0) |
874 | { | 880 | { |
875 | #if VERBOSE | 881 | #if VERBOSE |
876 | fprintf (stdout, "100%%]\n"); | 882 | fprintf (stdout, "100%%]\n"); |
877 | #endif | 883 | #endif |
878 | #if VERBOSE | 884 | #if VERBOSE |
879 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 885 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
880 | "All %d daemons started, now connecting peers!\n", | 886 | "All %d daemons started, now connecting peers!\n", num_peers); |
881 | num_peers); | ||
882 | #endif | 887 | #endif |
883 | GNUNET_SCHEDULER_cancel (die_task); | 888 | GNUNET_SCHEDULER_cancel (die_task); |
884 | /* Set up task in case topology creation doesn't finish | 889 | /* Set up task in case topology creation doesn't finish |
885 | * within a reasonable amount of time */ | 890 | * within a reasonable amount of time */ |
886 | die_task = GNUNET_SCHEDULER_add_delayed (timeout, | 891 | die_task = GNUNET_SCHEDULER_add_delayed (timeout, |
887 | &end_badly, | 892 | &end_badly, |
888 | "from peers_started_callback"); | 893 | "from peers_started_callback"); |
889 | #if DELAY_FOR_LOGGING | 894 | #if DELAY_FOR_LOGGING |
890 | fprintf (stdout, "Connecting topology in 10 seconds\n"); | 895 | fprintf (stdout, "Connecting topology in 10 seconds\n"); |
891 | gather_log_data (); | 896 | gather_log_data (); |
892 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 897 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
893 | (GNUNET_TIME_UNIT_SECONDS, 10), | 898 | (GNUNET_TIME_UNIT_SECONDS, 10), |
894 | &connect_topology, NULL); | 899 | &connect_topology, NULL); |
895 | #else | 900 | #else |
896 | connect_topology (); | 901 | connect_topology (); |
897 | #endif | 902 | #endif |
898 | ok = 0; | 903 | ok = 0; |
899 | } | 904 | } |
900 | } | 905 | } |
901 | 906 | ||
902 | /** | 907 | /** |
@@ -913,10 +918,10 @@ hostkey_callback (void *cls, | |||
913 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 918 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
914 | { | 919 | { |
915 | if (emsg != NULL) | 920 | if (emsg != NULL) |
916 | { | 921 | { |
917 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 922 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
918 | "Hostkey callback received error: %s\n", emsg); | 923 | "Hostkey callback received error: %s\n", emsg); |
919 | } | 924 | } |
920 | 925 | ||
921 | #if VERBOSE > 1 | 926 | #if VERBOSE > 1 |
922 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 927 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -926,39 +931,37 @@ hostkey_callback (void *cls, | |||
926 | 931 | ||
927 | #if VERBOSE | 932 | #if VERBOSE |
928 | if ((num_peers - peers_left) % modnum == 0) | 933 | if ((num_peers - peers_left) % modnum == 0) |
929 | { | 934 | { |
930 | if (num_peers - peers_left == 0) | 935 | if (num_peers - peers_left == 0) |
931 | fprintf (stdout, "0%%"); | 936 | fprintf (stdout, "0%%"); |
932 | else | 937 | else |
933 | fprintf (stdout, "%d%%", | 938 | fprintf (stdout, "%d%%", |
934 | (int) (((float) (num_peers - peers_left) / | 939 | (int) (((float) (num_peers - peers_left) / num_peers) * 100)); |
935 | num_peers) * 100)); | 940 | |
936 | 941 | } | |
937 | } | ||
938 | else if ((num_peers - peers_left) % dotnum == 0) | 942 | else if ((num_peers - peers_left) % dotnum == 0) |
939 | { | 943 | { |
940 | fprintf (stdout, "."); | 944 | fprintf (stdout, "."); |
941 | } | 945 | } |
942 | fflush (stdout); | 946 | fflush (stdout); |
943 | #endif | 947 | #endif |
944 | peers_left--; | 948 | peers_left--; |
945 | if (peers_left == 0) | 949 | if (peers_left == 0) |
946 | { | 950 | { |
947 | #if VERBOSE | 951 | #if VERBOSE |
948 | fprintf (stdout, "100%%]\n"); | 952 | fprintf (stdout, "100%%]\n"); |
949 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 953 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
950 | "All %d hostkeys created, now creating topology!\n", | 954 | "All %d hostkeys created, now creating topology!\n", num_peers); |
951 | num_peers); | ||
952 | #endif | 955 | #endif |
953 | GNUNET_SCHEDULER_cancel (die_task); | 956 | GNUNET_SCHEDULER_cancel (die_task); |
954 | /* Set up task in case topology creation doesn't finish | 957 | /* Set up task in case topology creation doesn't finish |
955 | * within a reasonable amount of time */ | 958 | * within a reasonable amount of time */ |
956 | die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, | 959 | die_task = GNUNET_SCHEDULER_add_delayed (test_timeout, |
957 | &end_badly, | 960 | &end_badly, |
958 | "from create_topology"); | 961 | "from create_topology"); |
959 | GNUNET_SCHEDULER_add_now (&create_topology, NULL); | 962 | GNUNET_SCHEDULER_add_now (&create_topology, NULL); |
960 | ok = 0; | 963 | ok = 0; |
961 | } | 964 | } |
962 | } | 965 | } |
963 | 966 | ||
964 | static void | 967 | static void |
@@ -972,13 +975,14 @@ run (void *cls, | |||
972 | char *connect_topology_option_str; | 975 | char *connect_topology_option_str; |
973 | char *connect_topology_option_modifier_string; | 976 | char *connect_topology_option_modifier_string; |
974 | unsigned long long temp_settle; | 977 | unsigned long long temp_settle; |
978 | |||
975 | ok = 1; | 979 | ok = 1; |
976 | 980 | ||
977 | dotOutFile = fopen (dotOutFileName, "w"); | 981 | dotOutFile = fopen (dotOutFileName, "w"); |
978 | if (dotOutFile != NULL) | 982 | if (dotOutFile != NULL) |
979 | { | 983 | { |
980 | fprintf (dotOutFile, "strict graph G {\n"); | 984 | fprintf (dotOutFile, "strict graph G {\n"); |
981 | } | 985 | } |
982 | 986 | ||
983 | #if VERBOSE | 987 | #if VERBOSE |
984 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 988 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -988,21 +992,21 @@ run (void *cls, | |||
988 | if (GNUNET_YES != | 992 | if (GNUNET_YES != |
989 | GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome", | 993 | GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome", |
990 | &test_directory)) | 994 | &test_directory)) |
991 | { | 995 | { |
992 | ok = 404; | 996 | ok = 404; |
993 | return; | 997 | return; |
994 | } | 998 | } |
995 | 999 | ||
996 | if ((GNUNET_YES == | 1000 | if ((GNUNET_YES == |
997 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology", | 1001 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology", |
998 | &topology_str)) | 1002 | &topology_str)) |
999 | && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) | 1003 | && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) |
1000 | { | 1004 | { |
1001 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1005 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1002 | "Invalid topology `%s' given for section %s option %s\n", | 1006 | "Invalid topology `%s' given for section %s option %s\n", |
1003 | topology_str, "TESTING", "TOPOLOGY"); | 1007 | topology_str, "TESTING", "TOPOLOGY"); |
1004 | topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */ | 1008 | topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */ |
1005 | } | 1009 | } |
1006 | 1010 | ||
1007 | if ((GNUNET_YES == | 1011 | if ((GNUNET_YES == |
1008 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 1012 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
@@ -1011,11 +1015,11 @@ run (void *cls, | |||
1011 | && (GNUNET_NO == | 1015 | && (GNUNET_NO == |
1012 | GNUNET_TESTING_topology_get (&connection_topology, | 1016 | GNUNET_TESTING_topology_get (&connection_topology, |
1013 | connect_topology_str))) | 1017 | connect_topology_str))) |
1014 | { | 1018 | { |
1015 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1019 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1016 | "Invalid connect topology `%s' given for section %s option %s\n", | 1020 | "Invalid connect topology `%s' given for section %s option %s\n", |
1017 | connect_topology_str, "TESTING", "CONNECT_TOPOLOGY"); | 1021 | connect_topology_str, "TESTING", "CONNECT_TOPOLOGY"); |
1018 | } | 1022 | } |
1019 | GNUNET_free_non_null (connect_topology_str); | 1023 | GNUNET_free_non_null (connect_topology_str); |
1020 | if ((GNUNET_YES == | 1024 | if ((GNUNET_YES == |
1021 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 1025 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
@@ -1024,31 +1028,31 @@ run (void *cls, | |||
1024 | && (GNUNET_NO == | 1028 | && (GNUNET_NO == |
1025 | GNUNET_TESTING_topology_option_get (&connect_topology_option, | 1029 | GNUNET_TESTING_topology_option_get (&connect_topology_option, |
1026 | connect_topology_option_str))) | 1030 | connect_topology_option_str))) |
1027 | { | 1031 | { |
1028 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1032 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1029 | "Invalid connect topology option `%s' given for section %s option %s\n", | 1033 | "Invalid connect topology option `%s' given for section %s option %s\n", |
1030 | connect_topology_option_str, "TESTING", | 1034 | connect_topology_option_str, "TESTING", |
1031 | "CONNECT_TOPOLOGY_OPTION"); | 1035 | "CONNECT_TOPOLOGY_OPTION"); |
1032 | connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */ | 1036 | connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */ |
1033 | } | 1037 | } |
1034 | GNUNET_free_non_null (connect_topology_option_str); | 1038 | GNUNET_free_non_null (connect_topology_option_str); |
1035 | if (GNUNET_YES == | 1039 | if (GNUNET_YES == |
1036 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 1040 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
1037 | "connect_topology_option_modifier", | 1041 | "connect_topology_option_modifier", |
1038 | &connect_topology_option_modifier_string)) | 1042 | &connect_topology_option_modifier_string)) |
1043 | { | ||
1044 | if (sscanf | ||
1045 | (connect_topology_option_modifier_string, "%lf", | ||
1046 | &connect_topology_option_modifier) != 1) | ||
1039 | { | 1047 | { |
1040 | if (sscanf | 1048 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1041 | (connect_topology_option_modifier_string, "%lf", | 1049 | _ |
1042 | &connect_topology_option_modifier) != 1) | 1050 | ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), |
1043 | { | 1051 | connect_topology_option_modifier_string, |
1044 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1052 | "connect_topology_option_modifier", "TESTING"); |
1045 | _ | ||
1046 | ("Invalid value `%s' for option `%s' in section `%s': expected float\n"), | ||
1047 | connect_topology_option_modifier_string, | ||
1048 | "connect_topology_option_modifier", "TESTING"); | ||
1049 | } | ||
1050 | GNUNET_free (connect_topology_option_modifier_string); | ||
1051 | } | 1053 | } |
1054 | GNUNET_free (connect_topology_option_modifier_string); | ||
1055 | } | ||
1052 | 1056 | ||
1053 | if (GNUNET_YES != | 1057 | if (GNUNET_YES != |
1054 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 1058 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
@@ -1063,11 +1067,11 @@ run (void *cls, | |||
1063 | && (GNUNET_NO == | 1067 | && (GNUNET_NO == |
1064 | GNUNET_TESTING_topology_get (&blacklist_topology, | 1068 | GNUNET_TESTING_topology_get (&blacklist_topology, |
1065 | blacklist_topology_str))) | 1069 | blacklist_topology_str))) |
1066 | { | 1070 | { |
1067 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1071 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1068 | "Invalid topology `%s' given for section %s option %s\n", | 1072 | "Invalid topology `%s' given for section %s option %s\n", |
1069 | topology_str, "TESTING", "BLACKLIST_TOPOLOGY"); | 1073 | topology_str, "TESTING", "BLACKLIST_TOPOLOGY"); |
1070 | } | 1074 | } |
1071 | GNUNET_free_non_null (topology_str); | 1075 | GNUNET_free_non_null (topology_str); |
1072 | GNUNET_free_non_null (blacklist_topology_str); | 1076 | GNUNET_free_non_null (blacklist_topology_str); |
1073 | 1077 | ||
@@ -1075,7 +1079,7 @@ run (void *cls, | |||
1075 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "settle_time", | 1079 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "settle_time", |
1076 | &temp_settle)) | 1080 | &temp_settle)) |
1077 | settle_time = | 1081 | settle_time = |
1078 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle); | 1082 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle); |
1079 | 1083 | ||
1080 | if (GNUNET_SYSERR == | 1084 | if (GNUNET_SYSERR == |
1081 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", | 1085 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", |
@@ -1086,21 +1090,23 @@ run (void *cls, | |||
1086 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout", | 1090 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout", |
1087 | &temp_settle)) | 1091 | &temp_settle)) |
1088 | connect_timeout = | 1092 | connect_timeout = |
1089 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle); | 1093 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle); |
1090 | else | 1094 | else |
1091 | { | 1095 | { |
1092 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout"); | 1096 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", |
1093 | return; | 1097 | "testing", "connect_timeout"); |
1094 | } | 1098 | return; |
1099 | } | ||
1095 | 1100 | ||
1096 | 1101 | ||
1097 | if (GNUNET_OK != | 1102 | if (GNUNET_OK != |
1098 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts", | 1103 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts", |
1099 | &connect_attempts)) | 1104 | &connect_attempts)) |
1100 | { | 1105 | { |
1101 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts"); | 1106 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", |
1102 | return; | 1107 | "testing", "connect_attempts"); |
1103 | } | 1108 | return; |
1109 | } | ||
1104 | 1110 | ||
1105 | main_cfg = cfg; | 1111 | main_cfg = cfg; |
1106 | 1112 | ||
@@ -1109,12 +1115,18 @@ run (void *cls, | |||
1109 | /** | 1115 | /** |
1110 | * How long until we fail the whole testcase? | 1116 | * How long until we fail the whole testcase? |
1111 | */ | 1117 | */ |
1112 | test_timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START), num_peers * 2); | 1118 | test_timeout = |
1119 | GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_multiply | ||
1120 | (GNUNET_TIME_UNIT_SECONDS, | ||
1121 | SECONDS_PER_PEER_START), num_peers * 2); | ||
1113 | 1122 | ||
1114 | /** | 1123 | /** |
1115 | * How long until we give up on starting the peers? | 1124 | * How long until we give up on starting the peers? |
1116 | */ | 1125 | */ |
1117 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START), num_peers); | 1126 | timeout = |
1127 | GNUNET_TIME_relative_multiply (GNUNET_TIME_relative_multiply | ||
1128 | (GNUNET_TIME_UNIT_SECONDS, | ||
1129 | SECONDS_PER_PEER_START), num_peers); | ||
1118 | 1130 | ||
1119 | modnum = num_peers / 4; | 1131 | modnum = num_peers / 4; |
1120 | dotnum = (num_peers / 50) + 1; | 1132 | dotnum = (num_peers / 50) + 1; |
@@ -1123,9 +1135,9 @@ run (void *cls, | |||
1123 | #endif | 1135 | #endif |
1124 | /* Set up a task to end testing if peer start fails */ | 1136 | /* Set up a task to end testing if peer start fails */ |
1125 | die_task = | 1137 | die_task = |
1126 | GNUNET_SCHEDULER_add_delayed (timeout, | 1138 | GNUNET_SCHEDULER_add_delayed (timeout, |
1127 | &end_badly, | 1139 | &end_badly, |
1128 | "didn't generate all hostkeys within a reasonable amount of time!!!"); | 1140 | "didn't generate all hostkeys within a reasonable amount of time!!!"); |
1129 | 1141 | ||
1130 | GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1); | 1142 | GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1); |
1131 | pg = GNUNET_TESTING_daemons_start (cfg, | 1143 | pg = GNUNET_TESTING_daemons_start (cfg, |
@@ -1144,10 +1156,12 @@ check () | |||
1144 | { | 1156 | { |
1145 | char *binary_name; | 1157 | char *binary_name; |
1146 | char *config_file_name; | 1158 | char *config_file_name; |
1159 | |||
1147 | GNUNET_asprintf (&binary_name, "test-testing-topology-%s", topology_string); | 1160 | GNUNET_asprintf (&binary_name, "test-testing-topology-%s", topology_string); |
1148 | GNUNET_asprintf (&config_file_name, "test_testing_data_topology_%s.conf", | 1161 | GNUNET_asprintf (&config_file_name, "test_testing_data_topology_%s.conf", |
1149 | topology_string); | 1162 | topology_string); |
1150 | int ret; | 1163 | int ret; |
1164 | |||
1151 | char *const argv[] = { binary_name, | 1165 | char *const argv[] = { binary_name, |
1152 | "-c", | 1166 | "-c", |
1153 | config_file_name, | 1167 | config_file_name, |
@@ -1162,11 +1176,11 @@ check () | |||
1162 | ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 1176 | ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
1163 | argv, binary_name, "nohelp", options, &run, &ok); | 1177 | argv, binary_name, "nohelp", options, &run, &ok); |
1164 | if (ret != GNUNET_OK) | 1178 | if (ret != GNUNET_OK) |
1165 | { | 1179 | { |
1166 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1180 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1167 | "`test-testing-topology-%s': Failed with error code %d\n", | 1181 | "`test-testing-topology-%s': Failed with error code %d\n", |
1168 | topology_string, ret); | 1182 | topology_string, ret); |
1169 | } | 1183 | } |
1170 | GNUNET_free (binary_name); | 1184 | GNUNET_free (binary_name); |
1171 | GNUNET_free (config_file_name); | 1185 | GNUNET_free (config_file_name); |
1172 | return ok; | 1186 | return ok; |
@@ -1206,10 +1220,10 @@ main (int argc, char *argv[]) | |||
1206 | * of by the testing framework. | 1220 | * of by the testing framework. |
1207 | */ | 1221 | */ |
1208 | if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK) | 1222 | if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK) |
1209 | { | 1223 | { |
1210 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1224 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1211 | "Failed to remove testing directory %s\n", test_directory); | 1225 | "Failed to remove testing directory %s\n", test_directory); |
1212 | } | 1226 | } |
1213 | GNUNET_free (our_binary_name); | 1227 | GNUNET_free (our_binary_name); |
1214 | return ret; | 1228 | return ret; |
1215 | } | 1229 | } |