aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-05-10 13:38:57 +0000
committerNathan S. Evans <evans@in.tum.de>2010-05-10 13:38:57 +0000
commit8219a880d84f4cbaf18e0d2443662e52c528d307 (patch)
treeb7b6998ab32f9c1eec40cc376c844cb6f7de7808 /src/testing
parentaf7d13f4f43d04c821b2bc70ec65a0900d65159b (diff)
downloadgnunet-8219a880d84f4cbaf18e0d2443662e52c528d307.tar.gz
gnunet-8219a880d84f4cbaf18e0d2443662e52c528d307.zip
change testing library to use timeout for peer and peergroup startup so testcase/user can decide how long to wait as opposed to arbitrary wait counts
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/test_testing.c6
-rw-r--r--src/testing/test_testing_connect.c8
-rw-r--r--src/testing/test_testing_group.c7
-rw-r--r--src/testing/test_testing_group_remote.c3
-rw-r--r--src/testing/test_testing_topology.c8
-rw-r--r--src/testing/testing.c39
-rw-r--r--src/testing/testing_group.c14
7 files changed, 47 insertions, 38 deletions
diff --git a/src/testing/test_testing.c b/src/testing/test_testing.c
index b33f3ee1b..9d8efe3f8 100644
--- a/src/testing/test_testing.c
+++ b/src/testing/test_testing.c
@@ -26,6 +26,8 @@
26 26
27#define VERBOSE GNUNET_NO 27#define VERBOSE GNUNET_NO
28 28
29#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
30
29static int ok; 31static int ok;
30 32
31static void 33static void
@@ -56,7 +58,7 @@ my_cb (void *cls,
56 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 58 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
57 "Daemon `%s' started, will now stop it.\n", GNUNET_i2s (id)); 59 "Daemon `%s' started, will now stop it.\n", GNUNET_i2s (id));
58#endif 60#endif
59 GNUNET_TESTING_daemon_stop (d, &end_cb, NULL, GNUNET_YES); 61 GNUNET_TESTING_daemon_stop (d, TIMEOUT, &end_cb, NULL, GNUNET_YES);
60} 62}
61 63
62 64
@@ -72,7 +74,7 @@ run (void *cls,
72#if VERBOSE 74#if VERBOSE
73 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemon.\n"); 75 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemon.\n");
74#endif 76#endif
75 d = GNUNET_TESTING_daemon_start (sched, cfg, NULL, NULL, NULL, &my_cb, NULL); 77 d = GNUNET_TESTING_daemon_start (sched, cfg, TIMEOUT, NULL, NULL, NULL, &my_cb, NULL);
76 GNUNET_assert (d != NULL); 78 GNUNET_assert (d != NULL);
77} 79}
78 80
diff --git a/src/testing/test_testing_connect.c b/src/testing/test_testing_connect.c
index a55207cec..3ce8acd71 100644
--- a/src/testing/test_testing_connect.c
+++ b/src/testing/test_testing_connect.c
@@ -69,14 +69,14 @@ static void
69end1_cb (void *cls, const char *emsg) 69end1_cb (void *cls, const char *emsg)
70{ 70{
71 GNUNET_assert (emsg == NULL); 71 GNUNET_assert (emsg == NULL);
72 GNUNET_TESTING_daemon_stop (d2, &end2_cb, NULL, GNUNET_YES); 72 GNUNET_TESTING_daemon_stop (d2, TIMEOUT, &end2_cb, NULL, GNUNET_YES);
73 d2 = NULL; 73 d2 = NULL;
74} 74}
75 75
76static void 76static void
77finish_testing(void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc) 77finish_testing(void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
78{ 78{
79 GNUNET_TESTING_daemon_stop (d1, &end1_cb, NULL, GNUNET_YES); 79 GNUNET_TESTING_daemon_stop (d1, TIMEOUT, &end1_cb, NULL, GNUNET_YES);
80 d1 = NULL; 80 d1 = NULL;
81} 81}
82 82
@@ -121,7 +121,7 @@ my_cb1 (void *cls,
121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 121 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
122 "Daemon `%s' started.\n", GNUNET_i2s (id)); 122 "Daemon `%s' started.\n", GNUNET_i2s (id));
123#endif 123#endif
124 d2 = GNUNET_TESTING_daemon_start (sched, c2, NULL, NULL, NULL, &my_cb2, NULL); 124 d2 = GNUNET_TESTING_daemon_start (sched, c2, TIMEOUT, NULL, NULL, NULL, &my_cb2, NULL);
125 GNUNET_assert (d2 != NULL); 125 GNUNET_assert (d2 != NULL);
126 126
127} 127}
@@ -142,7 +142,7 @@ run (void *cls,
142 GNUNET_CONFIGURATION_parse (c1, "test_testing_connect_peer1.conf"); 142 GNUNET_CONFIGURATION_parse (c1, "test_testing_connect_peer1.conf");
143 c2 = GNUNET_CONFIGURATION_create (); 143 c2 = GNUNET_CONFIGURATION_create ();
144 GNUNET_CONFIGURATION_parse (c2, "test_testing_connect_peer2.conf"); 144 GNUNET_CONFIGURATION_parse (c2, "test_testing_connect_peer2.conf");
145 d1 = GNUNET_TESTING_daemon_start (sched, c1, NULL, NULL, NULL, &my_cb1, NULL); 145 d1 = GNUNET_TESTING_daemon_start (sched, c1, TIMEOUT, NULL, NULL, NULL, &my_cb1, NULL);
146 GNUNET_assert (d1 != NULL); 146 GNUNET_assert (d1 != NULL);
147} 147}
148 148
diff --git a/src/testing/test_testing_group.c b/src/testing/test_testing_group.c
index 966945003..2429c4525 100644
--- a/src/testing/test_testing_group.c
+++ b/src/testing/test_testing_group.c
@@ -33,7 +33,6 @@
33 */ 33 */
34#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300) 34#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300)
35 35
36
37static int ok; 36static int ok;
38 37
39static int peers_left; 38static int peers_left;
@@ -64,12 +63,13 @@ my_cb (void *cls,
64 { 63 {
65 sleep(2); /* Give other services a chance to initialize before killing */ 64 sleep(2); /* Give other services a chance to initialize before killing */
66 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started successfully, ending test!\n"); 65 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers started successfully, ending test!\n");
67 GNUNET_TESTING_daemons_stop (pg); 66 GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
68 ok = 0; 67 ok = 0;
69 } 68 }
70 else if (failed_peers == peers_left) 69 else if (failed_peers == peers_left)
71 { 70 {
72 GNUNET_TESTING_daemons_stop (pg); 71 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Too many peers failed, ending test!\n");
72 GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
73 } 73 }
74} 74}
75 75
@@ -88,6 +88,7 @@ run (void *cls,
88 peers_left = NUM_PEERS; 88 peers_left = NUM_PEERS;
89 pg = GNUNET_TESTING_daemons_start (sched, cfg, 89 pg = GNUNET_TESTING_daemons_start (sched, cfg,
90 peers_left, 90 peers_left,
91 TIMEOUT,
91 NULL, NULL, 92 NULL, NULL,
92 &my_cb, NULL, NULL, NULL, NULL); 93 &my_cb, NULL, NULL, NULL, NULL);
93 GNUNET_assert (pg != NULL); 94 GNUNET_assert (pg != NULL);
diff --git a/src/testing/test_testing_group_remote.c b/src/testing/test_testing_group_remote.c
index c1bd2c8a6..6970fb634 100644
--- a/src/testing/test_testing_group_remote.c
+++ b/src/testing/test_testing_group_remote.c
@@ -59,7 +59,7 @@ my_cb (void *cls,
59 peers_left--; 59 peers_left--;
60 if (peers_left == 0) 60 if (peers_left == 0)
61 { 61 {
62 GNUNET_TESTING_daemons_stop (pg); 62 GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
63 ok = 0; 63 ok = 0;
64 } 64 }
65} 65}
@@ -88,6 +88,7 @@ run (void *cls,
88 peers_left = num_peers; 88 peers_left = num_peers;
89 pg = GNUNET_TESTING_daemons_start (sched, cfg, 89 pg = GNUNET_TESTING_daemons_start (sched, cfg,
90 peers_left, 90 peers_left,
91 TIMEOUT,
91 &my_cb, NULL, NULL, NULL, hostnames); 92 &my_cb, NULL, NULL, NULL, hostnames);
92 GNUNET_assert (pg != NULL); 93 GNUNET_assert (pg != NULL);
93} 94}
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index 30d83a72f..d00b52a0c 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -33,7 +33,7 @@
33#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600) 33#define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
34 34
35/** 35/**
36 * How long until we give up on connecting the peers? 36 * How long until we give up on starting the peers?
37 */ 37 */
38#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) 38#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
39 39
@@ -177,7 +177,7 @@ finish_testing ()
177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
178 "Calling daemons_stop\n"); 178 "Calling daemons_stop\n");
179#endif 179#endif
180 GNUNET_TESTING_daemons_stop (pg); 180 GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
181#if VERBOSE 181#if VERBOSE
182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
183 "daemons_stop finished\n"); 183 "daemons_stop finished\n");
@@ -280,7 +280,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext * tc)
280 280
281 if (pg != NULL) 281 if (pg != NULL)
282 { 282 {
283 GNUNET_TESTING_daemons_stop (pg); 283 GNUNET_TESTING_daemons_stop (pg, TIMEOUT);
284 ok = 7331; /* Opposite of leet */ 284 ok = 7331; /* Opposite of leet */
285 } 285 }
286 else 286 else
@@ -729,7 +729,7 @@ run (void *cls,
729 &end_badly, "didn't start all daemons in reasonable amount of time!!!"); 729 &end_badly, "didn't start all daemons in reasonable amount of time!!!");
730 730
731 pg = GNUNET_TESTING_daemons_start (sched, cfg, 731 pg = GNUNET_TESTING_daemons_start (sched, cfg,
732 peers_left, &hostkey_callback, NULL, &peers_started_callback, NULL, 732 peers_left, TIMEOUT, &hostkey_callback, NULL, &peers_started_callback, NULL,
733 &topology_callback, NULL, NULL); 733 &topology_callback, NULL, NULL);
734 734
735} 735}
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)
672struct GNUNET_TESTING_Daemon * 665struct GNUNET_TESTING_Daemon *
673GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched, 666GNUNET_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 */
890void 885void
891GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d, 886GNUNET_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,
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 57cea8007..eb83c9b78 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -240,6 +240,10 @@ struct GNUNET_TESTING_PeerGroup
240 */ 240 */
241 unsigned int total; 241 unsigned int total;
242 242
243 /**
244 * At what time should we fail the peer startup process?
245 */
246 struct GNUNET_TIME_Absolute max_timeout;
243}; 247};
244 248
245/** 249/**
@@ -2380,6 +2384,7 @@ GNUNET_TESTING_daemons_continue_startup(struct GNUNET_TESTING_PeerGroup *pg)
2380 * @param sched scheduler to use 2384 * @param sched scheduler to use
2381 * @param cfg configuration template to use 2385 * @param cfg configuration template to use
2382 * @param total number of daemons to start 2386 * @param total number of daemons to start
2387 * @param timeout total time allowed for peers to start
2383 * @param hostkey_callback function to call on each peers hostkey generation 2388 * @param hostkey_callback function to call on each peers hostkey generation
2384 * if NULL, peers will be started by this call, if non-null, 2389 * if NULL, peers will be started by this call, if non-null,
2385 * GNUNET_TESTING_daemons_continue_startup must be called after 2390 * GNUNET_TESTING_daemons_continue_startup must be called after
@@ -2397,6 +2402,7 @@ struct GNUNET_TESTING_PeerGroup *
2397GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, 2402GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
2398 const struct GNUNET_CONFIGURATION_Handle *cfg, 2403 const struct GNUNET_CONFIGURATION_Handle *cfg,
2399 unsigned int total, 2404 unsigned int total,
2405 struct GNUNET_TIME_Relative timeout,
2400 GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback, 2406 GNUNET_TESTING_NotifyHostkeyCreated hostkey_callback,
2401 void *hostkey_cls, 2407 void *hostkey_cls,
2402 GNUNET_TESTING_NotifyDaemonRunning cb, 2408 GNUNET_TESTING_NotifyDaemonRunning cb,
@@ -2432,6 +2438,7 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
2432 pg->notify_connection = connect_callback; 2438 pg->notify_connection = connect_callback;
2433 pg->notify_connection_cls = connect_callback_cls; 2439 pg->notify_connection_cls = connect_callback_cls;
2434 pg->total = total; 2440 pg->total = total;
2441 pg->max_timeout = GNUNET_TIME_relative_to_absolute(timeout);
2435 pg->peers = GNUNET_malloc (total * sizeof (struct PeerData)); 2442 pg->peers = GNUNET_malloc (total * sizeof (struct PeerData));
2436 if (NULL != hostnames) 2443 if (NULL != hostnames)
2437 { 2444 {
@@ -2533,6 +2540,7 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
2533 pg->peers[off].pg = pg; 2540 pg->peers[off].pg = pg;
2534 pg->peers[off].daemon = GNUNET_TESTING_daemon_start (sched, 2541 pg->peers[off].daemon = GNUNET_TESTING_daemon_start (sched,
2535 pcfg, 2542 pcfg,
2543 timeout,
2536 hostname, 2544 hostname,
2537 hostkey_callback, 2545 hostkey_callback,
2538 hostkey_cls, 2546 hostkey_cls,
@@ -2628,9 +2636,11 @@ GNUNET_TESTING_daemons_restart (struct GNUNET_TESTING_PeerGroup *pg, GNUNET_TEST
2628 * Shutdown all peers started in the given group. 2636 * Shutdown all peers started in the given group.
2629 * 2637 *
2630 * @param pg handle to the peer group 2638 * @param pg handle to the peer group
2639 * @param timeout how long to wait for shutdown
2640 *
2631 */ 2641 */
2632void 2642void
2633GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg) 2643GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg, struct GNUNET_TIME_Relative timeout)
2634{ 2644{
2635 unsigned int off; 2645 unsigned int off;
2636 2646
@@ -2642,7 +2652,7 @@ GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg)
2642 as well... */ 2652 as well... */
2643 2653
2644 if (NULL != pg->peers[off].daemon) 2654 if (NULL != pg->peers[off].daemon)
2645 GNUNET_TESTING_daemon_stop (pg->peers[off].daemon, NULL, NULL, GNUNET_YES); 2655 GNUNET_TESTING_daemon_stop (pg->peers[off].daemon, timeout, NULL, NULL, GNUNET_YES);
2646 if (NULL != pg->peers[off].cfg) 2656 if (NULL != pg->peers[off].cfg)
2647 GNUNET_CONFIGURATION_destroy (pg->peers[off].cfg); 2657 GNUNET_CONFIGURATION_destroy (pg->peers[off].cfg);
2648 2658