aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_buffers.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-04-27 11:19:51 -0400
committerNick Mathewson <nickm@torproject.org>2017-05-02 08:31:32 -0400
commit3836d9481f81cc1617a9a48de2c2ca178f4804c8 (patch)
tree820bd37f2d5397552b16b8778997352e925e9f6f /src/test/test_buffers.c
parent1bc21111d82579b6472357d43f07a85142b6614a (diff)
downloadtor-3836d9481f81cc1617a9a48de2c2ca178f4804c8.tar.gz
tor-3836d9481f81cc1617a9a48de2c2ca178f4804c8.zip
Add unit tests for the NO_METHOD compressor
These required some special-casing, since some of the assumption about real compression algorithms don't actually hold for the identity transform. Specifically, we had assumed: - compression functions typically change the lengths of their inputs. - decompression functions can detect truncated inputs - compression functions have detectable headers None of those is true for the identity transformation.
Diffstat (limited to 'src/test/test_buffers.c')
-rw-r--r--src/test/test_buffers.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/test/test_buffers.c b/src/test/test_buffers.c
index ce5ac97b3d..38b0824304 100644
--- a/src/test/test_buffers.c
+++ b/src/test/test_buffers.c
@@ -611,7 +611,11 @@ test_buffers_compress_fin_at_chunk_end_impl(compress_method_t method,
tt_int_op(fetch_from_buf(contents, in_len, buf), OP_EQ, 0);
- tt_uint_op(in_len, OP_GT, headerjunk);
+ if (method == NO_METHOD) {
+ tt_uint_op(in_len, OP_EQ, headerjunk);
+ } else {
+ tt_uint_op(in_len, OP_GT, headerjunk);
+ }
tt_int_op(0, OP_EQ, tor_uncompress(&expanded, &out_len,
contents + headerjunk,
@@ -855,6 +859,8 @@ struct testcase_t buffer_tests[] = {
&passthrough_setup, (char*)"x-zstd" },
{ "compress/lzma", test_buffers_compress, TT_FORK,
&passthrough_setup, (char*)"x-lzma" },
+ { "compress/none", test_buffers_compress, TT_FORK,
+ &passthrough_setup, (char*)"identity" },
END_OF_TESTCASES
};