From: Timo Sirainen Date: Mon, 14 Sep 2020 07:27:26 +0000 (+0300) Subject: lib-compression: test-compression - Convert from ostream-buffer to iostream-temp X-Git-Tag: 2.3.13~174 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0416a3fdc025720a38e4de785f30bc654ca4ca16;p=thirdparty%2Fdovecot%2Fcore.git lib-compression: test-compression - Convert from ostream-buffer to iostream-temp Using ostream-buffer required 48083d9e7fdbe257b0be33043ecf0ca87489eef9 change, but this broke some code that assumed the original behavior. --- diff --git a/src/lib-compression/test-compression.c b/src/lib-compression/test-compression.c index 9873db543f..1d65426c1f 100644 --- a/src/lib-compression/test-compression.c +++ b/src/lib-compression/test-compression.c @@ -3,7 +3,7 @@ #include "lib.h" #include "buffer.h" #include "istream.h" -#include "istream-hash.h" +#include "iostream-temp.h" #include "ostream.h" #include "sha1.h" #include "randgen.h" @@ -533,8 +533,7 @@ test_compression_handler_large_random_io(const struct compression_handler *handl #define RANDOMNESS_SIZE (1024*1024) unsigned char *randomness; struct istream *input, *dec_input; - struct ostream *buf_output, *output; - buffer_t *buf; + struct ostream *temp_output, *output; const unsigned char *data; size_t size; int ret; @@ -546,9 +545,8 @@ test_compression_handler_large_random_io(const struct compression_handler *handl /* write 1 MB of randomness to buffer */ input = i_stream_create_from_data(randomness, RANDOMNESS_SIZE); - buf = buffer_create_dynamic(default_pool, 1024); - buf_output = o_stream_create_buffer(buf); - output = handler->create_ostream(buf_output, i_rand_minmax(1, 6)); + temp_output = iostream_temp_create(".temp.", 0); + output = handler->create_ostream(temp_output, i_rand_minmax(1, 6)); switch (o_stream_send_istream(output, input)) { case OSTREAM_SEND_ISTREAM_RESULT_ERROR_INPUT: @@ -564,13 +562,12 @@ test_compression_handler_large_random_io(const struct compression_handler *handl } test_assert(output->offset == RANDOMNESS_SIZE); test_assert(output->stream_errno == 0); - o_stream_unref(&buf_output); - o_stream_unref(&output); i_stream_unref(&input); + input = iostream_temp_finish(&temp_output, SIZE_MAX); + /* verify that reading the input works */ - input = i_stream_create_from_data(buf->data, buf->used); dec_input = handler->create_istream(input, FALSE); while ((ret = i_stream_read_more(dec_input, &data, &size)) > 0) { @@ -583,7 +580,6 @@ test_compression_handler_large_random_io(const struct compression_handler *handl i_stream_unref(&dec_input); i_stream_unref(&input); - buffer_free(&buf); i_free(randomness); test_end(); }