diff options
Diffstat (limited to 'src/testing/testing.c')
-rw-r--r-- | src/testing/testing.c | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/src/testing/testing.c b/src/testing/testing.c index 65441c188..a73e48024 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c | |||
@@ -126,7 +126,7 @@ testing_init (void *cls, | |||
126 | { | 126 | { |
127 | d->server = NULL; | 127 | d->server = NULL; |
128 | if (GNUNET_YES == d->dead) | 128 | if (GNUNET_YES == d->dead) |
129 | GNUNET_TESTING_daemon_stop (d, d->dead_cb, d->dead_cb_cls, GNUNET_YES); | 129 | GNUNET_TESTING_daemon_stop (d, GNUNET_TIME_absolute_get_remaining(d->max_timeout), d->dead_cb, d->dead_cb_cls, GNUNET_YES); |
130 | else if (NULL != cb) | 130 | else if (NULL != cb) |
131 | cb (d->cb_cls, NULL, d->cfg, d, | 131 | cb (d->cb_cls, NULL, d->cfg, d, |
132 | _("Failed to connect to core service\n")); | 132 | _("Failed to connect to core service\n")); |
@@ -141,7 +141,7 @@ testing_init (void *cls, | |||
141 | d->server = server; | 141 | d->server = server; |
142 | d->running = GNUNET_YES; | 142 | d->running = GNUNET_YES; |
143 | if (GNUNET_YES == d->dead) | 143 | if (GNUNET_YES == d->dead) |
144 | GNUNET_TESTING_daemon_stop (d, d->dead_cb, d->dead_cb_cls, GNUNET_YES); | 144 | GNUNET_TESTING_daemon_stop (d, GNUNET_TIME_absolute_get_remaining(d->max_timeout), d->dead_cb, d->dead_cb_cls, GNUNET_YES); |
145 | else if (NULL != cb) | 145 | else if (NULL != cb) |
146 | cb (d->cb_cls, my_identity, d->cfg, d, NULL); | 146 | cb (d->cb_cls, my_identity, d->cfg, d, NULL); |
147 | #if DEBUG_TESTING | 147 | #if DEBUG_TESTING |
@@ -155,7 +155,7 @@ testing_init (void *cls, | |||
155 | if (d->th == NULL) | 155 | if (d->th == NULL) |
156 | { | 156 | { |
157 | if (GNUNET_YES == d->dead) | 157 | if (GNUNET_YES == d->dead) |
158 | GNUNET_TESTING_daemon_stop (d, d->dead_cb, d->dead_cb_cls, GNUNET_YES); | 158 | GNUNET_TESTING_daemon_stop (d, GNUNET_TIME_absolute_get_remaining(d->max_timeout), d->dead_cb, d->dead_cb_cls, GNUNET_YES); |
159 | else if (NULL != d->cb) | 159 | else if (NULL != d->cb) |
160 | d->cb (d->cb_cls, &d->id, d->cfg, d, | 160 | d->cb (d->cb_cls, &d->id, d->cfg, d, |
161 | _("Failed to connect to transport service!\n")); | 161 | _("Failed to connect to transport service!\n")); |
@@ -196,15 +196,14 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
196 | /* confirm copying complete */ | 196 | /* confirm copying complete */ |
197 | if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) | 197 | if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) |
198 | { | 198 | { |
199 | d->wait_runs++; | 199 | if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).value == 0) |
200 | if (d->wait_runs > MAX_EXEC_WAIT_RUNS) | ||
201 | { | 200 | { |
202 | cb = d->cb; | 201 | cb = d->cb; |
203 | d->cb = NULL; | 202 | d->cb = NULL; |
204 | if (NULL != cb) | 203 | if (NULL != cb) |
205 | cb (d->cb_cls, | 204 | cb (d->cb_cls, |
206 | NULL, | 205 | NULL, |
207 | d->cfg, d, _("`scp' does not seem to terminate.\n")); | 206 | d->cfg, d, _("`scp' does not seem to terminate (timeout copying config).\n")); |
208 | return; | 207 | return; |
209 | } | 208 | } |
210 | /* wait some more */ | 209 | /* wait some more */ |
@@ -305,7 +304,6 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
305 | "gnunet-peerinfo"); | 304 | "gnunet-peerinfo"); |
306 | #endif | 305 | #endif |
307 | d->phase = SP_HOSTKEY_CREATE; | 306 | d->phase = SP_HOSTKEY_CREATE; |
308 | d->wait_runs = 0; | ||
309 | d->task | 307 | d->task |
310 | = GNUNET_SCHEDULER_add_delayed (d->sched, | 308 | = GNUNET_SCHEDULER_add_delayed (d->sched, |
311 | GNUNET_CONSTANTS_EXEC_WAIT, | 309 | GNUNET_CONSTANTS_EXEC_WAIT, |
@@ -336,8 +334,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
336 | 334 | ||
337 | if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) | 335 | if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) |
338 | { | 336 | { |
339 | d->wait_runs++; | 337 | if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).value == 0) |
340 | if (d->wait_runs > MAX_EXEC_WAIT_RUNS) | ||
341 | { | 338 | { |
342 | cb = d->cb; | 339 | cb = d->cb; |
343 | d->cb = NULL; | 340 | d->cb = NULL; |
@@ -391,8 +388,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
391 | /* Fall through */ | 388 | /* Fall through */ |
392 | case SP_HOSTKEY_CREATED: | 389 | case SP_HOSTKEY_CREATED: |
393 | /* wait for topology finished */ | 390 | /* wait for topology finished */ |
394 | d->wait_runs++; | 391 | if ((GNUNET_YES == d->dead) || (GNUNET_TIME_absolute_get_remaining(d->max_timeout).value == 0)) |
395 | if ((GNUNET_YES == d->dead) || (d->wait_runs > MAX_EXEC_WAIT_RUNS)) | ||
396 | { | 392 | { |
397 | cb = d->cb; | 393 | cb = d->cb; |
398 | d->cb = NULL; | 394 | d->cb = NULL; |
@@ -475,7 +471,6 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
475 | "gnunet-arm", "gnunet-service-core"); | 471 | "gnunet-arm", "gnunet-service-core"); |
476 | #endif | 472 | #endif |
477 | d->phase = SP_START_ARMING; | 473 | d->phase = SP_START_ARMING; |
478 | d->wait_runs = 0; | ||
479 | d->task | 474 | d->task |
480 | = GNUNET_SCHEDULER_add_delayed (d->sched, | 475 | = GNUNET_SCHEDULER_add_delayed (d->sched, |
481 | GNUNET_CONSTANTS_EXEC_WAIT, | 476 | GNUNET_CONSTANTS_EXEC_WAIT, |
@@ -484,8 +479,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
484 | case SP_START_ARMING: | 479 | case SP_START_ARMING: |
485 | if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) | 480 | if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) |
486 | { | 481 | { |
487 | d->wait_runs++; | 482 | if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).value == 0) |
488 | if (d->wait_runs > MAX_EXEC_WAIT_RUNS) | ||
489 | { | 483 | { |
490 | cb = d->cb; | 484 | cb = d->cb; |
491 | d->cb = NULL; | 485 | d->cb = NULL; |
@@ -530,8 +524,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
530 | /* confirm copying complete */ | 524 | /* confirm copying complete */ |
531 | if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) | 525 | if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) |
532 | { | 526 | { |
533 | d->wait_runs++; | 527 | if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).value == 0) |
534 | if (d->wait_runs > MAX_EXEC_WAIT_RUNS) | ||
535 | { | 528 | { |
536 | d->dead_cb (d->dead_cb_cls, | 529 | d->dead_cb (d->dead_cb_cls, |
537 | _("either `gnunet-arm' or `ssh' does not seem to terminate.\n")); | 530 | _("either `gnunet-arm' or `ssh' does not seem to terminate.\n")); |
@@ -601,8 +594,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
601 | /* confirm copying complete */ | 594 | /* confirm copying complete */ |
602 | if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) | 595 | if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) |
603 | { | 596 | { |
604 | d->wait_runs++; | 597 | if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).value == 0) /* FIXME: config update should take timeout parameter! */ |
605 | if (d->wait_runs > MAX_EXEC_WAIT_RUNS) | ||
606 | { | 598 | { |
607 | cb = d->cb; | 599 | cb = d->cb; |
608 | d->cb = NULL; | 600 | d->cb = NULL; |
@@ -659,6 +651,7 @@ GNUNET_TESTING_daemon_continue_startup(struct GNUNET_TESTING_Daemon *daemon) | |||
659 | * | 651 | * |
660 | * @param sched scheduler to use | 652 | * @param sched scheduler to use |
661 | * @param cfg configuration to use | 653 | * @param cfg configuration to use |
654 | * @param timeout how long to wait starting up peers | ||
662 | * @param hostname name of the machine where to run GNUnet | 655 | * @param hostname name of the machine where to run GNUnet |
663 | * (use NULL for localhost). | 656 | * (use NULL for localhost). |
664 | * @param hostkey_callback function to call once the hostkey has been | 657 | * @param hostkey_callback function to call once the hostkey has been |
@@ -672,6 +665,7 @@ GNUNET_TESTING_daemon_continue_startup(struct GNUNET_TESTING_Daemon *daemon) | |||
672 | struct GNUNET_TESTING_Daemon * | 665 | struct GNUNET_TESTING_Daemon * |
673 | GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | 666 | GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, |
674 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 667 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
668 | struct GNUNET_TIME_Relative timeout, | ||
675 | const char *hostname, | 669 | const char *hostname, |
676 | GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, | 670 | GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, |
677 | void *hostkey_cls, | 671 | void *hostkey_cls, |
@@ -701,6 +695,7 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, | |||
701 | ret->hostkey_cls = hostkey_cls; | 695 | ret->hostkey_cls = hostkey_cls; |
702 | ret->cb = cb; | 696 | ret->cb = cb; |
703 | ret->cb_cls = cb_cls; | 697 | ret->cb_cls = cb_cls; |
698 | ret->max_timeout = GNUNET_TIME_relative_to_absolute(timeout); | ||
704 | ret->cfg = GNUNET_CONFIGURATION_dup (cfg); | 699 | ret->cfg = GNUNET_CONFIGURATION_dup (cfg); |
705 | GNUNET_CONFIGURATION_set_value_string (ret->cfg, | 700 | GNUNET_CONFIGURATION_set_value_string (ret->cfg, |
706 | "PATHS", | 701 | "PATHS", |
@@ -868,7 +863,6 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d, | |||
868 | } | 863 | } |
869 | 864 | ||
870 | GNUNET_free_non_null(del_arg); | 865 | GNUNET_free_non_null(del_arg); |
871 | d->wait_runs = 0; | ||
872 | d->task | 866 | d->task |
873 | = GNUNET_SCHEDULER_add_delayed (d->sched, | 867 | = GNUNET_SCHEDULER_add_delayed (d->sched, |
874 | GNUNET_CONSTANTS_EXEC_WAIT, | 868 | GNUNET_CONSTANTS_EXEC_WAIT, |
@@ -881,6 +875,7 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d, | |||
881 | * Stops a GNUnet daemon. | 875 | * Stops a GNUnet daemon. |
882 | * | 876 | * |
883 | * @param d the daemon that should be stopped | 877 | * @param d the daemon that should be stopped |
878 | * @param timeout how long to wait for process for shutdown to complete | ||
884 | * @param cb function called once the daemon was stopped | 879 | * @param cb function called once the daemon was stopped |
885 | * @param cb_cls closure for cb | 880 | * @param cb_cls closure for cb |
886 | * @param delete_files GNUNET_YES to remove files, GNUNET_NO | 881 | * @param delete_files GNUNET_YES to remove files, GNUNET_NO |
@@ -889,6 +884,7 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d, | |||
889 | */ | 884 | */ |
890 | void | 885 | void |
891 | GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, | 886 | GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, |
887 | struct GNUNET_TIME_Relative timeout, | ||
892 | GNUNET_TESTING_NotifyCompletion cb, void *cb_cls, | 888 | GNUNET_TESTING_NotifyCompletion cb, void *cb_cls, |
893 | int delete_files) | 889 | int delete_files) |
894 | { | 890 | { |
@@ -929,8 +925,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, | |||
929 | _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); | 925 | _("Terminating peer `%4s'\n"), GNUNET_i2s (&d->id)); |
930 | #endif | 926 | #endif |
931 | 927 | ||
932 | d->phase = SP_SHUTDOWN_START; | 928 | d->phase = SP_SHUTDOWN_START; |
933 | |||
934 | /* Check if this is a local or remote process */ | 929 | /* Check if this is a local or remote process */ |
935 | if (NULL != d->hostname) | 930 | if (NULL != d->hostname) |
936 | { | 931 | { |
@@ -969,7 +964,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, | |||
969 | } | 964 | } |
970 | 965 | ||
971 | GNUNET_free_non_null(del_arg); | 966 | GNUNET_free_non_null(del_arg); |
972 | d->wait_runs = 0; | 967 | d->max_timeout = GNUNET_TIME_relative_to_absolute(timeout); |
973 | d->task | 968 | d->task |
974 | = GNUNET_SCHEDULER_add_delayed (d->sched, | 969 | = GNUNET_SCHEDULER_add_delayed (d->sched, |
975 | GNUNET_CONSTANTS_EXEC_WAIT, | 970 | GNUNET_CONSTANTS_EXEC_WAIT, |