diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-04-03 11:46:01 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-04-24 10:26:14 -0400 |
commit | aca05fc5c08d6296c4f93850a0256bfd96890b18 (patch) | |
tree | d60364e182cf4d3564930eb44af423f03bf1abd6 /src/test | |
parent | 17d5734df47bc4b9bd40f878e492eb676ca47ae8 (diff) | |
download | tor-aca05fc5c08d6296c4f93850a0256bfd96890b18.tar.gz tor-aca05fc5c08d6296c4f93850a0256bfd96890b18.zip |
get_total_system_memory(): see how much RAM we have
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_util.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index a471b8eb19..20e65853d4 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -3606,6 +3606,34 @@ test_util_socketpair(void *arg) tor_close_socket(fds[1]); } +static void +test_util_max_mem(void *arg) +{ + size_t memory1, memory2; + int r, r2; + (void) arg; + + r = get_total_system_memory(&memory1); + r2 = get_total_system_memory(&memory2); + tt_int_op(r, ==, r2); + tt_int_op(memory2, ==, memory1); + + TT_BLATHER(("System memory: "U64_FORMAT, U64_PRINTF_ARG(memory1))); + + if (r==0) { + /* You have at least a megabyte. */ + tt_int_op(memory1, >, (1<<20)); + } else { + /* You do not have a petabyte. */ +#if SIZEOF_SIZE_T == SIZEOF_UINT64_T + tt_int_op(memory1, <, (U64_LITERAL(1)<<50)); +#endif + } + + done: + ; +} + struct testcase_t util_tests[] = { UTIL_LEGACY(time), UTIL_TEST(parse_http_time, 0), @@ -3669,6 +3697,7 @@ struct testcase_t util_tests[] = { (void*)"0" }, { "socketpair_ersatz", test_util_socketpair, TT_FORK, &socketpair_setup, (void*)"1" }, + UTIL_TEST(max_mem, 0), END_OF_TESTCASES }; |