From b624cdac21c7fd673c5c9e73be158f3b5fb79bc5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 8 Feb 2018 17:14:38 +0100 Subject: tst_QSharedPointer: Fix termination of external processes on Windows Timeouts with subsequent failures to delete the temporary directories have been observed in COIN. Previously, QProcess:terminate() was used to end the processes, which does not have any effect on console processes on Windows. Add a helper function which resorts to kill() on failure to terminate(). Change-Id: I05539d1703280d34b392f2e8ff8565b9a04d703c Reviewed-by: Thiago Macieira --- tests/auto/corelib/tools/qsharedpointer/externaltests.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp index 62dd33131b..3e1668522e 100644 --- a/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/externaltests.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #ifndef DEFAULT_MAKESPEC # error DEFAULT_MAKESPEC not defined @@ -69,6 +70,16 @@ static QString makespec() QT_BEGIN_NAMESPACE namespace QTest { #if QT_CONFIG(process) + static void ensureStopped(QProcess &process) + { + if (process.state() == QProcess::Running) { + process.terminate(); + QThread::msleep(20); + if (process.state() == QProcess::Running) + process.kill(); + } + } + class QExternalProcess: public QProcess { protected: @@ -594,7 +605,7 @@ namespace QTest { ok = qmake.waitForFinished(); exitCode = qmake.exitCode(); if (!ok) - qmake.terminate(); + QTest::ensureStopped(qmake); std_out += qmake.readAllStandardOutput(); std_err += qmake.readAllStandardError(); @@ -661,7 +672,7 @@ namespace QTest { make.closeWriteChannel(); bool ok = make.waitForFinished(channelMode == QProcess::ForwardedChannels ? -1 : 60000); if (!ok) - make.terminate(); + QTest::ensureStopped(make); exitCode = make.exitCode(); std_out += make.readAllStandardOutput(); std_err += make.readAllStandardError(); -- cgit v1.2.3