AndroidTestRunner: retry check for running device few times
Try to check if the device is running few times while waiting for the app to finish, just in case the adb ps command fails for some reason while the app is actually still running. Also, use ps -p <pid> to directly return only pid and avoiding to filter out all the other processes with grep. grep can be then used to only filter out the test package name and leaving out the ps header. Fixes: QTBUG-127488 Change-Id: I85fe61106381fd1a7a26ef6347f8ab4a4a6678bb Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> (cherry picked from commit 03006555ec872935d78fbb41f02c4cef3a5cab51) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
dcc4fde727
commit
87abb9422a
@ -455,12 +455,21 @@ static bool obtainPid() {
|
||||
}
|
||||
|
||||
static bool isRunning() {
|
||||
QByteArray output;
|
||||
const QStringList psArgs = { "shell"_L1, "ps | grep ' %1'"_L1.arg(g_options.package) };
|
||||
if (!execAdbCommand(psArgs, &output, false))
|
||||
if (g_testInfo.pid < 1)
|
||||
return false;
|
||||
|
||||
return output.indexOf(QLatin1StringView(" " + g_options.package.toUtf8())) > -1;
|
||||
QByteArray output;
|
||||
const QStringList psArgs = { "shell"_L1, "ps"_L1, "-p"_L1, QString::number(g_testInfo.pid),
|
||||
"|"_L1, "grep"_L1, "-o"_L1, " %1$"_L1.arg(g_options.package) };
|
||||
bool psSuccess = false;
|
||||
for (int i = 1; i <= 3; ++i) {
|
||||
psSuccess = execAdbCommand(psArgs, &output, false);
|
||||
if (psSuccess)
|
||||
break;
|
||||
QThread::msleep(250);
|
||||
}
|
||||
|
||||
return psSuccess && output.trimmed() == g_options.package.toUtf8();
|
||||
}
|
||||
|
||||
static void waitForStartedAndFinished()
|
||||
|
Loading…
x
Reference in New Issue
Block a user