dovecot-2.0: Removed istream test code that hasn't been tried fo...

dovecot at dovecot.org dovecot at dovecot.org
Sun Feb 28 14:13:36 EET 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/0c3e147505f4
changeset: 10808:0c3e147505f4
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Feb 25 09:54:12 2010 +0200
description:
Removed istream test code that hasn't been tried for years.

diffstat:

 src/lib/istream.c |  115 ---------------------------------------------------------
 1 files changed, 0 insertions(+), 115 deletions(-)

diffs (122 lines):

diff -r ba19f3c077a8 -r 0c3e147505f4 src/lib/istream.c
--- a/src/lib/istream.c	Mon Feb 22 19:10:24 2010 +0200
+++ b/src/lib/istream.c	Thu Feb 25 09:54:12 2010 +0200
@@ -583,118 +583,3 @@
 	io_stream_init(&_stream->iostream);
 	return &_stream->istream;
 }
-
-#ifdef STREAM_TEST
-/* gcc istream.c -o teststream liblib.a -Wall -DHAVE_CONFIG_H -DSTREAM_TEST -g */
-
-#include <fcntl.h>
-#include <unistd.h>
-#include "ostream.h"
-
-#define BUF_VALUE(offset) \
-        (((offset) % 256) ^ ((offset) / 256))
-
-static void check_buffer(const unsigned char *data, size_t size, size_t offset)
-{
-	size_t i;
-
-	for (i = 0; i < size; i++)
-		i_assert(data[i] == BUF_VALUE(i+offset));
-}
-
-int main(void)
-{
-	struct istream *input, *l_input;
-	struct ostream *output1, *output2;
-	int i, fd1, fd2;
-	unsigned char buf[1024];
-	const unsigned char *data;
-	size_t size;
-
-	lib_init();
-
-	fd1 = open("teststream.1", O_RDWR | O_CREAT | O_TRUNC, 0600);
-	if (fd1 < 0)
-		i_fatal("open() failed: %m");
-	fd2 = open("teststream.2", O_RDWR | O_CREAT | O_TRUNC, 0600);
-	if (fd2 < 0)
-		i_fatal("open() failed: %m");
-
-	/* write initial data */
-	for (i = 0; i < sizeof(buf); i++)
-		buf[i] = BUF_VALUE(i);
-	write(fd1, buf, sizeof(buf));
-
-	/* test reading */
-	input = i_stream_create_fd(fd1, 512, FALSE);
-	i_assert(i_stream_get_size(input) == sizeof(buf));
-
-	i_assert(i_stream_read_data(input, &data, &size, 0) > 0);
-	i_assert(size == 512);
-	check_buffer(data, size, 0);
-
-	i_stream_seek(input, 256);
-	i_assert(i_stream_read_data(input, &data, &size, 0) > 0);
-	i_assert(size == 512);
-	check_buffer(data, size, 256);
-
-	i_stream_seek(input, 0);
-	i_assert(i_stream_read_data(input, &data, &size, 512) == -2);
-	i_assert(size == 512);
-	check_buffer(data, size, 0);
-
-	i_stream_skip(input, 900);
-	i_assert(i_stream_read_data(input, &data, &size, 0) > 0);
-	i_assert(size == sizeof(buf) - 900);
-	check_buffer(data, size, 900);
-
-	/* test moving data */
-	output1 = o_stream_create_fd(fd1, 512, FALSE);
-	output2 = o_stream_create_fd(fd2, 512, FALSE);
-
-	i_stream_seek(input, 1); size = sizeof(buf)-1;
-	i_assert(o_stream_send_istream(output2, input) == size);
-	o_stream_flush(output2);
-
-	lseek(fd2, 0, SEEK_SET);
-	i_assert(read(fd2, buf, sizeof(buf)) == size);
-	check_buffer(buf, size, 1);
-
-	i_stream_seek(input, 0);
-	o_stream_seek(output1, sizeof(buf));
-	i_assert(o_stream_send_istream(output1, input) == sizeof(buf));
-
-	/* test moving with limits */
-	l_input = i_stream_create_limit(input, sizeof(buf)/2, 512);
-	i_stream_seek(l_input, 0);
-	o_stream_seek(output1, 10);
-	i_assert(o_stream_send_istream(output1, l_input) == 512);
-
-	i_stream_set_max_buffer_size(input, sizeof(buf));
-
-	i_stream_seek(input, 0);
-	i_assert(i_stream_read_data(input, &data, &size, sizeof(buf)-1) > 0);
-	i_assert(size == sizeof(buf));
-	check_buffer(data, 10, 0);
-	check_buffer(data + 10, 512, sizeof(buf)/2);
-	check_buffer(data + 10 + 512,
-		     size - (10 + 512), 10 + 512);
-
-	/* reading within limits */
-	i_stream_seek(l_input, 0);
-	i_assert(i_stream_read_data(l_input, &data, &size, 511) > 0);
-	i_assert(size == 512);
-	i_assert(i_stream_read_data(l_input, &data, &size, 512) == -2);
-	i_assert(size == 512);
-	i_stream_skip(l_input, 511);
-	i_assert(i_stream_read_data(l_input, &data, &size, 0) > 0);
-	i_assert(size == 1);
-	i_stream_skip(l_input, 1);
-	i_assert(i_stream_read_data(l_input, &data, &size, 0) == -1);
-	i_assert(size == 0);
-
-	unlink("teststream.1");
-	unlink("teststream.2");
-	return 0;
-}
-#endif


More information about the dovecot-cvs mailing list