From 10f254b234c7c13c0e528f574d075d88b3d72135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 20 Jul 2018 14:44:53 +0200 Subject: testlib: Allow pausing the process on crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes it easier to run a test repeatedly until it crashes, and then attach a debugger. Change-Id: I8ad5d706becd77a2743a51927c837f3d1da08624 Reviewed-by: Simon Hausmann Reviewed-by: Tor Arne Vestbø --- src/testlib/qtestcase.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index c1b4577157..d9fbfcffa8 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -87,7 +87,6 @@ #if defined(Q_OS_LINUX) #include -#include #include #endif @@ -101,6 +100,7 @@ #include #include #include +#include # if !defined(Q_OS_INTEGRITY) # include # endif @@ -1472,8 +1472,13 @@ void FatalSignalHandler::signal(int signum) { const int msecsFunctionTime = qRound(QTestLog::msecsFunctionTime()); const int msecsTotalTime = qRound(QTestLog::msecsTotalTime()); - if (signum != SIGINT) + if (signum != SIGINT) { stackTrace(); + if (qEnvironmentVariableIsSet("QTEST_PAUSE_ON_CRASH")) { + fprintf(stderr, "Pausing process %d for debugging\n", getpid()); + raise(SIGSTOP); + } + } qFatal("Received signal %d\n" " Function time: %dms Total time: %dms", signum, msecsFunctionTime, msecsTotalTime); -- cgit v1.2.3