diff options
author | George Kadianakis <desnacked@riseup.net> | 2021-07-06 13:42:53 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2021-07-06 13:42:53 +0300 |
commit | 167f3bc4ecbe4f0265413f3a1b91b6faab1c0f81 (patch) | |
tree | 394375d616c7fd7e977fdcd6528f6d48dcf897c8 /src/test/test_util.c | |
parent | 2758ae30b32cc75843cf216a310447eac4bdf7ac (diff) | |
parent | 98b9df61f6f2d33dab857b1e7d2f8e848678f5ed (diff) | |
download | tor-167f3bc4ecbe4f0265413f3a1b91b6faab1c0f81.tar.gz tor-167f3bc4ecbe4f0265413f3a1b91b6faab1c0f81.zip |
Merge branch 'maint-0.4.5' into maint-0.4.6
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index f10aed71ac..291a97d52b 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -7,6 +7,7 @@ #define COMPAT_TIME_PRIVATE #define UTIL_MALLOC_PRIVATE #define PROCESS_WIN32_PRIVATE +#define TIME_FMT_PRIVATE #include "lib/testsupport/testsupport.h" #include "core/or/or.h" #include "lib/buf/buffers.h" @@ -111,7 +112,7 @@ static time_t tor_timegm_wrapper(const struct tm *tm) { time_t t; - if (tor_timegm(tm, &t) < 0) + if (tor_timegm_impl(tm, &t) < 0) return -1; return t; } @@ -1502,6 +1503,28 @@ test_util_parse_http_time(void *arg) } static void +test_util_timegm_real(void *arg) +{ + (void)arg; + /* Get the real timegm again! We're not testing our impl; we want the + * one that will actually get called. */ +#undef tor_timegm + + /* Now check: is timegm the real inverse of gmtime? */ + time_t now = time(NULL), time2=0; + struct tm tm, *p; + p = tor_gmtime_r(&now, &tm); + tt_ptr_op(p, OP_NE, NULL); + + int r = tor_timegm(&tm, &time2); + tt_int_op(r, OP_EQ, 0); + tt_i64_op((int64_t) now, OP_EQ, (int64_t) time2); + + done: + ; +} + +static void test_util_config_line(void *arg) { char buf[1024]; @@ -7036,6 +7059,7 @@ struct testcase_t util_tests[] = { UTIL_TEST(monotonic_time_ratchet, TT_FORK), UTIL_TEST(monotonic_time_zero, 0), UTIL_TEST(monotonic_time_add_msec, 0), + UTIL_TEST(timegm_real, 0), UTIL_TEST(htonll, 0), UTIL_TEST(get_unquoted_path, 0), UTIL_TEST(map_anon, 0), |