[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r36163 - gnunet/src/rps
From: |
gnunet |
Subject: |
[GNUnet-SVN] r36163 - gnunet/src/rps |
Date: |
Sun, 2 Aug 2015 16:48:32 +0200 |
Author: ch3
Date: 2015-08-02 16:48:32 +0200 (Sun, 02 Aug 2015)
New Revision: 36163
Modified:
gnunet/src/rps/test_rps.c
Log:
-improved testing
Modified: gnunet/src/rps/test_rps.c
===================================================================
--- gnunet/src/rps/test_rps.c 2015-08-02 14:48:30 UTC (rev 36162)
+++ gnunet/src/rps/test_rps.c 2015-08-02 14:48:32 UTC (rev 36163)
@@ -267,7 +267,12 @@
*/
static struct GNUNET_SCHEDULER_Task *churn_task;
+/**
+ * Identifier for the churn task that runs periodically
+ */
+static struct GNUNET_SCHEDULER_Task *shutdown_task;
+
/**
* Called to initialise the given RPSPeer
*/
@@ -453,25 +458,23 @@
* Test the success of a single test
*/
static int
-evaluate (struct RPSPeer *loc_rps_peers,
- unsigned int num_loc_rps_peers,
- unsigned int expected_recv)
+evaluate (void)
{
unsigned int i;
int tmp_ok;
- tmp_ok = (1 == loc_rps_peers[0].num_rec_ids);
+ tmp_ok = 1;
- for (i = 0 ; i < num_loc_rps_peers ; i++)
+ for (i = 0; i < num_peers; i++)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%u. peer [%s] received %u of %u expected peer_ids: %i\n",
- i,
- GNUNET_i2s (loc_rps_peers[i].peer_id),
- loc_rps_peers[i].num_rec_ids,
- expected_recv,
- (1 == loc_rps_peers[i].num_rec_ids));
- tmp_ok &= (1 == loc_rps_peers[i].num_rec_ids);
+ "%u. peer [%s] received %u of %u expected peer_ids: %i\n",
+ i,
+ GNUNET_i2s (rps_peers[i].peer_id),
+ rps_peers[i].num_rec_ids,
+ rps_peers[i].num_ids_to_request,
+ (rps_peers[i].num_ids_to_request == rps_peers[i].num_rec_ids));
+ tmp_ok &= (rps_peers[i].num_ids_to_request == rps_peers[i].num_rec_ids);
}
return tmp_ok? 0 : 1;
}
@@ -495,7 +498,7 @@
* Task run on timeout to shut everything down.
*/
static void
-shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_op (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
unsigned int i;
@@ -650,7 +653,7 @@
*/
static void
rps_disconnect_adapter (void *cls,
- void *op_result)
+ void *op_result)
{
struct GNUNET_RPS_Handle *h = op_result;
GNUNET_RPS_disconnect (h);
@@ -665,7 +668,7 @@
static int
default_eval_cb (void)
{
- return evaluate (rps_peers, num_peers, 1);
+ return evaluate ();
}
static int
@@ -708,7 +711,7 @@
GNUNET_i2s (rps_peer->peer_id),
n);
- for (i = 0 ; i < n ; i++)
+ for (i = 0; i < n; i++)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%u: %s\n",
@@ -717,6 +720,12 @@
GNUNET_array_append (rps_peer->rec_ids, rps_peer->num_rec_ids,
recv_peers[i]);
}
+
+ if (0 == evaluate ())
+ {
+ GNUNET_SCHEDULER_cancel (shutdown_task);
+ shutdown_task = GNUNET_SCHEDULER_add_now (&shutdown_op, NULL);
+ }
}
/**
@@ -843,6 +852,16 @@
/***********************************
* MALICIOUS
***********************************/
+
+/**
+ * Initialise only non-mal RPSPeers
+ */
+static void mal_init_peer (struct RPSPeer *rps_peer)
+{
+ if (rps_peer->index >= round (portion * num_peers))
+ rps_peer->num_ids_to_request = 1;
+}
+
static void
mal_pre (void *cls, struct GNUNET_RPS_Handle *h)
{
@@ -888,18 +907,7 @@
#endif /* ENABLE_MALICIOUS */
}
-static int
-mal_eval (void)
-{
- unsigned int num_mal_peers;
- num_mal_peers = round (num_peers * portion);
- return evaluate (&rps_peers[num_mal_peers],
- num_peers - (num_mal_peers),
- 1);
-}
-
-
/***********************************
* SINGLE_REQUEST
***********************************/
@@ -1270,7 +1278,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Scan of directory failed\n");
}
- return 0;
+ return evaluate ();
}
@@ -1331,7 +1339,7 @@
if (NULL != churn_task)
GNUNET_SCHEDULER_cancel (churn_task);
- GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_task, NULL);
+ shutdown_task = GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_op, NULL);
}
@@ -1360,7 +1368,7 @@
{
cur_test_run.pre_test = mal_pre;
cur_test_run.main_test = mal_cb;
- cur_test_run.eval_cb = mal_eval;
+ cur_test_run.init_peer = mal_init_peer;
if (strstr (argv[0], "_1") != NULL)
{
@@ -1432,6 +1440,7 @@
num_peers = 1;
cur_test_run.main_test = req_cancel_cb;
cur_test_run.eval_cb = no_eval;
+ timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
}
else if (strstr (argv[0], "profiler") != NULL)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r36163 - gnunet/src/rps,
gnunet <=