summaryrefslogtreecommitdiff
path: root/src/test/test_util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-12-20 09:12:38 -0500
committerNick Mathewson <nickm@torproject.org>2017-12-20 09:12:38 -0500
commit60bf8f6cf6295808eec542be31649b0bd82ad926 (patch)
tree04790aed9d860ac448f999f2cfab7e03fbbdcda3 /src/test/test_util.c
parent219c969d7bf858c4df5fc6ee9b0c472a525b6b2a (diff)
downloadtor-60bf8f6cf6295808eec542be31649b0bd82ad926.tar.gz
tor-60bf8f6cf6295808eec542be31649b0bd82ad926.zip
Improve add_msec test to cover ms->sec rollover
Per mikeperry's suggestion, I'm making sure that the millisecond part of the time will always roll over in this test.
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r--src/test/test_util.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 1c58ad695d..9d139917fc 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -5970,6 +5970,16 @@ test_util_monotonic_time_add_msec(void *arg)
tt_i64_op(monotime_diff_msec(&t1, &t2), OP_EQ, 1337);
tt_i64_op(monotime_coarse_diff_msec(&ct1, &ct2), OP_EQ, 1337);
+ /* Add 1337 msec twice more; make sure that any second rollover issues
+ * worked. */
+ monotime_add_msec(&t2, &t2, 1337);
+ monotime_coarse_add_msec(&ct2, &ct2, 1337);
+ monotime_add_msec(&t2, &t2, 1337);
+ monotime_coarse_add_msec(&ct2, &ct2, 1337);
+ tt_i64_op(monotime_diff_msec(&t1, &t2), OP_EQ, 1337*3);
+ tt_i64_op(monotime_coarse_diff_msec(&ct1, &ct2), OP_EQ, 1337*3);
+
+
done:
;
}