summaryrefslogtreecommitdiff
path: root/src/test/test_util.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-04-27 10:25:52 -0400
committerNick Mathewson <nickm@torproject.org>2017-04-27 10:25:52 -0400
commit166aa8d7416989aa0f5e3169a0f08a1d1bea619d (patch)
tree372c93ec83849d40cb86d9722ac6c3ff9ad6c93e /src/test/test_util.c
parent36e62ae7e2e3d7fdec074a6dd5d6d2dfa9871a9f (diff)
downloadtor-166aa8d7416989aa0f5e3169a0f08a1d1bea619d.tar.gz
tor-166aa8d7416989aa0f5e3169a0f08a1d1bea619d.zip
Have a separate entry point for each compresion test
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r--src/test/test_util.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 920766f4df..1ac1e29ea8 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -2351,13 +2351,15 @@ test_util_compress_stream_impl(compress_method_t method,
static void
test_util_compress(void *arg)
{
- (void) arg;
- compress_method_t methods[] = {
- GZIP_METHOD,
- ZLIB_METHOD,
- LZMA_METHOD,
- ZSTD_METHOD
- };
+ const char *methodname = arg;
+ tt_assert(methodname);
+
+ compress_method_t method = compression_method_get_by_name(methodname);
+ tt_int_op(method, OP_NE, UNKNOWN_METHOD);
+
+ if (! tor_compress_supports_method(method)) {
+ tt_skip();
+ }
compression_level_t levels[] = {
BEST_COMPRESSION,
@@ -2366,19 +2368,14 @@ test_util_compress(void *arg)
LOW_COMPRESSION
};
- for (unsigned m = 0; m < ARRAY_LENGTH(methods); ++m) {
- compress_method_t method = methods[m];
+ test_util_compress_impl(method);
- if (! tor_compress_supports_method(method))
- continue;
-
- test_util_compress_impl(method);
-
- for (unsigned l = 0; l < ARRAY_LENGTH(levels); ++l) {
- compression_level_t level = levels[l];
- test_util_compress_stream_impl(method, level);
- }
+ for (unsigned l = 0; l < ARRAY_LENGTH(levels); ++l) {
+ compression_level_t level = levels[l];
+ test_util_compress_stream_impl(method, level);
}
+ done:
+ ;
}
static void
@@ -5720,6 +5717,10 @@ test_util_htonll(void *arg)
#define UTIL_TEST(name, flags) \
{ #name, test_util_ ## name, flags, NULL, NULL }
+#define COMPRESS(name, identifier) \
+ { "compress/" #name, test_util_compress, 0, &passthrough_setup, \
+ (char*)(identifier) }
+
#ifdef _WIN32
#define UTIL_TEST_NO_WIN(n, f) { #n, NULL, TT_SKIP, NULL, NULL }
#define UTIL_TEST_WIN_ONLY(n, f) UTIL_TEST(n, (f))
@@ -5744,7 +5745,10 @@ struct testcase_t util_tests[] = {
UTIL_LEGACY(strmisc),
UTIL_TEST(parse_integer, 0),
UTIL_LEGACY(pow2),
- UTIL_LEGACY(compress),
+ COMPRESS(zlib, "deflate"),
+ COMPRESS(gzip, "gzip"),
+ COMPRESS(lzma, "x-lzma"),
+ COMPRESS(zstd, "x-zstd"),
UTIL_TEST(gzip_compression_bomb, TT_FORK),
UTIL_LEGACY(datadir),
UTIL_LEGACY(memarea),