"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/lib-compression/test-compression.c" between
dovecot-2.3.16.tar.gz and dovecot-2.3.17.tar.gz

About: Dovecot is an IMAP and POP3 server, written with security primarily in mind.

test-compression.c  (dovecot-2.3.16):test-compression.c  (dovecot-2.3.17)
skipping to change at line 12 skipping to change at line 12
#include "lib.h" #include "lib.h"
#include "buffer.h" #include "buffer.h"
#include "istream.h" #include "istream.h"
#include "iostream-temp.h" #include "iostream-temp.h"
#include "ostream.h" #include "ostream.h"
#include "sha1.h" #include "sha1.h"
#include "randgen.h" #include "randgen.h"
#include "test-common.h" #include "test-common.h"
#include "compression.h" #include "compression.h"
#include "iostream-lz4.h"
#include "hex-binary.h" #include "hex-binary.h"
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
static void test_compression_handler_detect(const struct compression_handler *ha ndler) static void test_compression_handler_detect(const struct compression_handler *ha ndler)
{ {
const unsigned char test_data[] = {'h','e','l','l','o',' ', const unsigned char test_data[] = {'h','e','l','l','o',' ',
'w','o','r','l','d','\n'}; 'w','o','r','l','d','\n'};
skipping to change at line 955 skipping to change at line 956
test_end(); test_end();
} }
static void test_gz_large_header(void) static void test_gz_large_header(void)
{ {
test_gz_large_header_int(FALSE); test_gz_large_header_int(FALSE);
test_gz_large_header_int(TRUE); test_gz_large_header_int(TRUE);
} }
static void test_lz4_small_header(void)
{
const struct compression_handler *lz4;
struct iostream_lz4_header lz4_input;
struct istream *file_input, *input;
if (compression_lookup_handler("lz4", &lz4) <= 0)
return; /* not compiled in or unkown */
test_begin("lz4 small header");
memcpy(lz4_input.magic, IOSTREAM_LZ4_MAGIC, IOSTREAM_LZ4_MAGIC_LEN);
lz4_input.max_uncompressed_chunk_size[0] = 0;
lz4_input.max_uncompressed_chunk_size[1] = 1;
lz4_input.max_uncompressed_chunk_size[2] = 0;
lz4_input.max_uncompressed_chunk_size[3] = 0;
/* truncated header */
file_input = i_stream_create_from_data(&lz4_input, sizeof(lz4_input)-1);
input = lz4->create_istream(file_input);
test_assert(i_stream_read(input) == -1 &&
input->stream_errno == EINVAL);
i_stream_unref(&input);
i_stream_unref(&file_input);
/* partial initial header read */
file_input = test_istream_create_data(&lz4_input, sizeof(lz4_input));
file_input->blocking = TRUE;
test_istream_set_max_buffer_size(file_input, sizeof(lz4_input)-1);
(void)i_stream_read(file_input);
test_istream_set_max_buffer_size(file_input, sizeof(lz4_input));
input = lz4->create_istream(file_input);
test_assert(i_stream_read(input) == -1 &&
input->stream_errno == 0);
i_stream_unref(&input);
i_stream_unref(&file_input);
test_end();
}
static void test_uncompress_file(const char *path) static void test_uncompress_file(const char *path)
{ {
const struct compression_handler *handler; const struct compression_handler *handler;
struct istream *input, *file_input; struct istream *input, *file_input;
const unsigned char *data; const unsigned char *data;
size_t size; size_t size;
int ret; int ret;
ret = compression_lookup_handler_from_ext(path, &handler); ret = compression_lookup_handler_from_ext(path, &handler);
if (ret < 0) if (ret < 0)
skipping to change at line 1066 skipping to change at line 1109
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
static void (*const test_functions[])(void) = { static void (*const test_functions[])(void) = {
test_compression, test_compression,
test_istream_decompression_try, test_istream_decompression_try,
test_gz_concat, test_gz_concat,
test_gz_no_concat, test_gz_no_concat,
test_gz_header, test_gz_header,
test_gz_large_header, test_gz_large_header,
test_lz4_small_header,
test_compression_ext, test_compression_ext,
NULL NULL
}; };
if (argc == 2) { if (argc == 2) {
test_uncompress_file(argv[1]); test_uncompress_file(argv[1]);
return 0; return 0;
} }
if (argc == 3) { if (argc == 3) {
test_compress_file(argv[1], argv[2]); test_compress_file(argv[1], argv[2]);
return 0; return 0;
 End of changes. 3 change blocks. 
0 lines changed or deleted 44 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)