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>
This commit is contained in:
parent
38979332d0
commit
10f254b234
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user