dovecot-1.2: tests: Test message-parser better with nonblocking ...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Jun 12 06:10:09 EEST 2008
details: http://hg.dovecot.org/dovecot-1.2/rev/2ac2ca9089bf
changeset: 7834:2ac2ca9089bf
user: Timo Sirainen <tss at iki.fi>
date: Thu Jun 12 05:28:17 2008 +0300
description:
tests: Test message-parser better with nonblocking input.
diffstat:
3 files changed, 17 insertions(+), 3 deletions(-)
src/tests/test-common.c | 10 ++++++++++
src/tests/test-common.h | 1 +
src/tests/test-mail.c | 9 ++++++---
diffs (61 lines):
diff -r c6a49099a4fc -r 2ac2ca9089bf src/tests/test-common.c
--- a/src/tests/test-common.c Thu Jun 12 02:54:39 2008 +0300
+++ b/src/tests/test-common.c Thu Jun 12 05:28:17 2008 +0300
@@ -20,6 +20,11 @@ static ssize_t test_read(struct istream_
return -1;
}
+static ssize_t test_noread(struct istream_private *stream ATTR_UNUSED)
+{
+ return 0;
+}
+
struct istream *test_istream_create(const char *data)
{
struct istream *input;
@@ -35,6 +40,11 @@ void test_istream_set_size(struct istrea
void test_istream_set_size(struct istream *input, uoff_t size)
{
input->real_stream->pos = size;
+}
+
+void test_istream_set_allow_eof(struct istream *input, bool allow)
+{
+ input->real_stream->read = allow ? test_read : test_noread;
}
void test_out(const char *name, bool success)
diff -r c6a49099a4fc -r 2ac2ca9089bf src/tests/test-common.h
--- a/src/tests/test-common.h Thu Jun 12 02:54:39 2008 +0300
+++ b/src/tests/test-common.h Thu Jun 12 05:28:17 2008 +0300
@@ -3,6 +3,7 @@
struct istream *test_istream_create(const char *data);
void test_istream_set_size(struct istream *input, uoff_t size);
+void test_istream_set_allow_eof(struct istream *input, bool allow);
void test_out(const char *name, bool success);
void test_out_reason(const char *name, bool success, const char *reason);
diff -r c6a49099a4fc -r 2ac2ca9089bf src/tests/test-mail.c
--- a/src/tests/test-mail.c Thu Jun 12 02:54:39 2008 +0300
+++ b/src/tests/test-mail.c Thu Jun 12 05:28:17 2008 +0300
@@ -224,13 +224,16 @@ static void test_message_parser(void)
i_stream_unref(&input);
input = test_istream_create(test_msg);
+ test_istream_set_allow_eof(input, FALSE);
parser = message_parser_init(pool, input, 0, 0);
- for (i = 1; i <= TEST_MSG_LEN; i++) {
- test_istream_set_size(input, i);
+ for (i = 1; i <= TEST_MSG_LEN*2+1; i++) {
+ test_istream_set_size(input, i/2);
+ if (i > TEST_MSG_LEN*2)
+ test_istream_set_allow_eof(input, TRUE);
while ((ret = message_parser_parse_next_block(parser,
&block)) > 0) ;
- if (ret < 0 && i < TEST_MSG_LEN) {
+ if (ret < 0 && i < TEST_MSG_LEN*2) {
success = FALSE;
break;
}
More information about the dovecot-cvs
mailing list