aboutsummaryrefslogtreecommitdiff
path: root/src/testing/test_testing_topology.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/test_testing_topology.c')
-rw-r--r--src/testing/test_testing_topology.c853
1 files changed, 431 insertions, 422 deletions
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index 7360ab943..73b49e469 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -107,7 +107,7 @@ static enum GNUNET_TESTING_Topology blacklist_topology = GNUNET_TESTING_TOPOLOGY
107static enum GNUNET_TESTING_Topology connection_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* NONE actually means connect all allowed peers */ 107static enum GNUNET_TESTING_Topology connection_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* NONE actually means connect all allowed peers */
108 108
109static enum GNUNET_TESTING_TopologyOption connect_topology_option = 109static enum GNUNET_TESTING_TopologyOption connect_topology_option =
110 GNUNET_TESTING_TOPOLOGY_OPTION_ALL; 110 GNUNET_TESTING_TOPOLOGY_OPTION_ALL;
111 111
112static double connect_topology_option_modifier = 0.0; 112static double connect_topology_option_modifier = 0.0;
113 113
@@ -168,20 +168,19 @@ void
168shutdown_callback (void *cls, const char *emsg) 168shutdown_callback (void *cls, const char *emsg)
169{ 169{
170 if (emsg != NULL) 170 if (emsg != NULL)
171 { 171 {
172#if VERBOSE 172#if VERBOSE
173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n"); 173 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutdown of peers failed!\n");
174#endif 174#endif
175 if (ok == 0) 175 if (ok == 0)
176 ok = 666; 176 ok = 666;
177 } 177 }
178 else 178 else
179 { 179 {
180#if VERBOSE 180#if VERBOSE
181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers successfully shut down!\n");
182 "All peers successfully shut down!\n");
183#endif 182#endif
184 } 183 }
185} 184}
186 185
187#if DELAY_FOR_LOGGING 186#if DELAY_FOR_LOGGING
@@ -191,6 +190,7 @@ gather_log_data ()
191 char *peer_number; 190 char *peer_number;
192 char *connect_number; 191 char *connect_number;
193 struct GNUNET_OS_Process *mem_process; 192 struct GNUNET_OS_Process *mem_process;
193
194 GNUNET_asprintf (&peer_number, "%llu", num_peers); 194 GNUNET_asprintf (&peer_number, "%llu", num_peers);
195 GNUNET_asprintf (&connect_number, "%llu", expected_connections); 195 GNUNET_asprintf (&connect_number, "%llu", expected_connections);
196 mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", 196 mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl",
@@ -209,6 +209,7 @@ finish_testing ()
209 GNUNET_assert (pg != NULL); 209 GNUNET_assert (pg != NULL);
210 struct TestMessageContext *pos; 210 struct TestMessageContext *pos;
211 struct TestMessageContext *free_pos; 211 struct TestMessageContext *free_pos;
212
212#if VERBOSE 213#if VERBOSE
213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
214 "Called finish testing, stopping daemons.\n"); 215 "Called finish testing, stopping daemons.\n");
@@ -216,25 +217,25 @@ finish_testing ()
216 217
217 pos = test_messages; 218 pos = test_messages;
218 while (pos != NULL) 219 while (pos != NULL)
220 {
221 if (pos->peer1handle != NULL)
219 { 222 {
220 if (pos->peer1handle != NULL) 223 GNUNET_CORE_disconnect (pos->peer1handle);
221 { 224 pos->peer1handle = NULL;
222 GNUNET_CORE_disconnect (pos->peer1handle);
223 pos->peer1handle = NULL;
224 }
225 if (pos->peer2handle != NULL)
226 {
227 GNUNET_CORE_disconnect (pos->peer2handle);
228 pos->peer2handle = NULL;
229 }
230 free_pos = pos;
231 pos = pos->next;
232 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
233 {
234 GNUNET_SCHEDULER_cancel (free_pos->disconnect_task);
235 }
236 GNUNET_free (free_pos);
237 } 225 }
226 if (pos->peer2handle != NULL)
227 {
228 GNUNET_CORE_disconnect (pos->peer2handle);
229 pos->peer2handle = NULL;
230 }
231 free_pos = pos;
232 pos = pos->next;
233 if (free_pos->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
234 {
235 GNUNET_SCHEDULER_cancel (free_pos->disconnect_task);
236 }
237 GNUNET_free (free_pos);
238 }
238#if VERBOSE 239#if VERBOSE
239 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 240 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
240 "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n", 241 "Transmit_ready's scheduled %d, failed %d, transmit_ready's called %d\n",
@@ -248,10 +249,10 @@ finish_testing ()
248 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 249 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
249 250
250 if (dotOutFile != NULL) 251 if (dotOutFile != NULL)
251 { 252 {
252 fprintf (dotOutFile, "}"); 253 fprintf (dotOutFile, "}");
253 fclose (dotOutFile); 254 fclose (dotOutFile);
254 } 255 }
255 256
256 ok = 0; 257 ok = 0;
257} 258}
@@ -321,31 +322,31 @@ topology_cb (void *cls,
321 const struct GNUNET_PeerIdentity *second, const char *emsg) 322 const struct GNUNET_PeerIdentity *second, const char *emsg)
322{ 323{
323 FILE *outfile = cls; 324 FILE *outfile = cls;
325
324 if (first != NULL) 326 if (first != NULL)
327 {
328 if (outfile != NULL)
325 { 329 {
326 if (outfile != NULL) 330 fprintf (outfile, "\t\"%s\" -- ", GNUNET_i2s (first));
327 { 331 fprintf (outfile, "\"%s\";\n", GNUNET_i2s (second));
328 fprintf (outfile, "\t\"%s\" -- ", GNUNET_i2s (first));
329 fprintf (outfile, "\"%s\";\n", GNUNET_i2s (second));
330 }
331 topology_connections++;
332 } 332 }
333 topology_connections++;
334 }
333 else 335 else
336 {
337 fprintf (stderr,
338 "Finished iterating over topology, %d total connections!\n",
339 topology_connections);
340 if (outfile != NULL)
334 { 341 {
335 fprintf (stderr, 342 fprintf (outfile, "}\n");
336 "Finished iterating over topology, %d total connections!\n", 343 fclose (outfile);
337 topology_connections);
338 if (outfile != NULL)
339 {
340 fprintf (outfile, "}\n");
341 fclose (outfile);
342#if DO_STATS 344#if DO_STATS
343 GNUNET_TESTING_get_statistics (pg, &stats_finished, &stats_print, 345 GNUNET_TESTING_get_statistics (pg, &stats_finished, &stats_print, NULL);
344 NULL);
345#endif 346#endif
346 GNUNET_SCHEDULER_add_now (&finish_testing, NULL); 347 GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
347 }
348 } 348 }
349 }
349} 350}
350 351
351static int 352static int
@@ -358,24 +359,25 @@ process_mtype (void *cls,
358 FILE *dotOutFileFinished; 359 FILE *dotOutFileFinished;
359 struct TestMessageContext *pos = cls; 360 struct TestMessageContext *pos = cls;
360 struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *) message; 361 struct GNUNET_TestMessage *msg = (struct GNUNET_TestMessage *) message;
362
361 if (pos->uid != ntohl (msg->uid)) 363 if (pos->uid != ntohl (msg->uid))
362 return GNUNET_OK; 364 return GNUNET_OK;
363 365
364#if PROGRESS_BARS 366#if PROGRESS_BARS
365 if ((total_messages_received) % modnum == 0) 367 if ((total_messages_received) % modnum == 0)
366 { 368 {
367 if (total_messages_received == 0) 369 if (total_messages_received == 0)
368 fprintf (stdout, "0%%"); 370 fprintf (stdout, "0%%");
369 else 371 else
370 fprintf (stdout, "%d%%", 372 fprintf (stdout, "%d%%",
371 (int) (((float) total_messages_received / 373 (int) (((float) total_messages_received /
372 expected_messages) * 100)); 374 expected_messages) * 100));
373 375
374 } 376 }
375 else if (total_messages_received % dotnum == 0) 377 else if (total_messages_received % dotnum == 0)
376 { 378 {
377 fprintf (stdout, "."); 379 fprintf (stdout, ".");
378 } 380 }
379 fflush (stdout); 381 fflush (stdout);
380#endif 382#endif
381 383
@@ -391,27 +393,26 @@ process_mtype (void *cls,
391#endif 393#endif
392 394
393 if (total_messages_received == expected_messages) 395 if (total_messages_received == expected_messages)
394 { 396 {
395#if PROGRESS_BARS 397#if PROGRESS_BARS
396 fprintf (stdout, "100%%]\n"); 398 fprintf (stdout, "100%%]\n");
397#endif 399#endif
398 GNUNET_SCHEDULER_cancel (die_task); 400 GNUNET_SCHEDULER_cancel (die_task);
399 GNUNET_asprintf (&dotOutFileNameFinished, "%s.dot", "final_topology"); 401 GNUNET_asprintf (&dotOutFileNameFinished, "%s.dot", "final_topology");
400 dotOutFileFinished = fopen (dotOutFileNameFinished, "w"); 402 dotOutFileFinished = fopen (dotOutFileNameFinished, "w");
401 GNUNET_free (dotOutFileNameFinished); 403 GNUNET_free (dotOutFileNameFinished);
402 if (dotOutFileFinished != NULL) 404 if (dotOutFileFinished != NULL)
403 {
404 fprintf (dotOutFileFinished, "strict graph G {\n");
405 }
406 topology_connections = 0;
407 GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished);
408 //GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
409 }
410 else
411 { 405 {
412 pos->disconnect_task = 406 fprintf (dotOutFileFinished, "strict graph G {\n");
413 GNUNET_SCHEDULER_add_now (&disconnect_cores, pos);
414 } 407 }
408 topology_connections = 0;
409 GNUNET_TESTING_get_topology (pg, &topology_cb, dotOutFileFinished);
410 //GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
411 }
412 else
413 {
414 pos->disconnect_task = GNUNET_SCHEDULER_add_now (&disconnect_cores, pos);
415 }
415 416
416 return GNUNET_OK; 417 return GNUNET_OK;
417} 418}
@@ -420,6 +421,7 @@ static void
420end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 421end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
421{ 422{
422 char *msg = cls; 423 char *msg = cls;
424
423 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 425 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
424 "End badly was called (%s)... stopping daemons.\n", msg); 426 "End badly was called (%s)... stopping daemons.\n", msg);
425 struct TestMessageContext *pos; 427 struct TestMessageContext *pos;
@@ -427,21 +429,21 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
427 429
428 pos = test_messages; 430 pos = test_messages;
429 while (pos != NULL) 431 while (pos != NULL)
432 {
433 if (pos->peer1handle != NULL)
430 { 434 {
431 if (pos->peer1handle != NULL) 435 GNUNET_CORE_disconnect (pos->peer1handle);
432 { 436 pos->peer1handle = NULL;
433 GNUNET_CORE_disconnect (pos->peer1handle);
434 pos->peer1handle = NULL;
435 }
436 if (pos->peer2handle != NULL)
437 {
438 GNUNET_CORE_disconnect (pos->peer2handle);
439 pos->peer2handle = NULL;
440 }
441 free_pos = pos;
442 pos = pos->next;
443 GNUNET_free (free_pos);
444 } 437 }
438 if (pos->peer2handle != NULL)
439 {
440 GNUNET_CORE_disconnect (pos->peer2handle);
441 pos->peer2handle = NULL;
442 }
443 free_pos = pos;
444 pos = pos->next;
445 GNUNET_free (free_pos);
446 }
445 447
446#if VERBOSE 448#if VERBOSE
447 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 449 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -454,18 +456,18 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
454#endif 456#endif
455 457
456 if (pg != NULL) 458 if (pg != NULL)
457 { 459 {
458 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 460 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
459 ok = 7331; /* Opposite of leet */ 461 ok = 7331; /* Opposite of leet */
460 } 462 }
461 else 463 else
462 ok = 401; /* Never got peers started */ 464 ok = 401; /* Never got peers started */
463 465
464 if (dotOutFile != NULL) 466 if (dotOutFile != NULL)
465 { 467 {
466 fprintf (dotOutFile, "}"); 468 fprintf (dotOutFile, "}");
467 fclose (dotOutFile); 469 fclose (dotOutFile);
468 } 470 }
469} 471}
470 472
471static size_t 473static size_t
@@ -512,31 +514,32 @@ init_notify_peer2 (void *cls,
512 514
513 pos->peer2connected = GNUNET_YES; 515 pos->peer2connected = GNUNET_YES;
514 if (pos->peer1notified == GNUNET_YES) /* Peer 1 has been notified of connection to peer 2 */ 516 if (pos->peer1notified == GNUNET_YES) /* Peer 1 has been notified of connection to peer 2 */
515 { 517 {
516#if VERBOSE > 1 518#if VERBOSE > 1
517 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 519 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
518 "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", 520 "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n",
519 GNUNET_i2s (my_identity), GNUNET_h2s(&pos->peer1->id.hashPubKey)); 521 GNUNET_i2s (my_identity),
522 GNUNET_h2s (&pos->peer1->id.hashPubKey));
520#endif 523#endif
521 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 524 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle,
522 GNUNET_YES, 525 GNUNET_YES,
523 0, 526 0,
524 TIMEOUT, 527 TIMEOUT,
525 &pos->peer2->id, 528 &pos->peer2->id,
526 sizeof (struct 529 sizeof (struct
527 GNUNET_TestMessage), 530 GNUNET_TestMessage),
528 &transmit_ready, pos)) 531 &transmit_ready, pos))
529 { 532 {
530 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 533 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
531 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", 534 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
532 GNUNET_i2s (&pos->peer2->id)); 535 GNUNET_i2s (&pos->peer2->id));
533 transmit_ready_failed++; 536 transmit_ready_failed++;
534 } 537 }
535 else 538 else
536 { 539 {
537 transmit_ready_scheduled++; 540 transmit_ready_scheduled++;
538 }
539 } 541 }
542 }
540} 543}
541 544
542/** 545/**
@@ -546,51 +549,53 @@ init_notify_peer2 (void *cls,
546 * @param peer peer identity this notification is about 549 * @param peer peer identity this notification is about
547 * @param atsi performance data for the connection 550 * @param atsi performance data for the connection
548 */ 551 */
549static void connect_notify_peers (void *cls, 552static void
550 const struct 553connect_notify_peers (void *cls,
551 GNUNET_PeerIdentity *peer, 554 const struct
552 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 555 GNUNET_PeerIdentity *peer,
556 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
553{ 557{
554 struct TestMessageContext *pos = cls; 558 struct TestMessageContext *pos = cls;
555 559
556 if (0 == memcmp(peer, &pos->peer2->id, sizeof(struct GNUNET_PeerIdentity))) 560 if (0 == memcmp (peer, &pos->peer2->id, sizeof (struct GNUNET_PeerIdentity)))
557 { 561 {
558 pos->peer1notified = GNUNET_YES; 562 pos->peer1notified = GNUNET_YES;
559#if VERBOSE > 1 563#if VERBOSE > 1
560 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 564 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
561 "Peer `%s' notified of connection to peer `%s'\n", 565 "Peer `%s' notified of connection to peer `%s'\n",
562 GNUNET_i2s (&pos->peer1->id), GNUNET_h2s(&peer->hashPubKey)); 566 GNUNET_i2s (&pos->peer1->id), GNUNET_h2s (&peer->hashPubKey));
563#endif 567#endif
564 } 568 }
565 else 569 else
566 return; 570 return;
567 571
568 if (pos->peer2connected == GNUNET_YES) /* Already connected and notified of connection, send message! */ 572 if (pos->peer2connected == GNUNET_YES) /* Already connected and notified of connection, send message! */
569 { 573 {
570#if VERBOSE > 1 574#if VERBOSE > 1
571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 575 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
572 "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n", 576 "Scheduling message send to peer `%s' from peer `%s' (init_notify_peer2)\n",
573 GNUNET_i2s (&pos->peer2->id), GNUNET_h2s(&pos->peer1->id.hashPubKey)); 577 GNUNET_i2s (&pos->peer2->id),
578 GNUNET_h2s (&pos->peer1->id.hashPubKey));
574#endif 579#endif
575 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, 580 if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle,
576 GNUNET_YES, 581 GNUNET_YES,
577 0, 582 0,
578 TIMEOUT, 583 TIMEOUT,
579 &pos->peer2->id, 584 &pos->peer2->id,
580 sizeof (struct 585 sizeof (struct
581 GNUNET_TestMessage), 586 GNUNET_TestMessage),
582 &transmit_ready, pos)) 587 &transmit_ready, pos))
583 { 588 {
584 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 589 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
585 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n", 590 "RECEIVED NULL when asking core (1) for transmission to peer `%4s'\n",
586 GNUNET_i2s (&pos->peer2->id)); 591 GNUNET_i2s (&pos->peer2->id));
587 transmit_ready_failed++; 592 transmit_ready_failed++;
588 } 593 }
589 else 594 else
590 { 595 {
591 transmit_ready_scheduled++; 596 transmit_ready_scheduled++;
592 }
593 } 597 }
598 }
594} 599}
595 600
596static void 601static void
@@ -601,6 +606,7 @@ init_notify_peer1 (void *cls,
601 *publicKey) 606 *publicKey)
602{ 607{
603 struct TestMessageContext *pos = cls; 608 struct TestMessageContext *pos = cls;
609
604 total_server_connections++; 610 total_server_connections++;
605 611
606#if VERBOSE > 1 612#if VERBOSE > 1
@@ -631,27 +637,27 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
631 struct TestMessageContext *pos = cls; 637 struct TestMessageContext *pos = cls;
632 638
633 if ((pos == test_messages) && (settle_time.rel_value > 0)) 639 if ((pos == test_messages) && (settle_time.rel_value > 0))
634 { 640 {
635 topology_connections = 0; 641 topology_connections = 0;
636 GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); 642 GNUNET_TESTING_get_topology (pg, &topology_cb, NULL);
637 } 643 }
638 if (( (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)|| (cls == NULL)) 644 if (((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) || (cls == NULL))
639 return; 645 return;
640 646
641 if (die_task == GNUNET_SCHEDULER_NO_TASK) 647 if (die_task == GNUNET_SCHEDULER_NO_TASK)
642 { 648 {
643 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, 649 die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT,
644 &end_badly, 650 &end_badly,
645 "from send test messages (timeout)"); 651 "from send test messages (timeout)");
646 } 652 }
647 653
648 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) 654 if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS)
649 { 655 {
650 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 656 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
651 (GNUNET_TIME_UNIT_SECONDS, 1), 657 (GNUNET_TIME_UNIT_SECONDS, 1),
652 &send_test_messages, pos); 658 &send_test_messages, pos);
653 return; /* Otherwise we'll double schedule messages here! */ 659 return; /* Otherwise we'll double schedule messages here! */
654 } 660 }
655 661
656 /* 662 /*
657 * Connect to the sending peer 663 * Connect to the sending peer
@@ -669,15 +675,15 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
669 GNUNET_assert (pos->peer1handle != NULL); 675 GNUNET_assert (pos->peer1handle != NULL);
670 676
671 if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS) 677 if (total_server_connections < MAX_OUTSTANDING_CONNECTIONS)
672 { 678 {
673 GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next); 679 GNUNET_SCHEDULER_add_now (&send_test_messages, pos->next);
674 } 680 }
675 else 681 else
676 { 682 {
677 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 683 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
678 (GNUNET_TIME_UNIT_SECONDS, 1), 684 (GNUNET_TIME_UNIT_SECONDS, 1),
679 &send_test_messages, pos->next); 685 &send_test_messages, pos->next);
680 } 686 }
681} 687}
682 688
683 689
@@ -693,117 +699,118 @@ topology_callback (void *cls,
693 const char *emsg) 699 const char *emsg)
694{ 700{
695 struct TestMessageContext *temp_context; 701 struct TestMessageContext *temp_context;
702
696 if (emsg == NULL) 703 if (emsg == NULL)
697 { 704 {
698#if PROGRESS_BARS 705#if PROGRESS_BARS
699 if ((total_connections) % modnum == 0) 706 if ((total_connections) % modnum == 0)
700 { 707 {
701 if (total_connections == 0) 708 if (total_connections == 0)
702 fprintf (stdout, "0%%"); 709 fprintf (stdout, "0%%");
703 else 710 else
704 fprintf (stdout, "%d%%", 711 fprintf (stdout, "%d%%",
705 (int) (((float) total_connections / 712 (int) (((float) total_connections /
706 expected_connections) * 100)); 713 expected_connections) * 100));
707 714
708 } 715 }
709 else if (total_connections % dotnum == 0) 716 else if (total_connections % dotnum == 0)
710 { 717 {
711 fprintf (stdout, "."); 718 fprintf (stdout, ".");
712 } 719 }
713 fflush (stdout); 720 fflush (stdout);
714#endif 721#endif
715 total_connections++; 722 total_connections++;
716#if VERBOSE > 1 723#if VERBOSE > 1
717 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "connected peer %s to peer %s\n", 724 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "connected peer %s to peer %s\n",
718 first_daemon->shortname, second_daemon->shortname); 725 first_daemon->shortname, second_daemon->shortname);
719#endif 726#endif
720 temp_context = GNUNET_malloc (sizeof (struct TestMessageContext)); 727 temp_context = GNUNET_malloc (sizeof (struct TestMessageContext));
721 temp_context->peer1 = first_daemon; 728 temp_context->peer1 = first_daemon;
722 temp_context->peer2 = second_daemon; 729 temp_context->peer2 = second_daemon;
723 temp_context->next = test_messages; 730 temp_context->next = test_messages;
724 temp_context->uid = total_connections; 731 temp_context->uid = total_connections;
725 temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK; 732 temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
726 test_messages = temp_context; 733 test_messages = temp_context;
727 734
728 expected_messages++; 735 expected_messages++;
729 if (dotOutFile != NULL) 736 if (dotOutFile != NULL)
730 fprintf (dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname, 737 fprintf (dotOutFile, "\tn%s -- n%s;\n", first_daemon->shortname,
731 second_daemon->shortname); 738 second_daemon->shortname);
732 } 739 }
733#if VERBOSE 740#if VERBOSE
734 else 741 else
735 { 742 {
736 failed_connections++; 743 failed_connections++;
737 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 744 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
738 "Failed to connect peer %s to peer %s with error :\n%s\n", 745 "Failed to connect peer %s to peer %s with error :\n%s\n",
739 first_daemon->shortname, second_daemon->shortname, emsg); 746 first_daemon->shortname, second_daemon->shortname, emsg);
740 } 747 }
741#endif 748#endif
742 749
743 if (total_connections == expected_connections) 750 if (total_connections == expected_connections)
744 { 751 {
745#if PROGRESS_BARS 752#if PROGRESS_BARS
746 fprintf (stdout, "100%%]\n"); 753 fprintf (stdout, "100%%]\n");
747#endif 754#endif
748#if VERBOSE 755#if VERBOSE
749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 756 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
750 "Created %d total connections, which is our target number! Calling send messages.\n", 757 "Created %d total connections, which is our target number! Calling send messages.\n",
751 total_connections); 758 total_connections);
752#endif 759#endif
753 modnum = expected_messages / 4; 760 modnum = expected_messages / 4;
754 dotnum = (expected_messages / 50) + 1; 761 dotnum = (expected_messages / 50) + 1;
755 if (modnum == 0) 762 if (modnum == 0)
756 modnum = 1; 763 modnum = 1;
757 if (dotnum == 0) 764 if (dotnum == 0)
758 dotnum = 1; 765 dotnum = 1;
759 GNUNET_SCHEDULER_cancel (die_task); 766 GNUNET_SCHEDULER_cancel (die_task);
760 die_task = GNUNET_SCHEDULER_NO_TASK; 767 die_task = GNUNET_SCHEDULER_NO_TASK;
761#if DELAY_FOR_LOGGING 768#if DELAY_FOR_LOGGING
762 fprintf (stdout, "Sending test messages in 10 seconds.\n"); 769 fprintf (stdout, "Sending test messages in 10 seconds.\n");
763 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 770 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
764 (GNUNET_TIME_UNIT_SECONDS, 10), 771 (GNUNET_TIME_UNIT_SECONDS, 10),
765 &send_test_messages, test_messages); 772 &send_test_messages, test_messages);
766 gather_log_data (); 773 gather_log_data ();
767#else 774#else
768 if (settle_time.rel_value > 0) 775 if (settle_time.rel_value > 0)
769 { 776 {
770 GNUNET_TESTING_get_topology (pg, &topology_cb, NULL); 777 GNUNET_TESTING_get_topology (pg, &topology_cb, NULL);
771 } 778 }
772 GNUNET_SCHEDULER_add_delayed (settle_time, &send_test_messages, 779 GNUNET_SCHEDULER_add_delayed (settle_time, &send_test_messages,
773 test_messages); 780 test_messages);
774#endif 781#endif
775#if PROGRESS_BARS 782#if PROGRESS_BARS
776 fprintf (stdout, "Test message progress: ["); 783 fprintf (stdout, "Test message progress: [");
777#endif 784#endif
778 785
779 } 786 }
780 else if (total_connections + failed_connections == expected_connections) 787 else if (total_connections + failed_connections == expected_connections)
788 {
789 if (failed_connections <
790 (unsigned int) (fail_percentage * total_connections))
781 { 791 {
782 if (failed_connections < 792 GNUNET_SCHEDULER_cancel (die_task);
783 (unsigned int) (fail_percentage * total_connections)) 793 die_task = GNUNET_SCHEDULER_NO_TASK;
784 { 794 GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages);
785 GNUNET_SCHEDULER_cancel (die_task);
786 die_task = GNUNET_SCHEDULER_NO_TASK;
787 GNUNET_SCHEDULER_add_now (&send_test_messages, test_messages);
788 }
789 else
790 {
791 GNUNET_SCHEDULER_cancel (die_task);
792 die_task =
793 GNUNET_SCHEDULER_add_now (&end_badly,
794 "from topology_callback (too many failed connections)");
795 }
796 } 795 }
797 else 796 else
798 { 797 {
798 GNUNET_SCHEDULER_cancel (die_task);
799 die_task =
800 GNUNET_SCHEDULER_add_now (&end_badly,
801 "from topology_callback (too many failed connections)");
802 }
803 }
804 else
805 {
799#if VERBOSE > 1 806#if VERBOSE > 1
800 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 807 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
801 "Have %d total connections, %d failed connections, Want %d (at least %d)\n", 808 "Have %d total connections, %d failed connections, Want %d (at least %d)\n",
802 total_connections, failed_connections, expected_connections, 809 total_connections, failed_connections, expected_connections,
803 expected_connections - 810 expected_connections -
804 (unsigned int) (fail_percentage * expected_connections)); 811 (unsigned int) (fail_percentage * expected_connections));
805#endif 812#endif
806 } 813 }
807} 814}
808 815
809static void 816static void
@@ -821,8 +828,8 @@ connect_topology ()
821{ 828{
822 expected_connections = -1; 829 expected_connections = -1;
823 if ((pg != NULL) && (peers_left == 0)) 830 if ((pg != NULL) && (peers_left == 0))
824 { 831 {
825 expected_connections = 832 expected_connections =
826 GNUNET_TESTING_connect_topology (pg, connection_topology, 833 GNUNET_TESTING_connect_topology (pg, connection_topology,
827 connect_topology_option, 834 connect_topology_option,
828 connect_topology_option_modifier, 835 connect_topology_option_modifier,
@@ -830,19 +837,19 @@ connect_topology ()
830 connect_attempts, 837 connect_attempts,
831 &topology_creation_finished, NULL); 838 &topology_creation_finished, NULL);
832#if PROGRESS_BARS 839#if PROGRESS_BARS
833 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 840 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
834 "Have %d expected connections\n", expected_connections); 841 "Have %d expected connections\n", expected_connections);
835#endif 842#endif
836 } 843 }
837 844
838 GNUNET_SCHEDULER_cancel (die_task); 845 GNUNET_SCHEDULER_cancel (die_task);
839 if (expected_connections < 1) 846 if (expected_connections < 1)
840 { 847 {
841 die_task = 848 die_task =
842 GNUNET_SCHEDULER_add_now (&end_badly, 849 GNUNET_SCHEDULER_add_now (&end_badly,
843 "from connect topology (bad return)"); 850 "from connect topology (bad return)");
844 return; 851 return;
845 } 852 }
846 853
847 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 854 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
848 (GNUNET_TIME_UNIT_SECONDS, 855 (GNUNET_TIME_UNIT_SECONDS,
@@ -865,23 +872,22 @@ create_topology ()
865{ 872{
866 peers_left = num_peers; /* Reset counter */ 873 peers_left = num_peers; /* Reset counter */
867 if (GNUNET_TESTING_create_topology 874 if (GNUNET_TESTING_create_topology
868 (pg, topology, blacklist_topology, 875 (pg, topology, blacklist_topology, blacklist_transports) != GNUNET_SYSERR)
869 blacklist_transports) != GNUNET_SYSERR) 876 {
870 {
871#if PROGRESS_BARS 877#if PROGRESS_BARS
872 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 878 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
873 "Topology set up, now starting peers!\n"); 879 "Topology set up, now starting peers!\n");
874 fprintf (stdout, "Daemon start progress ["); 880 fprintf (stdout, "Daemon start progress [");
875#endif 881#endif
876 GNUNET_TESTING_daemons_continue_startup (pg); 882 GNUNET_TESTING_daemons_continue_startup (pg);
877 } 883 }
878 else 884 else
879 { 885 {
880 GNUNET_SCHEDULER_cancel (die_task); 886 GNUNET_SCHEDULER_cancel (die_task);
881 die_task = 887 die_task =
882 GNUNET_SCHEDULER_add_now (&end_badly, 888 GNUNET_SCHEDULER_add_now (&end_badly,
883 "from create topology (bad return)"); 889 "from create topology (bad return)");
884 } 890 }
885 GNUNET_SCHEDULER_cancel (die_task); 891 GNUNET_SCHEDULER_cancel (die_task);
886 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 892 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
887 (GNUNET_TIME_UNIT_SECONDS, 893 (GNUNET_TIME_UNIT_SECONDS,
@@ -898,11 +904,11 @@ peers_started_callback (void *cls,
898 struct GNUNET_TESTING_Daemon *d, const char *emsg) 904 struct GNUNET_TESTING_Daemon *d, const char *emsg)
899{ 905{
900 if (emsg != NULL) 906 if (emsg != NULL)
901 { 907 {
902 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 908 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
903 "Failed to start daemon with error: `%s'\n", emsg); 909 "Failed to start daemon with error: `%s'\n", emsg);
904 return; 910 return;
905 } 911 }
906 GNUNET_assert (id != NULL); 912 GNUNET_assert (id != NULL);
907#if VERBOSE > 1 913#if VERBOSE > 1
908 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n", 914 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started daemon %llu out of %llu\n",
@@ -910,50 +916,48 @@ peers_started_callback (void *cls,
910#endif 916#endif
911#if PROGRESS_BARS 917#if PROGRESS_BARS
912 if ((num_peers - peers_left) % modnum == 0) 918 if ((num_peers - peers_left) % modnum == 0)
913 { 919 {
914 if (num_peers - peers_left == 0) 920 if (num_peers - peers_left == 0)
915 fprintf (stdout, "0%%"); 921 fprintf (stdout, "0%%");
916 else 922 else
917 fprintf (stdout, "%d%%", 923 fprintf (stdout, "%d%%",
918 (int) (((float) (num_peers - peers_left) / 924 (int) (((float) (num_peers - peers_left) / num_peers) * 100));
919 num_peers) * 100)); 925
920 926 }
921 }
922 else if ((num_peers - peers_left) % dotnum == 0) 927 else if ((num_peers - peers_left) % dotnum == 0)
923 { 928 {
924 fprintf (stdout, "."); 929 fprintf (stdout, ".");
925 } 930 }
926 fflush (stdout); 931 fflush (stdout);
927#endif 932#endif
928 peers_left--; 933 peers_left--;
929 if (peers_left == 0) 934 if (peers_left == 0)
930 { 935 {
931#if PROGRESS_BARS 936#if PROGRESS_BARS
932 fprintf (stdout, "100%%]\n"); 937 fprintf (stdout, "100%%]\n");
933#endif 938#endif
934#if VERBOSE 939#if VERBOSE
935 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 940 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
936 "All %d daemons started, now connecting peers!\n", 941 "All %d daemons started, now connecting peers!\n", num_peers);
937 num_peers);
938#endif 942#endif
939 GNUNET_SCHEDULER_cancel (die_task); 943 GNUNET_SCHEDULER_cancel (die_task);
940 /* Set up task in case topology creation doesn't finish 944 /* Set up task in case topology creation doesn't finish
941 * within a reasonable amount of time */ 945 * within a reasonable amount of time */
942 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 946 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
943 (GNUNET_TIME_UNIT_MINUTES, 8), 947 (GNUNET_TIME_UNIT_MINUTES, 8),
944 &end_badly, 948 &end_badly,
945 "from peers_started_callback"); 949 "from peers_started_callback");
946#if DELAY_FOR_LOGGING 950#if DELAY_FOR_LOGGING
947 fprintf (stdout, "Connecting topology in 10 seconds\n"); 951 fprintf (stdout, "Connecting topology in 10 seconds\n");
948 gather_log_data (); 952 gather_log_data ();
949 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 953 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
950 (GNUNET_TIME_UNIT_SECONDS, 10), 954 (GNUNET_TIME_UNIT_SECONDS, 10),
951 &connect_topology, NULL); 955 &connect_topology, NULL);
952#else 956#else
953 connect_topology (); 957 connect_topology ();
954#endif 958#endif
955 ok = 0; 959 ok = 0;
956 } 960 }
957} 961}
958 962
959/** 963/**
@@ -970,10 +974,10 @@ hostkey_callback (void *cls,
970 struct GNUNET_TESTING_Daemon *d, const char *emsg) 974 struct GNUNET_TESTING_Daemon *d, const char *emsg)
971{ 975{
972 if (emsg != NULL) 976 if (emsg != NULL)
973 { 977 {
974 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 978 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
975 "Hostkey callback received error: %s\n", emsg); 979 "Hostkey callback received error: %s\n", emsg);
976 } 980 }
977 981
978#if VERBOSE > 1 982#if VERBOSE > 1
979 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 983 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -983,39 +987,37 @@ hostkey_callback (void *cls,
983 987
984#if PROGRESS_BARS 988#if PROGRESS_BARS
985 if ((num_peers - peers_left) % modnum == 0) 989 if ((num_peers - peers_left) % modnum == 0)
986 { 990 {
987 if (num_peers - peers_left == 0) 991 if (num_peers - peers_left == 0)
988 fprintf (stdout, "0%%"); 992 fprintf (stdout, "0%%");
989 else 993 else
990 fprintf (stdout, "%d%%", 994 fprintf (stdout, "%d%%",
991 (int) (((float) (num_peers - peers_left) / 995 (int) (((float) (num_peers - peers_left) / num_peers) * 100));
992 num_peers) * 100)); 996
993 997 }
994 }
995 else if ((num_peers - peers_left) % dotnum == 0) 998 else if ((num_peers - peers_left) % dotnum == 0)
996 { 999 {
997 fprintf (stdout, "."); 1000 fprintf (stdout, ".");
998 } 1001 }
999 fflush (stdout); 1002 fflush (stdout);
1000#endif 1003#endif
1001 peers_left--; 1004 peers_left--;
1002 if (peers_left == 0) 1005 if (peers_left == 0)
1003 { 1006 {
1004#if PROGRESS_BARS 1007#if PROGRESS_BARS
1005 fprintf (stdout, "100%%]\n"); 1008 fprintf (stdout, "100%%]\n");
1006 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1009 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1007 "All %d hostkeys created, now creating topology!\n", 1010 "All %d hostkeys created, now creating topology!\n", num_peers);
1008 num_peers);
1009#endif 1011#endif
1010 GNUNET_SCHEDULER_cancel (die_task); 1012 GNUNET_SCHEDULER_cancel (die_task);
1011 /* Set up task in case topology creation doesn't finish 1013 /* Set up task in case topology creation doesn't finish
1012 * within a reasonable amount of time */ 1014 * within a reasonable amount of time */
1013 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 1015 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
1014 &end_badly, 1016 &end_badly,
1015 "from create_topology"); 1017 "from create_topology");
1016 GNUNET_SCHEDULER_add_now (&create_topology, NULL); 1018 GNUNET_SCHEDULER_add_now (&create_topology, NULL);
1017 ok = 0; 1019 ok = 0;
1018 } 1020 }
1019} 1021}
1020 1022
1021static void 1023static void
@@ -1030,13 +1032,14 @@ run (void *cls,
1030 char *connect_topology_option_modifier_string; 1032 char *connect_topology_option_modifier_string;
1031 unsigned long long temp_settle; 1033 unsigned long long temp_settle;
1032 unsigned long long max_outstanding_connections; 1034 unsigned long long max_outstanding_connections;
1035
1033 ok = 1; 1036 ok = 1;
1034 1037
1035 dotOutFile = fopen (dotOutFileName, "w"); 1038 dotOutFile = fopen (dotOutFileName, "w");
1036 if (dotOutFile != NULL) 1039 if (dotOutFile != NULL)
1037 { 1040 {
1038 fprintf (dotOutFile, "strict graph G {\n"); 1041 fprintf (dotOutFile, "strict graph G {\n");
1039 } 1042 }
1040 1043
1041#if VERBOSE 1044#if VERBOSE
1042 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1045 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1046,21 +1049,21 @@ run (void *cls,
1046 if (GNUNET_YES != 1049 if (GNUNET_YES !=
1047 GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome", 1050 GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome",
1048 &test_directory)) 1051 &test_directory))
1049 { 1052 {
1050 ok = 404; 1053 ok = 404;
1051 return; 1054 return;
1052 } 1055 }
1053 1056
1054 if ((GNUNET_YES == 1057 if ((GNUNET_YES ==
1055 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology", 1058 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology",
1056 &topology_str)) 1059 &topology_str))
1057 && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) 1060 && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str)))
1058 { 1061 {
1059 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1062 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1060 "Invalid topology `%s' given for section %s option %s\n", 1063 "Invalid topology `%s' given for section %s option %s\n",
1061 topology_str, "TESTING", "TOPOLOGY"); 1064 topology_str, "TESTING", "TOPOLOGY");
1062 topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */ 1065 topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */
1063 } 1066 }
1064 1067
1065 if ((GNUNET_YES == 1068 if ((GNUNET_YES ==
1066 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 1069 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
@@ -1069,11 +1072,11 @@ run (void *cls,
1069 && (GNUNET_NO == 1072 && (GNUNET_NO ==
1070 GNUNET_TESTING_topology_get (&connection_topology, 1073 GNUNET_TESTING_topology_get (&connection_topology,
1071 connect_topology_str))) 1074 connect_topology_str)))
1072 { 1075 {
1073 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1076 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1074 "Invalid connect topology `%s' given for section %s option %s\n", 1077 "Invalid connect topology `%s' given for section %s option %s\n",
1075 connect_topology_str, "TESTING", "CONNECT_TOPOLOGY"); 1078 connect_topology_str, "TESTING", "CONNECT_TOPOLOGY");
1076 } 1079 }
1077 GNUNET_free_non_null (connect_topology_str); 1080 GNUNET_free_non_null (connect_topology_str);
1078 if ((GNUNET_YES == 1081 if ((GNUNET_YES ==
1079 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 1082 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
@@ -1082,31 +1085,31 @@ run (void *cls,
1082 && (GNUNET_NO == 1085 && (GNUNET_NO ==
1083 GNUNET_TESTING_topology_option_get (&connect_topology_option, 1086 GNUNET_TESTING_topology_option_get (&connect_topology_option,
1084 connect_topology_option_str))) 1087 connect_topology_option_str)))
1085 { 1088 {
1086 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1089 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1087 "Invalid connect topology option `%s' given for section %s option %s\n", 1090 "Invalid connect topology option `%s' given for section %s option %s\n",
1088 connect_topology_option_str, "TESTING", 1091 connect_topology_option_str, "TESTING",
1089 "CONNECT_TOPOLOGY_OPTION"); 1092 "CONNECT_TOPOLOGY_OPTION");
1090 connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */ 1093 connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */
1091 } 1094 }
1092 GNUNET_free_non_null (connect_topology_option_str); 1095 GNUNET_free_non_null (connect_topology_option_str);
1093 if (GNUNET_YES == 1096 if (GNUNET_YES ==
1094 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 1097 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
1095 "connect_topology_option_modifier", 1098 "connect_topology_option_modifier",
1096 &connect_topology_option_modifier_string)) 1099 &connect_topology_option_modifier_string))
1100 {
1101 if (sscanf
1102 (connect_topology_option_modifier_string, "%lf",
1103 &connect_topology_option_modifier) != 1)
1097 { 1104 {
1098 if (sscanf 1105 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1099 (connect_topology_option_modifier_string, "%lf", 1106 _
1100 &connect_topology_option_modifier) != 1) 1107 ("Invalid value `%s' for option `%s' in section `%s': expected float\n"),
1101 { 1108 connect_topology_option_modifier_string,
1102 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1109 "connect_topology_option_modifier", "TESTING");
1103 _
1104 ("Invalid value `%s' for option `%s' in section `%s': expected float\n"),
1105 connect_topology_option_modifier_string,
1106 "connect_topology_option_modifier", "TESTING");
1107 }
1108 GNUNET_free (connect_topology_option_modifier_string);
1109 } 1110 }
1111 GNUNET_free (connect_topology_option_modifier_string);
1112 }
1110 1113
1111 if (GNUNET_YES != 1114 if (GNUNET_YES !=
1112 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", 1115 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
@@ -1121,11 +1124,11 @@ run (void *cls,
1121 && (GNUNET_NO == 1124 && (GNUNET_NO ==
1122 GNUNET_TESTING_topology_get (&blacklist_topology, 1125 GNUNET_TESTING_topology_get (&blacklist_topology,
1123 blacklist_topology_str))) 1126 blacklist_topology_str)))
1124 { 1127 {
1125 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1128 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1126 "Invalid topology `%s' given for section %s option %s\n", 1129 "Invalid topology `%s' given for section %s option %s\n",
1127 topology_str, "TESTING", "BLACKLIST_TOPOLOGY"); 1130 topology_str, "TESTING", "BLACKLIST_TOPOLOGY");
1128 } 1131 }
1129 GNUNET_free_non_null (topology_str); 1132 GNUNET_free_non_null (topology_str);
1130 GNUNET_free_non_null (blacklist_topology_str); 1133 GNUNET_free_non_null (blacklist_topology_str);
1131 1134
@@ -1133,35 +1136,39 @@ run (void *cls,
1133 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "settle_time", 1136 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "settle_time",
1134 &temp_settle)) 1137 &temp_settle))
1135 settle_time = 1138 settle_time =
1136 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle); 1139 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
1137 1140
1138 if (GNUNET_OK == 1141 if (GNUNET_OK ==
1139 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout", 1142 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout",
1140 &temp_settle)) 1143 &temp_settle))
1141 connect_timeout = 1144 connect_timeout =
1142 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle); 1145 GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_settle);
1143 else 1146 else
1144 { 1147 {
1145 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_timeout"); 1148 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n",
1146 return; 1149 "testing", "connect_timeout");
1147 } 1150 return;
1151 }
1148 1152
1149 1153
1150 if (GNUNET_OK != 1154 if (GNUNET_OK !=
1151 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts", 1155 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts",
1152 &connect_attempts)) 1156 &connect_attempts))
1153 { 1157 {
1154 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "connect_attempts"); 1158 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n",
1155 return; 1159 "testing", "connect_attempts");
1156 } 1160 return;
1161 }
1157 1162
1158 if (GNUNET_OK != 1163 if (GNUNET_OK !=
1159 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "max_outstanding_connections", 1164 GNUNET_CONFIGURATION_get_value_number (cfg, "testing",
1160 &max_outstanding_connections)) 1165 "max_outstanding_connections",
1161 { 1166 &max_outstanding_connections))
1162 GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", "testing", "max_outstanding_connections"); 1167 {
1163 return; 1168 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n",
1164 } 1169 "testing", "max_outstanding_connections");
1170 return;
1171 }
1165 1172
1166 if (GNUNET_SYSERR == 1173 if (GNUNET_SYSERR ==
1167 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", 1174 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers",
@@ -1182,11 +1189,11 @@ run (void *cls,
1182#endif 1189#endif
1183 /* Set up a task to end testing if peer start fails */ 1190 /* Set up a task to end testing if peer start fails */
1184 die_task = 1191 die_task =
1185 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 1192 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
1186 (GNUNET_TIME_UNIT_SECONDS, 1193 (GNUNET_TIME_UNIT_SECONDS,
1187 SECONDS_PER_PEER_START * num_peers), 1194 SECONDS_PER_PEER_START * num_peers),
1188 &end_badly, 1195 &end_badly,
1189 "didn't generate all hostkeys within a reasonable amount of time!!!"); 1196 "didn't generate all hostkeys within a reasonable amount of time!!!");
1190 1197
1191 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1); 1198 GNUNET_assert (num_peers > 0 && num_peers < (unsigned int) -1);
1192 pg = GNUNET_TESTING_daemons_start (cfg, 1199 pg = GNUNET_TESTING_daemons_start (cfg,
@@ -1207,10 +1214,12 @@ check ()
1207{ 1214{
1208 char *binary_name; 1215 char *binary_name;
1209 char *config_file_name; 1216 char *config_file_name;
1217
1210 GNUNET_asprintf (&binary_name, "test-testing-topology-%s", topology_string); 1218 GNUNET_asprintf (&binary_name, "test-testing-topology-%s", topology_string);
1211 GNUNET_asprintf (&config_file_name, "test_testing_data_topology_%s.conf", 1219 GNUNET_asprintf (&config_file_name, "test_testing_data_topology_%s.conf",
1212 topology_string); 1220 topology_string);
1213 int ret; 1221 int ret;
1222
1214 char *const argv[] = { binary_name, 1223 char *const argv[] = { binary_name,
1215 "-c", 1224 "-c",
1216 config_file_name, 1225 config_file_name,
@@ -1225,11 +1234,11 @@ check ()
1225 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 1234 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
1226 argv, binary_name, "nohelp", options, &run, &ok); 1235 argv, binary_name, "nohelp", options, &run, &ok);
1227 if (ret != GNUNET_OK) 1236 if (ret != GNUNET_OK)
1228 { 1237 {
1229 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1238 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1230 "`test-testing-topology-%s': Failed with error code %d\n", 1239 "`test-testing-topology-%s': Failed with error code %d\n",
1231 topology_string, ret); 1240 topology_string, ret);
1232 } 1241 }
1233 GNUNET_free (binary_name); 1242 GNUNET_free (binary_name);
1234 GNUNET_free (config_file_name); 1243 GNUNET_free (config_file_name);
1235 return ok; 1244 return ok;
@@ -1273,10 +1282,10 @@ main (int argc, char *argv[])
1273 * of by the testing framework. 1282 * of by the testing framework.
1274 */ 1283 */
1275 if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK) 1284 if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK)
1276 { 1285 {
1277 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1286 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1278 "Failed to remove testing directory %s\n", test_directory); 1287 "Failed to remove testing directory %s\n", test_directory);
1279 } 1288 }
1280 GNUNET_free (our_binary_name); 1289 GNUNET_free (our_binary_name);
1281 return ret; 1290 return ret;
1282} 1291}