diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-08-05 14:01:49 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-08-05 14:01:49 -0400 |
commit | 50049df0d4b9ba3654749cfbb111c72e07d54bc5 (patch) | |
tree | 0e46b7707f5f298b52b5e423acbae8ac25876660 /src/test | |
parent | 9338847bf427b59d6dd5634fc2f8998ce0e269c1 (diff) | |
download | tor-50049df0d4b9ba3654749cfbb111c72e07d54bc5.tar.gz tor-50049df0d4b9ba3654749cfbb111c72e07d54bc5.zip |
Add a compat function to check how much disk space is free.
Closes ticket 16734.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_util.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 2bffb17bfd..f8e766162d 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -4347,6 +4347,30 @@ test_util_writepid(void *arg) tor_free(contents); } +static void +test_util_get_avail_disk_space(void *arg) +{ + (void) arg; + int64_t val; + + /* No answer for nonexistent directory */ + val = tor_get_avail_disk_space("/akljasdfklsajdklasjkldjsa"); + tt_int_op(val, OP_EQ, -1); + + /* Try the current directory */ + val = tor_get_avail_disk_space("."); + +#if !defined(HAVE_STATVFS) && !defined(_WIN32) + tt_i64_op(val, OP_EQ, -1); /* You don't have an implementation for this */ +#else + tt_i64_op(val, OP_GT, 0); /* You have some space. */ + tt_i64_op(val, OP_LT, ((int64_t)1)<<56); /* You don't have a zebibyte */ +#endif + + done: + ; +} + struct testcase_t util_tests[] = { UTIL_LEGACY(time), UTIL_TEST(parse_http_time, 0), @@ -4414,6 +4438,7 @@ struct testcase_t util_tests[] = { UTIL_TEST(hostname_validation, 0), UTIL_TEST(ipv4_validation, 0), UTIL_TEST(writepid, 0), + UTIL_TEST(get_avail_disk_space, 0), END_OF_TESTCASES }; |