From: Alexander Færøy Date: Tue, 3 Apr 2018 15:43:17 +0000 (+0200) Subject: Make get_total_system_memory mockable. X-Git-Tag: tor-0.3.3.5-rc~8^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bd42367a1e6f60d35242d2a5165f10e3a8623bf7;p=thirdparty%2Ftor.git 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 --- diff --git a/src/common/compat.c b/src/common/compat.c index 4cb346dfa5..7d9add50b2 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 *mem_out 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 93301feda0..3088e68355 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);