summaryrefslogtreecommitdiff
path: root/src/test/test_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r--src/test/test_util.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index d43bf781f2..ab63344806 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];
@@ -7043,6 +7066,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),