gtestutils: Set coredump rlimit to 0 when calling g_test_trap_fork()

g_test_trap_fork() is deprecated, but it’s still tested in the GLib
tests. If we don’t set the coredump rlimit to 0 to prevent coredumps,
the test for it creates a coredump (which is expected). On systems with
systemd-coredump, that causes systemd-coredump to spawn and process the
coredump for a while. That slows down the tests, and results in spurious
coredump lists in the system logs.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Fixes: #436
This commit is contained in:
Philip Withnall 2019-06-28 13:00:31 +01:00
parent d55f6fb5fe
commit f05dbab003

View File

@ -3311,6 +3311,18 @@ g_test_trap_fork (guint64 usec_timeout,
close (stdout_pipe[1]);
if (stderr_pipe[1] >= 3)
close (stderr_pipe[1]);
/* We typically expect these child processes to crash, and some
* tests spawn a *lot* of them. Avoid spamming system crash
* collection programs such as systemd-coredump and abrt.
*/
#ifdef HAVE_SYS_RESOURCE_H
{
struct rlimit limit = { 0, 0 };
(void) setrlimit (RLIMIT_CORE, &limit);
}
#endif
return TRUE;
}
else /* parent */