aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-10-11 14:42:53 +0200
committerJulius Bünger <buenger@mytum.de>2018-10-11 14:42:53 +0200
commit261dd70aa12d986e6f7b38c38f843621bcc47763 (patch)
tree7a288e89a95eaa50f32d647bc470dc8c6f181d43 /src
parentfbbf0db19d08fe54f5b51c82b6cb1c9c7a2d040d (diff)
downloadgnunet-261dd70aa12d986e6f7b38c38f843621bcc47763.tar.gz
gnunet-261dd70aa12d986e6f7b38c38f843621bcc47763.zip
RPS Tests: Refactor (run post_test before disconnect)
Diffstat (limited to 'src')
-rw-r--r--src/rps/test_rps.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 92d8c12ea..ba0371f38 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -673,6 +673,13 @@ ids_to_file (char *file_name,
673} */ 673} */
674 674
675/** 675/**
676 * Task run on timeout to collect statistics and potentially shut down.
677 */
678static void
679post_test_op (void *cls);
680
681
682/**
676 * Test the success of a single test 683 * Test the success of a single test
677 */ 684 */
678static int 685static int
@@ -732,6 +739,8 @@ static int check_statistics_collect_completed_single_peer (
732 } 739 }
733 return GNUNET_YES; 740 return GNUNET_YES;
734} 741}
742
743
735/** 744/**
736 * @brief Checks if all peers already received their statistics value from the 745 * @brief Checks if all peers already received their statistics value from the
737 * statistics service. 746 * statistics service.
@@ -758,6 +767,7 @@ static int check_statistics_collect_completed ()
758 return GNUNET_YES; 767 return GNUNET_YES;
759} 768}
760 769
770
761/** 771/**
762 * Task run on timeout to shut everything down. 772 * Task run on timeout to shut everything down.
763 */ 773 */
@@ -765,6 +775,7 @@ static void
765shutdown_op (void *cls) 775shutdown_op (void *cls)
766{ 776{
767 unsigned int i; 777 unsigned int i;
778 (void) cls;
768 779
769 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 780 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
770 "Shutdown task scheduled, going down.\n"); 781 "Shutdown task scheduled, going down.\n");
@@ -772,6 +783,7 @@ shutdown_op (void *cls)
772 if (NULL != post_test_task) 783 if (NULL != post_test_task)
773 { 784 {
774 GNUNET_SCHEDULER_cancel (post_test_task); 785 GNUNET_SCHEDULER_cancel (post_test_task);
786 post_test_op (NULL);
775 } 787 }
776 if (NULL != churn_task) 788 if (NULL != churn_task)
777 { 789 {
@@ -799,6 +811,7 @@ static void
799post_test_op (void *cls) 811post_test_op (void *cls)
800{ 812{
801 unsigned int i; 813 unsigned int i;
814 (void) cls;
802 815
803 post_test_task = NULL; 816 post_test_task = NULL;
804 post_test = GNUNET_YES; 817 post_test = GNUNET_YES;
@@ -811,16 +824,16 @@ post_test_op (void *cls)
811 } 824 }
812 for (i = 0; i < num_peers; i++) 825 for (i = 0; i < num_peers; i++)
813 { 826 {
814 if (NULL != rps_peers[i].op)
815 {
816 GNUNET_TESTBED_operation_done (rps_peers[i].op);
817 rps_peers[i].op = NULL;
818 }
819 if (NULL != cur_test_run.post_test) 827 if (NULL != cur_test_run.post_test)
820 { 828 {
821 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing post_test for peer %u\n", i); 829 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing post_test for peer %u\n", i);
822 cur_test_run.post_test (&rps_peers[i]); 830 cur_test_run.post_test (&rps_peers[i]);
823 } 831 }
832 if (NULL != rps_peers[i].op)
833 {
834 GNUNET_TESTBED_operation_done (rps_peers[i].op);
835 rps_peers[i].op = NULL;
836 }
824 } 837 }
825 /* If we do not collect statistics, shut down directly */ 838 /* If we do not collect statistics, shut down directly */
826 if (NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics || 839 if (NO_COLLECT_STATISTICS == cur_test_run.have_collect_statistics ||
@@ -905,6 +918,7 @@ info_cb (void *cb_cls,
905 const char *emsg) 918 const char *emsg)
906{ 919{
907 struct OpListEntry *entry = (struct OpListEntry *) cb_cls; 920 struct OpListEntry *entry = (struct OpListEntry *) cb_cls;
921 (void) op;
908 922
909 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test) 923 if (GNUNET_YES == in_shutdown || GNUNET_YES == post_test)
910 { 924 {
@@ -1070,6 +1084,9 @@ stat_complete_cb (void *cls, struct GNUNET_TESTBED_Operation *op,
1070{ 1084{
1071 //struct GNUNET_STATISTICS_Handle *sh = ca_result; 1085 //struct GNUNET_STATISTICS_Handle *sh = ca_result;
1072 //struct RPSPeer *peer = (struct RPSPeer *) cls; 1086 //struct RPSPeer *peer = (struct RPSPeer *) cls;
1087 (void) cls;
1088 (void) op;
1089 (void) ca_result;
1073 1090
1074 if (NULL != emsg) 1091 if (NULL != emsg)
1075 { 1092 {
@@ -1098,6 +1115,7 @@ rps_disconnect_adapter (void *cls,
1098{ 1115{
1099 struct RPSPeer *peer = cls; 1116 struct RPSPeer *peer = cls;
1100 struct GNUNET_RPS_Handle *h = op_result; 1117 struct GNUNET_RPS_Handle *h = op_result;
1118
1101 GNUNET_assert (NULL != peer); 1119 GNUNET_assert (NULL != peer);
1102 GNUNET_RPS_disconnect (h); 1120 GNUNET_RPS_disconnect (h);
1103 peer->rps_handle = NULL; 1121 peer->rps_handle = NULL;
@@ -1441,6 +1459,7 @@ seed_big_cb (struct RPSPeer *rps_peer)
1441static void 1459static void
1442single_peer_seed_cb (struct RPSPeer *rps_peer) 1460single_peer_seed_cb (struct RPSPeer *rps_peer)
1443{ 1461{
1462 (void) rps_peer;
1444 // TODO 1463 // TODO
1445} 1464}
1446 1465
@@ -1540,6 +1559,7 @@ churn_cb (void *cls,
1540 struct GNUNET_TESTBED_Operation *op, 1559 struct GNUNET_TESTBED_Operation *op,
1541 const char *emsg) 1560 const char *emsg)
1542{ 1561{
1562 (void) op;
1543 // FIXME 1563 // FIXME
1544 struct OpListEntry *entry = cls; 1564 struct OpListEntry *entry = cls;
1545 1565
@@ -1670,6 +1690,7 @@ manage_service_wrapper (unsigned int i, unsigned int j,
1670static void 1690static void
1671churn (void *cls) 1691churn (void *cls)
1672{ 1692{
1693 (void) cls;
1673 unsigned int i; 1694 unsigned int i;
1674 unsigned int j; 1695 unsigned int j;
1675 double portion_online; 1696 double portion_online;
@@ -1832,6 +1853,8 @@ profiler_cb (struct RPSPeer *rps_peer)
1832int 1853int
1833file_name_cb (void *cls, const char *filename) 1854file_name_cb (void *cls, const char *filename)
1834{ 1855{
1856 (void) cls;
1857
1835 if (NULL != strstr (filename, "sampler_el")) 1858 if (NULL != strstr (filename, "sampler_el"))
1836 { 1859 {
1837 struct RPS_SamplerElement *s_elem; 1860 struct RPS_SamplerElement *s_elem;
@@ -2501,6 +2524,8 @@ stat_iterator (void *cls,
2501 uint64_t value, 2524 uint64_t value,
2502 int is_persistent) 2525 int is_persistent)
2503{ 2526{
2527 (void) subsystem;
2528 (void) is_persistent;
2504 const struct STATcls *stat_cls = (const struct STATcls *) cls; 2529 const struct STATcls *stat_cls = (const struct STATcls *) cls;
2505 struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer; 2530 struct RPSPeer *rps_peer = (struct RPSPeer *) stat_cls->rps_peer;
2506 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n", 2531 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got stat value: %s - %" PRIu64 "\n",
@@ -2635,6 +2660,9 @@ run (void *cls,
2635 unsigned int links_succeeded, 2660 unsigned int links_succeeded,
2636 unsigned int links_failed) 2661 unsigned int links_failed)
2637{ 2662{
2663 (void) cls;
2664 (void) h;
2665 (void) links_failed;
2638 unsigned int i; 2666 unsigned int i;
2639 struct OpListEntry *entry; 2667 struct OpListEntry *entry;
2640 2668
@@ -2727,6 +2755,7 @@ int
2727main (int argc, char *argv[]) 2755main (int argc, char *argv[])
2728{ 2756{
2729 int ret_value; 2757 int ret_value;
2758 (void) argc;
2730 2759
2731 /* Defaults for tests */ 2760 /* Defaults for tests */
2732 num_peers = 5; 2761 num_peers = 5;
@@ -2748,6 +2777,7 @@ main (int argc, char *argv[])
2748 cur_test_run.pre_test = mal_pre; 2777 cur_test_run.pre_test = mal_pre;
2749 cur_test_run.main_test = mal_cb; 2778 cur_test_run.main_test = mal_cb;
2750 cur_test_run.init_peer = mal_init_peer; 2779 cur_test_run.init_peer = mal_init_peer;
2780 timeout_s = 40;
2751 2781
2752 if (strstr (argv[0], "_1") != NULL) 2782 if (strstr (argv[0], "_1") != NULL)
2753 { 2783 {