aboutsummaryrefslogtreecommitdiff
path: root/src/dht/test_dht_multipeer.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 21:46:35 +0000
commit502af2167f7c218366666ca4944bd7cc54b5b19a (patch)
treea91fec5cc9769d260640bd91c6633cb9cf395524 /src/dht/test_dht_multipeer.c
parent03af5a603b7cc53432249d5854cd412aa90dde0d (diff)
downloadgnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.tar.gz
gnunet-502af2167f7c218366666ca4944bd7cc54b5b19a.zip
indentation
Diffstat (limited to 'src/dht/test_dht_multipeer.c')
-rw-r--r--src/dht/test_dht_multipeer.c785
1 files changed, 421 insertions, 364 deletions
diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c
index d05901a2a..3bbf44be1 100644
--- a/src/dht/test_dht_multipeer.c
+++ b/src/dht/test_dht_multipeer.c
@@ -217,11 +217,12 @@ static char *blacklist_transports;
217 217
218static enum GNUNET_TESTING_Topology topology; 218static enum GNUNET_TESTING_Topology topology;
219 219
220static enum GNUNET_TESTING_Topology blacklist_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* Don't do any blacklisting */ 220static enum GNUNET_TESTING_Topology blacklist_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* Don't do any blacklisting */
221 221
222static enum GNUNET_TESTING_Topology connection_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* NONE actually means connect all allowed peers */ 222static enum GNUNET_TESTING_Topology connection_topology = GNUNET_TESTING_TOPOLOGY_NONE; /* NONE actually means connect all allowed peers */
223 223
224static enum GNUNET_TESTING_TopologyOption connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; 224static enum GNUNET_TESTING_TopologyOption connect_topology_option =
225 GNUNET_TESTING_TOPOLOGY_OPTION_ALL;
225 226
226static double connect_topology_option_modifier = 0.0; 227static double connect_topology_option_modifier = 0.0;
227 228
@@ -231,25 +232,26 @@ static int ok;
231/** 232/**
232 * Check whether peers successfully shut down. 233 * Check whether peers successfully shut down.
233 */ 234 */
234void shutdown_callback (void *cls, 235void
235 const char *emsg) 236shutdown_callback (void *cls, const char *emsg)
236{ 237{
237 if (emsg != NULL) 238 if (emsg != NULL)
238 { 239 {
239 if (ok == 0) 240 if (ok == 0)
240 ok = 2; 241 ok = 2;
241 } 242 }
242} 243}
243 244
244/** 245/**
245 * Task to release DHT handles for PUT 246 * Task to release DHT handles for PUT
246 */ 247 */
247static void 248static void
248put_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 249put_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
249{ 250{
250 struct TestPutContext *test_put = cls; 251 struct TestPutContext *test_put = cls;
252
251 test_put->disconnect_task = GNUNET_SCHEDULER_NO_TASK; 253 test_put->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
252 GNUNET_DHT_disconnect(test_put->dht_handle); 254 GNUNET_DHT_disconnect (test_put->dht_handle);
253 test_put->dht_handle = NULL; 255 test_put->dht_handle = NULL;
254} 256}
255 257
@@ -258,31 +260,31 @@ put_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
258 * testcase. 260 * testcase.
259 */ 261 */
260static void 262static void
261finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 263finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
262{ 264{
263 GNUNET_assert (pg != NULL); 265 GNUNET_assert (pg != NULL);
264 struct TestPutContext *test_put = all_puts; 266 struct TestPutContext *test_put = all_puts;
265 struct TestGetContext *test_get = all_gets; 267 struct TestGetContext *test_get = all_gets;
266 268
267 while (test_put != NULL) 269 while (test_put != NULL)
268 { 270 {
269 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 271 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
270 GNUNET_SCHEDULER_cancel(test_put->disconnect_task); 272 GNUNET_SCHEDULER_cancel (test_put->disconnect_task);
271 if (test_put->dht_handle != NULL) 273 if (test_put->dht_handle != NULL)
272 GNUNET_DHT_disconnect(test_put->dht_handle); 274 GNUNET_DHT_disconnect (test_put->dht_handle);
273 test_put = test_put->next; 275 test_put = test_put->next;
274 } 276 }
275 277
276 while (test_get != NULL) 278 while (test_get != NULL)
277 { 279 {
278 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 280 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
279 GNUNET_SCHEDULER_cancel(test_get->disconnect_task); 281 GNUNET_SCHEDULER_cancel (test_get->disconnect_task);
280 if (test_get->get_handle != NULL) 282 if (test_get->get_handle != NULL)
281 GNUNET_DHT_get_stop(test_get->get_handle); 283 GNUNET_DHT_get_stop (test_get->get_handle);
282 if (test_get->dht_handle != NULL) 284 if (test_get->dht_handle != NULL)
283 GNUNET_DHT_disconnect(test_get->dht_handle); 285 GNUNET_DHT_disconnect (test_get->dht_handle);
284 test_get = test_get->next; 286 test_get = test_get->next;
285 } 287 }
286 288
287 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 289 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
288 ok = 0; 290 ok = 0;
@@ -295,32 +297,33 @@ finish_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
295 * test. 297 * test.
296 */ 298 */
297static void 299static void
298end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 300end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
299{ 301{
300 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failing test with error: `%s'!\n", (char *)cls); 302 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failing test with error: `%s'!\n",
303 (char *) cls);
301 304
302 struct TestPutContext *test_put = all_puts; 305 struct TestPutContext *test_put = all_puts;
303 struct TestGetContext *test_get = all_gets; 306 struct TestGetContext *test_get = all_gets;
304 307
305 while (test_put != NULL) 308 while (test_put != NULL)
306 { 309 {
307 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 310 if (test_put->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
308 GNUNET_SCHEDULER_cancel(test_put->disconnect_task); 311 GNUNET_SCHEDULER_cancel (test_put->disconnect_task);
309 if (test_put->dht_handle != NULL) 312 if (test_put->dht_handle != NULL)
310 GNUNET_DHT_disconnect(test_put->dht_handle); 313 GNUNET_DHT_disconnect (test_put->dht_handle);
311 test_put = test_put->next; 314 test_put = test_put->next;
312 } 315 }
313 316
314 while (test_get != NULL) 317 while (test_get != NULL)
315 { 318 {
316 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK) 319 if (test_get->disconnect_task != GNUNET_SCHEDULER_NO_TASK)
317 GNUNET_SCHEDULER_cancel(test_get->disconnect_task); 320 GNUNET_SCHEDULER_cancel (test_get->disconnect_task);
318 if (test_get->get_handle != NULL) 321 if (test_get->get_handle != NULL)
319 GNUNET_DHT_get_stop(test_get->get_handle); 322 GNUNET_DHT_get_stop (test_get->get_handle);
320 if (test_get->dht_handle != NULL) 323 if (test_get->dht_handle != NULL)
321 GNUNET_DHT_disconnect(test_get->dht_handle); 324 GNUNET_DHT_disconnect (test_get->dht_handle);
322 test_get = test_get->next; 325 test_get = test_get->next;
323 } 326 }
324 327
325 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL); 328 GNUNET_TESTING_daemons_stop (pg, TIMEOUT, &shutdown_callback, NULL);
326 ok = 1; 329 ok = 1;
@@ -330,47 +333,51 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
330 * Task to release DHT handle associated with GET request. 333 * Task to release DHT handle associated with GET request.
331 */ 334 */
332static void 335static void
333get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 336get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
334{ 337{
335 struct TestGetContext *test_get = cls; 338 struct TestGetContext *test_get = cls;
336 outstanding_gets--; /* GET is really finished */ 339
337 GNUNET_DHT_disconnect(test_get->dht_handle); 340 outstanding_gets--; /* GET is really finished */
341 GNUNET_DHT_disconnect (test_get->dht_handle);
338 test_get->dht_handle = NULL; 342 test_get->dht_handle = NULL;
339 343
340 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%d gets succeeded, %d gets failed!\n", gets_completed, gets_failed); 344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%d gets succeeded, %d gets failed!\n",
341 if ((gets_completed == num_gets) && (outstanding_gets == 0))/* All gets successful */ 345 gets_completed, gets_failed);
342 { 346 if ((gets_completed == num_gets) && (outstanding_gets == 0)) /* All gets successful */
343 GNUNET_SCHEDULER_cancel (die_task); 347 {
344 //GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5), &get_topology, NULL); 348 GNUNET_SCHEDULER_cancel (die_task);
345 GNUNET_SCHEDULER_add_now(&finish_testing, NULL); 349 //GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MINUTES, 5), &get_topology, NULL);
346 } 350 GNUNET_SCHEDULER_add_now (&finish_testing, NULL);
347 else if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0)) /* Had some failures */ 351 }
348 { 352 else if ((gets_completed + gets_failed == num_gets) && (outstanding_gets == 0)) /* Had some failures */
349 GNUNET_SCHEDULER_cancel(die_task); 353 {
350 GNUNET_SCHEDULER_add_now(&end_badly, "not all gets succeeded!\n"); 354 GNUNET_SCHEDULER_cancel (die_task);
351 } 355 GNUNET_SCHEDULER_add_now (&end_badly, "not all gets succeeded!\n");
356 }
352} 357}
353 358
354/** 359/**
355 * Task to release get handle. 360 * Task to release get handle.
356 */ 361 */
357static void 362static void
358get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 363get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
359{ 364{
360 struct TestGetContext *test_get = cls; 365 struct TestGetContext *test_get = cls;
361 GNUNET_HashCode search_key; /* Key stored under */ 366 GNUNET_HashCode search_key; /* Key stored under */
362 char original_data[TEST_DATA_SIZE]; /* Made up data to store */ 367 char original_data[TEST_DATA_SIZE]; /* Made up data to store */
363 368
364 memset(original_data, test_get->uid, sizeof(original_data)); 369 memset (original_data, test_get->uid, sizeof (original_data));
365 GNUNET_CRYPTO_hash(original_data, TEST_DATA_SIZE, &search_key); 370 GNUNET_CRYPTO_hash (original_data, TEST_DATA_SIZE, &search_key);
366 371
367 if ( (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0) 372 if ((tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT) != 0)
368 { 373 {
369 gets_failed++; 374 gets_failed++;
370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Get from peer %s for key %s failed!\n", test_get->daemon->shortname, GNUNET_h2s(&search_key)); 375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
371 } 376 "Get from peer %s for key %s failed!\n",
372 GNUNET_assert(test_get->get_handle != NULL); 377 test_get->daemon->shortname, GNUNET_h2s (&search_key));
373 GNUNET_DHT_get_stop(test_get->get_handle); 378 }
379 GNUNET_assert (test_get->get_handle != NULL);
380 GNUNET_DHT_get_stop (test_get->get_handle);
374 GNUNET_SCHEDULER_add_now (&get_stop_finished, test_get); 381 GNUNET_SCHEDULER_add_now (&get_stop_finished, test_get);
375 test_get->get_handle = NULL; 382 test_get->get_handle = NULL;
376 test_get->disconnect_task = GNUNET_SCHEDULER_NO_TASK; 383 test_get->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
@@ -386,55 +393,58 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
386 * @param size number of bytes in data 393 * @param size number of bytes in data
387 * @param data pointer to the result data 394 * @param data pointer to the result data
388 */ 395 */
389void get_result_iterator (void *cls, 396void
390 struct GNUNET_TIME_Absolute exp, 397get_result_iterator (void *cls,
391 const GNUNET_HashCode * key, 398 struct GNUNET_TIME_Absolute exp,
392 const struct GNUNET_PeerIdentity * const *get_path, 399 const GNUNET_HashCode * key,
393 const struct GNUNET_PeerIdentity * const *put_path, 400 const struct GNUNET_PeerIdentity *const *get_path,
394 enum GNUNET_BLOCK_Type type, 401 const struct GNUNET_PeerIdentity *const *put_path,
395 size_t size, 402 enum GNUNET_BLOCK_Type type, size_t size, const void *data)
396 const void *data)
397{ 403{
398 struct TestGetContext *test_get = cls; 404 struct TestGetContext *test_get = cls;
399 GNUNET_HashCode search_key; /* Key stored under */ 405 GNUNET_HashCode search_key; /* Key stored under */
400 char original_data[TEST_DATA_SIZE]; /* Made up data to store */ 406 char original_data[TEST_DATA_SIZE]; /* Made up data to store */
401 unsigned int i; 407 unsigned int i;
402 memset(original_data, test_get->uid, sizeof(original_data)); 408
403 GNUNET_CRYPTO_hash(original_data, TEST_DATA_SIZE, &search_key); 409 memset (original_data, test_get->uid, sizeof (original_data));
410 GNUNET_CRYPTO_hash (original_data, TEST_DATA_SIZE, &search_key);
404 411
405 if (test_get->succeeded == GNUNET_YES) 412 if (test_get->succeeded == GNUNET_YES)
406 return; /* Get has already been successful, probably ending now */ 413 return; /* Get has already been successful, probably ending now */
407 414
408#if PATH_TRACKING 415#if PATH_TRACKING
409 if (put_path != NULL) 416 if (put_path != NULL)
410 { 417 {
411 fprintf(stderr, "PUT Path: "); 418 fprintf (stderr, "PUT Path: ");
412 for (i = 0; put_path[i] != NULL; i++) 419 for (i = 0; put_path[i] != NULL; i++)
413 fprintf(stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s(put_path[i])); 420 fprintf (stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s (put_path[i]));
414 fprintf(stderr, "\n"); 421 fprintf (stderr, "\n");
415 } 422 }
416 if (get_path != NULL) 423 if (get_path != NULL)
417 { 424 {
418 fprintf(stderr, "GET Path: "); 425 fprintf (stderr, "GET Path: ");
419 for (i = 0; get_path[i] != NULL; i++) 426 for (i = 0; get_path[i] != NULL; i++)
420 fprintf(stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s(get_path[i])); 427 fprintf (stderr, "%s%s", i == 0 ? "" : "->", GNUNET_i2s (get_path[i]));
421 fprintf(stderr, "\n"); 428 fprintf (stderr, "\n");
422 } 429 }
423#endif 430#endif
424 431
425 if ((0 != memcmp(&search_key, key, sizeof (GNUNET_HashCode))) || (0 != memcmp(original_data, data, sizeof(original_data)))) 432 if ((0 != memcmp (&search_key, key, sizeof (GNUNET_HashCode))) ||
426 { 433 (0 != memcmp (original_data, data, sizeof (original_data))))
427 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Key or data is not the same as was inserted!\n"); 434 {
428 } 435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
436 "Key or data is not the same as was inserted!\n");
437 }
429 else 438 else
430 { 439 {
431 gets_completed++; 440 gets_completed++;
432 test_get->succeeded = GNUNET_YES; 441 test_get->succeeded = GNUNET_YES;
433 } 442 }
434 443
435 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n"); 444 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received correct GET response!\n");
436 GNUNET_SCHEDULER_cancel(test_get->disconnect_task); 445 GNUNET_SCHEDULER_cancel (test_get->disconnect_task);
437 GNUNET_SCHEDULER_add_continuation(&get_stop_task, test_get, GNUNET_SCHEDULER_REASON_PREREQ_DONE); 446 GNUNET_SCHEDULER_add_continuation (&get_stop_task, test_get,
447 GNUNET_SCHEDULER_REASON_PREREQ_DONE);
438} 448}
439 449
440 450
@@ -442,43 +452,42 @@ void get_result_iterator (void *cls,
442 * Set up some data, and call API PUT function 452 * Set up some data, and call API PUT function
443 */ 453 */
444static void 454static void
445do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 455do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
446{ 456{
447 struct TestGetContext *test_get = cls; 457 struct TestGetContext *test_get = cls;
448 GNUNET_HashCode key; /* Made up key to store data under */ 458 GNUNET_HashCode key; /* Made up key to store data under */
449 char data[TEST_DATA_SIZE]; /* Made up data to store */ 459 char data[TEST_DATA_SIZE]; /* Made up data to store */
450 460
451 if (test_get == NULL) 461 if (test_get == NULL)
452 return; /* End of the list */ 462 return; /* End of the list */
453 memset(data, test_get->uid, sizeof(data)); 463 memset (data, test_get->uid, sizeof (data));
454 GNUNET_CRYPTO_hash(data, TEST_DATA_SIZE, &key); 464 GNUNET_CRYPTO_hash (data, TEST_DATA_SIZE, &key);
455 465
456 if (outstanding_gets > MAX_OUTSTANDING_GETS) 466 if (outstanding_gets > MAX_OUTSTANDING_GETS)
457 { 467 {
458 GNUNET_SCHEDULER_add_delayed (GET_DELAY, &do_get, test_get); 468 GNUNET_SCHEDULER_add_delayed (GET_DELAY, &do_get, test_get);
459 return; 469 return;
460 } 470 }
461 471
462 test_get->dht_handle = GNUNET_DHT_connect(test_get->daemon->cfg, 10); 472 test_get->dht_handle = GNUNET_DHT_connect (test_get->daemon->cfg, 10);
463 /* Insert the data at the first peer */ 473 /* Insert the data at the first peer */
464 GNUNET_assert(test_get->dht_handle != NULL); 474 GNUNET_assert (test_get->dht_handle != NULL);
465 outstanding_gets++; 475 outstanding_gets++;
466 test_get->get_handle = GNUNET_DHT_get_start(test_get->dht_handle, 476 test_get->get_handle = GNUNET_DHT_get_start (test_get->dht_handle,
467 GNUNET_TIME_UNIT_FOREVER_REL, 477 GNUNET_TIME_UNIT_FOREVER_REL,
468 GNUNET_BLOCK_TYPE_TEST, 478 GNUNET_BLOCK_TYPE_TEST,
469 &key, 479 &key,
470 DEFAULT_GET_REPLICATION, 480 DEFAULT_GET_REPLICATION,
471 route_option, 481 route_option,
472 NULL, 0, 482 NULL, 0,
473 NULL, 0, 483 NULL, 0,
474 &get_result_iterator, 484 &get_result_iterator, test_get);
475 test_get);
476#if VERBOSE 485#if VERBOSE
477 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting get for uid %u from peer %s\n", 486 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting get for uid %u from peer %s\n",
478 test_get->uid, 487 test_get->uid, test_get->daemon->shortname);
479 test_get->daemon->shortname);
480#endif 488#endif
481 test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed(GET_TIMEOUT, &get_stop_task, test_get); 489 test_get->disconnect_task =
490 GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &get_stop_task, test_get);
482 GNUNET_SCHEDULER_add_now (&do_get, test_get->next); 491 GNUNET_SCHEDULER_add_now (&do_get, test_get->next);
483} 492}
484 493
@@ -487,64 +496,68 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
487 * Schedule the GET request for some time in the future. 496 * Schedule the GET request for some time in the future.
488 */ 497 */
489static void 498static void
490put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 499put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
491{ 500{
492 struct TestPutContext *test_put = cls; 501 struct TestPutContext *test_put = cls;
502
493 outstanding_puts--; 503 outstanding_puts--;
494 puts_completed++; 504 puts_completed++;
495 505
496 GNUNET_SCHEDULER_cancel(test_put->disconnect_task); 506 GNUNET_SCHEDULER_cancel (test_put->disconnect_task);
497 test_put->disconnect_task = GNUNET_SCHEDULER_add_now(&put_disconnect_task, test_put); 507 test_put->disconnect_task =
508 GNUNET_SCHEDULER_add_now (&put_disconnect_task, test_put);
498 if (puts_completed == num_puts) 509 if (puts_completed == num_puts)
499 { 510 {
500 GNUNET_assert(outstanding_puts == 0); 511 GNUNET_assert (outstanding_puts == 0);
501 GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10), &do_get, all_gets); 512 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
502 return; 513 (GNUNET_TIME_UNIT_SECONDS, 10), &do_get,
503 } 514 all_gets);
515 return;
516 }
504} 517}
505 518
506/** 519/**
507 * Set up some data, and call API PUT function 520 * Set up some data, and call API PUT function
508 */ 521 */
509static void 522static void
510do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 523do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
511{ 524{
512 struct TestPutContext *test_put = cls; 525 struct TestPutContext *test_put = cls;
513 GNUNET_HashCode key; /* Made up key to store data under */ 526 GNUNET_HashCode key; /* Made up key to store data under */
514 char data[TEST_DATA_SIZE]; /* Made up data to store */ 527 char data[TEST_DATA_SIZE]; /* Made up data to store */
515 528
516 if (test_put == NULL) 529 if (test_put == NULL)
517 return; /* End of list */ 530 return; /* End of list */
518 531
519 memset(data, test_put->uid, sizeof(data)); 532 memset (data, test_put->uid, sizeof (data));
520 GNUNET_CRYPTO_hash(data, TEST_DATA_SIZE, &key); 533 GNUNET_CRYPTO_hash (data, TEST_DATA_SIZE, &key);
521 534
522 if (outstanding_puts > MAX_OUTSTANDING_PUTS) 535 if (outstanding_puts > MAX_OUTSTANDING_PUTS)
523 { 536 {
524 GNUNET_SCHEDULER_add_delayed (PUT_DELAY, &do_put, test_put); 537 GNUNET_SCHEDULER_add_delayed (PUT_DELAY, &do_put, test_put);
525 return; 538 return;
526 } 539 }
527 540
528#if VERBOSE 541#if VERBOSE
529 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting put for uid %u from peer %s\n", 542 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting put for uid %u from peer %s\n",
530 test_put->uid, 543 test_put->uid, test_put->daemon->shortname);
531 test_put->daemon->shortname);
532#endif 544#endif
533 test_put->dht_handle = GNUNET_DHT_connect(test_put->daemon->cfg, 10); 545 test_put->dht_handle = GNUNET_DHT_connect (test_put->daemon->cfg, 10);
534 546
535 GNUNET_assert(test_put->dht_handle != NULL); 547 GNUNET_assert (test_put->dht_handle != NULL);
536 outstanding_puts++; 548 outstanding_puts++;
537 GNUNET_DHT_put(test_put->dht_handle, 549 GNUNET_DHT_put (test_put->dht_handle,
538 &key, 550 &key,
539 DEFAULT_PUT_REPLICATION, 551 DEFAULT_PUT_REPLICATION,
540 route_option, 552 route_option,
541 GNUNET_BLOCK_TYPE_TEST, 553 GNUNET_BLOCK_TYPE_TEST,
542 sizeof(data), data, 554 sizeof (data), data,
543 GNUNET_TIME_UNIT_FOREVER_ABS, 555 GNUNET_TIME_UNIT_FOREVER_ABS,
544 GNUNET_TIME_UNIT_FOREVER_REL, 556 GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, test_put);
545 &put_finished, test_put); 557 test_put->disconnect_task =
546 test_put->disconnect_task = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_get_forever(), &put_disconnect_task, test_put); 558 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (),
547 GNUNET_SCHEDULER_add_now(&do_put, test_put->next); 559 &put_disconnect_task, test_put);
560 GNUNET_SCHEDULER_add_now (&do_put, test_put->next);
548} 561}
549 562
550 563
@@ -554,7 +567,7 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
554 * then call actual insert functions. 567 * then call actual insert functions.
555 */ 568 */
556static void 569static void
557setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 570setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
558{ 571{
559 int i; 572 int i;
560 uint32_t temp_daemon; 573 uint32_t temp_daemon;
@@ -563,27 +576,31 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
563 int remember[num_puts][num_peers]; 576 int remember[num_puts][num_peers];
564 577
565 for (i = 0; i < num_puts; i++) 578 for (i = 0; i < num_puts; i++)
566 { 579 {
567 test_put = GNUNET_malloc(sizeof(struct TestPutContext)); 580 test_put = GNUNET_malloc (sizeof (struct TestPutContext));
568 test_put->uid = i; 581 test_put->uid = i;
569 temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); 582 temp_daemon =
570 test_put->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); 583 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers);
571 test_put->next = all_puts; 584 test_put->daemon = GNUNET_TESTING_daemon_get (pg, temp_daemon);
572 all_puts = test_put; 585 test_put->next = all_puts;
573 } 586 all_puts = test_put;
587 }
574 588
575 for (i = 0; i < num_gets; i++) 589 for (i = 0; i < num_gets; i++)
576 { 590 {
577 test_get = GNUNET_malloc(sizeof(struct TestGetContext)); 591 test_get = GNUNET_malloc (sizeof (struct TestGetContext));
578 test_get->uid = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_puts); 592 test_get->uid =
579 temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); 593 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_puts);
580 while (remember[test_get->uid][temp_daemon] == 1) 594 temp_daemon =
581 temp_daemon = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, num_peers); 595 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers);
582 test_get->daemon = GNUNET_TESTING_daemon_get(pg, temp_daemon); 596 while (remember[test_get->uid][temp_daemon] == 1)
583 remember[test_get->uid][temp_daemon] = 1; 597 temp_daemon =
584 test_get->next = all_gets; 598 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers);
585 all_gets = test_get; 599 test_get->daemon = GNUNET_TESTING_daemon_get (pg, temp_daemon);
586 } 600 remember[test_get->uid][temp_daemon] = 1;
601 test_get->next = all_gets;
602 all_gets = test_get;
603 }
587 604
588 GNUNET_SCHEDULER_add_now (&do_put, all_puts); 605 GNUNET_SCHEDULER_add_now (&do_put, all_puts);
589} 606}
@@ -610,57 +627,61 @@ topology_callback (void *cls,
610 const char *emsg) 627 const char *emsg)
611{ 628{
612 if (emsg == NULL) 629 if (emsg == NULL)
613 { 630 {
614 total_connections++; 631 total_connections++;
615#if VERBOSE > 1 632#if VERBOSE > 1
616 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "connected peer %s to peer %s, distance %u\n", 633 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
617 first_daemon->shortname, 634 "connected peer %s to peer %s, distance %u\n",
618 second_daemon->shortname, 635 first_daemon->shortname, second_daemon->shortname, distance);
619 distance);
620#endif 636#endif
621 } 637 }
622#if VERBOSE 638#if VERBOSE
623 else 639 else
624 { 640 {
625 failed_connections++; 641 failed_connections++;
626 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to connect peer %s to peer %s with error :\n%s\n", 642 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
627 first_daemon->shortname, 643 "Failed to connect peer %s to peer %s with error :\n%s\n",
628 second_daemon->shortname, emsg); 644 first_daemon->shortname, second_daemon->shortname, emsg);
629 } 645 }
630#endif 646#endif
631 647
632 if (total_connections == expected_connections) 648 if (total_connections == expected_connections)
633 { 649 {
634#if VERBOSE 650#if VERBOSE
635 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 651 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
636 "Created %d total connections, which is our target number! Starting next phase of testing.\n", 652 "Created %d total connections, which is our target number! Starting next phase of testing.\n",
637 total_connections); 653 total_connections);
638#endif 654#endif
639 GNUNET_SCHEDULER_cancel (die_task); 655 GNUNET_SCHEDULER_cancel (die_task);
640 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 656 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
641 &end_badly, "from setup puts/gets"); 657 &end_badly,
642 658 "from setup puts/gets");
643 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &setup_puts_and_gets, NULL); 659
644 } 660 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
661 (GNUNET_TIME_UNIT_SECONDS, 2),
662 &setup_puts_and_gets, NULL);
663 }
645 else if (total_connections + failed_connections == expected_connections) 664 else if (total_connections + failed_connections == expected_connections)
646 { 665 {
647 GNUNET_SCHEDULER_cancel (die_task); 666 GNUNET_SCHEDULER_cancel (die_task);
648 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from topology_callback (too many failed connections)"); 667 die_task =
649 } 668 GNUNET_SCHEDULER_add_now (&end_badly,
669 "from topology_callback (too many failed connections)");
670 }
650} 671}
651 672
652static void 673static void
653peers_started_callback (void *cls, 674peers_started_callback (void *cls,
654 const struct GNUNET_PeerIdentity *id, 675 const struct GNUNET_PeerIdentity *id,
655 const struct GNUNET_CONFIGURATION_Handle *cfg, 676 const struct GNUNET_CONFIGURATION_Handle *cfg,
656 struct GNUNET_TESTING_Daemon *d, const char *emsg) 677 struct GNUNET_TESTING_Daemon *d, const char *emsg)
657{ 678{
658 if (emsg != NULL) 679 if (emsg != NULL)
659 { 680 {
660 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to start daemon with error: `%s'\n", 681 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
661 emsg); 682 "Failed to start daemon with error: `%s'\n", emsg);
662 return; 683 return;
663 } 684 }
664 GNUNET_assert (id != NULL); 685 GNUNET_assert (id != NULL);
665 686
666#if VERBOSE 687#if VERBOSE
@@ -670,63 +691,69 @@ peers_started_callback (void *cls,
670 691
671 peers_left--; 692 peers_left--;
672 if (peers_left == 0) 693 if (peers_left == 0)
673 { 694 {
674 695
675#if VERBOSE 696#if VERBOSE
676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 697 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
677 "All %d daemons started, now connecting peers!\n", 698 "All %d daemons started, now connecting peers!\n", num_peers);
678 num_peers);
679#endif 699#endif
680 GNUNET_SCHEDULER_cancel (die_task); 700 GNUNET_SCHEDULER_cancel (die_task);
681 701
682 expected_connections = -1; 702 expected_connections = -1;
683 if ((pg != NULL) && (peers_left == 0)) 703 if ((pg != NULL) && (peers_left == 0))
684 { 704 {
685 expected_connections = GNUNET_TESTING_connect_topology (pg, 705 expected_connections = GNUNET_TESTING_connect_topology (pg,
686 connection_topology, 706 connection_topology,
687 connect_topology_option, 707 connect_topology_option,
688 connect_topology_option_modifier, 708 connect_topology_option_modifier,
689 TIMEOUT, 709 TIMEOUT,
690 num_peers, 710 num_peers,
691 NULL, NULL); 711 NULL, NULL);
692#if VERBOSE 712#if VERBOSE
693 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
694 "Have %d expected connections\n", expected_connections); 714 "Have %d expected connections\n", expected_connections);
695#endif 715#endif
696 } 716 }
697 717
698 if (expected_connections == GNUNET_SYSERR) 718 if (expected_connections == GNUNET_SYSERR)
699 { 719 {
700 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from connect topology (bad return)"); 720 die_task =
701 } 721 GNUNET_SCHEDULER_add_now (&end_badly,
722 "from connect topology (bad return)");
723 }
702 724
703 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 725 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
704 &end_badly, "from connect topology (timeout)"); 726 &end_badly,
727 "from connect topology (timeout)");
705 728
706 ok = 0; 729 ok = 0;
707 } 730 }
708} 731}
709 732
710static void 733static void
711create_topology () 734create_topology ()
712{ 735{
713 peers_left = num_peers; /* Reset counter */ 736 peers_left = num_peers; /* Reset counter */
714 if (GNUNET_TESTING_create_topology (pg, topology, blacklist_topology, blacklist_transports) != GNUNET_SYSERR) 737 if (GNUNET_TESTING_create_topology
715 { 738 (pg, topology, blacklist_topology, blacklist_transports) != GNUNET_SYSERR)
739 {
716#if VERBOSE 740#if VERBOSE
717 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 741 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
718 "Topology set up, now starting peers!\n"); 742 "Topology set up, now starting peers!\n");
719#endif 743#endif
720 GNUNET_TESTING_daemons_continue_startup(pg); 744 GNUNET_TESTING_daemons_continue_startup (pg);
721 } 745 }
722 else 746 else
723 { 747 {
724 GNUNET_SCHEDULER_cancel (die_task); 748 GNUNET_SCHEDULER_cancel (die_task);
725 die_task = GNUNET_SCHEDULER_add_now (&end_badly, "from create topology (bad return)"); 749 die_task =
726 } 750 GNUNET_SCHEDULER_add_now (&end_badly,
751 "from create topology (bad return)");
752 }
727 GNUNET_SCHEDULER_cancel (die_task); 753 GNUNET_SCHEDULER_cancel (die_task);
728 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 754 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
729 &end_badly, "from continue startup (timeout)"); 755 &end_badly,
756 "from continue startup (timeout)");
730} 757}
731 758
732/** 759/**
@@ -737,39 +764,40 @@ create_topology ()
737 * @param d the daemon handle (pretty useless at this point, remove?) 764 * @param d the daemon handle (pretty useless at this point, remove?)
738 * @param emsg non-null on failure 765 * @param emsg non-null on failure
739 */ 766 */
740void hostkey_callback (void *cls, 767void
741 const struct GNUNET_PeerIdentity *id, 768hostkey_callback (void *cls,
742 struct GNUNET_TESTING_Daemon *d, 769 const struct GNUNET_PeerIdentity *id,
743 const char *emsg) 770 struct GNUNET_TESTING_Daemon *d, const char *emsg)
744{ 771{
745 if (emsg != NULL) 772 if (emsg != NULL)
746 { 773 {
747 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Hostkey callback received error: %s\n", emsg); 774 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
748 } 775 "Hostkey callback received error: %s\n", emsg);
776 }
749 777
750#if VERBOSE > 1 778#if VERBOSE > 1
751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 779 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
752 "Hostkey (%d/%d) created for peer `%s'\n", 780 "Hostkey (%d/%d) created for peer `%s'\n",
753 num_peers - peers_left, num_peers, GNUNET_i2s(id)); 781 num_peers - peers_left, num_peers, GNUNET_i2s (id));
754#endif 782#endif
755 783
756 784
757 peers_left--; 785 peers_left--;
758 if (peers_left == 0) 786 if (peers_left == 0)
759 { 787 {
760#if VERBOSE 788#if VERBOSE
761 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 789 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
762 "All %d hostkeys created, now creating topology!\n", 790 "All %d hostkeys created, now creating topology!\n", num_peers);
763 num_peers);
764#endif 791#endif
765 GNUNET_SCHEDULER_cancel (die_task); 792 GNUNET_SCHEDULER_cancel (die_task);
766 /* Set up task in case topology creation doesn't finish 793 /* Set up task in case topology creation doesn't finish
767 * within a reasonable amount of time */ 794 * within a reasonable amount of time */
768 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, 795 die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
769 &end_badly, "from create_topology"); 796 &end_badly,
770 GNUNET_SCHEDULER_add_now(&create_topology, NULL); 797 "from create_topology");
771 ok = 0; 798 GNUNET_SCHEDULER_add_now (&create_topology, NULL);
772 } 799 ok = 0;
800 }
773} 801}
774 802
775 803
@@ -778,11 +806,11 @@ run (void *cls,
778 char *const *args, 806 char *const *args,
779 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) 807 const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
780{ 808{
781 char * topology_str; 809 char *topology_str;
782 char * connect_topology_str; 810 char *connect_topology_str;
783 char * blacklist_topology_str; 811 char *blacklist_topology_str;
784 char * connect_topology_option_str; 812 char *connect_topology_option_str;
785 char * connect_topology_option_modifier_string; 813 char *connect_topology_option_modifier_string;
786 814
787#if PATH_TRACKING 815#if PATH_TRACKING
788 route_option = GNUNET_DHT_RO_RECORD_ROUTE; 816 route_option = GNUNET_DHT_RO_RECORD_ROUTE;
@@ -791,66 +819,91 @@ run (void *cls,
791#endif 819#endif
792 820
793 /* Get path from configuration file */ 821 /* Get path from configuration file */
794 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string(cfg, "paths", "servicehome", &test_directory)) 822 if (GNUNET_YES !=
795 { 823 GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome",
796 ok = 404; 824 &test_directory))
797 return; 825 {
798 } 826 ok = 404;
827 return;
828 }
799 829
800 if ((GNUNET_YES == 830 if ((GNUNET_YES ==
801 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "topology", 831 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology",
802 &topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&topology, topology_str))) 832 &topology_str)) &&
803 { 833 (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str)))
804 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 834 {
805 "Invalid topology `%s' given for section %s option %s\n", topology_str, "TESTING", "TOPOLOGY"); 835 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
806 topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */ 836 "Invalid topology `%s' given for section %s option %s\n",
807 } 837 topology_str, "TESTING", "TOPOLOGY");
838 topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */
839 }
808 840
809 if ((GNUNET_YES == 841 if ((GNUNET_YES ==
810 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "connect_topology", 842 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
811 &connect_topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&connection_topology, connect_topology_str))) 843 "connect_topology",
812 { 844 &connect_topology_str)) &&
813 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 845 (GNUNET_NO ==
814 "Invalid connect topology `%s' given for section %s option %s\n", connect_topology_str, "TESTING", "CONNECT_TOPOLOGY"); 846 GNUNET_TESTING_topology_get (&connection_topology,
815 } 847 connect_topology_str)))
816 GNUNET_free_non_null(connect_topology_str); 848 {
849 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
850 "Invalid connect topology `%s' given for section %s option %s\n",
851 connect_topology_str, "TESTING", "CONNECT_TOPOLOGY");
852 }
853 GNUNET_free_non_null (connect_topology_str);
817 if ((GNUNET_YES == 854 if ((GNUNET_YES ==
818 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "connect_topology_option", 855 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
819 &connect_topology_option_str)) && (GNUNET_NO == GNUNET_TESTING_topology_option_get(&connect_topology_option, connect_topology_option_str))) 856 "connect_topology_option",
820 { 857 &connect_topology_option_str)) &&
821 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 858 (GNUNET_NO ==
822 "Invalid connect topology option `%s' given for section %s option %s\n", connect_topology_option_str, "TESTING", "CONNECT_TOPOLOGY_OPTION"); 859 GNUNET_TESTING_topology_option_get (&connect_topology_option,
823 connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */ 860 connect_topology_option_str)))
824 } 861 {
825 GNUNET_free_non_null(connect_topology_option_str); 862 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
863 "Invalid connect topology option `%s' given for section %s option %s\n",
864 connect_topology_option_str, "TESTING",
865 "CONNECT_TOPOLOGY_OPTION");
866 connect_topology_option = GNUNET_TESTING_TOPOLOGY_OPTION_ALL; /* Defaults to NONE, set to ALL */
867 }
868 GNUNET_free_non_null (connect_topology_option_str);
826 if (GNUNET_YES == 869 if (GNUNET_YES ==
827 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "connect_topology_option_modifier", 870 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
828 &connect_topology_option_modifier_string)) 871 "connect_topology_option_modifier",
872 &connect_topology_option_modifier_string))
873 {
874 if (sscanf
875 (connect_topology_option_modifier_string, "%lf",
876 &connect_topology_option_modifier) != 1)
829 { 877 {
830 if (sscanf(connect_topology_option_modifier_string, "%lf", &connect_topology_option_modifier) != 1) 878 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
831 { 879 _
832 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 880 ("Invalid value `%s' for option `%s' in section `%s': expected float\n"),
833 _("Invalid value `%s' for option `%s' in section `%s': expected float\n"), 881 connect_topology_option_modifier_string,
834 connect_topology_option_modifier_string, 882 "connect_topology_option_modifier", "TESTING");
835 "connect_topology_option_modifier", 883 }
836 "TESTING"); 884 GNUNET_free (connect_topology_option_modifier_string);
837 } 885 }
838 GNUNET_free (connect_topology_option_modifier_string); 886
839 } 887 if (GNUNET_YES !=
840 888 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
841 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "blacklist_transports", 889 "blacklist_transports",
842 &blacklist_transports)) 890 &blacklist_transports))
843 blacklist_transports = NULL; 891 blacklist_transports = NULL;
844 892
845 if ((GNUNET_YES == 893 if ((GNUNET_YES ==
846 GNUNET_CONFIGURATION_get_value_string(cfg, "testing", "blacklist_topology", 894 GNUNET_CONFIGURATION_get_value_string (cfg, "testing",
847 &blacklist_topology_str)) && (GNUNET_NO == GNUNET_TESTING_topology_get(&blacklist_topology, blacklist_topology_str))) 895 "blacklist_topology",
848 { 896 &blacklist_topology_str)) &&
849 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 897 (GNUNET_NO ==
850 "Invalid topology `%s' given for section %s option %s\n", topology_str, "TESTING", "BLACKLIST_TOPOLOGY"); 898 GNUNET_TESTING_topology_get (&blacklist_topology,
851 } 899 blacklist_topology_str)))
852 GNUNET_free_non_null(topology_str); 900 {
853 GNUNET_free_non_null(blacklist_topology_str); 901 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
902 "Invalid topology `%s' given for section %s option %s\n",
903 topology_str, "TESTING", "BLACKLIST_TOPOLOGY");
904 }
905 GNUNET_free_non_null (topology_str);
906 GNUNET_free_non_null (blacklist_topology_str);
854 907
855 /* Get number of peers to start from configuration */ 908 /* Get number of peers to start from configuration */
856 if (GNUNET_SYSERR == 909 if (GNUNET_SYSERR ==
@@ -872,21 +925,22 @@ run (void *cls,
872 peers_left = num_peers; 925 peers_left = num_peers;
873 926
874 /* Set up a task to end testing if peer start fails */ 927 /* Set up a task to end testing if peer start fails */
875 die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), 928 die_task =
876 &end_badly, "didn't generate all hostkeys within a reasonable amount of time!!!"); 929 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
877 930 (GNUNET_TIME_UNIT_SECONDS,
878 pg = GNUNET_TESTING_daemons_start (cfg, 931 SECONDS_PER_PEER_START * num_peers),
879 peers_left, /* Total number of peers */ 932 &end_badly,
880 peers_left, /* Number of outstanding connections */ 933 "didn't generate all hostkeys within a reasonable amount of time!!!");
881 peers_left, /* Number of parallel ssh connections, or peers being started at once */ 934
882 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, SECONDS_PER_PEER_START * num_peers), 935 pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */
883 &hostkey_callback, 936 peers_left, /* Number of outstanding connections */
884 NULL, 937 peers_left, /* Number of parallel ssh connections, or peers being started at once */
885 &peers_started_callback, 938 GNUNET_TIME_relative_multiply
886 NULL, 939 (GNUNET_TIME_UNIT_SECONDS,
887 &topology_callback, 940 SECONDS_PER_PEER_START * num_peers),
888 NULL, 941 &hostkey_callback, NULL,
889 NULL); 942 &peers_started_callback, NULL,
943 &topology_callback, NULL, NULL);
890 944
891} 945}
892 946
@@ -894,10 +948,11 @@ static int
894check () 948check ()
895{ 949{
896 int ret; 950 int ret;
951
897 /* Arguments for GNUNET_PROGRAM_run */ 952 /* Arguments for GNUNET_PROGRAM_run */
898 char *const argv[] = {"test-dht-multipeer", /* Name to give running binary */ 953 char *const argv[] = { "test-dht-multipeer", /* Name to give running binary */
899 "-c", 954 "-c",
900 "test_dht_multipeer_data.conf", /* Config file to use */ 955 "test_dht_multipeer_data.conf", /* Config file to use */
901#if VERBOSE 956#if VERBOSE
902 "-L", "DEBUG", 957 "-L", "DEBUG",
903#endif 958#endif
@@ -908,12 +963,13 @@ check ()
908 }; 963 };
909 /* Run the run function as a new program */ 964 /* Run the run function as a new program */
910 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 965 ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
911 argv, "test-dht-multipeer", "nohelp", 966 argv, "test-dht-multipeer", "nohelp",
912 options, &run, &ok); 967 options, &run, &ok);
913 if (ret != GNUNET_OK) 968 if (ret != GNUNET_OK)
914 { 969 {
915 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "`test-dht-multipeer': Failed with error code %d\n", ret); 970 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
916 } 971 "`test-dht-multipeer': Failed with error code %d\n", ret);
972 }
917 return ok; 973 return ok;
918} 974}
919 975
@@ -935,9 +991,10 @@ main (int argc, char *argv[])
935 * of by the testing framework. 991 * of by the testing framework.
936 */ 992 */
937 if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK) 993 if (GNUNET_DISK_directory_remove (test_directory) != GNUNET_OK)
938 { 994 {
939 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Failed to remove testing directory %s\n", test_directory); 995 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
940 } 996 "Failed to remove testing directory %s\n", test_directory);
997 }
941 return ret; 998 return ret;
942} 999}
943 1000