diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-12-13 08:28:04 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-12-13 08:29:23 -0500 |
commit | 4c877ae87483d6e63c9e0309eb8abc009f9b9b87 (patch) | |
tree | 0ea831105d14594de5619d5416df145abcfc3314 /src/test/test_util.c | |
parent | 426110dfa2e27f134e7bf44341e5df6f454e49a3 (diff) | |
download | tor-4c877ae87483d6e63c9e0309eb8abc009f9b9b87.tar.gz tor-4c877ae87483d6e63c9e0309eb8abc009f9b9b87.zip |
Add monotime functions for clearing monotonic times
We need this to replace some of our "msec" users with monotime
users.
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 7856b506ba..7210f16746 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -5926,6 +5926,28 @@ test_util_monotonic_time_ratchet(void *arg) } static void +test_util_monotonic_time_zero(void *arg) +{ + (void) arg; + monotime_t t1; + monotime_coarse_t ct1; + monotime_init(); + /* Check 1: The current time is not zero. */ + monotime_get(&t1); + monotime_coarse_get(&ct1); + tt_assert(!monotime_is_zero(&t1)); + tt_assert(!monotime_coarse_is_zero(&ct1)); + + /* Check 2: The _zero() makes the time zero. */ + monotime_zero(&t1); + monotime_coarse_zero(&ct1); + tt_assert(monotime_is_zero(&t1)); + tt_assert(monotime_coarse_is_zero(&ct1)); + done: + ; +} + +static void test_util_htonll(void *arg) { (void)arg; @@ -6158,6 +6180,7 @@ struct testcase_t util_tests[] = { UTIL_TEST(calloc_check, 0), UTIL_TEST(monotonic_time, 0), UTIL_TEST(monotonic_time_ratchet, TT_FORK), + UTIL_TEST(monotonic_time_zero, 0), UTIL_TEST(htonll, 0), UTIL_TEST(get_unquoted_path, 0), END_OF_TESTCASES |