[tor-commits] [tor/master] Make tor_gettimeofday() mockable

nickm at torproject.org nickm at torproject.org
Mon Apr 23 13:14:38 UTC 2018


commit ce84de39efc09142d36d5b94963b1aeb2c0a1ae9
Author: Neel Chauhan <neel at neelc.org>
Date:   Mon Apr 16 20:18:40 2018 -0400

    Make tor_gettimeofday() mockable
---
 src/common/compat_time.c | 4 ++--
 src/common/compat_time.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/common/compat_time.c b/src/common/compat_time.c
index b940447b6..966216768 100644
--- a/src/common/compat_time.c
+++ b/src/common/compat_time.c
@@ -71,8 +71,8 @@ tor_sleep_msec(int msec)
 /** Set *timeval to the current time of day.  On error, log and terminate.
  * (Same as gettimeofday(timeval,NULL), but never returns -1.)
  */
-void
-tor_gettimeofday(struct timeval *timeval)
+MOCK_IMPL(void,
+tor_gettimeofday, (struct timeval *timeval))
 {
 #ifdef _WIN32
   /* Epoch bias copied from perl: number of units between windows epoch and
diff --git a/src/common/compat_time.h b/src/common/compat_time.h
index 75b57f6f2..09dd6add3 100644
--- a/src/common/compat_time.h
+++ b/src/common/compat_time.h
@@ -173,7 +173,7 @@ void monotime_coarse_add_msec(monotime_coarse_t *out,
 #define monotime_coarse_add_msec monotime_add_msec
 #endif /* defined(MONOTIME_COARSE_TYPE_IS_DIFFERENT) */
 
-void tor_gettimeofday(struct timeval *timeval);
+MOCK_DECL(void, tor_gettimeofday, (struct timeval *timeval));
 
 #ifdef TOR_UNIT_TESTS
 void tor_sleep_msec(int msec);





More information about the tor-commits mailing list