testlib: Implement FatalSignalHandler inline
Change-Id: Ie6f151cb099151616f83ea8d5e11e6625bedeb8c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
parent
89f443dfbc
commit
d005d743de
@ -1534,42 +1534,11 @@ void TestMethods::invokeTests(QObject *testObject) const
|
||||
}
|
||||
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_WASM)
|
||||
|
||||
class FatalSignalHandler
|
||||
{
|
||||
public:
|
||||
FatalSignalHandler();
|
||||
~FatalSignalHandler();
|
||||
|
||||
private:
|
||||
static void signal(int);
|
||||
sigset_t handledSignals;
|
||||
};
|
||||
|
||||
void FatalSignalHandler::signal(int signum)
|
||||
{
|
||||
const int msecsFunctionTime = qRound(QTestLog::msecsFunctionTime());
|
||||
const int msecsTotalTime = qRound(QTestLog::msecsTotalTime());
|
||||
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);
|
||||
#if defined(Q_OS_INTEGRITY)
|
||||
{
|
||||
struct sigaction act;
|
||||
memset(&act, 0, sizeof(struct sigaction));
|
||||
act.sa_handler = SIG_DFL;
|
||||
sigaction(signum, &act, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
FatalSignalHandler::FatalSignalHandler()
|
||||
FatalSignalHandler()
|
||||
{
|
||||
sigemptyset(&handledSignals);
|
||||
|
||||
@ -1627,8 +1596,7 @@ FatalSignalHandler::FatalSignalHandler()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
FatalSignalHandler::~FatalSignalHandler()
|
||||
~FatalSignalHandler()
|
||||
{
|
||||
// Unregister any of our remaining signal handlers
|
||||
struct sigaction act;
|
||||
@ -1648,8 +1616,35 @@ FatalSignalHandler::~FatalSignalHandler()
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static void signal(int signum)
|
||||
{
|
||||
const int msecsFunctionTime = qRound(QTestLog::msecsFunctionTime());
|
||||
const int msecsTotalTime = qRound(QTestLog::msecsTotalTime());
|
||||
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);
|
||||
#if defined(Q_OS_INTEGRITY)
|
||||
{
|
||||
struct sigaction act;
|
||||
memset(&act, 0, sizeof(struct sigaction));
|
||||
act.sa_handler = SIG_DFL;
|
||||
sigaction(signum, &act, NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
sigset_t handledSignals;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user