From b362c691713722b0ebc00d2fa0df16cd0dd79c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 23 Oct 2020 12:29:45 +0200 Subject: 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 --- tests/auto/testlib/selftests/tst_selftests.cpp | 24 +++++++++++++++++------- 1 file 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 }; } /* -- cgit v1.2.3