diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-02-08 17:14:38 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-02-08 19:56:03 +0000 |
commit | b624cdac21c7fd673c5c9e73be158f3b5fb79bc5 (patch) | |
tree | e091022fa1540f517dabab595021db1919f021a8 /tests/auto/corelib/tools/qsharedpointer/externaltests.cpp | |
parent | f1d227bceb5cbf58adbc107aa2e2f83df401d71e (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/qsharedpointer/externaltests.cpp')
-rw-r--r-- | tests/auto/corelib/tools/qsharedpointer/externaltests.cpp | 15 |
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(); |