/* Copyright (c) 2014-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "istream.h"
#include "ostream.h"
#include "sha1.h"
#include "randgen.h"
#include "test-common.h"
#include "compression.h"
#include <unistd.h>
#include <fcntl.h>
{
const unsigned char *data;
unsigned int i;
int fd;
/* write compressed data */
if (fd == -1)
/* 1) write lots of easily compressible data */
}
/* 2) write uncompressible data */
}
/* 3) write semi-compressible data */
for (i = 0; i < sizeof(buf); i++) {
if (i_rand_limit(3) == 0)
else
buf[i] = i;
}
}
/* read and uncompress the data */
}
i_close_fd(&fd);
test_end();
}
static void test_compression(void)
{
unsigned int i;
}
}
{
return; /* not compiled in */
/* write concated output */
if (str2[0] != '\0') {
}
/* read concated input */
const unsigned char *data;
}
}
static void test_gz_concat(void)
{
test_begin("gz concat");
test_end();
}
static void test_gz_no_concat(void)
{
test_begin("gz no concat");
test_end();
}
static void test_gz_large_header(void)
{
static const unsigned char gz_input[] = {
0x1f, 0x8b, 0x08, 0x08,
'a','a','a','a','a','a','a','a','a','a','a',
0
};
size_t i;
return; /* not compiled in */
test_begin("gz large header");
/* max buffer size smaller than gz header */
for (i = 1; i < sizeof(gz_input); i++) {
}
/* max buffer size is exactly the gz header */
test_end();
}
{
const unsigned char *data;
break;
}
}
{
const unsigned char *data;
/* write the compressed output file */
if (fd_in == -1)
if (fd_out == -1)
}
if (o_stream_finish(output) < 0) {
i_fatal("write(%s) failed: %s",
}
/* verify that we can read the compressed file */
}
i_fatal("Decompression couldn't get the original input");
i_close_fd(&fd_out);
}
{
static void (*const test_functions[])(void) = {
};
if (argc == 2) {
return 0;
}
if (argc == 3) {
return 0;
}
return test_run(test_functions);
}