GetAttachedDevices() should not include bad devices listed in .bad_devices file.
BUG=334724 TBR=craigdh@chromium.org Review URL: https://codereview.chromium.org/181433020 git-svn-id: http://src.chromium.org/svn/trunk/src/build@254905 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
Родитель
8684bb247f
Коммит
861fdce6b2
|
@ -293,6 +293,9 @@ def main():
|
|||
if args:
|
||||
parser.error('Unknown options %s' % args)
|
||||
|
||||
# Remove the last builds "bad devices" before checking device statuses.
|
||||
android_commands.ResetBadDevices()
|
||||
|
||||
if options.restart_usb:
|
||||
expected_devices = GetLastDevices(os.path.abspath(options.out_dir))
|
||||
devices = android_commands.GetAttachedDevices()
|
||||
|
|
|
@ -10,6 +10,7 @@ Assumes adb binary is currently on system path.
|
|||
import collections
|
||||
import datetime
|
||||
import inspect
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
|
@ -77,6 +78,29 @@ def GetAVDs():
|
|||
return avds
|
||||
|
||||
|
||||
def ResetBadDevices():
|
||||
"""Removes the file that keeps track of bad devices for a current build."""
|
||||
if os.path.exists(constants.BAD_DEVICES_JSON):
|
||||
os.remove(constants.BAD_DEVICES_JSON)
|
||||
|
||||
|
||||
def ExtendBadDevices(devices):
|
||||
"""Adds devices to BAD_DEVICES_JSON file.
|
||||
|
||||
The devices listed in the BAD_DEVICES_JSON file will not be returned by
|
||||
GetAttachedDevices.
|
||||
|
||||
Args:
|
||||
devices: list of bad devices to be added to the BAD_DEVICES_JSON file.
|
||||
"""
|
||||
if os.path.exists(constants.BAD_DEVICES_JSON):
|
||||
with open(constants.BAD_DEVICES_JSON, 'r') as f:
|
||||
bad_devices = json.load(f)
|
||||
devices.extend(bad_devices)
|
||||
with open(constants.BAD_DEVICES_JSON, 'w') as f:
|
||||
json.dump(list(set(devices)), f)
|
||||
|
||||
|
||||
def GetAttachedDevices(hardware=True, emulator=True, offline=False):
|
||||
"""Returns a list of attached, android devices and emulators.
|
||||
|
||||
|
@ -124,6 +148,13 @@ def GetAttachedDevices(hardware=True, emulator=True, offline=False):
|
|||
if offline:
|
||||
devices = devices + offline_devices
|
||||
|
||||
# Remove bad devices listed in the bad_devices json file.
|
||||
if os.path.exists(constants.BAD_DEVICES_JSON):
|
||||
with open(constants.BAD_DEVICES_JSON, 'r') as f:
|
||||
bad_devices = json.load(f)
|
||||
logging.info('Avoiding bad devices %s', ' '.join(bad_devices))
|
||||
devices = [device for device in devices if device not in bad_devices]
|
||||
|
||||
preferred_device = os.environ.get('ANDROID_SERIAL')
|
||||
if preferred_device in devices:
|
||||
devices.remove(preferred_device)
|
||||
|
|
|
@ -138,6 +138,10 @@ EMULATOR_SDK_ROOT = os.environ.get('ANDROID_EMULATOR_SDK_ROOT',
|
|||
os.path.join(DIR_SOURCE_ROOT,
|
||||
'android_emulator_sdk'))
|
||||
|
||||
BAD_DEVICES_JSON = os.path.join(DIR_SOURCE_ROOT,
|
||||
os.environ.get('CHROMIUM_OUT_DIR', 'out'),
|
||||
'bad_devices.json')
|
||||
|
||||
UPSTREAM_FLAKINESS_SERVER = 'test-results.appspot.com'
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче