diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-10-23 12:29:45 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-10-24 13:05:02 +0200 |
commit | b362c691713722b0ebc00d2fa0df16cd0dd79c7d (patch) | |
tree | 92de88ee940ee94bfe477fcc96de79adccb02731 /tests | |
parent | 815f31799c996890ce0e1b7371394fb79e3dfd7c (diff) |
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>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/testlib/selftests/tst_selftests.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index beda0f739e..1839737d15 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -977,13 +977,13 @@ TestProcessResult runTestProcess(const QString &test, const QStringList &argumen { QProcessEnvironment environment = testEnvironment(); - const bool crashes = test == "assert" || test == "exceptionthrow" + const bool expectedCrash = test == "assert" || test == "exceptionthrow" || test == "fetchbogus" || test == "crashedterminate" || test == "faildatatype" || test == "failfetchtype" || test == "crashes" || test == "silent" || test == "blacklisted" || test == "watchdog"; - if (crashes) { + if (expectedCrash) { environment.insert("QTEST_DISABLE_CORE_DUMP", "1"); environment.insert("QTEST_DISABLE_STACK_DUMP", "1"); if (test == "watchdog") @@ -997,15 +997,25 @@ TestProcessResult runTestProcess(const QString &test, const QStringList &argumen CAPTURE(command); INFO(environment.toStringList().join('\n').toStdString()); + + bool startedSuccessfully = process.waitForStarted(); + bool finishedSuccessfully = process.waitForFinished(); + CAPTURE(process.errorString()); + REQUIRE(startedSuccessfully); + REQUIRE(finishedSuccessfully); - REQUIRE(process.waitForStarted()); - REQUIRE(process.waitForFinished()); + auto standardOutput = process.readAllStandardOutput(); + auto standardError = process.readAllStandardError(); - if (!crashes) - REQUIRE(process.exitStatus() == QProcess::NormalExit); + auto processCrashed = process.exitStatus() == QProcess::CrashExit; + if (!expectedCrash && processCrashed) { + INFO(standardOutput.toStdString()); + INFO(standardError.toStdString()); + REQUIRE(!processCrashed); + } - return { process.exitCode(), process.readAllStandardOutput(), process.readAllStandardError() }; + return { process.exitCode(), standardOutput, standardError }; } /* |