dovecot-2.2: lib: test-istream-tee - more randomisation to the t...

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


details:   http://hg.dovecot.org/dovecot-2.2/rev/cba6877471ca
changeset: 17618:cba6877471ca
user:      Phil Carmody <phil at dovecot.fi>
date:      Thu Jul 10 15:59:53 2014 +0300
description:
lib: test-istream-tee - more randomisation to the tests
Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib/test-istream-tee.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (35 lines):

diff -r f87c9ca897a5 -r cba6877471ca src/lib/test-istream-tee.c
--- a/src/lib/test-istream-tee.c	Thu Jul 10 15:59:53 2014 +0300
+++ b/src/lib/test-istream-tee.c	Thu Jul 10 15:59:53 2014 +0300
@@ -47,23 +47,27 @@
 		test_assert(!tee_i_stream_child_is_waiting(child_input[i]));
 	}
 
-	for (len++; len <= TEST_STR_LEN; len++) {
+	delta = 1;
+	while ((len += delta) <= TEST_STR_LEN) {
 		test_istream_set_size(test_input, len);
 		for (i = 0; i < CHILD_COUNT; i++) {
 			test_assert(i_stream_read(child_input[i]) == -2);
 			test_assert(!tee_i_stream_child_is_waiting(child_input[i]));
 		}
 		for (i = 0; i < CHILD_COUNT-1; i++) {
-			i_stream_skip(child_input[i], 1);
+			i_stream_skip(child_input[i], delta);
 			test_assert(i_stream_read(child_input[i]) == 0);
 			test_assert(tee_i_stream_child_is_waiting(child_input[i]));
 		}
-		i_stream_skip(child_input[i], 1);
+		i_stream_skip(child_input[i], delta);
 		for (i = 0; i < CHILD_COUNT; i++) {
-			test_assert(i_stream_read(child_input[i]) == 1);
+			test_assert(i_stream_read(child_input[i]) == delta);
 			test_assert(i_stream_read(child_input[i]) == -2);
 			test_assert(!tee_i_stream_child_is_waiting(child_input[i]));
 		}
+		delta = rand() % 31 + 1; /* mustn't stand still */
+		if(delta > TEST_STR_LEN - len)
+			delta = 1;
 	}
 
 	for (i = 0; i < CHILD_COUNT-1; i++) {


More information about the dovecot-cvs mailing list