aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing.c13
-rw-r--r--src/testing/testing_group.c50
2 files changed, 37 insertions, 26 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 9558f45eb..dafe0efbe 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -63,18 +63,22 @@ static struct GNUNET_CORE_MessageHandler no_handlers[] = { {NULL, 0, 0} };
63 * @param message HELLO message of peer 63 * @param message HELLO message of peer
64 */ 64 */
65static void 65static void
66process_hello (void *cls, const struct GNUNET_MessageHeader *message) 66process_hello (void *cls,
67 const struct GNUNET_MessageHeader *message)
67{ 68{
68 struct GNUNET_TESTING_Daemon *daemon = cls; 69 struct GNUNET_TESTING_Daemon *daemon = cls;
70#if WAIT_FOR_HELLO
69 GNUNET_TESTING_NotifyDaemonRunning cb; 71 GNUNET_TESTING_NotifyDaemonRunning cb;
72#endif
70 73
71 int msize; 74 int msize;
72 if (daemon == NULL) 75 if (daemon == NULL)
73 return; 76 return;
74 77
75 GNUNET_assert (daemon->phase == SP_GET_HELLO || daemon->phase == SP_START_DONE); 78 GNUNET_assert (daemon->phase == SP_GET_HELLO || daemon->phase == SP_START_DONE);
76 79#if WAIT_FOR_HELLO
77 cb = daemon->cb; 80 cb = daemon->cb;
81#endif
78 daemon->cb = NULL; 82 daemon->cb = NULL;
79 if (daemon->task != GNUNET_SCHEDULER_NO_TASK) /* Assertion here instead? */ 83 if (daemon->task != GNUNET_SCHEDULER_NO_TASK) /* Assertion here instead? */
80 GNUNET_SCHEDULER_cancel(daemon->task); 84 GNUNET_SCHEDULER_cancel(daemon->task);
@@ -119,7 +123,10 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
119 123
120#if WAIT_FOR_HELLO 124#if WAIT_FOR_HELLO
121 if (NULL != cb) /* FIXME: what happens when this callback calls GNUNET_TESTING_daemon_stop? */ 125 if (NULL != cb) /* FIXME: what happens when this callback calls GNUNET_TESTING_daemon_stop? */
122 cb (daemon->cb_cls, &daemon->id, daemon->cfg, daemon, NULL); 126 cb (daemon->cb_cls,
127 &daemon->id,
128 daemon->cfg,
129 daemon, NULL);
123#endif 130#endif
124} 131}
125 132
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index b1e3beb8c..66bcae842 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -2424,16 +2424,17 @@ static unsigned int
2424copy_allowed(struct GNUNET_TESTING_PeerGroup *pg, 2424copy_allowed(struct GNUNET_TESTING_PeerGroup *pg,
2425 GNUNET_TESTING_ConnectionProcessor proc) 2425 GNUNET_TESTING_ConnectionProcessor proc)
2426{ 2426{
2427 struct UnblacklistContext un_ctx;
2428 unsigned int count; 2427 unsigned int count;
2429 unsigned int total; 2428 unsigned int total;
2430 struct PeerConnection *iter; 2429 struct PeerConnection *iter;
2430#if !OLD
2431 struct UnblacklistContext un_ctx;
2431 2432
2432 un_ctx.pg = pg; 2433 un_ctx.pg = pg;
2434#endif
2433 total = 0; 2435 total = 0;
2434 for (count = 0; count < pg->total - 1; count++) 2436 for (count = 0; count < pg->total - 1; count++)
2435 { 2437 {
2436 un_ctx.first_uid = count;
2437#if OLD 2438#if OLD
2438 iter = pg->peers[count].allowed_peers_head; 2439 iter = pg->peers[count].allowed_peers_head;
2439 while (iter != NULL) 2440 while (iter != NULL)
@@ -2443,10 +2444,15 @@ copy_allowed(struct GNUNET_TESTING_PeerGroup *pg,
2443 iter = iter->next; 2444 iter = iter->next;
2444 } 2445 }
2445#else 2446#else
2446 total += GNUNET_CONTAINER_multihashmap_iterate(pg->peers[count].allowed_peers, &unblacklist_iterator, &un_ctx); 2447 un_ctx.first_uid = count;
2448 total += GNUNET_CONTAINER_multihashmap_iterate(pg->peers[count].allowed_peers,
2449 &unblacklist_iterator,
2450 &un_ctx);
2447#endif 2451#endif
2448 } 2452 }
2449 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unblacklisted %u peers\n", total); 2453 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2454 "Unblacklisted %u peers\n",
2455 total);
2450 return total; 2456 return total;
2451} 2457}
2452 2458
@@ -2467,16 +2473,16 @@ create_line(struct GNUNET_TESTING_PeerGroup *pg,
2467 GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list) 2473 GNUNET_TESTING_ConnectionProcessor proc, enum PeerLists list)
2468{ 2474{
2469 unsigned int count; 2475 unsigned int count;
2470 int connect_attempts; 2476 unsigned int connect_attempts;
2471 2477
2472 connect_attempts = 0; 2478 connect_attempts = 0;
2473
2474 /* Connect each peer to the next highest numbered peer */ 2479 /* Connect each peer to the next highest numbered peer */
2475 for (count = 0; count < pg->total - 1; count++) 2480 for (count = 0; count < pg->total - 1; count++)
2476 { 2481 {
2477#if VERBOSE_TESTING 2482#if VERBOSE_TESTING
2478 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2483 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2479 "Connecting peer %d to peer %d\n", count, count + 1); 2484 "Connecting peer %d to peer %d\n",
2485 count, count + 1);
2480#endif 2486#endif
2481 connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES); 2487 connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES);
2482 } 2488 }
@@ -2504,15 +2510,14 @@ create_from_file(struct GNUNET_TESTING_PeerGroup *pg, char *filename,
2504 int connect_attempts; 2510 int connect_attempts;
2505 unsigned int first_peer_index; 2511 unsigned int first_peer_index;
2506 unsigned int second_peer_index; 2512 unsigned int second_peer_index;
2507 connect_attempts = 0;
2508 struct stat frstat; 2513 struct stat frstat;
2509 int count; 2514 int count;
2510 char *data; 2515 char *data;
2511 char *buf; 2516 char *buf;
2512 unsigned int total_peers; 2517 unsigned int total_peers;
2513
2514 enum States curr_state; 2518 enum States curr_state;
2515 2519
2520 connect_attempts = 0;
2516 if (GNUNET_OK != GNUNET_DISK_file_test (filename)) 2521 if (GNUNET_OK != GNUNET_DISK_file_test (filename))
2517 GNUNET_DISK_fn_write (filename, NULL, 0, GNUNET_DISK_PERM_USER_READ); 2522 GNUNET_DISK_fn_write (filename, NULL, 0, GNUNET_DISK_PERM_USER_READ);
2518 2523
@@ -4272,22 +4277,17 @@ void
4272choose_random_connections(struct GNUNET_TESTING_PeerGroup *pg, 4277choose_random_connections(struct GNUNET_TESTING_PeerGroup *pg,
4273 double percentage) 4278 double percentage)
4274{ 4279{
4275 struct RandomContext random_ctx;
4276 uint32_t pg_iter; 4280 uint32_t pg_iter;
4277#if OLD 4281#if OLD
4278 struct PeerConnection *temp_peers;
4279 struct PeerConnection *conn_iter; 4282 struct PeerConnection *conn_iter;
4280 double random_number; 4283 double random_number;
4284#else
4285 struct RandomContext random_ctx;
4281#endif 4286#endif
4282 4287
4283 for (pg_iter = 0; pg_iter < pg->total; pg_iter++) 4288 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
4284 { 4289 {
4285 random_ctx.first_uid = pg_iter;
4286 random_ctx.first = &pg->peers[pg_iter];
4287 random_ctx.percentage = percentage;
4288 random_ctx.pg = pg;
4289#if OLD 4290#if OLD
4290 temp_peers = NULL;
4291 conn_iter = pg->peers[pg_iter].connect_peers_head; 4291 conn_iter = pg->peers[pg_iter].connect_peers_head;
4292 while (conn_iter != NULL) 4292 while (conn_iter != NULL)
4293 { 4293 {
@@ -4303,17 +4303,21 @@ choose_random_connections(struct GNUNET_TESTING_PeerGroup *pg,
4303 conn_iter = conn_iter->next; 4303 conn_iter = conn_iter->next;
4304 } 4304 }
4305#else 4305#else
4306 pg->peers[pg_iter].connect_peers_working_set = 4306 random_ctx.first_uid = pg_iter;
4307 GNUNET_CONTAINER_multihashmap_create (pg->total); 4307 random_ctx.first = &pg->peers[pg_iter];
4308 random_ctx.percentage = percentage;
4309 random_ctx.pg = pg;
4310 pg->peers[pg_iter].connect_peers_working_set
4311 = GNUNET_CONTAINER_multihashmap_create (pg->total);
4308 GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter].connect_peers, 4312 GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter].connect_peers,
4309 &random_connect_iterator, 4313 &random_connect_iterator,
4310 &random_ctx); 4314 &random_ctx);
4311 /* Now remove the old connections */ 4315 /* Now remove the old connections */
4312 GNUNET_CONTAINER_multihashmap_destroy (pg-> 4316 GNUNET_CONTAINER_multihashmap_destroy (pg->
4313 peers[pg_iter].connect_peers); 4317 peers[pg_iter].connect_peers);
4314 /* And replace with the random set */ 4318 /* And replace with the random set */
4315 pg->peers[pg_iter].connect_peers = 4319 pg->peers[pg_iter].connect_peers
4316 pg->peers[pg_iter].connect_peers_working_set; 4320 = pg->peers[pg_iter].connect_peers_working_set;
4317#endif 4321#endif
4318 } 4322 }
4319 4323