Mercurial > dovecot > original-hg > dovecot-1.2
changeset 7834:2ac2ca9089bf HEAD
tests: Test message-parser better with nonblocking input.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 12 Jun 2008 05:28:17 +0300 |
parents | c6a49099a4fc |
children | 1b0d19442120 |
files | src/tests/test-common.c src/tests/test-common.h src/tests/test-mail.c |
diffstat | 3 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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; @@ -37,6 +42,11 @@ 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) { test_out_reason(name, success, NULL);
--- 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);
--- 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 @@ 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; }