summaryrefslogtreecommitdiffstats
path: root/tests/auto/testlib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-10-11 09:38:42 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-10-14 08:18:53 -0700
commitc849c48d19cc0b086f98688d760fa6e008adc50e (patch)
treee89fca477ad3b8b6122dde5b09cee7df33161348 /tests/auto/testlib
parent673f89d62c8516ce30c44ba933f410f6c9e8b1a2 (diff)
Autotest/Unix: request zero-sized core dumps for crashing code
Unix systems have got crash loggers in the past 15-20 years, notably macOS and Linux (abrtd, systemd-coredumpd, etc.). By setting the core dump limit to zero, those tools should be mostly inhibited from running and thus not interfere with the parent process' timeouts. Even for systems without core dump loggers, disabling the writing of a core dump to the filesystem should also help. Pick-to: 6.4 Change-Id: I12a088d1ae424825abd3fffd171d112d0671effe Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/testlib')
-rw-r--r--tests/auto/testlib/selftests/crashes/tst_crashes.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/auto/testlib/selftests/crashes/tst_crashes.cpp b/tests/auto/testlib/selftests/crashes/tst_crashes.cpp
index abac42c723..38ed27d331 100644
--- a/tests/auto/testlib/selftests/crashes/tst_crashes.cpp
+++ b/tests/auto/testlib/selftests/crashes/tst_crashes.cpp
@@ -7,6 +7,8 @@
#ifdef Q_OS_WIN
#include <qt_windows.h>
+#else
+#include <sys/resource.h>
#endif
class tst_Crashes: public QObject
@@ -22,6 +24,12 @@ void tst_Crashes::crash()
#if defined(Q_OS_WIN)
//we avoid the error dialogbox to appear on windows
SetErrorMode( SEM_NOGPFAULTERRORBOX | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
+#elif defined(RLIMIT_CORE)
+ // Unix: set our core dump limit to zero to request no dialogs.
+ if (struct rlimit rlim; getrlimit(RLIMIT_CORE, &rlim) == 0) {
+ rlim.rlim_cur = 0;
+ setrlimit(RLIMIT_CORE, &rlim);
+ }
#endif
/*
We deliberately dereference an invalid but non-zero address;