diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2020-11-25 19:05:16 +0200 |
---|---|---|
committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2021-06-07 18:40:27 +0000 |
commit | 1365a1c7a76a73838909d63acb60ebdfcbdff62e (patch) | |
tree | c642eb3b3da086b8047c9195cea74086a3d6cabd /src | |
parent | 6765dbf77a556f7711fa34886a02a4f30131fac0 (diff) |
Android: fix androidtestrunner passing when output file doesn't exist
Task-number: QTBUG-88508
Change-Id: If19d2b272b1760228b6a1e6e1af6db3bfbf0ec1e
Reviewed-by: BogDan Vatra <bogdan@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/androidtestrunner/main.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/tools/androidtestrunner/main.cpp b/src/tools/androidtestrunner/main.cpp index e0a69bb9cb..45b1b6202e 100644 --- a/src/tools/androidtestrunner/main.cpp +++ b/src/tools/androidtestrunner/main.cpp @@ -415,10 +415,21 @@ static bool pullFiles() bool ret = true; for (auto it = g_options.outFiles.constBegin(); it != g_options.outFiles.end(); ++it) { QByteArray output; - if (!execCommand(QStringLiteral("%1 shell run-as %2 cat files/output.%3") + + // If the output file doesn't exist, adb still returns 0 exit code. + // Thus we need to explicitly check "echo $?". + if (!execCommand(QStringLiteral("%1 shell \'run-as %2 cat files/output.%3; echo $?\'") .arg(g_options.adbCommand, g_options.package, it.key()), &output)) { return false; } + + // Handle the exit code then remove it from the output. + bool ok; + int ret = output.right(3).toInt(&ok); + if (ret || !ok) + return false; + + output.chop(3); auto checkerIt = g_options.checkFiles.find(it.key()); ret = ret && checkerIt != g_options.checkFiles.end() && checkerIt.value()(output); if (it.value() == QStringLiteral("-")){ |