diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-01-09 12:47:24 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-02-12 12:48:11 -0500 |
commit | 52d222aafbc21d674624fdd4c8fc834a40af69c7 (patch) | |
tree | fc1664f9cfb3797ce7041635372fea08780b9ec3 /src/common/compat_libevent.c | |
parent | d379fc6e0ffce916753e5ef1ac0783703d150fa5 (diff) | |
download | tor-52d222aafbc21d674624fdd4c8fc834a40af69c7.tar.gz tor-52d222aafbc21d674624fdd4c8fc834a40af69c7.zip |
Add tests for buffer time tracking.
Diffstat (limited to 'src/common/compat_libevent.c')
-rw-r--r-- | src/common/compat_libevent.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c index 4d0fff833b..b7987bc99a 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 |