diff --git a/glnx-backport-testutils.c b/glnx-backport-testutils.c index 31105c90..3440872d 100644 --- a/glnx-backport-testutils.c +++ b/glnx-backport-testutils.c @@ -33,6 +33,9 @@ #include "glnx-backport-testutils.h" #include "glnx-backports.h" +#include +#include + #if !GLIB_CHECK_VERSION (2, 68, 0) /* Backport of g_assertion_message_cmpstrv() */ void @@ -143,3 +146,17 @@ _glnx_test_incomplete_printf (const char *format, #endif } #endif + +#if !GLIB_CHECK_VERSION (2, 78, 0) +void +_glnx_test_disable_crash_reporting (void) +{ + struct rlimit limit = { 0, 0 }; + + (void) setrlimit (RLIMIT_CORE, &limit); + + /* On Linux, RLIMIT_CORE = 0 is ignored if core dumps are + * configured to be written to a pipe, but PR_SET_DUMPABLE is not. */ + (void) prctl (PR_SET_DUMPABLE, 0, 0, 0, 0); +} +#endif diff --git a/glnx-backport-testutils.h b/glnx-backport-testutils.h index 9c17f06e..f579c0eb 100644 --- a/glnx-backport-testutils.h +++ b/glnx-backport-testutils.h @@ -201,4 +201,9 @@ void _glnx_test_skip_printf (const char *format, ...) G_GNUC_PRINTF (1, 2); void _glnx_test_incomplete_printf (const char *format, ...) G_GNUC_PRINTF (1, 2); #endif +#if !GLIB_CHECK_VERSION (2, 78, 0) +#define g_test_disable_crash_reporting _glnx_test_disable_crash_reporting +void _glnx_test_disable_crash_reporting (void); +#endif + G_END_DECLS diff --git a/tests/testing-helper.c b/tests/testing-helper.c index 7c2192cf..0886678f 100644 --- a/tests/testing-helper.c +++ b/tests/testing-helper.c @@ -243,6 +243,7 @@ main (int argc, } g_test_init (&argc, &argv, NULL); + g_test_disable_crash_reporting (); #if GLIB_CHECK_VERSION(2, 38, 0) g_test_set_nonfatal_assertions (); #endif