From 2b6fe8bb7f9c40bd28090bc1b3528bc02c3b15ac Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Fri, 29 Jun 2012 12:47:51 -0400 Subject: [PATCH] Make load-dependent monotonic timer tests off-by-default You can reenable them with @all, or say @fine_timing just to get them. --- test/regress_main.c | 6 ++++++ test/regress_util.c | 39 +++++++++++++++++++++++++++++++-------- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/test/regress_main.c b/test/regress_main.c index c735b1e5..415cbb00 100644 --- a/test/regress_main.c +++ b/test/regress_main.c @@ -393,9 +393,15 @@ const char *livenettests[] = { "+dns/resolve_reverse", NULL }; +const char *finetimetests[] = { + "+util/monotonic_res_precise", + "+util/monotonic_res_fallback", + NULL +}; struct testlist_alias_t testaliases[] = { { "all", alltests }, { "live_net", livenettests }, + { "fine_timing", finetimetests }, END_OF_ALIASES }; diff --git a/test/regress_util.c b/test/regress_util.c index 0f49249c..0944f069 100644 --- a/test/regress_util.c +++ b/test/regress_util.c @@ -1231,7 +1231,7 @@ end: } static void -test_evutil_monotonic(void *data_) +test_evutil_monotonic_res(void *data_) { /* Basic santity-test for monotonic timers. What we'd really like * to do is make sure that they can't go backwards even when the @@ -1245,7 +1245,7 @@ test_evutil_monotonic(void *data_) struct timeval tv[10], delay; int total_diff = 0; - int flags = 0, wantres, acceptdiff, i, maxstep = 25*1000; + int flags = 0, wantres, acceptdiff, i; if (precise) flags |= EV_MONOT_PRECISE; if (fallback) @@ -1262,8 +1262,6 @@ test_evutil_monotonic(void *data_) wantres = 40*1000; acceptdiff = 20*1000; } - if (precise) - maxstep = 500; TT_BLATHER(("Precise = %d", precise)); TT_BLATHER(("Fallback = %d", fallback)); @@ -1290,7 +1288,29 @@ test_evutil_monotonic(void *data_) } tt_int_op(abs(total_diff/9 - wantres), <, acceptdiff); - /* Second, find out what precision we actually see. */ +end: + ; +} + +static void +test_evutil_monotonic_prc(void *data_) +{ + struct basic_test_data *data = data_; + struct evutil_monotonic_timer timer; + const int precise = strstr(data->setup_data, "precise") != NULL; + const int fallback = strstr(data->setup_data, "fallback") != NULL; + struct timeval tv[10]; + int total_diff = 0; + int i, maxstep = 25*1000,flags=0; + if (precise) + maxstep = 500; + if (precise) + flags |= EV_MONOT_PRECISE; + if (fallback) + flags |= EV_MONOT_FALLBACK; + tt_int_op(evutil_configure_monotonic_time_(&timer, flags), ==, 0); + + /* find out what precision we actually see. */ evutil_gettime_monotonic_(&timer, &tv[0]); for (i = 1; i < 10; ++i) { @@ -1338,9 +1358,12 @@ struct testcase_t util_testcases[] = { { "mm_calloc", test_event_calloc, 0, NULL, NULL }, { "mm_strdup", test_event_strdup, 0, NULL, NULL }, { "usleep", test_evutil_usleep, 0, NULL, NULL }, - { "monotonic", test_evutil_monotonic, 0, &basic_setup, (void*)"" }, - { "monotonic_precise", test_evutil_monotonic, 0, &basic_setup, (void*)"precise" }, - { "monotonic_fallback", test_evutil_monotonic, 0, &basic_setup, (void*)"fallback" }, + { "monotonic_res", test_evutil_monotonic_res, 0, &basic_setup, (void*)"" }, + { "monotonic_res_precise", test_evutil_monotonic_res, TT_OFF_BY_DEFAULT, &basic_setup, (void*)"precise" }, + { "monotonic_res_fallback", test_evutil_monotonic_res, TT_OFF_BY_DEFAULT, &basic_setup, (void*)"fallback" }, + { "monotonic_prc", test_evutil_monotonic_prc, 0, &basic_setup, (void*)"" }, + { "monotonic_prc_precise", test_evutil_monotonic_prc, 0, &basic_setup, (void*)"precise" }, + { "monotonic_prc_fallback", test_evutil_monotonic_prc, 0, &basic_setup, (void*)"fallback" }, END_OF_TESTCASES, }; -- 2.40.0