Use denylist throughout //build/android.

Bug: 1097306
Change-Id: I7a96cddd408d6b75e3a55c68f7e18fd481476361
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2384079
Commit-Queue: John Budorick <jbudorick@chromium.org>
Reviewed-by: Haiyang Pan <hypan@google.com>
Reviewed-by: Ben Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803531}
GitOrigin-RevId: 8b57e6056791aa93ca95c0e5e1db89584d906bf9
This commit is contained in:
John Budorick 2020-09-01 16:57:50 +00:00 коммит произвёл Copybara-Service
Родитель e0ef5872fc
Коммит 23dc5c5783
14 изменённых файлов: 109 добавлений и 83 удалений

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

@ -14,7 +14,7 @@ import sys
import devil_chromium
from devil.android import apk_helper
from devil.android import device_blacklist
from devil.android import device_denylist
from devil.android import device_errors
from devil.android import device_utils
from devil.utils import run_tests_helper
@ -58,7 +58,12 @@ def main():
' times for multiple devices.')
parser.add_argument('--adb-path', type=os.path.abspath,
help='Absolute path to the adb binary to use.')
parser.add_argument('--blacklist-file', help='Device blacklist JSON file.')
# TODO(crbug.com/1097306): Remove this once callers have all switched to
# --denylist-file.
parser.add_argument('--blacklist-file',
dest='denylist_file',
help=argparse.SUPPRESS)
parser.add_argument('--denylist-file', help='Device denylist JSON file.')
parser.add_argument('-v', '--verbose', action='count',
help='Enable verbose logging.')
parser.add_argument('--downgrade', action='store_true',
@ -98,13 +103,12 @@ def main():
and helper.GetSplitName()):
splits.append(f)
blacklist = (device_blacklist.Blacklist(args.blacklist_file)
if args.blacklist_file
else None)
devices = device_utils.DeviceUtils.HealthyDevices(blacklist=blacklist,
denylist = (device_denylist.Denylist(args.denylist_file)
if args.denylist_file else None)
devices = device_utils.DeviceUtils.HealthyDevices(denylist=denylist,
device_arg=args.devices)
def blacklisting_install(device):
def denylisting_install(device):
try:
if args.splits:
device.InstallSplitApk(apk, splits, reinstall=args.keep_data,
@ -116,16 +120,16 @@ def main():
except (device_errors.CommandFailedError,
device_errors.DeviceUnreachableError):
logging.exception('Failed to install %s', apk)
if blacklist:
blacklist.Extend([str(device)], reason='install_failure')
logging.warning('Blacklisting %s', str(device))
if denylist:
denylist.Extend([str(device)], reason='install_failure')
logging.warning('Denylisting %s', str(device))
except device_errors.CommandTimeoutError:
logging.exception('Timed out while installing %s', apk)
if blacklist:
blacklist.Extend([str(device)], reason='install_timeout')
logging.warning('Blacklisting %s', str(device))
if denylist:
denylist.Extend([str(device)], reason='install_timeout')
logging.warning('Denylisting %s', str(device))
device_utils.DeviceUtils.parallel(devices).pMap(blacklisting_install)
device_utils.DeviceUtils.parallel(devices).pMap(denylisting_install)
if __name__ == '__main__':

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

@ -17,7 +17,7 @@ import time
import devil_chromium
from devil.android import device_blacklist
from devil.android import device_denylist
from devil.android import device_utils
from devil.android import forwarder
from devil.utils import run_tests_helper
@ -39,9 +39,12 @@ def main(argv):
parser.add_argument(
'--device',
help='Serial number of device we should use.')
parser.add_argument(
'--blacklist-file',
help='Device blacklist JSON file.')
# TODO(crbug.com/1097306): Remove this once callers have all switched to
# --denylist-file.
parser.add_argument('--blacklist-file',
dest='denylist_file',
help=argparse.SUPPRESS)
parser.add_argument('--denylist-file', help='Device denylist JSON file.')
parser.add_argument(
'--debug',
action='store_const',
@ -72,11 +75,10 @@ def main(argv):
constants.SetOutputDirectory(args.output_directory)
devil_chromium.Initialize(output_directory=constants.GetOutDirectory())
blacklist = (device_blacklist.Blacklist(args.blacklist_file)
if args.blacklist_file
else None)
device = device_utils.DeviceUtils.HealthyDevices(
blacklist=blacklist, device_arg=args.device)[0]
denylist = (device_denylist.Denylist(args.denylist_file)
if args.denylist_file else None)
device = device_utils.DeviceUtils.HealthyDevices(denylist=denylist,
device_arg=args.device)[0]
try:
forwarder.Forwarder.Map(port_pairs, device)
while True:

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

@ -22,7 +22,7 @@ def main():
while True:
try:
devices = device_utils.DeviceUtils.HealthyDevices(blacklist=None)
devices = device_utils.DeviceUtils.HealthyDevices(denylist=None)
for d in devices:
d.RunShellCommand(['touch', '/sdcard/host_heartbeat'],
check_return=True)

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

@ -11,7 +11,7 @@ Add the gn arg:
incremental_install = true
This causes all apks to be built as incremental except for blacklisted ones.
This causes all apks to be built as incremental except for denylisted ones.
## Running

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

@ -144,7 +144,7 @@ def Install(device, install_json, apk=None, enable_device_cache=False,
enable_device_cache: Whether to enable on-device caching of checksums.
use_concurrency: Whether to speed things up using multiple threads.
permissions: A list of the permissions to grant, or None to grant all
non-blacklisted permissions in the manifest.
non-denylisted permissions in the manifest.
"""
if isinstance(install_json, basestring):
with open(install_json) as f:

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

@ -45,7 +45,7 @@ def DetermineDeviceToUse(devices):
Returns:
A single device_utils.DeviceUtils instance.
Raises:
device_errors.NoDevicesError: Raised when no non-blacklisted devices exist.
device_errors.NoDevicesError: Raised when no non-denylisted devices exist.
device_errors.MultipleDevicesError: Raise when multiple devices exist, but
|devices| does not distinguish which to use.
"""

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

@ -28,7 +28,7 @@ import _strptime # pylint: disable=unused-import
import devil_chromium
from devil.android import battery_utils
from devil.android import device_blacklist
from devil.android import device_denylist
from devil.android import device_errors
from devil.android import device_temp_file
from devil.android import device_utils
@ -63,11 +63,12 @@ class _PHASES(object):
def ProvisionDevices(args):
blacklist = (device_blacklist.Blacklist(args.blacklist_file)
if args.blacklist_file
else None)
devices = [d for d in device_utils.DeviceUtils.HealthyDevices(blacklist)
if not args.emulators or d.adb.is_emulator]
denylist = (device_denylist.Denylist(args.denylist_file)
if args.denylist_file else None)
devices = [
d for d in device_utils.DeviceUtils.HealthyDevices(denylist)
if not args.emulators or d.adb.is_emulator
]
if args.device:
devices = [d for d in devices if d == args.device]
if not devices:
@ -76,19 +77,19 @@ def ProvisionDevices(args):
if args.emulators:
parallel_devices.pMap(SetProperties, args)
else:
parallel_devices.pMap(ProvisionDevice, blacklist, args)
parallel_devices.pMap(ProvisionDevice, denylist, args)
if args.auto_reconnect:
_LaunchHostHeartbeat()
blacklisted_devices = blacklist.Read() if blacklist else []
if args.output_device_blacklist:
with open(args.output_device_blacklist, 'w') as f:
json.dump(blacklisted_devices, f)
if all(d in blacklisted_devices for d in devices):
denylisted_devices = denylist.Read() if denylist else []
if args.output_device_denylist:
with open(args.output_device_denylist, 'w') as f:
json.dump(denylisted_devices, f)
if all(d in denylisted_devices for d in devices):
raise device_errors.NoDevicesError
return 0
def ProvisionDevice(device, blacklist, options):
def ProvisionDevice(device, denylist, options):
def should_run_phase(phase_name):
return not options.phases or phase_name in options.phases
@ -132,17 +133,18 @@ def ProvisionDevice(device, blacklist, options):
CheckExternalStorage(device)
except device_errors.CommandTimeoutError:
logging.exception('Timed out waiting for device %s. Adding to blacklist.',
logging.exception('Timed out waiting for device %s. Adding to denylist.',
str(device))
if blacklist:
blacklist.Extend([str(device)], reason='provision_timeout')
if denylist:
denylist.Extend([str(device)], reason='provision_timeout')
except (device_errors.CommandFailedError,
device_errors.DeviceUnreachableError):
logging.exception('Failed to provision device %s. Adding to blacklist.',
logging.exception('Failed to provision device %s. Adding to denylist.',
str(device))
if blacklist:
blacklist.Extend([str(device)], reason='provision_failure')
if denylist:
denylist.Extend([str(device)], reason='provision_failure')
def CheckExternalStorage(device):
"""Checks that storage is writable and if not makes it writable.
@ -499,7 +501,12 @@ def main():
' (the default is to provision all devices attached)')
parser.add_argument('--adb-path',
help='Absolute path to the adb binary to use.')
parser.add_argument('--blacklist-file', help='Device blacklist JSON file.')
# TODO(crbug.com/1097306): Remove this once callers have all switched to
# --denylist-file.
parser.add_argument('--blacklist-file',
dest='denylist_file',
help=argparse.SUPPRESS)
parser.add_argument('--denylist-file', help='Device denylist JSON file.')
parser.add_argument('--phase', action='append', choices=_PHASES.ALL,
dest='phases',
help='Phases of provisioning to run. '
@ -537,8 +544,13 @@ def main():
help='Log more information.')
parser.add_argument('--max-battery-temp', type=int, metavar='NUM',
help='Wait for the battery to have this temp or lower.')
# TODO(crbug.com/1097306): Remove this once callers have all switched to
# --output-device-denylist.
parser.add_argument('--output-device-blacklist',
help='Json file to output the device blacklist.')
dest='output_device_denylist',
help=argparse.SUPPRESS)
parser.add_argument('--output-device-denylist',
help='Json file to output the device denylist.')
parser.add_argument('--chrome-specific-wipe', action='store_true',
help='only wipe chrome specific data during provisioning')
parser.add_argument('--emulators', action='store_true',

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

@ -12,7 +12,7 @@ import threading
import devil_chromium
from devil import base_error
from devil.android import device_blacklist
from devil.android import device_denylist
from devil.android import device_errors
from devil.android import device_utils
from devil.android import logcat_monitor
@ -100,9 +100,8 @@ class LocalDeviceEnvironment(environment.Environment):
def __init__(self, args, output_manager, _error_func):
super(LocalDeviceEnvironment, self).__init__(output_manager)
self._blacklist = (device_blacklist.Blacklist(args.blacklist_file)
if args.blacklist_file
else None)
self._denylist = (device_denylist.Denylist(args.denylist_file)
if args.denylist_file else None)
self._device_serials = args.test_devices
self._devices_lock = threading.Lock()
self._devices = None
@ -153,7 +152,7 @@ class LocalDeviceEnvironment(environment.Environment):
device_arg = self._device_serials
self._devices = device_utils.DeviceUtils.HealthyDevices(
self._blacklist,
self._denylist,
retries=5,
enable_usb_resets=True,
enable_device_files_cache=self._enable_device_cache,
@ -164,7 +163,7 @@ class LocalDeviceEnvironment(environment.Environment):
if self._logcat_output_file:
self._logcat_output_dir = tempfile.mkdtemp()
@handle_shard_failures_with(on_failure=self.BlacklistDevice)
@handle_shard_failures_with(on_failure=self.DenylistDevice)
def prepare_device(d):
d.WaitUntilFullyBooted()
@ -190,8 +189,8 @@ class LocalDeviceEnvironment(environment.Environment):
self.parallel_devices.pMap(prepare_device)
@property
def blacklist(self):
return self._blacklist
def denylist(self):
return self._denylist
@property
def concurrent_adb(self):
@ -247,7 +246,7 @@ class LocalDeviceEnvironment(environment.Environment):
if not self._devices:
return
@handle_shard_failures_with(on_failure=self.BlacklistDevice)
@handle_shard_failures_with(on_failure=self.DenylistDevice)
def tear_down_device(d):
# Write the cache even when not using it so that it will be ready the
# first time that it is enabled. Writing it every time is also necessary
@ -289,16 +288,16 @@ class LocalDeviceEnvironment(environment.Environment):
if os.path.exists(m.output_file)])
shutil.rmtree(self._logcat_output_dir)
def BlacklistDevice(self, device, reason='local_device_failure'):
def DenylistDevice(self, device, reason='local_device_failure'):
device_serial = device.adb.GetDeviceSerial()
if self._blacklist:
self._blacklist.Extend([device_serial], reason=reason)
if self._denylist:
self._denylist.Extend([device_serial], reason=reason)
with self._devices_lock:
self._devices = [d for d in self._devices if str(d) != device_serial]
logging.error('Device %s blacklisted: %s', device_serial, reason)
logging.error('Device %s denylisted: %s', device_serial, reason)
if not self._devices:
raise device_errors.NoDevicesError(
'All devices were blacklisted due to errors')
'All devices were denylisted due to errors')
@staticmethod
def DisableTracing():

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

@ -397,7 +397,7 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun):
#override
def SetUp(self):
@local_device_environment.handle_shard_failures_with(
on_failure=self._env.BlacklistDevice)
on_failure=self._env.DenylistDevice)
@trace_event.traced
def individual_device_set_up(device, host_device_tuples):
def install_apk(dev):
@ -510,7 +510,7 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun):
# test list so that tests can be split up and run in batches rather than all
# at once (since test output is not streamed).
@local_device_environment.handle_shard_failures_with(
on_failure=self._env.BlacklistDevice)
on_failure=self._env.DenylistDevice)
def list_tests(dev):
timeout = 30
retries = 1

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

@ -165,7 +165,7 @@ class LocalDeviceInstrumentationTestRun(
target_package = _GetTargetPackageName(self._test_instance.test_apk)
@local_device_environment.handle_shard_failures_with(
self._env.BlacklistDevice)
self._env.DenylistDevice)
@trace_event.traced
def individual_device_set_up(device, host_device_tuples):
steps = []
@ -404,7 +404,7 @@ class LocalDeviceInstrumentationTestRun(
return
@local_device_environment.handle_shard_failures_with(
self._env.BlacklistDevice)
self._env.DenylistDevice)
@trace_event.traced
def individual_device_tear_down(dev):
if str(dev) in self._flag_changers:

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

@ -257,10 +257,14 @@ def AddDeviceOptions(parser):
type=os.path.realpath,
help='Specify the absolute path of the adb binary that '
'should be used.')
parser.add_argument(
'--blacklist-file',
type=os.path.realpath,
help='Device blacklist file.')
# TODO(crbug.com/1097306): Remove this once callers have all switched to
# --denylist-file.
parser.add_argument('--blacklist-file',
dest='denylist_file',
help=argparse.SUPPRESS)
parser.add_argument('--denylist-file',
type=os.path.realpath,
help='Device denylist file.')
parser.add_argument(
'-d', '--device', nargs='+',
dest='test_devices',

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

@ -43,7 +43,6 @@
../../third_party/catapult/devil/devil/android/constants/file_system.py
../../third_party/catapult/devil/devil/android/crash_handler.py
../../third_party/catapult/devil/devil/android/decorators.py
../../third_party/catapult/devil/devil/android/device_blacklist.py
../../third_party/catapult/devil/devil/android/device_denylist.py
../../third_party/catapult/devil/devil/android/device_errors.py
../../third_party/catapult/devil/devil/android/device_list.py

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

@ -19,7 +19,7 @@ from multiprocessing.pool import ThreadPool
import devil_chromium
from devil.android import device_blacklist
from devil.android import device_denylist
from devil.android import device_errors
from devil.android import device_utils
from devil.utils import run_tests_helper
@ -233,7 +233,12 @@ def main():
parser.add_argument('--device',
help='The serial number of the device. If not specified '
'will use all devices.')
parser.add_argument('--blacklist-file', help='Device blacklist JSON file.')
# TODO(crbug.com/1097306): Remove this once callers have all switched to
# --denylist-file.
parser.add_argument('--blacklist-file',
dest='denylist_file',
help=argparse.SUPPRESS)
parser.add_argument('--denylist-file', help='Device denylist JSON file.')
parser.add_argument('-a', '--all-tombstones', action='store_true',
help='Resolve symbols for all tombstones, rather than '
'just the most recent.')
@ -253,9 +258,8 @@ def main():
devil_chromium.Initialize(adb_path=args.adb_path)
blacklist = (device_blacklist.Blacklist(args.blacklist_file)
if args.blacklist_file
else None)
denylist = (device_denylist.Denylist(args.denylist_file)
if args.denylist_file else None)
if args.output_directory:
constants.SetOutputDirectory(args.output_directory)
@ -265,7 +269,7 @@ def main():
if args.device:
devices = [device_utils.DeviceUtils(args.device)]
else:
devices = device_utils.DeviceUtils.HealthyDevices(blacklist)
devices = device_utils.DeviceUtils.HealthyDevices(denylist)
# This must be done serially because strptime can hit a race condition if
# used for the first time in a multithreaded environment.

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

@ -31,7 +31,7 @@ import sys
import devil_chromium
from devil.android import apk_helper
from devil.android import device_blacklist
from devil.android import device_denylist
from devil.android import device_errors
from devil.android import device_utils
from devil.utils import run_tests_helper
@ -63,7 +63,10 @@ def main():
description="Script to do semi-automated upgrade testing.")
parser.add_argument('-v', '--verbose', action='count',
help='Print verbose log information.')
parser.add_argument('--blacklist-file', help='Device blacklist JSON file.')
parser.add_argument('--blacklist-file',
dest='denylist_file',
help=argparse.SUPPRESS)
parser.add_argument('--denylist-file', help='Device denylist JSON file.')
command_parsers = parser.add_subparsers(dest='command')
subparser = command_parsers.add_parser('create_app_data')
@ -90,11 +93,10 @@ def main():
devil_chromium.Initialize()
blacklist = (device_blacklist.Blacklist(args.blacklist_file)
if args.blacklist_file
else None)
denylist = (device_denylist.Denylist(args.denylist_file)
if args.denylist_file else None)
devices = device_utils.DeviceUtils.HealthyDevices(blacklist)
devices = device_utils.DeviceUtils.HealthyDevices(denylist)
if not devices:
raise device_errors.NoDevicesError()
device = devices[0]