aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_bwmgt.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-04-13 10:37:06 -0400
committerNick Mathewson <nickm@torproject.org>2018-04-13 10:41:15 -0400
commit787bafc0f916c143ac244a217accf755817512df (patch)
tree132c454218d727330668c6aec0591b4efd255ba8 /src/test/test_bwmgt.c
parent3f514fe3b1d217c80edb1524976203bc535f9502 (diff)
downloadtor-787bafc0f916c143ac244a217accf755817512df.tar.gz
tor-787bafc0f916c143ac244a217accf755817512df.zip
Increase tolerances for imprecise time.
Diffstat (limited to 'src/test/test_bwmgt.c')
-rw-r--r--src/test/test_bwmgt.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/test/test_bwmgt.c b/src/test/test_bwmgt.c
index 2428b15058..1a54f44fc4 100644
--- a/src/test/test_bwmgt.c
+++ b/src/test/test_bwmgt.c
@@ -125,6 +125,7 @@ test_bwmgt_token_buf_refill(void *arg)
token_bucket_t b;
const uint32_t SEC =
(uint32_t)monotime_msec_to_approx_coarse_stamp_units(1000);
+ printf("%d\n", (int)SEC);
token_bucket_init(&b, 16*KB, 64*KB, START_TS);
/* Make the buffer much emptier, then let one second elapse. */
@@ -163,25 +164,25 @@ test_bwmgt_token_buf_refill(void *arg)
tt_int_op(0, OP_EQ, b.read_bucket);
tt_int_op(1, OP_EQ, token_bucket_refill(&b, START_TS + SEC*3/2 + SEC*61));
tt_int_op(0, OP_EQ, token_bucket_refill(&b, START_TS + SEC*3/2 + SEC*62));
- tt_int_op(b.read_bucket, OP_GT, 32*KB-300);
- tt_int_op(b.read_bucket, OP_LT, 32*KB+300);
+ tt_int_op(b.read_bucket, OP_GT, 32*KB-400);
+ tt_int_op(b.read_bucket, OP_LT, 32*KB+400);
/* Underflow the bucket, make sure we detect when it has tokens again. */
tt_int_op(1, OP_EQ, token_bucket_dec_read(&b, b.read_bucket+16*KB));
tt_int_op(-16*KB, OP_EQ, b.read_bucket);
// half a second passes...
tt_int_op(0, OP_EQ, token_bucket_refill(&b, START_TS + SEC*64));
- tt_int_op(b.read_bucket, OP_GT, -8*KB-200);
- tt_int_op(b.read_bucket, OP_LT, -8*KB+200);
+ tt_int_op(b.read_bucket, OP_GT, -8*KB-300);
+ tt_int_op(b.read_bucket, OP_LT, -8*KB+300);
// a second passes
tt_int_op(1, OP_EQ, token_bucket_refill(&b, START_TS + SEC*65));
- tt_int_op(b.read_bucket, OP_GT, 8*KB-200);
- tt_int_op(b.read_bucket, OP_LT, 8*KB+200);
+ tt_int_op(b.read_bucket, OP_GT, 8*KB-400);
+ tt_int_op(b.read_bucket, OP_LT, 8*KB+400);
// We step a second backwards, and nothing happens.
tt_int_op(0, OP_EQ, token_bucket_refill(&b, START_TS + SEC*64));
- tt_int_op(b.read_bucket, OP_GT, 8*KB-200);
- tt_int_op(b.read_bucket, OP_LT, 8*KB+200);
+ tt_int_op(b.read_bucket, OP_GT, 8*KB-400);
+ tt_int_op(b.read_bucket, OP_LT, 8*KB+400);
// A ridiculous amount of time passes.
tt_int_op(0, OP_EQ, token_bucket_refill(&b, INT32_MAX));