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
This commit is contained in:
Alexander Færøy 2018-04-03 17:43:17 +02:00 committed by David Goulet
parent 0803d79f55
commit bd42367a1e
2 changed files with 3 additions and 3 deletions

View File

@ -3409,8 +3409,8 @@ get_total_system_memory_impl(void)
* Try to find out how much physical memory the system has. On success, * 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. * return 0 and set *<b>mem_out</b> to that value. On failure, return -1.
*/ */
int MOCK_IMPL(int,
get_total_system_memory(size_t *mem_out) get_total_system_memory, (size_t *mem_out))
{ {
static size_t mem_cached=0; static size_t mem_cached=0;
uint64_t m = get_total_system_memory_impl(); uint64_t m = get_total_system_memory_impl();

View File

@ -699,7 +699,7 @@ char *make_path_absolute(char *fname);
char **get_environment(void); 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); int compute_num_cpus(void);