summaryrefslogtreecommitdiff
path: root/src/rps/test_rps.c
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2015-05-19 22:41:36 +0000
committerJulius Bünger <buenger@mytum.de>2015-05-19 22:41:36 +0000
commit39a851d4c34ba9a622cac5be5fbf242f8fcc6485 (patch)
tree122cffdc57b3a444b815843f3789ea7612e7897e /src/rps/test_rps.c
parentb1ae28f03cdefc73799aadf2651b522c101c0f92 (diff)
downloadgnunet-39a851d4c34ba9a622cac5be5fbf242f8fcc6485.tar.gz
gnunet-39a851d4c34ba9a622cac5be5fbf242f8fcc6485.zip
-restructured test
Diffstat (limited to 'src/rps/test_rps.c')
-rw-r--r--src/rps/test_rps.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 87b0620ee..f8f918d35 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -35,12 +35,13 @@
35/** 35/**
36 * How many peers do we start? 36 * How many peers do we start?
37 */ 37 */
38#define NUM_PEERS 5 38uint32_t num_peers;
39 39
40/** 40/**
41 * How long do we run the test? 41 * How long do we run the test?
42 */ 42 */
43#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) 43//#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)
44static struct GNUNET_TIME_Relative timeout;
44 45
45 46
46/** 47/**
@@ -152,12 +153,12 @@ struct RPSPeer
152/** 153/**
153 * Information for all the peers. 154 * Information for all the peers.
154 */ 155 */
155static struct RPSPeer rps_peers[NUM_PEERS]; 156static struct RPSPeer *rps_peers;
156 157
157/** 158/**
158 * IDs of the peers. 159 * IDs of the peers.
159 */ 160 */
160static struct GNUNET_PeerIdentity rps_peer_ids[NUM_PEERS]; 161static struct GNUNET_PeerIdentity *rps_peer_ids;
161 162
162/** 163/**
163 * Number of online peers. 164 * Number of online peers.
@@ -204,6 +205,11 @@ typedef int (*EvaluationCallback) (void);
204struct SingleTestRun 205struct SingleTestRun
205{ 206{
206 /** 207 /**
208 * Name of the test
209 */
210 char *name;
211
212 /**
207 * Called directly after connecting to the service 213 * Called directly after connecting to the service
208 */ 214 */
209 PreTest pre_test; 215 PreTest pre_test;
@@ -385,7 +391,7 @@ seed_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
385 unsigned int i; 391 unsigned int i;
386 392
387 // TODO if malicious don't seed mal peers 393 // TODO if malicious don't seed mal peers
388 amount = round (.5 * NUM_PEERS); 394 amount = round (.5 * num_peers);
389 395
390 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding peers:\n"); 396 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Seeding peers:\n");
391 for (i = 0 ; i < amount ; i++) 397 for (i = 0 ; i < amount ; i++)
@@ -511,8 +517,15 @@ rps_disconnect_adapter (void *cls,
511static int 517static int
512default_eval_cb (void) 518default_eval_cb (void)
513{ 519{
514 return evaluate (rps_peers, NUM_PEERS, 1); 520 return evaluate (rps_peers, num_peers, 1);
515} 521}
522
523static int
524no_eval (void)
525{
526 return 1;
527}
528
516/*********************************** 529/***********************************
517 * MALICIOUS 530 * MALICIOUS
518***********************************/ 531***********************************/
@@ -525,7 +538,7 @@ mal_pre (void *cls, struct GNUNET_RPS_Handle *h)
525 538
526 GNUNET_assert (1 >= portion 539 GNUNET_assert (1 >= portion
527 && 0 < portion); 540 && 0 < portion);
528 num_mal_peers = round (portion * NUM_PEERS); 541 num_mal_peers = round (portion * num_peers);
529 542
530 if (rps_peer->index < num_mal_peers) 543 if (rps_peer->index < num_mal_peers)
531 { 544 {
@@ -548,7 +561,7 @@ mal_cb (struct RPSPeer *rps_peer)
548 #ifdef ENABLE_MALICIOUS 561 #ifdef ENABLE_MALICIOUS
549 GNUNET_assert (1 >= portion 562 GNUNET_assert (1 >= portion
550 && 0 < portion); 563 && 0 < portion);
551 num_mal_peers = round (portion * NUM_PEERS); 564 num_mal_peers = round (portion * num_peers);
552 565
553 if (rps_peer->index >= num_mal_peers) 566 if (rps_peer->index >= num_mal_peers)
554 { /* It's useless to ask a malicious peer about a random sample - 567 { /* It's useless to ask a malicious peer about a random sample -
@@ -566,9 +579,9 @@ mal_eval (void)
566{ 579{
567 unsigned int num_mal_peers; 580 unsigned int num_mal_peers;
568 581
569 num_mal_peers = round (NUM_PEERS * portion); 582 num_mal_peers = round (num_peers * portion);
570 return evaluate (&rps_peers[num_mal_peers], 583 return evaluate (&rps_peers[num_mal_peers],
571 NUM_PEERS - (num_mal_peers), 584 num_peers - (num_mal_peers),
572 1); 585 1);
573} 586}
574 587
@@ -605,12 +618,6 @@ seed_cb (struct RPSPeer *rps_peer)
605 seed_peers, rps_peer); 618 seed_peers, rps_peer);
606} 619}
607 620
608static int
609seed_eval (void)
610{
611 return 1;
612}
613
614/*********************************** 621/***********************************
615 * SEED_BIG 622 * SEED_BIG
616***********************************/ 623***********************************/
@@ -795,7 +802,12 @@ run (void *cls,
795 &rps_disconnect_adapter, 802 &rps_disconnect_adapter,
796 &rps_peers[i]); 803 &rps_peers[i]);
797 } 804 }
798 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &shutdown_task, NULL); 805
806 if (NULL != churn_task)
807 GNUNET_SCHEDULER_cancel (churn_task);
808
809 //GNUNET_SCHEDULER_add_delayed (TIMEOUT, &shutdown_task, NULL);
810 GNUNET_SCHEDULER_add_delayed (timeout, &shutdown_task, NULL);
799} 811}
800 812
801 813