diff options
Diffstat (limited to 'src/testing/test_testing_topology_blacklist.c')
-rw-r--r-- | src/testing/test_testing_topology_blacklist.c | 90 |
1 files changed, 42 insertions, 48 deletions
diff --git a/src/testing/test_testing_topology_blacklist.c b/src/testing/test_testing_topology_blacklist.c index f9185b6fc..d60e3a8fb 100644 --- a/src/testing/test_testing_topology_blacklist.c +++ b/src/testing/test_testing_topology_blacklist.c | |||
@@ -173,10 +173,8 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
173 | 173 | ||
174 | 174 | ||
175 | void | 175 | void |
176 | topology_callback (void *cls, | 176 | topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, |
177 | const struct GNUNET_PeerIdentity *first, | 177 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
178 | const struct GNUNET_PeerIdentity *second, | ||
179 | uint32_t distance, | ||
180 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 178 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
181 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 179 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
182 | struct GNUNET_TESTING_Daemon *first_daemon, | 180 | struct GNUNET_TESTING_Daemon *first_daemon, |
@@ -222,9 +220,9 @@ topology_callback (void *cls, | |||
222 | } | 220 | } |
223 | else if (total_connections + failed_connections == expected_connections) | 221 | else if (total_connections + failed_connections == expected_connections) |
224 | { | 222 | { |
225 | if ((failed_connections == expected_failed_connections) | 223 | if ((failed_connections == expected_failed_connections) && |
226 | && (total_connections == | 224 | (total_connections == |
227 | expected_connections - expected_failed_connections)) | 225 | expected_connections - expected_failed_connections)) |
228 | { | 226 | { |
229 | GNUNET_SCHEDULER_cancel (die_task); | 227 | GNUNET_SCHEDULER_cancel (die_task); |
230 | die_task = GNUNET_SCHEDULER_NO_TASK; | 228 | die_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -260,11 +258,11 @@ connect_topology () | |||
260 | GNUNET_TESTING_connect_topology (pg, connection_topology, | 258 | GNUNET_TESTING_connect_topology (pg, connection_topology, |
261 | connect_topology_option, | 259 | connect_topology_option, |
262 | connect_topology_option_modifier, | 260 | connect_topology_option_modifier, |
263 | connect_timeout, | 261 | connect_timeout, connect_attempts, |
264 | connect_attempts, NULL, NULL); | 262 | NULL, NULL); |
265 | #if VERBOSE | 263 | #if VERBOSE |
266 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 264 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n", |
267 | "Have %d expected connections\n", expected_connections); | 265 | expected_connections); |
268 | #endif | 266 | #endif |
269 | } | 267 | } |
270 | 268 | ||
@@ -276,9 +274,9 @@ connect_topology () | |||
276 | "from connect topology (bad return)"); | 274 | "from connect topology (bad return)"); |
277 | } | 275 | } |
278 | 276 | ||
279 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, | 277 | die_task = |
280 | &end_badly, | 278 | GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, |
281 | "from connect topology (timeout)"); | 279 | "from connect topology (timeout)"); |
282 | } | 280 | } |
283 | 281 | ||
284 | static void | 282 | static void |
@@ -302,15 +300,14 @@ create_topology () | |||
302 | "from create topology (bad return)"); | 300 | "from create topology (bad return)"); |
303 | } | 301 | } |
304 | GNUNET_SCHEDULER_cancel (die_task); | 302 | GNUNET_SCHEDULER_cancel (die_task); |
305 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, | 303 | die_task = |
306 | &end_badly, | 304 | GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, |
307 | "from continue startup (timeout)"); | 305 | "from continue startup (timeout)"); |
308 | } | 306 | } |
309 | 307 | ||
310 | 308 | ||
311 | static void | 309 | static void |
312 | peers_started_callback (void *cls, | 310 | peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, |
313 | const struct GNUNET_PeerIdentity *id, | ||
314 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 311 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
315 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 312 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
316 | { | 313 | { |
@@ -335,10 +332,10 @@ peers_started_callback (void *cls, | |||
335 | GNUNET_SCHEDULER_cancel (die_task); | 332 | GNUNET_SCHEDULER_cancel (die_task); |
336 | /* Set up task in case topology creation doesn't finish | 333 | /* Set up task in case topology creation doesn't finish |
337 | * within a reasonable amount of time */ | 334 | * within a reasonable amount of time */ |
338 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 335 | die_task = |
339 | (GNUNET_TIME_UNIT_MINUTES, 5), | 336 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
340 | &end_badly, | 337 | (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, |
341 | "from peers_started_callback"); | 338 | "from peers_started_callback"); |
342 | connect_topology (); | 339 | connect_topology (); |
343 | ok = 0; | 340 | ok = 0; |
344 | } | 341 | } |
@@ -353,8 +350,7 @@ peers_started_callback (void *cls, | |||
353 | * @param emsg non-null on failure | 350 | * @param emsg non-null on failure |
354 | */ | 351 | */ |
355 | void | 352 | void |
356 | hostkey_callback (void *cls, | 353 | hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, |
357 | const struct GNUNET_PeerIdentity *id, | ||
358 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 354 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
359 | { | 355 | { |
360 | if (emsg != NULL) | 356 | if (emsg != NULL) |
@@ -364,8 +360,8 @@ hostkey_callback (void *cls, | |||
364 | } | 360 | } |
365 | 361 | ||
366 | #if VERBOSE | 362 | #if VERBOSE |
367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 363 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostkey created for peer `%s'\n", |
368 | "Hostkey created for peer `%s'\n", GNUNET_i2s (id)); | 364 | GNUNET_i2s (id)); |
369 | #endif | 365 | #endif |
370 | peers_left--; | 366 | peers_left--; |
371 | if (peers_left == 0) | 367 | if (peers_left == 0) |
@@ -377,19 +373,18 @@ hostkey_callback (void *cls, | |||
377 | GNUNET_SCHEDULER_cancel (die_task); | 373 | GNUNET_SCHEDULER_cancel (die_task); |
378 | /* Set up task in case topology creation doesn't finish | 374 | /* Set up task in case topology creation doesn't finish |
379 | * within a reasonable amount of time */ | 375 | * within a reasonable amount of time */ |
380 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 376 | die_task = |
381 | (GNUNET_TIME_UNIT_MINUTES, 5), | 377 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
382 | &end_badly, | 378 | (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, |
383 | "from hostkey_callback"); | 379 | "from hostkey_callback"); |
384 | GNUNET_SCHEDULER_add_now (&create_topology, NULL); | 380 | GNUNET_SCHEDULER_add_now (&create_topology, NULL); |
385 | ok = 0; | 381 | ok = 0; |
386 | } | 382 | } |
387 | } | 383 | } |
388 | 384 | ||
389 | static void | 385 | static void |
390 | run (void *cls, | 386 | run (void *cls, char *const *args, const char *cfgfile, |
391 | char *const *args, | 387 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
392 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
393 | { | 388 | { |
394 | unsigned long long topology_num; | 389 | unsigned long long topology_num; |
395 | unsigned long long connect_topology_num; | 390 | unsigned long long connect_topology_num; |
@@ -429,8 +424,7 @@ run (void *cls, | |||
429 | topology = topology_num; | 424 | topology = topology_num; |
430 | 425 | ||
431 | if (GNUNET_YES == | 426 | if (GNUNET_YES == |
432 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", | 427 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_topology", |
433 | "connect_topology", | ||
434 | &connect_topology_num)) | 428 | &connect_topology_num)) |
435 | connection_topology = connect_topology_num; | 429 | connection_topology = connect_topology_num; |
436 | 430 | ||
@@ -528,15 +522,14 @@ run (void *cls, | |||
528 | 522 | ||
529 | 523 | ||
530 | /* Set up a task to end testing if peer start fails */ | 524 | /* Set up a task to end testing if peer start fails */ |
531 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 525 | die_task = |
532 | (GNUNET_TIME_UNIT_MINUTES, 5), | 526 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
533 | &end_badly, | 527 | (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, |
534 | "didn't start all daemons in reasonable amount of time!!!"); | 528 | "didn't start all daemons in reasonable amount of time!!!"); |
535 | 529 | ||
536 | pg = GNUNET_TESTING_daemons_start (cfg, | 530 | pg = GNUNET_TESTING_daemons_start (cfg, peers_left, peers_left, peers_left, |
537 | peers_left, peers_left, peers_left, | 531 | TIMEOUT, &hostkey_callback, NULL, |
538 | TIMEOUT, &hostkey_callback, | 532 | &peers_started_callback, NULL, |
539 | NULL, &peers_started_callback, NULL, | ||
540 | &topology_callback, NULL, NULL); | 533 | &topology_callback, NULL, NULL); |
541 | 534 | ||
542 | } | 535 | } |
@@ -557,9 +550,10 @@ check () | |||
557 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 550 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
558 | GNUNET_GETOPT_OPTION_END | 551 | GNUNET_GETOPT_OPTION_END |
559 | }; | 552 | }; |
560 | ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 553 | ret = |
561 | argv, "test-testing-topology-blacklist", "nohelp", | 554 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
562 | options, &run, &ok); | 555 | "test-testing-topology-blacklist", "nohelp", options, |
556 | &run, &ok); | ||
563 | if (ret != GNUNET_OK) | 557 | if (ret != GNUNET_OK) |
564 | { | 558 | { |
565 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 559 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |