From ac8dc6926559362e54dc822d571590852609c775 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Julius=20B=C3=BCnger?= Date: Mon, 8 Jan 2018 17:12:01 +0100 Subject: [PATCH] rps tests: proper implementation of flags for tests --- src/rps/test_rps.c | 67 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c index 4d6f1bfd1..6189557f6 100644 --- a/src/rps/test_rps.c +++ b/src/rps/test_rps.c @@ -325,6 +325,34 @@ typedef void (*PostTest) (void *cls, struct GNUNET_RPS_Handle *h); */ typedef int (*EvaluationCallback) (void); +/** + * @brief Do we have Churn? + */ +enum OPTION_CHURN { + /** + * @brief If we have churn this is set + */ + HAVE_CHURN, + /** + * @brief If we have no churn this is set + */ + HAVE_NO_CHURN, +}; + +/** + * @brief Is it ok to quit the test before the timeout? + */ +enum OPTION_QUICK_QUIT { + /** + * @brief It is ok for the test to quit before the timeout triggers + */ + HAVE_QUICK_QUIT, + + /** + * @brief It is NOT ok for the test to quit before the timeout triggers + */ + HAVE_NO_QUICK_QUIT, +}; /** * Structure to define a single test @@ -377,9 +405,14 @@ struct SingleTestRun uint32_t num_requests; /** - * Run with churn + * Run with (-out) churn + */ + enum OPTION_CHURN have_churn; + + /** + * Quit test before timeout? */ - int have_churn; + enum OPTION_QUICK_QUIT have_quick_quit; } cur_test_run; /** @@ -801,7 +834,7 @@ default_reply_handle (void *cls, rps_peer->num_recv_ids++; } - if (0 == evaluate () && 0 != strncmp (cur_test_run.name, "test-rps-churn", 14)) + if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n"); GNUNET_assert (NULL != shutdown_task); @@ -1144,7 +1177,7 @@ churn_test_cb (struct RPSPeer *rps_peer) } /* Start churn */ - if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) + if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting churn task\n"); @@ -1436,7 +1469,7 @@ profiler_cb (struct RPSPeer *rps_peer) } /* Start churn */ - if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) + if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting churn task\n"); @@ -1616,7 +1649,7 @@ main (int argc, char *argv[]) cur_test_run.pre_test = NULL; cur_test_run.reply_handle = default_reply_handle; cur_test_run.eval_cb = default_eval_cb; - cur_test_run.have_churn = GNUNET_YES; + cur_test_run.have_churn = HAVE_CHURN; churn_task = NULL; timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); @@ -1651,7 +1684,7 @@ main (int argc, char *argv[]) GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test single request\n"); cur_test_run.name = "test-rps-single-req"; cur_test_run.main_test = single_req_cb; - cur_test_run.have_churn = GNUNET_NO; + cur_test_run.have_churn = HAVE_NO_CHURN; } else if (strstr (argv[0], "_delayed_reqs") != NULL) @@ -1659,7 +1692,7 @@ main (int argc, char *argv[]) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test delayed requests\n"); cur_test_run.name = "test-rps-delayed-reqs"; cur_test_run.main_test = delay_req_cb; - cur_test_run.have_churn = GNUNET_NO; + cur_test_run.have_churn = HAVE_NO_CHURN; } else if (strstr (argv[0], "_seed_big") != NULL) @@ -1669,7 +1702,7 @@ main (int argc, char *argv[]) cur_test_run.name = "test-rps-seed-big"; cur_test_run.main_test = seed_big_cb; cur_test_run.eval_cb = no_eval; - cur_test_run.have_churn = GNUNET_NO; + cur_test_run.have_churn = HAVE_NO_CHURN; timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); } @@ -1678,7 +1711,7 @@ main (int argc, char *argv[]) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on a single peer\n"); cur_test_run.name = "test-rps-single-peer-seed"; cur_test_run.main_test = single_peer_seed_cb; - cur_test_run.have_churn = GNUNET_NO; + cur_test_run.have_churn = HAVE_NO_CHURN; } else if (strstr (argv[0], "_seed_request") != NULL) @@ -1686,7 +1719,7 @@ main (int argc, char *argv[]) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on multiple peers\n"); cur_test_run.name = "test-rps-seed-request"; cur_test_run.main_test = seed_req_cb; - cur_test_run.have_churn = GNUNET_NO; + cur_test_run.have_churn = HAVE_NO_CHURN; } else if (strstr (argv[0], "_seed") != NULL) @@ -1695,7 +1728,7 @@ main (int argc, char *argv[]) cur_test_run.name = "test-rps-seed"; cur_test_run.main_test = seed_cb; cur_test_run.eval_cb = no_eval; - cur_test_run.have_churn = GNUNET_NO; + cur_test_run.have_churn = HAVE_NO_CHURN; } else if (strstr (argv[0], "_req_cancel") != NULL) @@ -1705,7 +1738,7 @@ main (int argc, char *argv[]) num_peers = 1; cur_test_run.main_test = req_cancel_cb; cur_test_run.eval_cb = no_eval; - cur_test_run.have_churn = GNUNET_NO; + cur_test_run.have_churn = HAVE_NO_CHURN; timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); } @@ -1718,7 +1751,8 @@ main (int argc, char *argv[]) cur_test_run.main_test = churn_test_cb; cur_test_run.reply_handle = default_reply_handle; cur_test_run.eval_cb = default_eval_cb; - cur_test_run.have_churn = GNUNET_YES; + cur_test_run.have_churn = HAVE_CHURN; + cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT; timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); } @@ -1735,8 +1769,9 @@ main (int argc, char *argv[]) cur_test_run.eval_cb = profiler_eval; cur_test_run.request_interval = 2; cur_test_run.num_requests = 5; - cur_test_run.have_churn = GNUNET_YES; - timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); + cur_test_run.have_churn = HAVE_CHURN; + cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT; + timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300); /* 'Clean' directory */ (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); -- 2.25.1