diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-07-20 14:44:53 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-07-31 10:13:40 +0000 |
commit | 10f254b234c7c13c0e528f574d075d88b3d72135 (patch) | |
tree | d3402813177f3dc21d521e714a5eba6e606c2ab7 | |
parent | 38979332d0a66666ebd178bccd7e7a2b300a7e42 (diff) |
testlib: Allow pausing the process on crash
Makes it easier to run a test repeatedly until it crashes, and then
attach a debugger.
Change-Id: I8ad5d706becd77a2743a51927c837f3d1da08624
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r-- | src/testlib/qtestcase.cpp | 9 |
1 files 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 <sys/types.h> -#include <unistd.h> #include <fcntl.h> #endif @@ -101,6 +100,7 @@ #include <errno.h> #include <signal.h> #include <time.h> +#include <unistd.h> # if !defined(Q_OS_INTEGRITY) # include <sys/resource.h> # 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); |