]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Improve add_msec test to cover ms->sec rollover
authorNick Mathewson <nickm@torproject.org>
Wed, 20 Dec 2017 14:12:38 +0000 (09:12 -0500)
committerNick Mathewson <nickm@torproject.org>
Wed, 20 Dec 2017 14:12:38 +0000 (09:12 -0500)
Per mikeperry's suggestion, I'm making sure that the millisecond
part of the time will always roll over in this test.

src/test/test_util.c

index 1c58ad695dabb71e8b2423c4e30468ee23ae4834..9d139917fc81149e0126ccb2837b6335b61b3d64 100644 (file)
@@ -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:
   ;
 }