]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-test: test-common - Add test generic event
authorStephan Bosch <stephan.bosch@open-xchange.com>
Mon, 27 Oct 2025 20:30:51 +0000 (21:30 +0100)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 5 Nov 2025 10:17:48 +0000 (10:17 +0000)
Use it to replace events created for some individual tests. Also replace the
event created by test-submission.

20 files changed:
src/imap/test-imap-client-hibernate.c
src/lib-auth-client/test-auth-client.c
src/lib-auth-client/test-auth-master.c
src/lib-http/test-http-client-errors.c
src/lib-http/test-http-payload.c
src/lib-http/test-http-server-errors.c
src/lib-imap-client/test-imapc-client.c
src/lib-login/test-login-server-auth.c
src/lib-lua/test-lua-http-client.c
src/lib-master/test-event-stats.c
src/lib-sasl/test-sasl-authentication.c
src/lib-smtp/test-smtp-client-errors.c
src/lib-smtp/test-smtp-payload.c
src/lib-smtp/test-smtp-server-errors.c
src/lib-smtp/test-smtp-submit.c
src/lib-storage/test-mail.c
src/lib-test/test-common.c
src/lib-test/test-common.h
src/lib-test/test-subprocess.c
src/lib-test/test-subprocess.h

index 3f18b966e4c4c7bb3871d13a73f3d8bbec56b535..6ee48d7feb00ac6d68cda367a90042dce08d8f85 100644 (file)
@@ -322,7 +322,7 @@ int main(int argc, char *argv[])
 
        master_service_init_finish(master_service);
        test_tmp_dir_init();
-       test_subprocesses_init(FALSE);
+       test_subprocesses_init();
 
        static void (*const test_functions[])(void) = {
                test_imap_client_hibernate,
index 2007f10b1fc4f0aff6e64187f0814c566d88e393..2dc5f5ee061f495758925fc662fdebc7173975e3 100644 (file)
@@ -1268,8 +1268,9 @@ int main(int argc, char *argv[])
        }
 
        test_init();
+       event_set_forced_debug(test_event, debug);
        test_set_cleanup_callback(main_cleanup);
-       test_subprocesses_init(debug);
+       test_subprocesses_init();
 
        ret = test_run(test_functions);
 
index 596fa01e9359dedac3ae458f68614f79e032c570..4392fcc87dc471afec243b9e9067360102ef0e01 100644 (file)
@@ -1922,8 +1922,9 @@ int main(int argc, char *argv[])
        }
 
        test_init();
+       event_set_forced_debug(test_event, debug);
        test_set_cleanup_callback(main_cleanup);
-       test_subprocesses_init(debug);
+       test_subprocesses_init();
 
        ret = test_run(test_functions);
 
index 38c9f48e3218fa1d2cb742368f800e1ce0dfc6df..e0a5bacb9ca49cfa420214b4518b80b2b6ebc775 100644 (file)
@@ -3819,7 +3819,8 @@ int main(int argc, char *argv[])
        }
 
        test_init();
-       test_subprocesses_init(debug);
+       event_set_forced_debug(test_event, debug);
+       test_subprocesses_init();
 
        /* listen on localhost */
        i_zero(&bind_ip);
index 1c5f290484200001a7a2b8eeb7da6b6b98ec1604..115c44934c00e962c4090d6b46938c6422b23ab4 100644 (file)
@@ -38,7 +38,7 @@ enum payload_handling {
 };
 
 static bool debug = FALSE;
-static struct event *test_event, *client_event, *server_event;
+static struct event *common_event, *client_event, *server_event;
 static bool small_socket_buffers = FALSE;
 static const char *failure = NULL;
 static struct timeout *to_continue = NULL;
@@ -141,7 +141,7 @@ static void test_files_read_dir(const char *path)
 
        /* Close the directory */
        if (closedir(dirp) < 0)
-               e_error(test_event, "test files: "
+               e_error(common_event, "test files: "
                        "failed to close directory %s: %m", path);
 }
 
@@ -174,7 +174,7 @@ test_file_open(const char *path, unsigned int *status_r, const char **reason_r)
 
        fd = open(path, O_RDONLY);
        if (fd < 0) {
-               e_debug(test_event, "test files: open(%s) failed: %m", path);
+               e_debug(common_event, "test files: open(%s) failed: %m", path);
 
                switch (errno) {
                case EFAULT:
@@ -1693,7 +1693,7 @@ static int test_run_server(struct test_server_data *data)
 
        i_set_failure_prefix("SERVER: ");
 
-       e_debug(test_event, "PID=%s", my_pid);
+       e_debug(common_event, "PID=%s", my_pid);
 
        ioloop_nested = NULL;
        ioloop_nested_depth = 0;
@@ -1703,7 +1703,7 @@ static int test_run_server(struct test_server_data *data)
        test_server_deinit();
        io_loop_destroy(&ioloop);
 
-       e_debug(test_event, "Terminated");
+       e_debug(common_event, "Terminated");
 
        i_close_fd(&fd_listen);
        test_files_deinit();
@@ -1722,7 +1722,7 @@ test_run_client(
 
        i_set_failure_prefix("CLIENT: ");
 
-       e_debug(test_event, "PID=%s", my_pid);
+       e_debug(common_event, "PID=%s", my_pid);
 
        ioloop_nested = NULL;
        ioloop_nested_depth = 0;
@@ -1733,7 +1733,7 @@ test_run_client(
        test_client_deinit();
        io_loop_destroy(&ioloop);
 
-       e_debug(test_event, "Terminated");
+       e_debug(common_event, "Terminated");
 }
 
 static void
@@ -2435,12 +2435,11 @@ static void (*const test_functions[])(void) = {
 static void main_init(void)
 {
        ssl_iostream_openssl_init();
-       test_event = event_create(NULL);
-       client_event = event_create(test_event);
+       common_event = test_event;
+       client_event = event_create(common_event);
        event_set_append_log_prefix(client_event, "test client: ");
-       server_event = event_create(test_event);
+       server_event = event_create(common_event);
        event_set_append_log_prefix(server_event, "test server: ");
-       event_set_forced_debug(server_event, debug);
 }
 
 static void main_deinit(void)
@@ -2449,7 +2448,7 @@ static void main_deinit(void)
        ssl_iostream_openssl_deinit();
        event_unref(&client_event);
        event_unref(&server_event);
-       event_unref(&test_event);
+       common_event = NULL;
 }
 
 int main(int argc, char *argv[])
@@ -2458,15 +2457,11 @@ int main(int argc, char *argv[])
        int ret;
 
        lib_init();
-       main_init();
 
        while ((c = getopt(argc, argv, "DS")) > 0) {
                switch (c) {
                case 'D':
                        debug = TRUE;
-                       event_set_forced_debug(test_event, TRUE);
-                       event_set_forced_debug(client_event, TRUE);
-                       event_set_forced_debug(server_event, TRUE);
                        break;
                case 'S':
                        small_socket_buffers = TRUE;
@@ -2477,7 +2472,9 @@ int main(int argc, char *argv[])
        }
 
        test_init();
-       test_subprocesses_init(debug);
+       event_set_forced_debug(test_event, debug);
+       test_subprocesses_init();
+       main_init();
 
        /* listen on localhost */
        i_zero(&bind_ip);
index efb15dedc3788f9afb32a7fc6a78f51026aba8b1..41fdb195b8cd46051c2516cb1a6aa6516b2e06d6 100644 (file)
@@ -1027,7 +1027,8 @@ int main(int argc, char *argv[])
        }
 
        test_init();
-       test_subprocesses_init(debug);
+       event_set_forced_debug(test_event, debug);
+       test_subprocesses_init();
 
        /* listen on localhost */
        i_zero(&bind_ip);
index e1bf9c8ba3697d597f6c01ee14d3e733e7d084b6..e5e857a18b8e5e5b05f90d829838db56a7f75e90 100644 (file)
@@ -961,7 +961,8 @@ int main(int argc ATTR_UNUSED, char *argv[])
        }
 
        test_init();
-       test_subprocesses_init(debug);
+       event_set_forced_debug(test_event, debug);
+       test_subprocesses_init();
 
        /* listen on localhost */
        i_zero(&bind_ip);
index 97caa218e3cf3a32231a95474a15756f7d78558a..5c70e7085d9d8399c9b9b4e369f16ad45cc7a708 100644 (file)
@@ -983,8 +983,9 @@ int main(int argc, char *argv[])
        master_service_init_finish(master_service);
 
        test_init();
+       event_set_forced_debug(test_event, debug);
        test_set_cleanup_callback(main_cleanup);
-       test_subprocesses_init(debug);
+       test_subprocesses_init();
 
        ret = test_run(test_functions);
 
index 216d6a4a5ca989b6dc3c779ca2ba0b91d4b464d2..29239cbca176ac54969f615139bf74fecac879c1 100644 (file)
@@ -55,13 +55,14 @@ typedef void (*test_dns_init_t)(void);
  */
 
 /* common */
+static struct event *common_event;
 static struct ip_addr bind_ip;
 static in_port_t *bind_ports = 0;
 static struct ioloop *ioloop;
 static bool debug = FALSE;
-static struct event *test_event;
 
 /* server */
+static struct event *server_event, *dns_event;
 static struct io *io_listen;
 static int fd_listen = -1;
 static struct connection_list *server_conn_list;
@@ -73,6 +74,7 @@ static void (*test_server_deinit)(struct server_connection *conn);
 static void (*test_server_input)(struct server_connection *conn);
 
 /* client */
+static struct event *client_event;
 static struct timeout *to_client_progress = NULL;
 
 /*
@@ -112,7 +114,7 @@ test_dns_simple_post_input(struct server_connection *conn)
        while ((line = i_stream_read_next_line(conn->conn.input)) != NULL) {
                if (str_begins_with(line, "VERSION"))
                        continue;
-               e_debug(test_event, "DNS REQUEST: %s", line);
+               e_debug(dns_event, "DNS REQUEST: %s", line);
 
                if (strcmp(line, "IP\thosta") == 0) {
                        o_stream_nsend_str(conn->conn.output,
@@ -264,7 +266,7 @@ test_client_simple_post_run_post(struct dlua_script *script, const char *url)
        if (lua_isinteger(script->L, -1)) {
                ret = lua_tointeger(script->L, -1);
                /* not guaranteed to fail, but it will happen often */
-               e_debug(test_event, "http_request_post() returned %d", ret);
+               e_debug(client_event, "http_request_post() returned %d", ret);
                test_assert(ret == 0);
        }
 
@@ -277,12 +279,12 @@ static bool test_client_simple_post(void)
        struct dlua_script *script;
        const char *error;
 
-       if (event_want_debug(test_event))
+       if (event_want_debug(client_event))
                test_expect_errors(4);
 
        if (dlua_script_create_file(
                TEST_LUA_SCRIPT_DIR "/test-lua-http-client.lua",
-               &script, test_event, &error) < 0)
+               &script, client_event, &error) < 0)
                i_fatal("dlua_script_create_file() failed: %s", error);
 
        dlua_dovecot_register(script);
@@ -311,12 +313,12 @@ static bool test_client_second_post(void)
        struct dlua_script *script;
        const char *error;
 
-       if (event_want_debug(test_event))
+       if (event_want_debug(client_event))
                test_expect_errors(4);
 
        if (dlua_script_create_file(
                TEST_LUA_SCRIPT_DIR "/test-lua-http-client.lua",
-               &script, test_event, &error) < 0)
+               &script, client_event, &error) < 0)
                i_fatal("dlua_script_create_file() failed: %s", error);
 
        dlua_dovecot_register(script);
@@ -384,12 +386,12 @@ static void test_bad_settings(void)
 
        test_begin("bad settings");
 
-       if (event_want_debug(test_event))
+       if (event_want_debug(common_event))
                test_expect_errors(4);
 
        if (dlua_script_create_file(
                TEST_LUA_SCRIPT_DIR "/test-lua-http-client.lua",
-               &script, test_event, &error) < 0)
+               &script, common_event, &error) < 0)
                i_fatal("dlua_script_create_file() failed: %s", error);
 
        dlua_dovecot_register(script);
@@ -634,7 +636,7 @@ static int test_open_server_fd(in_port_t *bind_port)
 {
        int fd = net_listen(&bind_ip, bind_port, 128);
 
-       e_debug(test_event, "server listening on %u", *bind_port);
+       e_debug(common_event, "server listening on %u", *bind_port);
        if (fd == -1) {
                i_fatal("listen(%s:%u) failed: %m",
                        net_ip2addr(&bind_ip), *bind_port);
@@ -646,7 +648,7 @@ static int test_run_server(struct test_server_data *data)
 {
        i_set_failure_prefix("SERVER[%u]: ", data->index + 1);
 
-       e_debug(test_event, "PID=%s", my_pid);
+       e_debug(server_event, "PID=%s", my_pid);
 
        server_ssl_ctx = NULL;
 
@@ -655,11 +657,10 @@ static int test_run_server(struct test_server_data *data)
        data->server_test(data->index);
        io_loop_destroy(&ioloop);
 
-       e_debug(test_event, "Terminated");
+       e_debug(server_event, "Terminated");
 
        i_close_fd(&fd_listen);
        i_free(bind_ports);
-       event_unref(&test_event);
        main_deinit();
        master_service_deinit_forked(&master_service);
        return 0;
@@ -671,18 +672,17 @@ static int test_run_dns(test_dns_init_t dns_test)
 
        i_set_failure_prefix("DNS: ");
 
-       e_debug(test_event, "PID=%s", my_pid);
+       e_debug(dns_event, "PID=%s", my_pid);
 
        test_subprocess_notify_signal_send_parent(SIGHUP);
        ioloop = io_loop_create();
        dns_test();
        io_loop_destroy(&ioloop);
 
-       e_debug(test_event, "Terminated");
+       e_debug(dns_event, "Terminated");
 
        i_close_fd(&fd_listen);
        i_free(bind_ports);
-       event_unref(&test_event);
        main_deinit();
        master_service_deinit_forked(&master_service);
        return 0;
@@ -692,13 +692,13 @@ static void test_run_client(test_client_init_t client_test)
 {
        i_set_failure_prefix("CLIENT: ");
 
-       e_debug(test_event, "PID=%s", my_pid);
+       e_debug(client_event, "PID=%s", my_pid);
 
        ioloop = io_loop_create();
        test_client_run(client_test);
        io_loop_destroy(&ioloop);
 
-       e_debug(test_event, "Terminated");
+       e_debug(client_event, "Terminated");
 }
 
 static void
@@ -773,12 +773,25 @@ test_run_client_server(test_client_init_t client_test,
 static void main_init(void)
 {
        ssl_iostream_openssl_init();
+
+       common_event = test_event;
+       client_event = event_create(common_event);
+       event_set_append_log_prefix(client_event, "test client: ");
+       server_event = event_create(common_event);
+       event_set_append_log_prefix(server_event, "test server: ");
+       dns_event = event_create(common_event);
+       event_set_append_log_prefix(dns_event, "test dns: ");
 }
 
 static void main_deinit(void)
 {
        ssl_iostream_context_cache_free();
        ssl_iostream_openssl_deinit();
+
+       event_unref(&client_event);
+       event_unref(&server_event);
+       event_unref(&dns_event);
+       common_event = NULL;
 }
 
 int main(int argc, char *argv[])
@@ -809,25 +822,20 @@ int main(int argc, char *argv[])
        if (master_service_settings_read_simple(master_service, &error) < 0)
                i_fatal("Error reading configuration: %s", error);
 
-       main_init();
-
        master_service_init_finish(master_service);
 
        test_init();
-       test_subprocesses_init(debug);
+       event_set_forced_debug(test_event, debug);
+       test_subprocesses_init();
+       main_init();
 
        /* listen on localhost */
        i_zero(&bind_ip);
        bind_ip.family = AF_INET;
        bind_ip.u.ip4.s_addr = htonl(INADDR_LOOPBACK);
 
-       test_event = event_create(NULL);
-       event_set_forced_debug(test_event, debug);
-
        ret = test_run(test_functions);
 
-       event_unref(&test_event);
-
        main_deinit();
        master_service_deinit(&master_service);
 
index e3f60dbaf9dfff63f0bf93be5ac705e8666623a2..6c39219cc3e495563f43a9f6f03fc9f04cec770c 100644 (file)
@@ -564,6 +564,7 @@ int main(void)
        int ret;
        i_set_info_handler(test_fail_callback);
        lib_init();
+       test_init_no_event();
        ret = run_tests();
        lib_deinit();
        return ret;
index 4a9451435c46e21abfeb67bf10659cdbb375a4a8..cec76cc28e028093baa252cec9cb69a32387e67f 100644 (file)
@@ -62,8 +62,6 @@ struct test_sasl_context {
        bool finished:1;
 };
 
-struct event *test_event;
-
 static void
 test_create_channel_binding_data(struct test_sasl_context *tctx, const char *type)
 {
@@ -1602,7 +1600,7 @@ int main(int argc, char *argv[])
                }
        }
 
-       test_event = event_create(NULL);
+       test_init();
        event_set_forced_debug(test_event, debug);
        password_schemes_init();
        dsasl_clients_init();
@@ -1617,7 +1615,6 @@ int main(int argc, char *argv[])
 
        dsasl_clients_deinit();
        password_schemes_deinit();
-       event_unref(&test_event);
        lib_signals_deinit();
        lib_deinit();
        return ret;
index abb69c7bc539882bbe1e911fddfabc2d0abc3c4b..b25b97151c6e9b2f3b977a2d3102e7aa070adf59 100644 (file)
@@ -4344,7 +4344,8 @@ int main(int argc, char *argv[])
        }
 
        test_init();
-       test_subprocesses_init(debug);
+       event_set_forced_debug(test_event, debug);
+       test_subprocesses_init();
 
        /* listen on localhost */
        i_zero(&bind_ip);
index 98724eeeb7d06abfb4381e793aa47e4f3204cba3..3fd0cd3c2487abd56fab90b76aafdec6ded45cb4 100644 (file)
@@ -1537,7 +1537,8 @@ int main(int argc, char *argv[])
        }
 
        test_init();
-       test_subprocesses_init(debug);
+       event_set_forced_debug(test_event, debug);
+       test_subprocesses_init();
 
        /* listen on localhost */
        i_zero(&bind_ip);
index 804ecb0c104b55d9d4b40ede00ccd2655245d26e..0fa90b818c92ef9565ebf4ec09cce20b3490969a 100644 (file)
@@ -4168,7 +4168,8 @@ int main(int argc, char *argv[])
        }
 
        test_init();
-       test_subprocesses_init(debug);
+       event_set_forced_debug(test_event, debug);
+       test_subprocesses_init();
 
        /* listen on localhost */
        i_zero(&bind_ip);
index dab6c45761926206bbd7f591a9064a9a12935737..5132fda3e4f6338845676e3eeb8e104c8df239db 100644 (file)
@@ -2191,7 +2191,8 @@ int main(int argc, char *argv[])
        master_service_init_finish(master_service);
 
        test_init();
-       test_subprocesses_init(debug);
+       event_set_forced_debug(test_event, debug);
+       test_subprocesses_init();
 
        /* listen on localhost */
        i_zero(&bind_ip);
index 367fbf157d918a8c21497733e1aa4892e7df4bf6..3262d06af2721c6e0b154e9dcac13df6daf6a64f 100644 (file)
@@ -7,8 +7,6 @@
 #include "message-size.h"
 #include "test-mail-storage-common.h"
 
-static struct event *test_event;
-
 static int
 test_mail_save_trans(struct mailbox_transaction_context *trans,
                     struct istream *input)
@@ -748,11 +746,9 @@ int main(int argc, char **argv)
                                             MASTER_SERVICE_FLAG_NO_INIT_DATASTACK_FRAME,
                                             &argc, &argv, "");
 
-       test_event = event_create(NULL);
        if (null_strcmp(argv[1], "-D") == 0)
                event_set_forced_debug(test_event, TRUE);
        ret = test_run(tests);
-       event_unref(&test_event);
        master_service_deinit(&master_service);
        return ret;
 }
index 9ae966c35100eca6b50bf6f69643d1ba73eda5a0..d3604bde3a49a3a08bb4784aed6b3f433a8ca64b 100644 (file)
@@ -22,6 +22,8 @@ static jmp_buf fatal_jmpbuf;
 
 #define OUT_NAME_ALIGN 70
 
+struct event *test_event = NULL;
+
 static char *test_prefix;
 static bool test_success;
 static bool test_running;
@@ -405,7 +407,7 @@ static void test_atexit(void)
        test_cleanup();
 }
 
-void test_init(void)
+void test_init_no_event(void)
 {
        if (test_initialized)
                return;
@@ -425,6 +427,16 @@ void test_init(void)
        /* Don't set fatal handler until actually needed for fatal testing */
 }
 
+void test_init(void)
+{
+       if (test_initialized)
+               return;
+
+       test_init_no_event();
+       test_event = event_create(NULL);
+       event_set_append_log_prefix(test_event, "test: ");
+}
+
 void test_init_signals(void)
 {
        lib_signals_init();
@@ -446,6 +458,8 @@ static int test_deinit(void)
 
        test_subprocesses_deinit();
 
+       event_unref(&test_event);
+
        if (test_deinit_lib)
                lib_deinit();
        if (test_deinit_lib_signals)
@@ -453,6 +467,11 @@ static int test_deinit(void)
        return failure_count == 0 ? 0 : 1;
 }
 
+void test_forked_deinit(void)
+{
+       event_unref(&test_event);
+}
+
 static void test_run_funcs(void (*const test_functions[])(void))
 {
        unsigned int i;
@@ -568,6 +587,8 @@ int test_run_named_with_fatals(const char *match, const struct named_test tests[
 
 void test_forked_end(void)
 {
+       test_forked_deinit();
+
        i_set_error_handler(default_error_handler);
        i_set_fatal_handler(default_fatal_handler);
 
@@ -581,6 +602,8 @@ void test_forked_end(void)
 void ATTR_NORETURN
 test_exit(int status)
 {
+       test_forked_deinit();
+
        i_free_and_null(expected_error_str);
        i_free_and_null(expected_fatal_str);
        i_free_and_null(test_prefix);
index fadae3b382db7443fe7fa27867dd5ad316b4a7c9..26343c199591a19028050c7655e54c1916e1a410 100644 (file)
@@ -8,6 +8,8 @@
 #  define ON_VALGRIND FALSE
 #endif
 
+extern struct event *test_event;
+
 struct istream *test_istream_create(const char *data);
 struct istream *test_istream_create_data(const void *data, size_t size);
 void test_istream_set_size(struct istream *input, uoff_t size);
@@ -147,6 +149,8 @@ void test_out_reason_quiet(const char *name, bool success, const char *reason)
        ATTR_NULL(3);
 
 void test_init(void);
+void test_init_no_event(void);
+void test_forked_deinit(void);
 
 int test_run(void (*const test_functions[])(void)) ATTR_WARN_UNUSED_RESULT;
 struct named_test {
index 7e8ce087e3900f993a12f4bcc9b229974ca7bbb1..9e94e62811008ab8f93647cb5a29f38583a616c5 100644 (file)
@@ -21,7 +21,6 @@ struct test_subprocess {
 
 volatile sig_atomic_t test_subprocess_child_mark = 0;
 static volatile bool test_subprocess_notification_signal_received[SIGUSR1 + 1];
-static struct event *test_subprocess_event = NULL;
 static ARRAY(struct test_subprocess *) test_subprocesses = ARRAY_INIT;
 static void
 test_subprocess_notification_signal(const siginfo_t *si, void *context);
@@ -75,7 +74,7 @@ test_subprocess_child(int (*func)(void *context), void *context,
        /* Prevent race condition */
        lib_signals_clear_handlers_and_ignore(SIGTERM);
 
-       event_unref(&test_subprocess_event);
+       test_forked_deinit();
        lib_signals_deinit();
 
        if (!continue_test) {
@@ -125,20 +124,20 @@ static void test_subprocess_verify_exit_status(int status)
                       WIFEXITED(status) && WEXITSTATUS(status) == 0);
        if (WIFEXITED(status)) {
                if (WEXITSTATUS(status) != 0) {
-                       e_warning(test_subprocess_event,
+                       e_warning(test_event,
                                  "Sub-process exited with status %d",
                                  WEXITSTATUS(status));
                }
        } else if (WIFSIGNALED(status)) {
-               e_warning(test_subprocess_event,
+               e_warning(test_event,
                          "Sub-process forcibly terminated with signal %d",
                          WTERMSIG(status));
        } else if (WIFSTOPPED(status)) {
-               e_warning(test_subprocess_event,
+               e_warning(test_event,
                          "Sub-process stopped with signal %d",
                          WSTOPSIG(status));
        } else {
-               e_warning(test_subprocess_event,
+               e_warning(test_event,
                          "Sub-process terminated abnormally with status %d",
                          status);
        }
@@ -193,7 +192,7 @@ test_subprocess_wait_for_children(unsigned int timeout_secs,
                test_assert(wret > 0 || errno == ECHILD);
                if (wret < 0) {
                        if (errno == EINTR) {
-                               e_warning(test_subprocess_event,
+                               e_warning(test_event,
                                          "Wait for sub-processes timed out");
                                break;
                        }
@@ -210,7 +209,7 @@ test_subprocess_wait_for_children(unsigned int timeout_secs,
                                i_assert(subps_left == 0);
                                break;
                        }
-                       e_warning(test_subprocess_event,
+                       e_warning(test_event,
                                  "Wait for sub-processes failed: %m");
                        break;
                }
@@ -219,7 +218,7 @@ test_subprocess_wait_for_children(unsigned int timeout_secs,
                for (i = 0; i < subps_count; i++) {
                        if (subps[i] == NULL || subps[i]->pid != wret)
                                continue;
-                       e_debug(test_subprocess_event,
+                       e_debug(test_event,
                                "Terminated sub-process [%u]", i);
                        i_free(subps[i]);
                        subps_left--;
@@ -248,10 +247,10 @@ void test_subprocess_kill_all(unsigned int timeout_secs)
                if (subps[i] == NULL || subps[i]->pid == (pid_t)-1)
                        continue;
 
-               e_debug(test_subprocess_event,
+               e_debug(test_event,
                        "Terminating sub-process [%u]", i);
                if (kill(subps[i]->pid, SIGTERM) < 0) {
-                       e_error(test_subprocess_event,
+                       e_error(test_event,
                                "Failed to kill sub-process [%u] with SIGTERM: "
                                "%m", i);
                }
@@ -264,8 +263,7 @@ void test_subprocess_kill_all(unsigned int timeout_secs)
        for (i = 0; i < subps_count; i++) {
                if (subps[i] == NULL || subps[i]->pid == (pid_t)-1)
                        continue;
-               e_warning(test_subprocess_event,
-                         "Forcibly killed sub-process [%u]", i);
+               e_warning(test_event, "Forcibly killed sub-process [%u]", i);
                test_subprocess_kill_forced(subps[i]);
                i_assert(subps_left > 0);
                i_free(subps[i]);
@@ -381,7 +379,7 @@ test_subprocess_notification_signal(const siginfo_t *si,
        test_subprocess_notification_signal_received[signo] = TRUE;
 }
 
-void test_subprocesses_init(bool debug)
+void test_subprocesses_init(void)
 {
        test_init();
        test_init_signals();
@@ -392,10 +390,6 @@ void test_subprocesses_init(bool debug)
        lib_signals_set_handler(SIGALRM, 0, test_subprocess_alarm, NULL);
 
        i_array_init(&test_subprocesses, 8);
-
-       test_subprocess_event = event_create(NULL);
-       event_set_forced_debug(test_subprocess_event, debug);
-       event_set_append_log_prefix(test_subprocess_event, "test: ");
 }
 
 void test_subprocesses_deinit(void)
@@ -403,6 +397,4 @@ void test_subprocesses_deinit(void)
        test_subprocess_cleanup();
        test_subprocess_free_all();
        array_free(&test_subprocesses);
-
-       event_unref(&test_subprocess_event);
 }
index edfccbadc44242fd7aabe5bf8d804948c2323340..9c321ccf339982c8316972a388df6c6816215def 100644 (file)
@@ -42,6 +42,6 @@ void test_subprocess_notify_signal_reset(int signo);
    If the timeout is reached, i_fatal() is called. */
 void test_subprocess_notify_signal_wait(int signo, unsigned int timeout_msecs);
 
-void test_subprocesses_init(bool debug);
+void test_subprocesses_init(void);
 
 #endif