Add option to android test_runner to specify what devices to run on.

BUG=612360

Review-Url: https://codereview.chromium.org/2045583004
Cr-Original-Commit-Position: refs/heads/master@{#398609}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 8a61f0862d71b51516175fc5903082ca1c495f55
This commit is contained in:
bpastene 2016-06-08 10:29:34 -07:00 коммит произвёл Commit bot
Родитель b4f8295b6d
Коммит 2ff05a61e4
2 изменённых файлов: 20 добавлений и 11 удалений

Просмотреть файл

@ -11,6 +11,7 @@ import threading
from devil.android import device_blacklist
from devil.android import device_errors
from devil.android import device_list
from devil.android import device_utils
from devil.android import logcat_monitor
from devil.utils import file_utils
@ -41,23 +42,27 @@ class LocalDeviceEnvironment(environment.Environment):
self._logcat_output_file = args.logcat_output_file
self._max_tries = 1 + args.num_retries
self._skip_clear_data = args.skip_clear_data
self._target_devices_file = args.target_devices_file
self._tool_name = args.tool
#override
def SetUp(self):
available_devices = device_utils.DeviceUtils.HealthyDevices(
device_arg = 'default'
if self._target_devices_file:
device_arg = device_list.GetPersistentDeviceList(
self._target_devices_file)
if not device_arg:
logging.warning('No target devices specified. Falling back to '
'running on all available devices.')
device_arg = 'default'
elif self._device_serial:
device_arg = self._device_serial
self._devices = device_utils.DeviceUtils.HealthyDevices(
self._blacklist, enable_device_files_cache=self._enable_device_cache,
default_retries=self._max_tries - 1)
if not available_devices:
raise device_errors.NoDevicesError
if self._device_serial:
self._devices = [d for d in available_devices
if d.adb.GetDeviceSerial() == self._device_serial]
default_retries=self._max_tries - 1, device_arg=device_arg)
if not self._devices:
raise device_errors.DeviceUnreachableError(
'Could not find device %r' % self._device_serial)
else:
self._devices = available_devices
raise device_errors.NoDevicesError
if self._enable_device_cache:
for d in self._devices:

Просмотреть файл

@ -227,6 +227,10 @@ def AddDeviceOptions(parser):
help='Do not wipe app data between tests. Use this to '
'speed up local development and never on bots '
'(increases flakiness)')
group.add_argument('--target-devices-file',
help='Path to file with json list of device serials to '
'run tests on. When not specified, all available '
'devices are used.')
def AddGTestOptions(parser):