aboutsummaryrefslogtreecommitdiff
path: root/src/rps
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2018-01-08 17:12:01 +0100
committerJulius Bünger <buenger@mytum.de>2018-01-08 17:13:32 +0100
commitac8dc6926559362e54dc822d571590852609c775 (patch)
tree907e752f02e578291877580b4d0e58ceb27ac47b /src/rps
parent805d0505def4d842f17eaceb8152356e1caf0e4c (diff)
downloadgnunet-ac8dc6926559362e54dc822d571590852609c775.tar.gz
gnunet-ac8dc6926559362e54dc822d571590852609c775.zip
rps tests: proper implementation of flags for tests
Diffstat (limited to 'src/rps')
-rw-r--r--src/rps/test_rps.c67
1 files 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);
325 */ 325 */
326typedef int (*EvaluationCallback) (void); 326typedef int (*EvaluationCallback) (void);
327 327
328/**
329 * @brief Do we have Churn?
330 */
331enum OPTION_CHURN {
332 /**
333 * @brief If we have churn this is set
334 */
335 HAVE_CHURN,
336 /**
337 * @brief If we have no churn this is set
338 */
339 HAVE_NO_CHURN,
340};
341
342/**
343 * @brief Is it ok to quit the test before the timeout?
344 */
345enum OPTION_QUICK_QUIT {
346 /**
347 * @brief It is ok for the test to quit before the timeout triggers
348 */
349 HAVE_QUICK_QUIT,
350
351 /**
352 * @brief It is NOT ok for the test to quit before the timeout triggers
353 */
354 HAVE_NO_QUICK_QUIT,
355};
328 356
329/** 357/**
330 * Structure to define a single test 358 * Structure to define a single test
@@ -377,9 +405,14 @@ struct SingleTestRun
377 uint32_t num_requests; 405 uint32_t num_requests;
378 406
379 /** 407 /**
380 * Run with churn 408 * Run with (-out) churn
409 */
410 enum OPTION_CHURN have_churn;
411
412 /**
413 * Quit test before timeout?
381 */ 414 */
382 int have_churn; 415 enum OPTION_QUICK_QUIT have_quick_quit;
383} cur_test_run; 416} cur_test_run;
384 417
385/** 418/**
@@ -801,7 +834,7 @@ default_reply_handle (void *cls,
801 rps_peer->num_recv_ids++; 834 rps_peer->num_recv_ids++;
802 } 835 }
803 836
804 if (0 == evaluate () && 0 != strncmp (cur_test_run.name, "test-rps-churn", 14)) 837 if (0 == evaluate () && HAVE_QUICK_QUIT == cur_test_run.have_quick_quit)
805 { 838 {
806 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n"); 839 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test succeeded before timeout\n");
807 GNUNET_assert (NULL != shutdown_task); 840 GNUNET_assert (NULL != shutdown_task);
@@ -1144,7 +1177,7 @@ churn_test_cb (struct RPSPeer *rps_peer)
1144 } 1177 }
1145 1178
1146 /* Start churn */ 1179 /* Start churn */
1147 if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) 1180 if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task)
1148 { 1181 {
1149 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1150 "Starting churn task\n"); 1183 "Starting churn task\n");
@@ -1436,7 +1469,7 @@ profiler_cb (struct RPSPeer *rps_peer)
1436 } 1469 }
1437 1470
1438 /* Start churn */ 1471 /* Start churn */
1439 if (GNUNET_YES == cur_test_run.have_churn && NULL == churn_task) 1472 if (HAVE_CHURN == cur_test_run.have_churn && NULL == churn_task)
1440 { 1473 {
1441 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1474 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1442 "Starting churn task\n"); 1475 "Starting churn task\n");
@@ -1616,7 +1649,7 @@ main (int argc, char *argv[])
1616 cur_test_run.pre_test = NULL; 1649 cur_test_run.pre_test = NULL;
1617 cur_test_run.reply_handle = default_reply_handle; 1650 cur_test_run.reply_handle = default_reply_handle;
1618 cur_test_run.eval_cb = default_eval_cb; 1651 cur_test_run.eval_cb = default_eval_cb;
1619 cur_test_run.have_churn = GNUNET_YES; 1652 cur_test_run.have_churn = HAVE_CHURN;
1620 churn_task = NULL; 1653 churn_task = NULL;
1621 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); 1654 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30);
1622 1655
@@ -1651,7 +1684,7 @@ main (int argc, char *argv[])
1651 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test single request\n"); 1684 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Test single request\n");
1652 cur_test_run.name = "test-rps-single-req"; 1685 cur_test_run.name = "test-rps-single-req";
1653 cur_test_run.main_test = single_req_cb; 1686 cur_test_run.main_test = single_req_cb;
1654 cur_test_run.have_churn = GNUNET_NO; 1687 cur_test_run.have_churn = HAVE_NO_CHURN;
1655 } 1688 }
1656 1689
1657 else if (strstr (argv[0], "_delayed_reqs") != NULL) 1690 else if (strstr (argv[0], "_delayed_reqs") != NULL)
@@ -1659,7 +1692,7 @@ main (int argc, char *argv[])
1659 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test delayed requests\n"); 1692 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test delayed requests\n");
1660 cur_test_run.name = "test-rps-delayed-reqs"; 1693 cur_test_run.name = "test-rps-delayed-reqs";
1661 cur_test_run.main_test = delay_req_cb; 1694 cur_test_run.main_test = delay_req_cb;
1662 cur_test_run.have_churn = GNUNET_NO; 1695 cur_test_run.have_churn = HAVE_NO_CHURN;
1663 } 1696 }
1664 1697
1665 else if (strstr (argv[0], "_seed_big") != NULL) 1698 else if (strstr (argv[0], "_seed_big") != NULL)
@@ -1669,7 +1702,7 @@ main (int argc, char *argv[])
1669 cur_test_run.name = "test-rps-seed-big"; 1702 cur_test_run.name = "test-rps-seed-big";
1670 cur_test_run.main_test = seed_big_cb; 1703 cur_test_run.main_test = seed_big_cb;
1671 cur_test_run.eval_cb = no_eval; 1704 cur_test_run.eval_cb = no_eval;
1672 cur_test_run.have_churn = GNUNET_NO; 1705 cur_test_run.have_churn = HAVE_NO_CHURN;
1673 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); 1706 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
1674 } 1707 }
1675 1708
@@ -1678,7 +1711,7 @@ main (int argc, char *argv[])
1678 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on a single peer\n"); 1711 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on a single peer\n");
1679 cur_test_run.name = "test-rps-single-peer-seed"; 1712 cur_test_run.name = "test-rps-single-peer-seed";
1680 cur_test_run.main_test = single_peer_seed_cb; 1713 cur_test_run.main_test = single_peer_seed_cb;
1681 cur_test_run.have_churn = GNUNET_NO; 1714 cur_test_run.have_churn = HAVE_NO_CHURN;
1682 } 1715 }
1683 1716
1684 else if (strstr (argv[0], "_seed_request") != NULL) 1717 else if (strstr (argv[0], "_seed_request") != NULL)
@@ -1686,7 +1719,7 @@ main (int argc, char *argv[])
1686 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on multiple peers\n"); 1719 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Test seeding and requesting on multiple peers\n");
1687 cur_test_run.name = "test-rps-seed-request"; 1720 cur_test_run.name = "test-rps-seed-request";
1688 cur_test_run.main_test = seed_req_cb; 1721 cur_test_run.main_test = seed_req_cb;
1689 cur_test_run.have_churn = GNUNET_NO; 1722 cur_test_run.have_churn = HAVE_NO_CHURN;
1690 } 1723 }
1691 1724
1692 else if (strstr (argv[0], "_seed") != NULL) 1725 else if (strstr (argv[0], "_seed") != NULL)
@@ -1695,7 +1728,7 @@ main (int argc, char *argv[])
1695 cur_test_run.name = "test-rps-seed"; 1728 cur_test_run.name = "test-rps-seed";
1696 cur_test_run.main_test = seed_cb; 1729 cur_test_run.main_test = seed_cb;
1697 cur_test_run.eval_cb = no_eval; 1730 cur_test_run.eval_cb = no_eval;
1698 cur_test_run.have_churn = GNUNET_NO; 1731 cur_test_run.have_churn = HAVE_NO_CHURN;
1699 } 1732 }
1700 1733
1701 else if (strstr (argv[0], "_req_cancel") != NULL) 1734 else if (strstr (argv[0], "_req_cancel") != NULL)
@@ -1705,7 +1738,7 @@ main (int argc, char *argv[])
1705 num_peers = 1; 1738 num_peers = 1;
1706 cur_test_run.main_test = req_cancel_cb; 1739 cur_test_run.main_test = req_cancel_cb;
1707 cur_test_run.eval_cb = no_eval; 1740 cur_test_run.eval_cb = no_eval;
1708 cur_test_run.have_churn = GNUNET_NO; 1741 cur_test_run.have_churn = HAVE_NO_CHURN;
1709 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); 1742 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
1710 } 1743 }
1711 1744
@@ -1718,7 +1751,8 @@ main (int argc, char *argv[])
1718 cur_test_run.main_test = churn_test_cb; 1751 cur_test_run.main_test = churn_test_cb;
1719 cur_test_run.reply_handle = default_reply_handle; 1752 cur_test_run.reply_handle = default_reply_handle;
1720 cur_test_run.eval_cb = default_eval_cb; 1753 cur_test_run.eval_cb = default_eval_cb;
1721 cur_test_run.have_churn = GNUNET_YES; 1754 cur_test_run.have_churn = HAVE_CHURN;
1755 cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
1722 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); 1756 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10);
1723 } 1757 }
1724 1758
@@ -1735,8 +1769,9 @@ main (int argc, char *argv[])
1735 cur_test_run.eval_cb = profiler_eval; 1769 cur_test_run.eval_cb = profiler_eval;
1736 cur_test_run.request_interval = 2; 1770 cur_test_run.request_interval = 2;
1737 cur_test_run.num_requests = 5; 1771 cur_test_run.num_requests = 5;
1738 cur_test_run.have_churn = GNUNET_YES; 1772 cur_test_run.have_churn = HAVE_CHURN;
1739 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 90); 1773 cur_test_run.have_quick_quit = HAVE_NO_QUICK_QUIT;
1774 timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 300);
1740 1775
1741 /* 'Clean' directory */ 1776 /* 'Clean' directory */
1742 (void) GNUNET_DISK_directory_remove ("/tmp/rps/"); 1777 (void) GNUNET_DISK_directory_remove ("/tmp/rps/");