]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-test: test-common - Add test_forked_end().
authorStephan Bosch <stephan.bosch@open-xchange.com>
Fri, 10 Apr 2020 15:32:16 +0000 (17:32 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 22 May 2020 08:42:33 +0000 (08:42 +0000)
src/lib-test/test-common.c
src/lib-test/test-common.h

index 59bd55937b7682b0e0ad4aed9370ee76a0ba2186..1c3ce53193b4291fec636d5a1c2860cfb10d0658 100644 (file)
@@ -381,6 +381,17 @@ int test_run_named_with_fatals(const char *match, const struct named_test tests[
        return test_deinit();
 }
 
+void test_forked_end(void)
+{
+       i_set_error_handler(default_error_handler);
+       i_set_fatal_handler(default_fatal_handler);
+
+       i_free_and_null(expected_error_str);
+       i_free_and_null(expected_fatal_str);
+       i_free_and_null(test_prefix);
+       t_pop_last_unsafe(); /* as we were within a T_BEGIN { tests[i].func(); } T_END */
+}
+
 void ATTR_NORETURN
 test_exit(int status)
 {
index 1f1318fe6cf83281ce16f6dbddab5452665dfcfa..0ac5e6d1d453049e843af8a5d88538124ebb824a 100644 (file)
@@ -99,6 +99,9 @@ void test_expect_fatal_string(const char *substr);
 #define FATAL_NAMELESS(x) x, /* Were you to want to use the X trick but not name the tests */
 #define FATAL_NAMED(x) { .name = #x , .func = x },
 
+/* If a child is forked within test context, but wants to operate outside it,
+   then this will avoid valgrind leak errors */
+void test_forked_end(void);
 /* If a fork() wants to exit(), then this will avoid valgrind leak errors */
 void test_exit(int status) ATTR_NORETURN;