[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.3.3] Make get_total_system_memory mockable.



commit bd42367a1e6f60d35242d2a5165f10e3a8623bf7
Author: Alexander Færøy <ahf@xxxxxxxxxxxxxx>
Date:   Tue Apr 3 17:43:17 2018 +0200

    Make get_total_system_memory mockable.
    
    This patch makes get_total_system_memory mockable, which allows us to
    alter the return value of the function in tests.
    
    See: https://bugs.torproject.org/24782
---
 src/common/compat.c | 4 ++--
 src/common/compat.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/common/compat.c b/src/common/compat.c
index 4cb346dfa..7d9add50b 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -3409,8 +3409,8 @@ get_total_system_memory_impl(void)
  * Try to find out how much physical memory the system has. On success,
  * return 0 and set *<b>mem_out</b> to that value. On failure, return -1.
  */
-int
-get_total_system_memory(size_t *mem_out)
+MOCK_IMPL(int,
+get_total_system_memory, (size_t *mem_out))
 {
   static size_t mem_cached=0;
   uint64_t m = get_total_system_memory_impl();
diff --git a/src/common/compat.h b/src/common/compat.h
index 93301feda..3088e6835 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -699,7 +699,7 @@ char *make_path_absolute(char *fname);
 
 char **get_environment(void);
 
-int get_total_system_memory(size_t *mem_out);
+MOCK_DECL(int, get_total_system_memory, (size_t *mem_out));
 
 int compute_num_cpus(void);
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits