aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorwachs <wachs@140774ce-b5e7-0310-ab8b-a85725594a96>2013-01-07 15:52:52 +0000
committerwachs <wachs@140774ce-b5e7-0310-ab8b-a85725594a96>2013-01-07 15:52:52 +0000
commit18e0094f66f5cebf9a101405c4c5b9b723a81e6b (patch)
treefb0ddd53cb413b301b731730218feb56cb0487e0 /src/gns
parentaceeea673654c7f0ef01d40fc6086982ddb88ec8 (diff)
fixing test by debugging (but still fails)
git-svn-id: https://gnunet.org/svn/gnunet@25707 140774ce-b5e7-0310-ab8b-a85725594a96
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 5791e399fe..7f83ca3d85 100644
--- a/src/gns/test_gns_dht_three_peers.c
+++ b/src/gns/test_gns_dht_three_peers.c
@@ -49,6 +49,7 @@
/* Timeout for entire testcase */
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 60)
+#define SETUP_TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10)
/* Global return value (0 for success, anything else for failure) */
static int ok;
@@ -58,6 +59,8 @@ static GNUNET_SCHEDULER_TaskIdentifier die_task;
static GNUNET_SCHEDULER_TaskIdentifier wait_task;
+static GNUNET_SCHEDULER_TaskIdentifier setup_task;
+
static struct GNUNET_CRYPTO_ShortHashCode dave_hash;
static struct GNUNET_CRYPTO_ShortHashCode bob_hash;
@@ -173,6 +176,37 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
}
static void
+setup_end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ setup_task = GNUNET_SCHEDULER_NO_TASK;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Timeout during setup, test failed\n");
+
+ if (NULL != connect_ops[0])
+ {
+ GNUNET_TESTBED_operation_done (connect_ops[0]);
+ connect_ops[0] = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect peer 0 and 1\n");
+ }
+
+ if (NULL != connect_ops[1])
+ {
+ GNUNET_TESTBED_operation_done (connect_ops[1]);
+ connect_ops[1] = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect peer 1 and 2\n");
+ }
+
+ if (NULL != connect_ops[2])
+ {
+ GNUNET_TESTBED_operation_done (connect_ops[2]);
+ connect_ops[2] = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Could not connect peer 0 and 2\n");
+ }
+
+ GNUNET_SCHEDULER_shutdown ();
+ ok = GNUNET_SYSERR;
+}
+
+static void
end_now ()
{
GNUNET_SCHEDULER_add_now (&end, NULL);
@@ -261,6 +295,11 @@ void
all_connected ()
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Created all connections! Waiting for PUTs\n");
+ if (GNUNET_SCHEDULER_NO_TASK != setup_task)
+ {
+ GNUNET_SCHEDULER_cancel (setup_task);
+ setup_task = GNUNET_SCHEDULER_NO_TASK;
+ }
wait_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &commence_testing, NULL);
}
@@ -573,6 +612,8 @@ void testbed_master (void *cls,
GNUNET_assert (NULL != peers);
cpeers = peers;
+ setup_task = GNUNET_SCHEDULER_add_delayed (SETUP_TIMEOUT, &setup_end_badly, NULL);
+
/* peer 0: dave */
GNUNET_assert (NULL != peers[0]);
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
break;
case GNUNET_TESTBED_ET_CONNECT:
connections ++;
+ if ((event->details.peer_connect.peer1 == cpeers[0]) &&
+ (event->details.peer_connect.peer2 == cpeers[1]))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 0 and 1 are connected\n");
+ GNUNET_TESTBED_operation_done (connect_ops[0]);
+ connect_ops[0] = NULL;
+ }
+
+ if ((event->details.peer_connect.peer1 == cpeers[1]) &&
+ (event->details.peer_connect.peer2 == cpeers[2]))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 and 2 are connected\n");
+ GNUNET_TESTBED_operation_done (connect_ops[1]);
+ connect_ops[1] = NULL;
+ }
+
+ if ((event->details.peer_connect.peer1 == cpeers[0]) &&
+ (event->details.peer_connect.peer2 == cpeers[2]))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 0 and 2 are connected\n");
+ GNUNET_TESTBED_operation_done (connect_ops[2]);
+ connect_ops[2] = NULL;
+ }
if (connections == 3)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All peers connected\n");
- GNUNET_TESTBED_operation_done (connect_ops[0]);
- connect_ops[0] = NULL;
- GNUNET_TESTBED_operation_done (connect_ops[1]);
- connect_ops[1] = NULL;
- GNUNET_TESTBED_operation_done (connect_ops[2]);
- connect_ops[2] = NULL;
all_connected ();
}
break;