diff options
author | Alexander Færøy <ahf@torproject.org> | 2017-04-20 15:56:38 +0200 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-04-25 08:10:09 -0400 |
commit | 1c77d8690caa1ad80b9d9581cac8eddae95e82d1 (patch) | |
tree | 87cb3f07a2919f11fef5eafe671bd97f8c825710 /src/test/test_util.c | |
parent | 04682d302aeeb0c2a0d9859bc0c1feee38daf16a (diff) | |
download | tor-1c77d8690caa1ad80b9d9581cac8eddae95e82d1.tar.gz tor-1c77d8690caa1ad80b9d9581cac8eddae95e82d1.zip |
Add function to check if a given compression method is supported.
This patch adds support for checking if a given `compress_method_t` is
supported by the currently running Tor instance using
`tor_compress_supports_method()`.
See: https://bugs.torproject.org/21662
Diffstat (limited to 'src/test/test_util.c')
-rw-r--r-- | src/test/test_util.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 6a7db3137a..1e33de82ae 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -2252,6 +2252,9 @@ test_util_gzip(void *arg) tor_compress_state_t *state = NULL; (void)arg; + tt_assert(tor_compress_supports_method(GZIP_METHOD)); + tt_assert(tor_compress_supports_method(ZLIB_METHOD)); + buf1 = tor_strdup("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ"); tt_assert(detect_compression_method(buf1, strlen(buf1)) == UNKNOWN_METHOD); @@ -2414,6 +2417,8 @@ test_util_lzma(void *arg) tor_compress_state_t *state = NULL; (void)arg; + tt_assert(tor_compress_supports_method(LZMA_METHOD)); + buf1 = tor_strdup("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ"); tt_assert(detect_compression_method(buf1, strlen(buf1)) == UNKNOWN_METHOD); @@ -2507,6 +2512,10 @@ test_util_lzma(void *arg) tor_free(buf1); #else (void)arg; + tt_assert(! tor_compress_supports_method(LZMA_METHOD)); + + done: + ; #endif // HAVE_LZMA. } @@ -2520,6 +2529,8 @@ test_util_zstd(void *arg) tor_compress_state_t *state = NULL; (void)arg; + tt_assert(tor_compress_supports_method(ZSTD_METHOD)); + buf1 = tor_strdup("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ"); tt_assert(detect_compression_method(buf1, strlen(buf1)) == UNKNOWN_METHOD); @@ -2613,6 +2624,10 @@ test_util_zstd(void *arg) tor_free(buf1); #else (void)arg; + tt_assert(! tor_compress_supports_method(ZSTD_METHOD)); + + done: + ; #endif // HAVE_ZSTD. } |