mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-26 07:31:33 +01:00
Have a separate entry point for each compresion test
This commit is contained in:
parent
36e62ae7e2
commit
166aa8d741
2 changed files with 50 additions and 39 deletions
|
@ -689,13 +689,15 @@ test_buffers_compress_impl(compress_method_t method,
|
||||||
static void
|
static void
|
||||||
test_buffers_compress(void *arg)
|
test_buffers_compress(void *arg)
|
||||||
{
|
{
|
||||||
(void) arg;
|
const char *methodname = arg;
|
||||||
compress_method_t methods[] = {
|
tt_assert(methodname);
|
||||||
GZIP_METHOD,
|
|
||||||
ZLIB_METHOD,
|
compress_method_t method = compression_method_get_by_name(methodname);
|
||||||
LZMA_METHOD,
|
tt_int_op(method, OP_NE, UNKNOWN_METHOD);
|
||||||
ZSTD_METHOD
|
|
||||||
};
|
if (! tor_compress_supports_method(method)) {
|
||||||
|
tt_skip();
|
||||||
|
}
|
||||||
|
|
||||||
compression_level_t levels[] = {
|
compression_level_t levels[] = {
|
||||||
BEST_COMPRESSION,
|
BEST_COMPRESSION,
|
||||||
|
@ -704,12 +706,6 @@ test_buffers_compress(void *arg)
|
||||||
LOW_COMPRESSION
|
LOW_COMPRESSION
|
||||||
};
|
};
|
||||||
|
|
||||||
for (unsigned m = 0; m < ARRAY_LENGTH(methods); ++m) {
|
|
||||||
compress_method_t method = methods[m];
|
|
||||||
|
|
||||||
if (! tor_compress_supports_method(method))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (unsigned l = 0; l < ARRAY_LENGTH(levels); ++l) {
|
for (unsigned l = 0; l < ARRAY_LENGTH(levels); ++l) {
|
||||||
compression_level_t level = levels[l];
|
compression_level_t level = levels[l];
|
||||||
|
|
||||||
|
@ -717,7 +713,9 @@ test_buffers_compress(void *arg)
|
||||||
test_buffers_compress_impl(method, level, 1);
|
test_buffers_compress_impl(method, level, 1);
|
||||||
test_buffers_compress_fin_at_chunk_end_impl(method, level);
|
test_buffers_compress_fin_at_chunk_end_impl(method, level);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
done:
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const uint8_t *tls_read_ptr;
|
static const uint8_t *tls_read_ptr;
|
||||||
|
@ -844,11 +842,20 @@ struct testcase_t buffer_tests[] = {
|
||||||
{ "allocation_tracking", test_buffer_allocation_tracking, TT_FORK,
|
{ "allocation_tracking", test_buffer_allocation_tracking, TT_FORK,
|
||||||
NULL, NULL },
|
NULL, NULL },
|
||||||
{ "time_tracking", test_buffer_time_tracking, TT_FORK, NULL, NULL },
|
{ "time_tracking", test_buffer_time_tracking, TT_FORK, NULL, NULL },
|
||||||
{ "compress", test_buffers_compress, TT_FORK, NULL, NULL },
|
|
||||||
{ "tls_read_mocked", test_buffers_tls_read_mocked, 0,
|
{ "tls_read_mocked", test_buffers_tls_read_mocked, 0,
|
||||||
NULL, NULL },
|
NULL, NULL },
|
||||||
{ "chunk_size", test_buffers_chunk_size, 0, NULL, NULL },
|
{ "chunk_size", test_buffers_chunk_size, 0, NULL, NULL },
|
||||||
{ "find_contentlen", test_buffers_find_contentlen, 0, NULL, NULL },
|
{ "find_contentlen", test_buffers_find_contentlen, 0, NULL, NULL },
|
||||||
|
|
||||||
|
{ "compress/zlib", test_buffers_compress, TT_FORK,
|
||||||
|
&passthrough_setup, (char*)"deflate" },
|
||||||
|
{ "compress/gzip", test_buffers_compress, TT_FORK,
|
||||||
|
&passthrough_setup, (char*)"gzip" },
|
||||||
|
{ "compress/zstd", test_buffers_compress, TT_FORK,
|
||||||
|
&passthrough_setup, (char*)"x-zstd" },
|
||||||
|
{ "compress/lzma", test_buffers_compress, TT_FORK,
|
||||||
|
&passthrough_setup, (char*)"x-lzma" },
|
||||||
|
|
||||||
END_OF_TESTCASES
|
END_OF_TESTCASES
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2351,13 +2351,15 @@ test_util_compress_stream_impl(compress_method_t method,
|
||||||
static void
|
static void
|
||||||
test_util_compress(void *arg)
|
test_util_compress(void *arg)
|
||||||
{
|
{
|
||||||
(void) arg;
|
const char *methodname = arg;
|
||||||
compress_method_t methods[] = {
|
tt_assert(methodname);
|
||||||
GZIP_METHOD,
|
|
||||||
ZLIB_METHOD,
|
compress_method_t method = compression_method_get_by_name(methodname);
|
||||||
LZMA_METHOD,
|
tt_int_op(method, OP_NE, UNKNOWN_METHOD);
|
||||||
ZSTD_METHOD
|
|
||||||
};
|
if (! tor_compress_supports_method(method)) {
|
||||||
|
tt_skip();
|
||||||
|
}
|
||||||
|
|
||||||
compression_level_t levels[] = {
|
compression_level_t levels[] = {
|
||||||
BEST_COMPRESSION,
|
BEST_COMPRESSION,
|
||||||
|
@ -2366,19 +2368,14 @@ test_util_compress(void *arg)
|
||||||
LOW_COMPRESSION
|
LOW_COMPRESSION
|
||||||
};
|
};
|
||||||
|
|
||||||
for (unsigned m = 0; m < ARRAY_LENGTH(methods); ++m) {
|
|
||||||
compress_method_t method = methods[m];
|
|
||||||
|
|
||||||
if (! tor_compress_supports_method(method))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
test_util_compress_impl(method);
|
test_util_compress_impl(method);
|
||||||
|
|
||||||
for (unsigned l = 0; l < ARRAY_LENGTH(levels); ++l) {
|
for (unsigned l = 0; l < ARRAY_LENGTH(levels); ++l) {
|
||||||
compression_level_t level = levels[l];
|
compression_level_t level = levels[l];
|
||||||
test_util_compress_stream_impl(method, level);
|
test_util_compress_stream_impl(method, level);
|
||||||
}
|
}
|
||||||
}
|
done:
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -5720,6 +5717,10 @@ test_util_htonll(void *arg)
|
||||||
#define UTIL_TEST(name, flags) \
|
#define UTIL_TEST(name, flags) \
|
||||||
{ #name, test_util_ ## name, flags, NULL, NULL }
|
{ #name, test_util_ ## name, flags, NULL, NULL }
|
||||||
|
|
||||||
|
#define COMPRESS(name, identifier) \
|
||||||
|
{ "compress/" #name, test_util_compress, 0, &passthrough_setup, \
|
||||||
|
(char*)(identifier) }
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define UTIL_TEST_NO_WIN(n, f) { #n, NULL, TT_SKIP, NULL, NULL }
|
#define UTIL_TEST_NO_WIN(n, f) { #n, NULL, TT_SKIP, NULL, NULL }
|
||||||
#define UTIL_TEST_WIN_ONLY(n, f) UTIL_TEST(n, (f))
|
#define UTIL_TEST_WIN_ONLY(n, f) UTIL_TEST(n, (f))
|
||||||
|
@ -5744,7 +5745,10 @@ struct testcase_t util_tests[] = {
|
||||||
UTIL_LEGACY(strmisc),
|
UTIL_LEGACY(strmisc),
|
||||||
UTIL_TEST(parse_integer, 0),
|
UTIL_TEST(parse_integer, 0),
|
||||||
UTIL_LEGACY(pow2),
|
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_TEST(gzip_compression_bomb, TT_FORK),
|
||||||
UTIL_LEGACY(datadir),
|
UTIL_LEGACY(datadir),
|
||||||
UTIL_LEGACY(memarea),
|
UTIL_LEGACY(memarea),
|
||||||
|
|
Loading…
Add table
Reference in a new issue