aboutsummaryrefslogtreecommitdiff
path: root/src/common/compat_libevent.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2014-01-09 12:47:24 -0500
committerNick Mathewson <nickm@torproject.org>2014-02-12 12:48:11 -0500
commit52d222aafbc21d674624fdd4c8fc834a40af69c7 (patch)
treefc1664f9cfb3797ce7041635372fea08780b9ec3 /src/common/compat_libevent.c
parentd379fc6e0ffce916753e5ef1ac0783703d150fa5 (diff)
downloadtor-52d222aafbc21d674624fdd4c8fc834a40af69c7.tar
tor-52d222aafbc21d674624fdd4c8fc834a40af69c7.tar.gz
Add tests for buffer time tracking.
Diffstat (limited to 'src/common/compat_libevent.c')
-rw-r--r--src/common/compat_libevent.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 4d0fff833..b7987bc99 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -626,7 +626,9 @@ tor_add_bufferevent_to_rate_limit_group(struct bufferevent *bev,
}
#endif
-#if defined(LIBEVENT_VERSION_NUMBER) && LIBEVENT_VERSION_NUMBER >= V(2,1,1)
+
+#if defined(LIBEVENT_VERSION_NUMBER) && LIBEVENT_VERSION_NUMBER >= V(2,1,1) \
+ && !defined(TOR_UNIT_TESTS)
void
tor_gettimeofday_cached(struct timeval *tv)
{
@@ -659,5 +661,15 @@ tor_gettimeofday_cache_clear(void)
{
cached_time_hires.tv_sec = 0;
}
+
+#ifdef TOR_UNIT_TESTS
+/** For testing: force-update the cached time to a given value. */
+void
+tor_gettimeofday_cache_set(const struct timeval *tv)
+{
+ tor_assert(tv);
+ memcpy(&cached_time_hires, tv, sizeof(*tv));
+}
+#endif
#endif