changeset 22596:1a7bbda6284b

iostream-multiplex: Check return values in tests
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Fri, 06 Oct 2017 08:52:18 +0300
parents a3632f4d817f
children 9a335a0ec5bc
files src/lib/test-istream-multiplex.c src/lib/test-multiplex.c src/lib/test-ostream-multiplex.c
diffstat 3 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/test-istream-multiplex.c	Fri Oct 06 08:46:00 2017 +0300
+++ b/src/lib/test-istream-multiplex.c	Fri Oct 06 08:52:18 2017 +0300
@@ -265,7 +265,7 @@
 		{ 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)
@@ -310,6 +310,7 @@
 	i_stream_unref(&chan0);
 	i_stream_unref(&is);
 
+	test_assert(o_stream_nfinish(os) == 0);
 	o_stream_unref(&os);
 
 	io_loop_destroy(&ioloop);
--- a/src/lib/test-multiplex.c	Fri Oct 06 08:46:00 2017 +0300
+++ b/src/lib/test-multiplex.c	Fri Oct 06 08:52:18 2017 +0300
@@ -38,8 +38,8 @@
 	unsigned char buf[128];
 	size_t len = 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)
@@ -107,8 +107,10 @@
 	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]);
--- a/src/lib/test-ostream-multiplex.c	Fri Oct 06 08:46:00 2017 +0300
+++ b/src/lib/test-ostream-multiplex.c	Fri Oct 06 08:52:18 2017 +0300
@@ -94,9 +94,9 @@
 	size_t rounds = 1 + rand() % 10;
 	for(size_t i = 0; i < rounds; i++) {
 		if ((rand() % 2) != 0)
-			o_stream_send_str(chan1, msgs[rand() % N_ELEMENTS(msgs)]);
+			o_stream_nsend_str(chan1, msgs[rand() % N_ELEMENTS(msgs)]);
 		else
-			o_stream_send_str(chan0, msgs[rand() % N_ELEMENTS(msgs)]);
+			o_stream_nsend_str(chan0, msgs[rand() % N_ELEMENTS(msgs)]);
 	}
 }
 
@@ -127,7 +127,9 @@
 	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);