diff options
author | Alexander Færøy <ahf@torproject.org> | 2018-04-03 17:43:17 +0200 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2018-04-12 10:51:45 -0400 |
commit | bd42367a1e6f60d35242d2a5165f10e3a8623bf7 (patch) | |
tree | a0ea2cf4ff7c9309581341bc84ac974a8af70375 /src/common | |
parent | 0803d79f55e0554c8f9c479112f3a317a97b4ddf (diff) | |
download | tor-bd42367a1e6f60d35242d2a5165f10e3a8623bf7.tar.gz tor-bd42367a1e6f60d35242d2a5165f10e3a8623bf7.zip |
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 (limited to 'src/common')
-rw-r--r-- | src/common/compat.c | 4 | ||||
-rw-r--r-- | 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 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 *<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 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); |