summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/tools
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-02-08 17:14:38 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-02-08 19:56:03 +0000
commitb624cdac21c7fd673c5c9e73be158f3b5fb79bc5 (patch)
treee091022fa1540f517dabab595021db1919f021a8 /tests/auto/corelib/tools
parentf1d227bceb5cbf58adbc107aa2e2f83df401d71e (diff)
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 <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/tools')
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/externaltests.cpp15
1 files 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 <QtCore/QDateTime>
#include <QtCore/QDebug>
#include <QtCore/QLibraryInfo>
+#include <QtCore/QThread>
#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();