summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2016-12-08 14:07:25 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2017-01-03 14:11:06 +0000
commite3a47a7e5f9c4a027a5a7c9fa376f17dfd9634b7 (patch)
tree727ae63716008443c5ff06e55b8374bffa45db6d
parent2e49b44ad1a95134f0b68064125d1944cf209e0a (diff)
Disable core dumps for selftests that are meant to be crashing
Task-number: QTBUG-55155 Change-Id: I26a1461f35f916f3980fcb18cdddf3502e22fc90 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit aec85a53df3dbe3047c6db0f6eb39cb161cd3e6b) Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
-rw-r--r--src/testlib/qtestcase.cpp16
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp4
2 files changed, 19 insertions, 1 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 80aeff7bd1..270f8b57ac 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -94,6 +94,7 @@
#include <errno.h>
#include <signal.h>
#include <time.h>
+#include <sys/resource.h>
#endif
#if defined(Q_OS_MACX)
@@ -105,6 +106,21 @@ QT_BEGIN_NAMESPACE
using QtMiscUtils::toHexUpper;
using QtMiscUtils::fromHex;
+static void disableCoreDump()
+{
+ bool ok = false;
+ const int disableCoreDump = qEnvironmentVariableIntValue("QTEST_DISABLE_CORE_DUMP", &ok);
+ if (ok && disableCoreDump == 1) {
+#if defined(Q_OS_UNIX)
+ struct rlimit limit;
+ limit.rlim_cur = 0;
+ limit.rlim_max = 0;
+ if (setrlimit(RLIMIT_CORE, &limit) != 0)
+ qWarning("Failed to disable core dumps: %d", errno);
+#endif
+ }
+}
+Q_CONSTRUCTOR_FUNCTION(disableCoreDump);
static void stackTrace()
{
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index 63c48fc809..cad336f0ac 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -573,8 +573,10 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
QProcess proc;
QProcessEnvironment environment = processEnvironment();
- if (crashes)
+ if (crashes) {
+ environment.insert("QTEST_DISABLE_CORE_DUMP", "1");
environment.insert("QTEST_DISABLE_STACK_DUMP", "1");
+ }
proc.setProcessEnvironment(environment);
const QString path = subdir + QLatin1Char('/') + subdir;
proc.start(path, arguments);