commit bd42367a1e6f60d35242d2a5165f10e3a8623bf7
parent 0803d79f55e0554c8f9c479112f3a317a97b4ddf
Author: Alexander Færøy <ahf@torproject.org>
Date: Tue, 3 Apr 2018 17:43:17 +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
Diffstat:
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git 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
@@ -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);