浏览代码

Make tor_gettimeofday() mockable

Neel Chauhan 6 年之前
父节点
当前提交
ce84de39ef
共有 2 个文件被更改,包括 3 次插入3 次删除
  1. 2 2
      src/common/compat_time.c
  2. 1 1
      src/common/compat_time.h

+ 2 - 2
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

+ 1 - 1
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);