dovecot-2.2: lib: test-istream-concat - add simultanious limit s...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jul 10 13:02:04 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/4583a0c2e368
changeset: 17616:4583a0c2e368
user:      Phil Carmody <phil at dovecot.fi>
date:      Thu Jul 10 15:59:53 2014 +0300
description:
lib: test-istream-concat - add simultanious limit streams back into the mix
Return to the previous complex nested stream-type case.

1 time in 10, it tests the simple case of:

test_stream \
test_stream -}- concat_stream
test_stream /
(2-11 of these)

9 times in 10, it tests this configuration instead:

test_stream \                  / limit_stream
test_stream -}- concat_stream {- limit_stream
test_stream /                  \ limit_stream
(2-11 of these)                 (1-9 of these)

Since 31efe2d04793 lib: istream-concat read() returned -2 too early., all tests
pass every time.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib/test-istream-concat.c |  20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diffs (49 lines):

diff -r 9280679be21e -r 4583a0c2e368 src/lib/test-istream-concat.c
--- a/src/lib/test-istream-concat.c	Thu Jul 10 15:59:53 2014 +0300
+++ b/src/lib/test-istream-concat.c	Thu Jul 10 15:59:53 2014 +0300
@@ -51,11 +51,11 @@
 
 static bool test_istream_concat_random(void)
 {
-	struct istream **streams, *input;
+	struct istream **streams, *concat, **limits = NULL;
 	const unsigned char *data;
 	unsigned char *w_data;
 	size_t size = 0;
-	unsigned int i, j, offset, stream_count, data_len;
+	unsigned int i, j, offset, stream_count, data_len, simult;
 
 	stream_count = (rand() % TEST_MAX_ISTREAM_COUNT) + 2;
 	streams = t_new(struct istream *, stream_count + 1);
@@ -70,10 +70,18 @@
 	streams[i] = NULL;
 	i_assert(offset > 0);
 
-	input = i_stream_create_concat(streams);
-	i_stream_set_max_buffer_size(input, TEST_MAX_BUFFER_SIZE);
+	concat = i_stream_create_concat(streams);
+	i_stream_set_max_buffer_size(concat, TEST_MAX_BUFFER_SIZE);
+
+	simult = rand() % TEST_MAX_ISTREAM_COUNT;
+	if (simult > 0) {
+		limits = t_new(struct istream *, simult);
+		for (i = 0; i < simult; i++)
+			limits[i] = i_stream_create_limit(concat, (uoff_t)-1);
+	}
 
 	for (i = 0; i < 1000; i++) {
+		struct istream *input = (simult == 0) ? concat : limits[rand() % simult];
 		if (rand() % 3 == 0) {
 			i_stream_seek(input, rand() % offset);
 		} else {
@@ -97,7 +105,9 @@
 	}
 	for (i = 0; i < stream_count; i++)
 		i_stream_unref(&streams[i]);
-	i_stream_unref(&input);
+	for (i = 0; i < simult; i++)
+		i_stream_unref(&limits[i]);
+	i_stream_unref(&concat);
 	return !test_has_failed();
 }
 


More information about the dovecot-cvs mailing list