From: Stephan Bosch Date: Sat, 11 Apr 2020 11:51:49 +0000 (+0200) Subject: master: test-master-login-auth - Split off test_run_server/client() from test_run_cli... X-Git-Tag: 2.3.13~584 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4f0b28f3fec5881d93cf6352bb0e643ab497abbb;p=thirdparty%2Fdovecot%2Fcore.git master: test-master-login-auth - Split off test_run_server/client() from test_run_client_server(). --- diff --git a/src/master/test-master-login-auth.c b/src/master/test-master-login-auth.c index 025380fd94..4ea8e77fa3 100644 --- a/src/master/test-master-login-auth.c +++ b/src/master/test-master-login-auth.c @@ -893,6 +893,36 @@ static void test_server_kill_forced(void) } } +static void test_run_server(test_server_init_t *server_test) +{ + i_set_failure_prefix("SERVER: "); + + if (debug) + i_debug("PID=%s", my_pid); + + ioloop = io_loop_create(); + server_test(); + io_loop_destroy(&ioloop); + + i_close_fd(&fd_listen); +} + +static void test_run_client(test_client_init_t *client_test) +{ + i_set_failure_prefix("CLIENT: "); + + if (debug) + i_debug("PID=%s", my_pid); + + i_sleep_intr_msecs(100); /* wait a little for server setup */ + + ioloop = io_loop_create(); + if (client_test()) + io_loop_run(ioloop); + test_client_deinit(); + io_loop_destroy(&ioloop); +} + static void test_run_client_server(test_client_init_t *client_test, test_server_init_t *server_test) @@ -914,15 +944,10 @@ test_run_client_server(test_client_init_t *client_test, io_loop_destroy(&ioloop); } lib_signals_deinit(); + /* child: server */ - i_set_failure_prefix("SERVER: "); - if (debug) - i_debug("PID=%s", my_pid); - ioloop = io_loop_create(); - server_test(); - io_loop_destroy(&ioloop); - if (fd_listen != -1) - i_close_fd(&fd_listen); + test_run_server(server_test); + /* wait for it to be killed; this way, valgrind will not object to this process going away inelegantly. */ i_sleep_intr_secs(60); @@ -935,17 +960,7 @@ test_run_client_server(test_client_init_t *client_test, } /* parent: client */ - i_set_failure_prefix("CLIENT: "); - if (debug) - i_debug("PID=%s", my_pid); - - i_sleep_intr_msecs(100); /* wait a little for server setup */ - - ioloop = io_loop_create(); - if (client_test()) - io_loop_run(ioloop); - test_client_deinit(); - io_loop_destroy(&ioloop); + test_run_client(client_test); i_unset_failure_prefix(); test_server_kill_forced();