testlib selftest: Spit out stdout/stderr when test crashes

The old test harness used to spit out stderr only, but
to be on the safe side we spit out both.

Change-Id: Ib8e57fd1b0e4d8542ac552a6fe58c07016df7f5f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2020-10-23 12:29:45 +02:00
parent 815f31799c
commit b362c69171

View File

@ -977,13 +977,13 @@ TestProcessResult runTestProcess(const QString &test, const QStringList &argumen
{ {
QProcessEnvironment environment = testEnvironment(); QProcessEnvironment environment = testEnvironment();
const bool crashes = test == "assert" || test == "exceptionthrow" const bool expectedCrash = test == "assert" || test == "exceptionthrow"
|| test == "fetchbogus" || test == "crashedterminate" || test == "fetchbogus" || test == "crashedterminate"
|| test == "faildatatype" || test == "failfetchtype" || test == "faildatatype" || test == "failfetchtype"
|| test == "crashes" || test == "silent" || test == "crashes" || test == "silent"
|| test == "blacklisted" || test == "watchdog"; || test == "blacklisted" || test == "watchdog";
if (crashes) { if (expectedCrash) {
environment.insert("QTEST_DISABLE_CORE_DUMP", "1"); environment.insert("QTEST_DISABLE_CORE_DUMP", "1");
environment.insert("QTEST_DISABLE_STACK_DUMP", "1"); environment.insert("QTEST_DISABLE_STACK_DUMP", "1");
if (test == "watchdog") if (test == "watchdog")
@ -997,15 +997,25 @@ TestProcessResult runTestProcess(const QString &test, const QStringList &argumen
CAPTURE(command); CAPTURE(command);
INFO(environment.toStringList().join('\n').toStdString()); INFO(environment.toStringList().join('\n').toStdString());
bool startedSuccessfully = process.waitForStarted();
bool finishedSuccessfully = process.waitForFinished();
CAPTURE(process.errorString()); CAPTURE(process.errorString());
REQUIRE(startedSuccessfully);
REQUIRE(finishedSuccessfully);
REQUIRE(process.waitForStarted()); auto standardOutput = process.readAllStandardOutput();
REQUIRE(process.waitForFinished()); auto standardError = process.readAllStandardError();
if (!crashes) auto processCrashed = process.exitStatus() == QProcess::CrashExit;
REQUIRE(process.exitStatus() == QProcess::NormalExit); if (!expectedCrash && processCrashed) {
INFO(standardOutput.toStdString());
INFO(standardError.toStdString());
REQUIRE(!processCrashed);
}
return { process.exitCode(), process.readAllStandardOutput(), process.readAllStandardError() }; return { process.exitCode(), standardOutput, standardError };
} }
/* /*