]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-compression: Fix test-compression to build without zlib
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 20 Feb 2017 12:26:41 +0000 (14:26 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 20 Feb 2017 12:26:41 +0000 (14:26 +0200)
src/lib-compression/test-compression.c

index f99f3a1ba3028690a8b1ab268a812dd95d051846..7779e5605c28c4584290d4efd632b16ee051c140 100644 (file)
@@ -7,7 +7,6 @@
 #include "sha1.h"
 #include "randgen.h"
 #include "test-common.h"
-#include "istream-zlib.h"
 #include "compression.h"
 
 #include <unistd.h>
@@ -155,13 +154,14 @@ static void test_gz_concat(void)
 
 static void test_gz_no_concat(void)
 {
-       test_begin("gz concat");
+       test_begin("gz no concat");
        test_gz("hello", "");
        test_end();
 }
 
 static void test_gz_large_header(void)
 {
+       const struct compression_handler *gz = compression_lookup_handler("gz");
        static const unsigned char gz_input[] = {
                0x1f, 0x8b, 0x08, 0x08,
                'a','a','a','a','a','a','a','a','a','a','a',
@@ -170,6 +170,9 @@ static void test_gz_large_header(void)
        struct istream *file_input, *input;
        size_t i;
 
+       if (gz == NULL || gz->create_istream == NULL)
+               return; /* not compiled in */
+
        test_begin("gz large header");
 
        /* max buffer size smaller than gz header */
@@ -178,7 +181,7 @@ static void test_gz_large_header(void)
                test_istream_set_size(file_input, i);
                test_istream_set_max_buffer_size(file_input, i);
 
-               input = i_stream_create_gz(file_input, FALSE);
+               input = gz->create_istream(file_input, FALSE);
                test_assert_idx(i_stream_read(input) == 0, i);
                test_assert_idx(i_stream_read(input) == -1 &&
                                input->stream_errno == EINVAL, i);
@@ -188,7 +191,7 @@ static void test_gz_large_header(void)
 
        /* max buffer size is exactly the gz header */
        file_input = test_istream_create_data(gz_input, sizeof(gz_input));
-       input = i_stream_create_gz(file_input, FALSE);
+       input = gz->create_istream(file_input, FALSE);
        test_istream_set_size(input, i);
        test_istream_set_allow_eof(input, FALSE);
        test_istream_set_max_buffer_size(input, i);