summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-08-31 14:30:34 -0400
committerNick Mathewson <nickm@torproject.org>2016-08-31 14:30:34 -0400
commitd4f05dcd0e0fe654d64950d70d6d54ff7a6a280e (patch)
treefd79bbf700c155a6a23a72a84d462aa41d06a008 /src/test
parentd299c043d405e0ba2f565009270bba012def6191 (diff)
downloadtor-d4f05dcd0e0fe654d64950d70d6d54ff7a6a280e.tar.gz
tor-d4f05dcd0e0fe654d64950d70d6d54ff7a6a280e.zip
Detect and suppress bug message from zlib compression bomb test
Diffstat (limited to 'src/test')
-rw-r--r--src/test/log_test_helpers.h7
-rw-r--r--src/test/test_util.c9
2 files changed, 15 insertions, 1 deletions
diff --git a/src/test/log_test_helpers.h b/src/test/log_test_helpers.h
index 039c7ae1eb..f33ee67a90 100644
--- a/src/test/log_test_helpers.h
+++ b/src/test/log_test_helpers.h
@@ -35,6 +35,13 @@ int mock_saved_log_has_entry(void);
tt_assert_msg(mock_saved_log_has_message_containing(str), \
"expected log to contain " # str);
+#define expect_single_log_msg_containing(str) \
+ do { \
+ tt_assert_msg(mock_saved_log_has_message_containing(str), \
+ "expected log to contain " # str); \
+ tt_int_op(smartlist_len(mock_saved_logs()), OP_EQ, 1); \
+ } while (0);
+
#define expect_no_log_msg(str) \
tt_assert_msg(!mock_saved_log_has_message(str), \
"expected log to not contain " # str);
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 061398cb84..2ff9d77104 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -2216,10 +2216,17 @@ test_util_gzip_compression_bomb(void *arg)
size_t result_len = 0;
tor_zlib_state_t *state = NULL;
+
/* Make sure we can't produce a compression bomb */
+ const int prev_level = setup_full_capture_of_logs(LOG_WARN);
tt_int_op(-1, OP_EQ, tor_gzip_compress(&result, &result_len,
one_mb, one_million,
ZLIB_METHOD));
+ expect_single_log_msg_containing(
+ "We compressed something and got an insanely high "
+ "compression factor; other Tors would think this "
+ "was a zlib bomb.");
+ teardown_capture_of_logs(prev_level);
/* Here's a compression bomb that we made manually. */
const char compression_bomb[1039] =
@@ -5464,7 +5471,7 @@ struct testcase_t util_tests[] = {
UTIL_LEGACY(strmisc),
UTIL_LEGACY(pow2),
UTIL_LEGACY(gzip),
- UTIL_LEGACY(gzip_compression_bomb),
+ UTIL_TEST(gzip_compression_bomb, TT_FORK),
UTIL_LEGACY(datadir),
UTIL_LEGACY(memarea),
UTIL_LEGACY(control_formats),