From: Aki Tuomi Date: Fri, 6 Oct 2017 05:52:18 +0000 (+0300) Subject: iostream-multiplex: Check return values in tests X-Git-Tag: 2.3.0.rc1~856 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bc038dfe3ea41392ab50cd4c1c1fdd620cc3deef;p=thirdparty%2Fdovecot%2Fcore.git iostream-multiplex: Check return values in tests --- diff --git a/src/lib/test-istream-multiplex.c b/src/lib/test-istream-multiplex.c index 7d927dfbf1..f510f3b2bd 100644 --- a/src/lib/test-istream-multiplex.c +++ b/src/lib/test-istream-multiplex.c @@ -264,7 +264,7 @@ static void test_send_msg(struct ostream *os, uint8_t cid, const char *msg) { msg, strlen(msg) }, { "\n", 1 } /* newline added for i_stream_next_line */ }; - o_stream_sendv(os, iov, N_ELEMENTS(iov)); + o_stream_nsendv(os, iov, N_ELEMENTS(iov)); } static void test_istream_multiplex_stream_write(struct ostream *channel) @@ -309,6 +309,7 @@ static void test_istream_multiplex_stream(void) i_stream_unref(&chan0); i_stream_unref(&is); + test_assert(o_stream_nfinish(os) == 0); o_stream_unref(&os); io_loop_destroy(&ioloop); diff --git a/src/lib/test-multiplex.c b/src/lib/test-multiplex.c index d7e1f279d1..a4d3a4cfe0 100644 --- a/src/lib/test-multiplex.c +++ b/src/lib/test-multiplex.c @@ -37,8 +37,8 @@ static void test_multiplex_channel_write(struct test_channel *channel) unsigned char buf[128]; size_t len = i_rand() % sizeof(buf); random_fill(buf, len); - o_stream_send(channel->out, buf, len); - o_stream_send(channel->out_alt, buf, len); + o_stream_nsend(channel->out, buf, len); + o_stream_nsend(channel->out_alt, buf, len); } static void test_multiplex_stream_write(struct ostream *channel ATTR_UNUSED) @@ -106,8 +106,10 @@ static void teardown_channel(struct test_channel *channel) io_remove(&channel->io); io_remove(&channel->io_alt); i_stream_unref(&channel->in); + test_assert(o_stream_nfinish(channel->out) == 0); o_stream_unref(&channel->out); i_stream_unref(&channel->in_alt); + test_assert(o_stream_nfinish(channel->out_alt) == 0); o_stream_unref(&channel->out_alt); i_close_fd(&channel->fds[0]); i_close_fd(&channel->fds[1]); diff --git a/src/lib/test-ostream-multiplex.c b/src/lib/test-ostream-multiplex.c index 0228badd47..29cc8bb169 100644 --- a/src/lib/test-ostream-multiplex.c +++ b/src/lib/test-ostream-multiplex.c @@ -92,9 +92,9 @@ static void test_ostream_multiplex_stream_write(struct ostream *channel ATTR_UNU size_t rounds = 1 + i_rand() % 10; for(size_t i = 0; i < rounds; i++) { if ((i_rand() % 2) != 0) - o_stream_send_str(chan1, msgs[i_rand() % N_ELEMENTS(msgs)]); + o_stream_nsend_str(chan1, msgs[i_rand() % N_ELEMENTS(msgs)]); else - o_stream_send_str(chan0, msgs[i_rand() % N_ELEMENTS(msgs)]); + o_stream_nsend_str(chan0, msgs[i_rand() % N_ELEMENTS(msgs)]); } } @@ -125,7 +125,9 @@ static void test_ostream_multiplex_stream(void) io_remove(&io0); io_remove(&io1); + test_assert(o_stream_nfinish(chan1) == 0); o_stream_unref(&chan1); + test_assert(o_stream_nfinish(chan0) == 0); o_stream_unref(&chan0); i_stream_unref(&is);