aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-01-07 15:52:52 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-01-07 15:52:52 +0000
commit4f7aeb69790dc198a032ad3184a5b86f92c9f010 (patch)
treefb0ddd53cb413b301b731730218feb56cb0487e0 /src/gns
parent317a32c0cd8040dc14c574a50fe2bfd43da19c93 (diff)
downloadgnunet-4f7aeb69790dc198a032ad3184a5b86f92c9f010.tar.gz
gnunet-4f7aeb69790dc198a032ad3184a5b86f92c9f010.zip
fixing test by debugging (but still fails)
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/test_gns_dht_three_peers.c70
1 files changed, 64 insertions, 6 deletions
diff --git a/src/gns/test_gns_dht_three_peers.c b/src/gns/test_gns_dht_three_peers.c
index 5791e399f..7f83ca3d8 100644
--- a/src/gns/test_gns_dht_three_peers.c
+++ b/src/gns/test_gns_dht_three_peers.c
@@ -49,6 +49,7 @@
49 49
50/* Timeout for entire testcase */ 50/* Timeout for entire testcase */
51#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60) 51#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60)
52#define SETUP_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
52 53
53/* Global return value (0 for success, anything else for failure) */ 54/* Global return value (0 for success, anything else for failure) */
54static int ok; 55static int ok;
@@ -58,6 +59,8 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task;
58 59
59static GNUNET_SCHEDULER_TaskIdentifier wait_task; 60static GNUNET_SCHEDULER_TaskIdentifier wait_task;
60 61
62static GNUNET_SCHEDULER_TaskIdentifier setup_task;
63
61static struct GNUNET_CRYPTO_ShortHashCode dave_hash; 64static struct GNUNET_CRYPTO_ShortHashCode dave_hash;
62 65
63static struct GNUNET_CRYPTO_ShortHashCode bob_hash; 66static struct GNUNET_CRYPTO_ShortHashCode bob_hash;
@@ -173,6 +176,37 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
173} 176}
174 177
175static void 178static void
179setup_end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
180{
181 setup_task = GNUNET_SCHEDULER_NO_TASK;
182 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout during setup, test failed\n");
183
184 if (NULL != connect_ops[0])
185 {
186 GNUNET_TESTBED_operation_done (connect_ops[0]);
187 connect_ops[0] = NULL;
188 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect peer 0 and 1\n");
189 }
190
191 if (NULL != connect_ops[1])
192 {
193 GNUNET_TESTBED_operation_done (connect_ops[1]);
194 connect_ops[1] = NULL;
195 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect peer 1 and 2\n");
196 }
197
198 if (NULL != connect_ops[2])
199 {
200 GNUNET_TESTBED_operation_done (connect_ops[2]);
201 connect_ops[2] = NULL;
202 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect peer 0 and 2\n");
203 }
204
205 GNUNET_SCHEDULER_shutdown ();
206 ok = GNUNET_SYSERR;
207}
208
209static void
176end_now () 210end_now ()
177{ 211{
178 GNUNET_SCHEDULER_add_now (&end, NULL); 212 GNUNET_SCHEDULER_add_now (&end, NULL);
@@ -261,6 +295,11 @@ void
261all_connected () 295all_connected ()
262{ 296{
263 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Created all connections! Waiting for PUTs\n"); 297 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Created all connections! Waiting for PUTs\n");
298 if (GNUNET_SCHEDULER_NO_TASK != setup_task)
299 {
300 GNUNET_SCHEDULER_cancel (setup_task);
301 setup_task = GNUNET_SCHEDULER_NO_TASK;
302 }
264 wait_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &commence_testing, NULL); 303 wait_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &commence_testing, NULL);
265} 304}
266 305
@@ -573,6 +612,8 @@ void testbed_master (void *cls,
573 GNUNET_assert (NULL != peers); 612 GNUNET_assert (NULL != peers);
574 cpeers = peers; 613 cpeers = peers;
575 614
615 setup_task = GNUNET_SCHEDULER_add_delayed (SETUP_TIMEOUT, &setup_end_badly, NULL);
616
576 /* peer 0: dave */ 617 /* peer 0: dave */
577 GNUNET_assert (NULL != peers[0]); 618 GNUNET_assert (NULL != peers[0]);
578 get_cfg_ops[0] = GNUNET_TESTBED_peer_get_information (peers[0], 619 get_cfg_ops[0] = GNUNET_TESTBED_peer_get_information (peers[0],
@@ -606,15 +647,32 @@ void testbed_controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformat
606 break; 647 break;
607 case GNUNET_TESTBED_ET_CONNECT: 648 case GNUNET_TESTBED_ET_CONNECT:
608 connections ++; 649 connections ++;
650 if ((event->details.peer_connect.peer1 == cpeers[0]) &&
651 (event->details.peer_connect.peer2 == cpeers[1]))
652 {
653 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 0 and 1 are connected\n");
654 GNUNET_TESTBED_operation_done (connect_ops[0]);
655 connect_ops[0] = NULL;
656 }
657
658 if ((event->details.peer_connect.peer1 == cpeers[1]) &&
659 (event->details.peer_connect.peer2 == cpeers[2]))
660 {
661 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 and 2 are connected\n");
662 GNUNET_TESTBED_operation_done (connect_ops[1]);
663 connect_ops[1] = NULL;
664 }
665
666 if ((event->details.peer_connect.peer1 == cpeers[0]) &&
667 (event->details.peer_connect.peer2 == cpeers[2]))
668 {
669 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 0 and 2 are connected\n");
670 GNUNET_TESTBED_operation_done (connect_ops[2]);
671 connect_ops[2] = NULL;
672 }
609 if (connections == 3) 673 if (connections == 3)
610 { 674 {
611 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers connected\n"); 675 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers connected\n");
612 GNUNET_TESTBED_operation_done (connect_ops[0]);
613 connect_ops[0] = NULL;
614 GNUNET_TESTBED_operation_done (connect_ops[1]);
615 connect_ops[1] = NULL;
616 GNUNET_TESTBED_operation_done (connect_ops[2]);
617 connect_ops[2] = NULL;
618 all_connected (); 676 all_connected ();
619 } 677 }
620 break; 678 break;