From: Stephan Bosch Date: Tue, 4 May 2021 00:19:07 +0000 (+0200) Subject: lib-program-client: test-program-client-unix - Add test for delayed disconnect after... X-Git-Tag: 2.3.16~224 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d9ce815d935e4689d2d02e2f5817a949a74719ee;p=thirdparty%2Fdovecot%2Fcore.git lib-program-client: test-program-client-unix - Add test for delayed disconnect after sending result code. --- diff --git a/src/lib-program-client/test-program-client-unix.c b/src/lib-program-client/test-program-client-unix.c index 4bfbcab26c..2965813971 100644 --- a/src/lib-program-client/test-program-client-unix.c +++ b/src/lib-program-client/test-program-client-unix.c @@ -137,6 +137,12 @@ test_program_input_handle(struct test_client *client, const char *line) return 0; } +static void test_program_end(struct test_client *client) +{ + timeout_remove(&test_globals.to); + test_program_client_destroy(&client); +} + static void test_program_run(struct test_client *client) { const char *const *args; @@ -157,7 +163,12 @@ static void test_program_run(struct test_client *client) } else if (strcmp(args[0], "test_program_failure") == 0) { o_stream_nsend_str(client->out, "-\n"); } - test_program_client_destroy(&client); + if (count < 3 || strcmp(args[1], "slow_disconnect") != 0) + test_program_client_destroy(&client); + else { + test_globals.to = timeout_add_short( + 500, test_program_end, client); + } } static void test_program_input(struct test_client *client) @@ -292,17 +303,11 @@ static void test_program_success(void) test_end(); } -static void test_program_io(void) +static void test_program_io_common(const char *const *args) { struct program_client *pc; int ret; - const char *const args[] = { - "test_program_io", NULL - }; - - test_begin("test_program_io (async)"); - pc = program_client_unix_create(TEST_SOCKET, args, &pc_set, FALSE); struct istream *is = test_istream_create(pclient_test_io_string); @@ -324,6 +329,25 @@ static void test_program_io(void) i_stream_unref(&is); o_stream_unref(&os); buffer_free(&output); +} + +static void test_program_io(void) +{ + const char *args[3] = { + "test_program_io", NULL, NULL + }; + + test_begin("test_program_io (async)"); + + test_program_io_common(args); + + test_end(); + + args[1] = "slow_disconnect"; + + test_begin("test_program_io (async, slow disconnect)"); + + test_program_io_common(args); test_end(); }