diff options
author | Maurice Kalinowski <maurice.kalinowski@theqtcompany.com> | 2015-12-08 11:45:07 +0100 |
---|---|---|
committer | Oliver Wolff <oliver.wolff@theqtcompany.com> | 2016-01-05 07:03:31 +0000 |
commit | b2f1ca59b7cc7764d673f5ed806552f188ed6361 (patch) | |
tree | 910e717fc13c4bb38cd9a8f66d2846e32358dc2c | |
parent | 6a860f3719800fa58360da3001370532bb246f5f (diff) |
Parse the pid file for exit code
0ea3d630b1fd1fc21c65c43063792e4cbf0c2cdf in qtbase writes the exit
code of the application into the pid file. This needs to be read
from winrtrunner and then passed as exit code of winrtrunner itself.
This allows to use winrtrunner for CI and other automated systems as the
exit code of the application itself is passed.
Task-number: QTBUG-38654
Change-Id: I28f915bf5c002078ba62546fea1ee014da5d0147
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
-rw-r--r-- | src/winrtrunner/appxlocalengine.cpp | 25 | ||||
-rw-r--r-- | src/winrtrunner/appxlocalengine.h | 1 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/winrtrunner/appxlocalengine.cpp b/src/winrtrunner/appxlocalengine.cpp index f16fbff10..2c3c0dd66 100644 --- a/src/winrtrunner/appxlocalengine.cpp +++ b/src/winrtrunner/appxlocalengine.cpp @@ -417,6 +417,26 @@ bool AppxLocalEngine::installPackage(IAppxManifestReader *reader, const QString return SUCCEEDED(hr); } +bool AppxLocalEngine::parseExitCode() +{ + Q_D(AppxLocalEngine); + const QString exitFileName(QStringLiteral("exitCode.tmp")); + bool ok = false; + QFile exitCodeFile(devicePath(QString::number(pid()).append(QStringLiteral(".pid")))); + if (exitCodeFile.open(QIODevice::ReadOnly)) { + d->exitCode = exitCodeFile.readAll().toInt(&ok); + exitCodeFile.close(); + exitCodeFile.remove(); + } + if (!ok && !GetExitCodeProcess(d->processHandle, &d->exitCode)) { + d->exitCode = UINT_MAX; + qCWarning(lcWinRtRunner).nospace() << "Failed to obtain process exit code."; + qCDebug(lcWinRtRunner, "GetLastError: 0x%x", GetLastError()); + return false; + } + return true; +} + bool AppxLocalEngine::install(bool removeFirst) { Q_D(const AppxLocalEngine); @@ -552,10 +572,7 @@ bool AppxLocalEngine::stop() if (!d->processHandle) qCDebug(lcWinRtRunner) << "No handle to the process; the exit code won't be available."; - if (d->processHandle && !GetExitCodeProcess(d->processHandle, &d->exitCode)) { - d->exitCode = UINT_MAX; - qCWarning(lcWinRtRunner).nospace() << "Failed to obtain process exit code."; - qCDebug(lcWinRtRunner, "GetLastError: 0x%x", GetLastError()); + if (d->processHandle && !parseExitCode()) { return false; } diff --git a/src/winrtrunner/appxlocalengine.h b/src/winrtrunner/appxlocalengine.h index b9e9e4028..73b0291b3 100644 --- a/src/winrtrunner/appxlocalengine.h +++ b/src/winrtrunner/appxlocalengine.h @@ -74,6 +74,7 @@ private: QString extensionSdkPath() const Q_DECL_OVERRIDE; bool installPackage(IAppxManifestReader *reader, const QString &filePath) Q_DECL_OVERRIDE; + bool parseExitCode(); friend struct QScopedPointerDeleter<AppxLocalEngine>; Q_DECLARE_PRIVATE(AppxLocalEngine) }; |