diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-09-08 14:39:20 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-09-08 14:39:20 -0400 |
commit | b0a9e54705d16d08ae7aff272492832dbb35646d (patch) | |
tree | 82064efbdc8c3ed2151c9783cbf6aab44e565df1 /src/test/test_rendcache.c | |
parent | d0fe86f39ebcc9b2e17ee3b7fb638e34c2133418 (diff) | |
download | tor-b0a9e54705d16d08ae7aff272492832dbb35646d.tar.gz tor-b0a9e54705d16d08ae7aff272492832dbb35646d.zip |
Resolve more BUG warnings in the unit tests
Diffstat (limited to 'src/test/test_rendcache.c')
-rw-r--r-- | src/test/test_rendcache.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/test/test_rendcache.c b/src/test/test_rendcache.c index e210e053b6..17d86bc39e 100644 --- a/src/test/test_rendcache.c +++ b/src/test/test_rendcache.c @@ -12,6 +12,7 @@ #include "config.h" #include <openssl/rsa.h> #include "rend_test_helpers.h" +#include "log_test_helpers.h" #define NS_MODULE rend_cache @@ -646,6 +647,7 @@ test_rend_cache_init(void *data) static void test_rend_cache_decrement_allocation(void *data) { + int log_level = 0; (void)data; // Test when the cache has enough allocations @@ -655,20 +657,27 @@ test_rend_cache_decrement_allocation(void *data) // Test when there are not enough allocations rend_cache_total_allocation = 1; + log_level = setup_full_capture_of_logs(LOG_WARN); rend_cache_decrement_allocation(2); tt_int_op(rend_cache_total_allocation, OP_EQ, 0); + expect_single_log_msg_containing( + "Underflow in rend_cache_decrement_allocation"); + teardown_capture_of_logs(log_level); + log_level = 0; // And again rend_cache_decrement_allocation(2); tt_int_op(rend_cache_total_allocation, OP_EQ, 0); done: - (void)0; + if (log_level) + teardown_capture_of_logs(log_level); } static void test_rend_cache_increment_allocation(void *data) { + int log_level = 0; (void)data; // Test when the cache is not overflowing @@ -678,15 +687,21 @@ test_rend_cache_increment_allocation(void *data) // Test when there are too many allocations rend_cache_total_allocation = SIZE_MAX-1; + log_level = setup_full_capture_of_logs(LOG_WARN); rend_cache_increment_allocation(2); tt_u64_op(rend_cache_total_allocation, OP_EQ, SIZE_MAX); + expect_single_log_msg_containing( + "Overflow in rend_cache_increment_allocation"); + teardown_capture_of_logs(log_level); + log_level = 0; // And again rend_cache_increment_allocation(2); tt_u64_op(rend_cache_total_allocation, OP_EQ, SIZE_MAX); done: - (void)0; + if (log_level) + teardown_capture_of_logs(log_level); } static void |