diff options
author | Julius Bünger <buenger@mytum.de> | 2015-04-03 11:28:21 +0000 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2015-04-03 11:28:21 +0000 |
commit | d780cfa0eca9d603d59f7fb0380088fe096a7e57 (patch) | |
tree | 58f1f63a0f8fd200793e634d014bbb2d63567356 /src | |
parent | 4c8b28dea0b03bd08c2bbc787394f4a06e383e4d (diff) | |
download | gnunet-d780cfa0eca9d603d59f7fb0380088fe096a7e57.tar.gz gnunet-d780cfa0eca9d603d59f7fb0380088fe096a7e57.zip |
-restructured tests
Diffstat (limited to 'src')
-rw-r--r-- | src/rps/test_rps.c | 375 |
1 files changed, 230 insertions, 145 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 52684bfde..d1b7f9eaa 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c | |||
@@ -40,25 +40,7 @@ | |||
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, 40) | 43 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) |
44 | |||
45 | |||
46 | /** | ||
47 | * Different tests to run | ||
48 | */ | ||
49 | #define SINGLE_REQUEST 1 | ||
50 | #define DELAYED_REQUESTS 2 | ||
51 | #define SEED 3 | ||
52 | #define SEED_BIG 4 | ||
53 | #define SINGLE_PEER_SEED 5 | ||
54 | #define SEED_REQUEST 6 | ||
55 | #define REQUEST_CANCEL 7 | ||
56 | //TODO start big mal | ||
57 | |||
58 | /** | ||
59 | * What test are we running? | ||
60 | */ | ||
61 | unsigned int test_type = 0; | ||
62 | 44 | ||
63 | 45 | ||
64 | /** | 46 | /** |
@@ -100,7 +82,7 @@ struct RPSPeer | |||
100 | /** | 82 | /** |
101 | * A request handle to check for an request | 83 | * A request handle to check for an request |
102 | */ | 84 | */ |
103 | struct GNUNET_RPS_Request_Handle *req_handle; | 85 | //struct GNUNET_RPS_Request_Handle *req_handle; |
104 | 86 | ||
105 | /** | 87 | /** |
106 | * Received PeerIDs | 88 | * Received PeerIDs |
@@ -131,6 +113,45 @@ static int ok; | |||
131 | 113 | ||
132 | 114 | ||
133 | /** | 115 | /** |
116 | * Called directly after connecting to the service | ||
117 | */ | ||
118 | typedef void (*PreTest) (void *cls, struct GNUNET_RPS_Handle *h); | ||
119 | |||
120 | /** | ||
121 | * Called from within #rps_connect_complete_cb () | ||
122 | * Executes functions to test the api/service | ||
123 | */ | ||
124 | typedef void (*MainTest) (struct RPSPeer *rps_peer); | ||
125 | |||
126 | /** | ||
127 | * Function called after disconnect to evaluate test success | ||
128 | */ | ||
129 | typedef int (*EvaluationCallback) (void); | ||
130 | |||
131 | |||
132 | /** | ||
133 | * Structure to define a single test | ||
134 | */ | ||
135 | struct SingleTestRun | ||
136 | { | ||
137 | /** | ||
138 | * Called directly after connecting to the service | ||
139 | */ | ||
140 | PreTest pre_test; | ||
141 | |||
142 | /** | ||
143 | * Function to execute the functions to be tested | ||
144 | */ | ||
145 | MainTest main_test; | ||
146 | |||
147 | /** | ||
148 | * Function to evaluate the test results | ||
149 | */ | ||
150 | EvaluationCallback eval_cb; | ||
151 | } cur_test_run; | ||
152 | |||
153 | |||
154 | /** | ||
134 | * Test the success of a single test | 155 | * Test the success of a single test |
135 | */ | 156 | */ |
136 | static int | 157 | static int |
@@ -173,14 +194,11 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
173 | 194 | ||
174 | 195 | ||
175 | /** | 196 | /** |
176 | * Callback to call when network size estimate is updated. | 197 | * Callback to call on receipt of a reply |
177 | * | 198 | * |
178 | * @param cls closure | 199 | * @param cls closure |
179 | * @param timestamp server timestamp | 200 | * @param n number of peers |
180 | * @param estimate the value of the current network size estimate | 201 | * @param recv_peers the received peers |
181 | * @param std_dev standard deviation (rounded down to nearest integer) | ||
182 | * of the size estimation values seen | ||
183 | * | ||
184 | */ | 202 | */ |
185 | static void | 203 | static void |
186 | handle_reply (void *cls, uint64_t n, const struct GNUNET_PeerIdentity *recv_peers) | 204 | handle_reply (void *cls, uint64_t n, const struct GNUNET_PeerIdentity *recv_peers) |
@@ -206,7 +224,7 @@ handle_reply (void *cls, uint64_t n, const struct GNUNET_PeerIdentity *recv_peer | |||
206 | 224 | ||
207 | 225 | ||
208 | /** | 226 | /** |
209 | * (Randomly) request random peers. | 227 | * Request random peers. |
210 | */ | 228 | */ |
211 | void | 229 | void |
212 | request_peers (void *cls, | 230 | request_peers (void *cls, |
@@ -289,8 +307,6 @@ rps_connect_complete_cb (void *cls, | |||
289 | { | 307 | { |
290 | struct RPSPeer *rps_peer = cls; | 308 | struct RPSPeer *rps_peer = cls; |
291 | struct GNUNET_RPS_Handle *rps = ca_result; | 309 | struct GNUNET_RPS_Handle *rps = ca_result; |
292 | //struct GNUNET_RPS_Request_Handle *req_handle; | ||
293 | uint32_t num_mal_peers; | ||
294 | 310 | ||
295 | rps_peer->rps_handle = rps; | 311 | rps_peer->rps_handle = rps; |
296 | 312 | ||
@@ -307,62 +323,7 @@ rps_connect_complete_cb (void *cls, | |||
307 | 323 | ||
308 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started client successfully\n"); | 324 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Started client successfully\n"); |
309 | 325 | ||
310 | #ifdef ENABLE_MALICIOUS | 326 | cur_test_run.main_test (rps_peer); |
311 | if (1 == mal_type | ||
312 | || 2 == mal_type) | ||
313 | { | ||
314 | GNUNET_assert (1 >= portion | ||
315 | && 0 < portion); | ||
316 | num_mal_peers = round (portion * NUM_PEERS); | ||
317 | |||
318 | if (rps_peer->index >= num_mal_peers) | ||
319 | { /* It's useless to ask a malicious peer about a random sample - | ||
320 | it's not sampling */ | ||
321 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | ||
322 | seed_peers, rps_peer); | ||
323 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | ||
324 | request_peers, rps_peer); | ||
325 | } | ||
326 | } | ||
327 | #endif /* ENABLE_MALICIOUS */ | ||
328 | |||
329 | if (SINGLE_REQUEST == test_type) | ||
330 | { | ||
331 | //(void) GNUNET_RPS_request_peers (rps, 1, handle_reply, NULL); | ||
332 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | ||
333 | request_peers, rps_peer); | ||
334 | } | ||
335 | else if (DELAYED_REQUESTS == test_type) | ||
336 | { | ||
337 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | ||
338 | request_peers, rps_peer); | ||
339 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | ||
340 | request_peers, rps_peer); | ||
341 | } | ||
342 | else if (SEED == test_type) | ||
343 | { | ||
344 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | ||
345 | seed_peers, rps_peer); | ||
346 | } | ||
347 | else if (SEED_BIG == test_type) | ||
348 | { | ||
349 | // TODO test seeding > GNUNET_SERVER_MAX_MESSAGE_SIZE peers | ||
350 | } | ||
351 | else if (SINGLE_PEER_SEED == test_type) | ||
352 | { | ||
353 | // TODO | ||
354 | } | ||
355 | else if (SEED_REQUEST == test_type) | ||
356 | { | ||
357 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | ||
358 | seed_peers, rps_peer); | ||
359 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15), | ||
360 | request_peers, rps_peer); | ||
361 | } | ||
362 | else if (REQUEST_CANCEL == test_type) | ||
363 | { | ||
364 | // TODO | ||
365 | } | ||
366 | } | 327 | } |
367 | 328 | ||
368 | 329 | ||
@@ -381,14 +342,51 @@ rps_connect_adapter (void *cls, | |||
381 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 342 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
382 | { | 343 | { |
383 | struct GNUNET_RPS_Handle *h; | 344 | struct GNUNET_RPS_Handle *h; |
384 | #ifdef ENABLE_MALICIOUS | ||
385 | uint32_t num_mal_peers; | ||
386 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | ||
387 | #endif /* ENABLE_MALICIOUS */ | ||
388 | 345 | ||
389 | h = GNUNET_RPS_connect (cfg); | 346 | h = GNUNET_RPS_connect (cfg); |
390 | 347 | ||
348 | if (NULL != cur_test_run.pre_test) | ||
349 | cur_test_run.pre_test (cls, h); | ||
350 | |||
351 | return h; | ||
352 | } | ||
353 | |||
354 | |||
355 | /** | ||
356 | * Adapter function called to destroy connection to | ||
357 | * RPS service. | ||
358 | * | ||
359 | * @param cls closure | ||
360 | * @param op_result service handle returned from the connect adapter | ||
361 | */ | ||
362 | static void | ||
363 | rps_disconnect_adapter (void *cls, | ||
364 | void *op_result) | ||
365 | { | ||
366 | struct GNUNET_RPS_Handle *h = op_result; | ||
367 | GNUNET_RPS_disconnect (h); | ||
368 | } | ||
369 | |||
370 | |||
371 | /*********************************************************************** | ||
372 | * Definition of tests | ||
373 | ***********************************************************************/ | ||
374 | |||
375 | static int | ||
376 | default_eval_cb (void) | ||
377 | { | ||
378 | return evaluate (rps_peers, NUM_PEERS, 1); | ||
379 | } | ||
380 | /*********************************** | ||
381 | * MALICIOUS | ||
382 | ***********************************/ | ||
383 | static void | ||
384 | mal_pre (void *cls, struct GNUNET_RPS_Handle *h) | ||
385 | { | ||
391 | #ifdef ENABLE_MALICIOUS | 386 | #ifdef ENABLE_MALICIOUS |
387 | uint32_t num_mal_peers; | ||
388 | struct RPSPeer *rps_peer = (struct RPSPeer *) cls; | ||
389 | |||
392 | GNUNET_assert (1 >= portion | 390 | GNUNET_assert (1 >= portion |
393 | && 0 < portion); | 391 | && 0 < portion); |
394 | num_mal_peers = round (portion * NUM_PEERS); | 392 | num_mal_peers = round (portion * NUM_PEERS); |
@@ -404,26 +402,124 @@ rps_connect_adapter (void *cls, | |||
404 | GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers, rps_peer_ids); | 402 | GNUNET_RPS_act_malicious (h, mal_type, num_mal_peers, rps_peer_ids); |
405 | } | 403 | } |
406 | #endif /* ENABLE_MALICIOUS */ | 404 | #endif /* ENABLE_MALICIOUS */ |
405 | } | ||
407 | 406 | ||
408 | return h; | 407 | static void |
408 | mal_cb (struct RPSPeer *rps_peer) | ||
409 | { | ||
410 | uint32_t num_mal_peers; | ||
411 | |||
412 | #ifdef ENABLE_MALICIOUS | ||
413 | GNUNET_assert (1 >= portion | ||
414 | && 0 < portion); | ||
415 | num_mal_peers = round (portion * NUM_PEERS); | ||
416 | |||
417 | if (rps_peer->index >= num_mal_peers) | ||
418 | { /* It's useless to ask a malicious peer about a random sample - | ||
419 | it's not sampling */ | ||
420 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | ||
421 | seed_peers, rps_peer); | ||
422 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | ||
423 | request_peers, rps_peer); | ||
424 | } | ||
425 | #endif /* ENABLE_MALICIOUS */ | ||
409 | } | 426 | } |
410 | 427 | ||
428 | static int | ||
429 | mal_eval (void) | ||
430 | { | ||
431 | unsigned int num_mal_peers; | ||
411 | 432 | ||
412 | /** | 433 | num_mal_peers = round (NUM_PEERS * portion); |
413 | * Adapter function called to destroy connection to | 434 | return evaluate (&rps_peers[num_mal_peers], |
414 | * RPS service. | 435 | NUM_PEERS - (num_mal_peers), |
415 | * | 436 | 1); |
416 | * @param cls closure | 437 | } |
417 | * @param op_result service handle returned from the connect adapter | 438 | |
418 | */ | 439 | |
440 | /*********************************** | ||
441 | * SINGLE_REQUEST | ||
442 | ***********************************/ | ||
419 | static void | 443 | static void |
420 | rps_disconnect_adapter (void *cls, | 444 | single_req_cb (struct RPSPeer *rps_peer) |
421 | void *op_result) | ||
422 | { | 445 | { |
423 | struct GNUNET_RPS_Handle *h = op_result; | 446 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), |
424 | GNUNET_RPS_disconnect (h); | 447 | request_peers, rps_peer); |
448 | } | ||
449 | |||
450 | /*********************************** | ||
451 | * DELAYED_REQUESTS | ||
452 | ***********************************/ | ||
453 | static void | ||
454 | delay_req_cb (struct RPSPeer *rps_peer) | ||
455 | { | ||
456 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | ||
457 | request_peers, rps_peer); | ||
458 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | ||
459 | request_peers, rps_peer); | ||
460 | } | ||
461 | |||
462 | /*********************************** | ||
463 | * SEED | ||
464 | ***********************************/ | ||
465 | static void | ||
466 | seed_cb (struct RPSPeer *rps_peer) | ||
467 | { | ||
468 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10), | ||
469 | seed_peers, rps_peer); | ||
425 | } | 470 | } |
426 | 471 | ||
472 | static int | ||
473 | seed_eval (void) | ||
474 | { | ||
475 | return 1; | ||
476 | } | ||
477 | |||
478 | /*********************************** | ||
479 | * SEED_BIG | ||
480 | ***********************************/ | ||
481 | static void | ||
482 | seed_big_cb (struct RPSPeer *rps_peer) | ||
483 | { | ||
484 | // TODO test seeding > GNUNET_SERVER_MAX_MESSAGE_SIZE peers | ||
485 | } | ||
486 | |||
487 | /*********************************** | ||
488 | * SINGLE_PEER_SEED | ||
489 | ***********************************/ | ||
490 | static void | ||
491 | single_peer_seed_cb (struct RPSPeer *rps_peer) | ||
492 | { | ||
493 | // TODO | ||
494 | } | ||
495 | |||
496 | /*********************************** | ||
497 | * SEED_REQUEST | ||
498 | ***********************************/ | ||
499 | static void | ||
500 | seed_req_cb (struct RPSPeer *rps_peer) | ||
501 | { | ||
502 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2), | ||
503 | seed_peers, rps_peer); | ||
504 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15), | ||
505 | request_peers, rps_peer); | ||
506 | } | ||
507 | |||
508 | //TODO start big mal | ||
509 | |||
510 | /*********************************** | ||
511 | * REQUEST_CANCEL | ||
512 | ***********************************/ | ||
513 | static void | ||
514 | req_cancel_cb (struct RPSPeer *rps_peer) | ||
515 | { | ||
516 | // TODO | ||
517 | } | ||
518 | |||
519 | /*********************************************************************** | ||
520 | * /Definition of tests | ||
521 | ***********************************************************************/ | ||
522 | |||
427 | 523 | ||
428 | /** | 524 | /** |
429 | * Actual "main" function for the testcase. | 525 | * Actual "main" function for the testcase. |
@@ -459,10 +555,6 @@ run (void *cls, | |||
459 | tmp_i); | 555 | tmp_i); |
460 | } | 556 | } |
461 | 557 | ||
462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
463 | "Type %i\n", | ||
464 | test_type); | ||
465 | |||
466 | GNUNET_assert (NUM_PEERS == num_peers); | 558 | GNUNET_assert (NUM_PEERS == num_peers); |
467 | for (i = 0 ; i < num_peers ; i++) | 559 | for (i = 0 ; i < num_peers ; i++) |
468 | { | 560 | { |
@@ -491,50 +583,67 @@ run (void *cls, | |||
491 | int | 583 | int |
492 | main (int argc, char *argv[]) | 584 | main (int argc, char *argv[]) |
493 | { | 585 | { |
494 | if (strstr (argv[0], "malicious_1") != NULL) | 586 | cur_test_run.pre_test = NULL; |
495 | { | 587 | cur_test_run.eval_cb = default_eval_cb; |
496 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test malicious peer type 1\n"); | 588 | |
497 | mal_type = 1; | 589 | if (strstr (argv[0], "malicious") != NULL) |
498 | } | ||
499 | else if (strstr (argv[0], "malicious_2") != NULL) | ||
500 | { | 590 | { |
501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test malicious peer type 2\n"); | 591 | cur_test_run.pre_test = mal_pre; |
502 | mal_type = 2; | 592 | cur_test_run.main_test = mal_cb; |
593 | cur_test_run.eval_cb = mal_eval; | ||
594 | |||
595 | if (strstr (argv[0], "_1") != NULL) | ||
596 | { | ||
597 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test malicious peer type 1\n"); | ||
598 | mal_type = 1; | ||
599 | } | ||
600 | else if (strstr (argv[0], "_2") != NULL) | ||
601 | { | ||
602 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test malicious peer type 2\n"); | ||
603 | mal_type = 2; | ||
604 | } | ||
605 | else if (strstr (argv[0], "_3") != NULL) | ||
606 | { | ||
607 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test malicious peer type 3\n"); | ||
608 | mal_type = 3; | ||
609 | } | ||
503 | } | 610 | } |
611 | |||
504 | else if (strstr (argv[0], "_single_req") != NULL) | 612 | else if (strstr (argv[0], "_single_req") != NULL) |
505 | { | 613 | { |
506 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test single request\n"); | 614 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test single request\n"); |
507 | test_type = SINGLE_REQUEST; | 615 | cur_test_run.main_test = single_req_cb; |
508 | } | 616 | } |
509 | else if (strstr (argv[0], "_delayed_reqs") != NULL) | 617 | else if (strstr (argv[0], "_delayed_reqs") != NULL) |
510 | { | 618 | { |
511 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test delayed requests\n"); | 619 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test delayed requests\n"); |
512 | test_type = DELAYED_REQUESTS; | 620 | cur_test_run.main_test = delay_req_cb; |
513 | } | 621 | } |
514 | else if (strstr (argv[0], "_seed_big") != NULL) | 622 | else if (strstr (argv[0], "_seed_big") != NULL) |
515 | { | 623 | { |
516 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding (num_peers > GNUNET_SERVER_MAX_MESSAGE_SIZE)\n"); | 624 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding (num_peers > GNUNET_SERVER_MAX_MESSAGE_SIZE)\n"); |
517 | test_type = SEED_BIG; | 625 | cur_test_run.main_test = seed_big_cb; |
518 | } | 626 | } |
519 | else if (strstr (argv[0], "_single_peer_seed") != NULL) | 627 | else if (strstr (argv[0], "_single_peer_seed") != NULL) |
520 | { | 628 | { |
521 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on a single peer\n"); | 629 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on a single peer\n"); |
522 | test_type = SINGLE_PEER_SEED; | 630 | cur_test_run.main_test = single_peer_seed_cb; |
523 | } | 631 | } |
524 | else if (strstr (argv[0], "_seed_request") != NULL) | 632 | else if (strstr (argv[0], "_seed_request") != NULL) |
525 | { | 633 | { |
526 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on multiple peers\n"); | 634 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on multiple peers\n"); |
527 | test_type = SEED_REQUEST; | 635 | cur_test_run.main_test = seed_req_cb; |
528 | } | 636 | } |
529 | else if (strstr (argv[0], "_seed") != NULL) | 637 | else if (strstr (argv[0], "_seed") != NULL) |
530 | { | 638 | { |
531 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding\n"); | 639 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding\n"); |
532 | test_type = SEED; | 640 | cur_test_run.main_test = seed_cb; |
641 | cur_test_run.eval_cb = seed_eval; | ||
533 | } | 642 | } |
534 | else if (strstr (argv[0], "_req_cancel") != NULL) | 643 | else if (strstr (argv[0], "_req_cancel") != NULL) |
535 | { | 644 | { |
536 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test cancelling a request\n"); | 645 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test cancelling a request\n"); |
537 | test_type = REQUEST_CANCEL; | 646 | cur_test_run.main_test = req_cancel_cb; |
538 | } | 647 | } |
539 | 648 | ||
540 | ok = 1; | 649 | ok = 1; |
@@ -544,31 +653,7 @@ main (int argc, char *argv[]) | |||
544 | 0, NULL, NULL, | 653 | 0, NULL, NULL, |
545 | &run, NULL); | 654 | &run, NULL); |
546 | 655 | ||
547 | unsigned int num_mal_peers; | 656 | return cur_test_run.eval_cb(); |
548 | if (1 == mal_type) | ||
549 | { | ||
550 | num_mal_peers = round (NUM_PEERS * portion); | ||
551 | ok = evaluate (&rps_peers[num_mal_peers], | ||
552 | NUM_PEERS - (num_mal_peers), | ||
553 | 1); | ||
554 | } | ||
555 | else if (2 == mal_type) | ||
556 | { | ||
557 | num_mal_peers = round (NUM_PEERS * portion); | ||
558 | ok = evaluate (&rps_peers[num_mal_peers], | ||
559 | NUM_PEERS - (num_mal_peers), | ||
560 | 1); | ||
561 | } | ||
562 | else if (SINGLE_REQUEST == test_type) | ||
563 | { | ||
564 | ok = evaluate (rps_peers, NUM_PEERS, 1); | ||
565 | } | ||
566 | else if (SEED_REQUEST == test_type) | ||
567 | { | ||
568 | ok = evaluate (rps_peers, NUM_PEERS, 1); | ||
569 | } | ||
570 | |||
571 | return ok; | ||
572 | } | 657 | } |
573 | 658 | ||
574 | /* end of test_rps_multipeer.c */ | 659 | /* end of test_rps_multipeer.c */ |