test-iostream-pump.c revision 84b746f56209d4a85af73cd26850e75f519ae0b0
5a580c3a38ced62d4bcc95b8ac7c4f2935b5d294Timo Sirainen/* Copyright (c) 2016-2017 Dovecot authors, see the included COPYING file */
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen /* to somehow discern between error and success .. */
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainenstatic void pump_nonblocking_timeout(struct nonblock_ctx *ctx)
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen /* allow more input */
5cba8fd913459269b521513e16e3afcbbd030ac5Timo Sirainen /* allow more output. give always one byte less than the
9a4e08ad8a4cd4ee70e0c47e3e2eb1ee9f9a818dTimo Sirainen input size so there's something in internal buffer. */
9a4e08ad8a4cd4ee70e0c47e3e2eb1ee9f9a818dTimo Sirainen test_ostream_set_max_output_size(ctx->out, size-1);
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainenconst char *run_pump(struct istream *in, struct ostream *out, int *counter, buffer_t *out_buffer)
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen test_assert(i_stream_get_size(in, TRUE, &ctx.max_size) > 0);
d9e404180ff26dbbaea68534a5f176765022b76bTimo Sirainen to2 = timeout_add_short(0, pump_nonblocking_timeout, &ctx);
alarm(0);
return ret;
if (block)
int counter;
test_end();
int counter;
test_end();
int counter;
test_end();
int counter;
test_end();
int counter;
test_end();
int counter;
test_end();
if (!block) {
int counter;
test_end();
void test_iostream_pump(void)
T_BEGIN {
} T_END;