From: Stephan Bosch Date: Tue, 7 Apr 2020 01:07:58 +0000 (+0200) Subject: lib-http: test-http-payload - Split off test_run_client/server() from test_run_client... X-Git-Tag: 2.3.13~714 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=afe749a69897320106c3e21ed5ca9324f00c1ba5;p=thirdparty%2Fdovecot%2Fcore.git lib-http: test-http-payload - Split off test_run_client/server() from test_run_client_server(). --- diff --git a/src/lib-http/test-http-payload.c b/src/lib-http/test-http-payload.c index 4aae08a8df..fc071532e6 100644 --- a/src/lib-http/test-http-payload.c +++ b/src/lib-http/test-http-payload.c @@ -1603,13 +1603,55 @@ static void test_server_kill_forced(void) } static void -test_run_client_server( +test_run_server(const struct http_server_settings *server_set) +{ + struct ioloop *ioloop; + + i_set_failure_prefix("SERVER: "); + + if (debug) + i_debug("PID=%s", my_pid); + + ioloop_nested = NULL; + ioloop_nested_depth = 0; + + ioloop = io_loop_create(); + test_server_init(server_set); + io_loop_run(ioloop); + test_server_deinit(); + io_loop_destroy(&ioloop); + + i_close_fd(&fd_listen); + test_files_deinit(); +} + +static void +test_run_client( const struct http_client_settings *client_set, - const struct http_server_settings *server_set, void (*client_init)(const struct http_client_settings *client_set)) { struct ioloop *ioloop; + i_set_failure_prefix("CLIENT: "); + + if (debug) + i_debug("PID=%s", my_pid); + + ioloop_nested = NULL; + ioloop_nested_depth = 0; + ioloop = io_loop_create(); + client_init(client_set); + io_loop_run(ioloop); + test_client_deinit(); + io_loop_destroy(&ioloop); +} + +static void +test_run_client_server( + const struct http_client_settings *client_set, + const struct http_server_settings *server_set, + void (*client_init)(const struct http_client_settings *client_set)) +{ failure = NULL; test_open_server_fd(); @@ -1623,20 +1665,10 @@ test_run_client_server( server_pid = (pid_t)-1; hostpid_init(); lib_signals_deinit(); + /* child: server */ - i_set_failure_prefix("SERVER: "); - if (debug) - i_debug("PID=%s", my_pid); - ioloop_nested = NULL; - ioloop_nested_depth = 0; - ioloop = io_loop_create(); - test_server_init(server_set); - io_loop_run(ioloop); - test_server_deinit(); - io_loop_destroy(&ioloop); - - i_close_fd(&fd_listen); - test_files_deinit(); + test_run_server(server_set); + lib_deinit(); exit(1); } @@ -1645,16 +1677,7 @@ test_run_client_server( lib_signals_ioloop_attach(); /* parent: client */ - i_set_failure_prefix("CLIENT: "); - if (debug) - i_debug("PID=%s", my_pid); - ioloop_nested = NULL; - ioloop_nested_depth = 0; - ioloop = io_loop_create(); - client_init(client_set); - io_loop_run(ioloop); - test_client_deinit(); - io_loop_destroy(&ioloop); + test_run_client(client_set, client_init); i_unset_failure_prefix(); test_server_kill_forced();