AndroidTestRunner: check if any device is running at start
Check if any or specified device is running and fail with appropriate message instead of attempting to run other adb commands that might fail with other reasons that hide the actual root cause. Change-Id: I61078ca988f381e834b41140e36b0e4a5f77714f Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> (cherry picked from commit d5491ec2ab5630c95c25c0e4142ddf4af398f083) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
87abb9422a
commit
80eba25971
@ -509,6 +509,20 @@ static void obtainSdkVersion()
|
||||
qCritical() << "Unable to obtain the SDK version of the target.";
|
||||
}
|
||||
|
||||
static QStringList runningDevices()
|
||||
{
|
||||
QByteArray output;
|
||||
execAdbCommand({ "devices"_L1 }, &output, false);
|
||||
|
||||
QStringList devices;
|
||||
for (const QByteArray &line : output.split(u'\n')) {
|
||||
if (line.contains("\tdevice"_L1))
|
||||
devices.append(QString::fromUtf8(line.split(u'\t').first()));
|
||||
}
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
static bool pullFiles()
|
||||
{
|
||||
bool ret = true;
|
||||
@ -755,6 +769,16 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
const QStringList devices = runningDevices();
|
||||
if (devices.isEmpty()) {
|
||||
qCritical("No connected devices or running emulators can be found.");
|
||||
return 1;
|
||||
} else if (!g_options.serial.isEmpty() && !devices.contains(g_options.serial)) {
|
||||
qCritical("No connected device or running emulator with serial '%s' can be found.",
|
||||
qPrintable(g_options.serial));
|
||||
return 1;
|
||||
}
|
||||
|
||||
obtainSdkVersion();
|
||||
|
||||
QString manifest = g_options.buildPath + "/AndroidManifest.xml"_L1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user