aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_circuitmux.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-09-14 08:40:10 -0400
committerNick Mathewson <nickm@torproject.org>2018-09-14 08:40:12 -0400
commit6e5e1be7375e6e8de38af1f8c2c13e35d745edea (patch)
tree6fb3ca1064b4783dc9661556b69acbaa02cfd65f /src/test/test_circuitmux.c
parentf02e8b5944c238979c0c0cf3ce4a8911026b2210 (diff)
downloadtor-6e5e1be7375e6e8de38af1f8c2c13e35d745edea.tar.gz
tor-6e5e1be7375e6e8de38af1f8c2c13e35d745edea.zip
Make circuitmux ewma timing test more tolerant on 32bit osx
Since we use a 32-bit approximation for millisecond conversion here, we can't expect so much precision. Fixes part of bug 27139; bugfix on 0.3.4.1-alpha.
Diffstat (limited to 'src/test/test_circuitmux.c')
-rw-r--r--src/test/test_circuitmux.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/test/test_circuitmux.c b/src/test/test_circuitmux.c
index 14c7598703..c81d53ae51 100644
--- a/src/test/test_circuitmux.c
+++ b/src/test/test_circuitmux.c
@@ -13,6 +13,8 @@
#include "scheduler.h"
#include "test.h"
+#include <math.h>
+
/* XXXX duplicated function from test_circuitlist.c */
static channel_t *
new_fake_channel(void)
@@ -103,16 +105,19 @@ test_cmux_compute_ticks(void *arg)
monotime_coarse_set_mock_time_nsec(now);
tick = cell_ewma_get_current_tick_and_fraction(&rem);
tt_uint_op(tick, OP_EQ, tick_zero);
- tt_double_op(rem, OP_GT, .149999999);
- tt_double_op(rem, OP_LT, .150000001);
+#ifdef USING_32BIT_MSEC_HACK
+ const double tolerance = .0005;
+#else
+ const double tolerance = .00000001;
+#endif
+ tt_double_op(fabs(rem - .15), OP_LT, tolerance);
/* 25 second later and we should be in another tick. */
now = START_NS + NS_PER_S * 25;
monotime_coarse_set_mock_time_nsec(now);
tick = cell_ewma_get_current_tick_and_fraction(&rem);
tt_uint_op(tick, OP_EQ, tick_zero + 2);
- tt_double_op(rem, OP_GT, .499999999);
- tt_double_op(rem, OP_LT, .500000001);
+ tt_double_op(fabs(rem - .5), OP_LT, tolerance);
done:
;