diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/fs/fs_test_lib.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/fs/fs_test_lib.c')
-rw-r--r-- | src/fs/fs_test_lib.c | 139 |
1 files changed, 53 insertions, 86 deletions
diff --git a/src/fs/fs_test_lib.c b/src/fs/fs_test_lib.c index 334432232..17291d1bd 100644 --- a/src/fs/fs_test_lib.c +++ b/src/fs/fs_test_lib.c | |||
@@ -151,8 +151,8 @@ shutdown_callback (void *cls, const char *emsg) | |||
151 | 151 | ||
152 | if (emsg != NULL) | 152 | if (emsg != NULL) |
153 | { | 153 | { |
154 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 154 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Shutdown of peers failed: %s\n", |
155 | "Shutdown of peers failed: %s\n", emsg); | 155 | emsg); |
156 | } | 156 | } |
157 | else | 157 | else |
158 | { | 158 | { |
@@ -213,23 +213,20 @@ progress_cb (void *cls, const struct GNUNET_FS_ProgressInfo *info) | |||
213 | break; | 213 | break; |
214 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: | 214 | case GNUNET_FS_STATUS_PUBLISH_PROGRESS: |
215 | if (daemon->verbose) | 215 | if (daemon->verbose) |
216 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 216 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Publishing at %llu/%llu bytes\n", |
217 | "Publishing at %llu/%llu bytes\n", | ||
218 | (unsigned long long) info->value.publish.completed, | 217 | (unsigned long long) info->value.publish.completed, |
219 | (unsigned long long) info->value.publish.size); | 218 | (unsigned long long) info->value.publish.size); |
220 | break; | 219 | break; |
221 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: | 220 | case GNUNET_FS_STATUS_DOWNLOAD_PROGRESS: |
222 | if (daemon->verbose) | 221 | if (daemon->verbose) |
223 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 222 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Download at %llu/%llu bytes\n", |
224 | "Download at %llu/%llu bytes\n", | ||
225 | (unsigned long long) info->value.download.completed, | 223 | (unsigned long long) info->value.download.completed, |
226 | (unsigned long long) info->value.download.size); | 224 | (unsigned long long) info->value.download.size); |
227 | break; | 225 | break; |
228 | case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: | 226 | case GNUNET_FS_STATUS_DOWNLOAD_COMPLETED: |
229 | GNUNET_SCHEDULER_cancel (daemon->download_timeout_task); | 227 | GNUNET_SCHEDULER_cancel (daemon->download_timeout_task); |
230 | daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK; | 228 | daemon->download_timeout_task = GNUNET_SCHEDULER_NO_TASK; |
231 | GNUNET_SCHEDULER_add_continuation (&report_success, | 229 | GNUNET_SCHEDULER_add_continuation (&report_success, daemon, |
232 | daemon, | ||
233 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 230 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
234 | break; | 231 | break; |
235 | case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: | 232 | case GNUNET_FS_STATUS_DOWNLOAD_ACTIVE: |
@@ -260,8 +257,7 @@ struct StartContext | |||
260 | 257 | ||
261 | 258 | ||
262 | static void | 259 | static void |
263 | notify_running (void *cls, | 260 | notify_running (void *cls, const struct GNUNET_PeerIdentity *id, |
264 | const struct GNUNET_PeerIdentity *id, | ||
265 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 261 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
266 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 262 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
267 | { | 263 | { |
@@ -270,8 +266,8 @@ notify_running (void *cls, | |||
270 | 266 | ||
271 | if (emsg != NULL) | 267 | if (emsg != NULL) |
272 | { | 268 | { |
273 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 269 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to start daemon: %s\n"), |
274 | _("Failed to start daemon: %s\n"), emsg); | 270 | emsg); |
275 | return; | 271 | return; |
276 | } | 272 | } |
277 | i = 0; | 273 | i = 0; |
@@ -291,19 +287,16 @@ notify_running (void *cls, | |||
291 | sctx->have++; | 287 | sctx->have++; |
292 | if (sctx->have == sctx->total) | 288 | if (sctx->have == sctx->total) |
293 | { | 289 | { |
294 | GNUNET_SCHEDULER_add_continuation (sctx->cont, | 290 | GNUNET_SCHEDULER_add_continuation (sctx->cont, sctx->cont_cls, |
295 | sctx->cont_cls, | ||
296 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 291 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
297 | sctx->daemons[0]->gcfg = sctx->cfg; | 292 | sctx->daemons[0]->gcfg = sctx->cfg; |
298 | GNUNET_SCHEDULER_cancel (sctx->timeout_task); | 293 | GNUNET_SCHEDULER_cancel (sctx->timeout_task); |
299 | for (i = 0; i < sctx->total; i++) | 294 | for (i = 0; i < sctx->total; i++) |
300 | { | 295 | { |
301 | sctx->daemons[i]->fs = GNUNET_FS_start (sctx->daemons[i]->cfg, | 296 | sctx->daemons[i]->fs = |
302 | "<tester>", | 297 | GNUNET_FS_start (sctx->daemons[i]->cfg, "<tester>", &progress_cb, |
303 | &progress_cb, | 298 | sctx->daemons[i], GNUNET_FS_FLAGS_NONE, |
304 | sctx->daemons[i], | 299 | GNUNET_FS_OPTIONS_END); |
305 | GNUNET_FS_FLAGS_NONE, | ||
306 | GNUNET_FS_OPTIONS_END); | ||
307 | } | 300 | } |
308 | GNUNET_free (sctx); | 301 | GNUNET_free (sctx); |
309 | } | 302 | } |
@@ -330,8 +323,7 @@ start_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
330 | sctx->daemons[i] = NULL; | 323 | sctx->daemons[i] = NULL; |
331 | } | 324 | } |
332 | GNUNET_CONFIGURATION_destroy (sctx->cfg); | 325 | GNUNET_CONFIGURATION_destroy (sctx->cfg); |
333 | GNUNET_SCHEDULER_add_continuation (sctx->cont, | 326 | GNUNET_SCHEDULER_add_continuation (sctx->cont, sctx->cont_cls, |
334 | sctx->cont_cls, | ||
335 | GNUNET_SCHEDULER_REASON_TIMEOUT); | 327 | GNUNET_SCHEDULER_REASON_TIMEOUT); |
336 | GNUNET_free (sctx); | 328 | GNUNET_free (sctx); |
337 | } | 329 | } |
@@ -371,8 +363,7 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file, | |||
371 | GNUNET_break (0); | 363 | GNUNET_break (0); |
372 | GNUNET_CONFIGURATION_destroy (sctx->cfg); | 364 | GNUNET_CONFIGURATION_destroy (sctx->cfg); |
373 | GNUNET_free (sctx); | 365 | GNUNET_free (sctx); |
374 | GNUNET_SCHEDULER_add_continuation (cont, | 366 | GNUNET_SCHEDULER_add_continuation (cont, cont_cls, |
375 | cont_cls, | ||
376 | GNUNET_SCHEDULER_REASON_TIMEOUT); | 367 | GNUNET_SCHEDULER_REASON_TIMEOUT); |
377 | return; | 368 | return; |
378 | } | 369 | } |
@@ -380,13 +371,11 @@ GNUNET_FS_TEST_daemons_start (const char *template_cfg_file, | |||
380 | daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon)); | 371 | daemons[i] = GNUNET_malloc (sizeof (struct GNUNET_FS_TestDaemon)); |
381 | sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg, total, total, /* Outstanding connections */ | 372 | sctx->group = GNUNET_TESTING_daemons_start (sctx->cfg, total, total, /* Outstanding connections */ |
382 | total, /* Outstanding ssh connections */ | 373 | total, /* Outstanding ssh connections */ |
383 | timeout, | 374 | timeout, NULL, NULL, |
384 | NULL, | 375 | ¬ify_running, sctx, NULL, NULL, |
385 | NULL, | 376 | NULL); |
386 | ¬ify_running, | 377 | sctx->timeout_task = |
387 | sctx, NULL, NULL, NULL); | 378 | GNUNET_SCHEDULER_add_delayed (timeout, &start_timeout, sctx); |
388 | sctx->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, | ||
389 | &start_timeout, sctx); | ||
390 | } | 379 | } |
391 | 380 | ||
392 | 381 | ||
@@ -412,10 +401,8 @@ struct ConnectContext | |||
412 | * @param emsg error message (NULL on success) | 401 | * @param emsg error message (NULL on success) |
413 | */ | 402 | */ |
414 | static void | 403 | static void |
415 | notify_connection (void *cls, | 404 | notify_connection (void *cls, const struct GNUNET_PeerIdentity *first, |
416 | const struct GNUNET_PeerIdentity *first, | 405 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
417 | const struct GNUNET_PeerIdentity *second, | ||
418 | uint32_t distance, | ||
419 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 406 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
420 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 407 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
421 | struct GNUNET_TESTING_Daemon *first_daemon, | 408 | struct GNUNET_TESTING_Daemon *first_daemon, |
@@ -425,13 +412,12 @@ notify_connection (void *cls, | |||
425 | struct ConnectContext *cc = cls; | 412 | struct ConnectContext *cc = cls; |
426 | 413 | ||
427 | if (emsg != NULL) | 414 | if (emsg != NULL) |
428 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 415 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to connect peers: %s\n", |
429 | "Failed to connect peers: %s\n", emsg); | 416 | emsg); |
430 | GNUNET_SCHEDULER_add_continuation (cc->cont, | 417 | GNUNET_SCHEDULER_add_continuation (cc->cont, cc->cont_cls, |
431 | cc->cont_cls, | 418 | (emsg != |
432 | (emsg != NULL) | 419 | NULL) ? GNUNET_SCHEDULER_REASON_TIMEOUT : |
433 | ? GNUNET_SCHEDULER_REASON_TIMEOUT | 420 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
434 | : GNUNET_SCHEDULER_REASON_PREREQ_DONE); | ||
435 | GNUNET_free (cc); | 421 | GNUNET_free (cc); |
436 | } | 422 | } |
437 | 423 | ||
@@ -457,11 +443,9 @@ GNUNET_FS_TEST_daemons_connect (struct GNUNET_FS_TestDaemon *daemon1, | |||
457 | ncc = GNUNET_malloc (sizeof (struct ConnectContext)); | 443 | ncc = GNUNET_malloc (sizeof (struct ConnectContext)); |
458 | ncc->cont = cont; | 444 | ncc->cont = cont; |
459 | ncc->cont_cls = cont_cls; | 445 | ncc->cont_cls = cont_cls; |
460 | GNUNET_TESTING_daemons_connect (daemon1->daemon, | 446 | GNUNET_TESTING_daemons_connect (daemon1->daemon, daemon2->daemon, timeout, |
461 | daemon2->daemon, | 447 | CONNECT_ATTEMPTS, GNUNET_YES, |
462 | timeout, | 448 | ¬ify_connection, ncc); |
463 | CONNECT_ATTEMPTS, | ||
464 | GNUNET_YES, ¬ify_connection, ncc); | ||
465 | } | 449 | } |
466 | 450 | ||
467 | 451 | ||
@@ -610,11 +594,8 @@ file_generator (void *cls, uint64_t offset, size_t max, void *buf, char **emsg) | |||
610 | */ | 594 | */ |
611 | void | 595 | void |
612 | GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon, | 596 | GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon, |
613 | struct GNUNET_TIME_Relative timeout, | 597 | struct GNUNET_TIME_Relative timeout, uint32_t anonymity, |
614 | uint32_t anonymity, | 598 | int do_index, uint64_t size, uint32_t seed, |
615 | int do_index, | ||
616 | uint64_t size, | ||
617 | uint32_t seed, | ||
618 | unsigned int verbose, | 599 | unsigned int verbose, |
619 | GNUNET_FS_TEST_UriContinuation cont, void *cont_cls) | 600 | GNUNET_FS_TEST_UriContinuation cont, void *cont_cls) |
620 | { | 601 | { |
@@ -657,29 +638,23 @@ GNUNET_FS_TEST_publish (struct GNUNET_FS_TestDaemon *daemon, | |||
657 | off += bsize; | 638 | off += bsize; |
658 | } | 639 | } |
659 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); | 640 | GNUNET_assert (GNUNET_OK == GNUNET_DISK_file_close (fh)); |
660 | fi = GNUNET_FS_file_information_create_from_file (daemon->fs, | 641 | fi = GNUNET_FS_file_information_create_from_file (daemon->fs, daemon, |
661 | daemon, | ||
662 | daemon->publish_tmp_file, | 642 | daemon->publish_tmp_file, |
663 | NULL, NULL, | 643 | NULL, NULL, do_index, |
664 | do_index, &bo); | 644 | &bo); |
665 | } | 645 | } |
666 | else | 646 | else |
667 | { | 647 | { |
668 | fi = GNUNET_FS_file_information_create_from_reader (daemon->fs, | 648 | fi = GNUNET_FS_file_information_create_from_reader (daemon->fs, daemon, |
669 | daemon, | 649 | size, &file_generator, |
670 | size, | 650 | daemon, NULL, NULL, |
671 | &file_generator, | 651 | do_index, &bo); |
672 | daemon, | ||
673 | NULL, | ||
674 | NULL, do_index, &bo); | ||
675 | } | 652 | } |
676 | daemon->publish_context = GNUNET_FS_publish_start (daemon->fs, | 653 | daemon->publish_context = |
677 | fi, | 654 | GNUNET_FS_publish_start (daemon->fs, fi, NULL, NULL, NULL, |
678 | NULL, NULL, NULL, | 655 | GNUNET_FS_PUBLISH_OPTION_NONE); |
679 | GNUNET_FS_PUBLISH_OPTION_NONE); | 656 | daemon->publish_timeout_task = |
680 | daemon->publish_timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, | 657 | GNUNET_SCHEDULER_add_delayed (timeout, &publish_timeout, daemon); |
681 | &publish_timeout, | ||
682 | daemon); | ||
683 | } | 658 | } |
684 | 659 | ||
685 | 660 | ||
@@ -716,10 +691,8 @@ download_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
716 | void | 691 | void |
717 | GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon, | 692 | GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon, |
718 | struct GNUNET_TIME_Relative timeout, | 693 | struct GNUNET_TIME_Relative timeout, |
719 | uint32_t anonymity, | 694 | uint32_t anonymity, uint32_t seed, |
720 | uint32_t seed, | 695 | const struct GNUNET_FS_Uri *uri, unsigned int verbose, |
721 | const struct GNUNET_FS_Uri *uri, | ||
722 | unsigned int verbose, | ||
723 | GNUNET_SCHEDULER_Task cont, void *cont_cls) | 696 | GNUNET_SCHEDULER_Task cont, void *cont_cls) |
724 | { | 697 | { |
725 | uint64_t size; | 698 | uint64_t size; |
@@ -730,18 +703,12 @@ GNUNET_FS_TEST_download (struct GNUNET_FS_TestDaemon *daemon, | |||
730 | daemon->download_cont = cont; | 703 | daemon->download_cont = cont; |
731 | daemon->download_cont_cls = cont_cls; | 704 | daemon->download_cont_cls = cont_cls; |
732 | daemon->download_seed = seed; | 705 | daemon->download_seed = seed; |
733 | daemon->download_context = GNUNET_FS_download_start (daemon->fs, | 706 | daemon->download_context = |
734 | uri, | 707 | GNUNET_FS_download_start (daemon->fs, uri, NULL, NULL, NULL, 0, size, |
735 | NULL, NULL, | 708 | anonymity, GNUNET_FS_DOWNLOAD_OPTION_NONE, NULL, |
736 | NULL, | 709 | NULL); |
737 | 0, | 710 | daemon->download_timeout_task = |
738 | size, | 711 | GNUNET_SCHEDULER_add_delayed (timeout, &download_timeout, daemon); |
739 | anonymity, | ||
740 | GNUNET_FS_DOWNLOAD_OPTION_NONE, | ||
741 | NULL, NULL); | ||
742 | daemon->download_timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, | ||
743 | &download_timeout, | ||
744 | daemon); | ||
745 | } | 712 | } |
746 | 713 | ||
747 | /* end of test_fs_lib.c */ | 714 | /* end of test_fs_lib.c */ |