Index: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/android.py |
diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/android.py b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/android.py |
index aa91d00c5f7bd69281e920e58c9645bef0496c2e..9eb62d7d777a84cbb216afd2ef9cd06b4f1d9560 100644 |
--- a/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/android.py |
+++ b/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/port/android.py |
@@ -121,7 +121,8 @@ HOST_FONT_FILES = [ |
[['/usr/share/fonts/truetype/ttf-indic-fonts-core/'], 'lohit_ta.ttf', 'ttf-indic-fonts-core'], |
[['/usr/share/fonts/truetype/ttf-indic-fonts-core/'], 'MuktiNarrow.ttf', 'ttf-indic-fonts-core'], |
[['/usr/share/fonts/truetype/thai/', '/usr/share/fonts/truetype/tlwg/'], 'Garuda.ttf', 'fonts-tlwg-garuda'], |
- [['/usr/share/fonts/truetype/ttf-indic-fonts-core/', '/usr/share/fonts/truetype/ttf-punjabi-fonts/'], 'lohit_pa.ttf', 'ttf-indic-fonts-core'], |
+ [['/usr/share/fonts/truetype/ttf-indic-fonts-core/', '/usr/share/fonts/truetype/ttf-punjabi-fonts/'], 'lohit_pa.ttf', |
+ 'ttf-indic-fonts-core'], |
] |
# Test resources that need to be accessed as files directly. |
@@ -254,7 +255,9 @@ class AndroidCommands(object): |
else: |
error_handler = None |
- result = self._executive.run_command(self.adb_command() + command, error_handler=error_handler, debug_logging=self._debug_logging) |
+ result = self._executive.run_command(self.adb_command() + command, |
+ error_handler=error_handler, |
+ debug_logging=self._debug_logging) |
# We limit the length to avoid outputting too verbose commands, such as "adb logcat". |
self._log_debug('Run adb result: ' + result[:80]) |
@@ -310,7 +313,8 @@ class AndroidCommands(object): |
def _determine_adb_version(adb_command_path, executive, debug_logging): |
re_version = re.compile('^.*version ([\d\.]+)') |
try: |
- output = executive.run_command([adb_command_path, 'version'], error_handler=executive.ignore_error, |
+ output = executive.run_command([adb_command_path, 'version'], |
+ error_handler=executive.ignore_error, |
debug_logging=debug_logging) |
except OSError: |
return None |
@@ -351,8 +355,11 @@ class AndroidDevices(object): |
# 0123456789ABCDEF device |
re_device = re.compile('^([a-zA-Z0-9_:.-]+)\tdevice$', re.MULTILINE) |
- result = executive.run_command([AndroidCommands.adb_command_path(executive, debug_logging=self._debug_logging), 'devices'], |
- error_handler=executive.ignore_error, debug_logging=self._debug_logging) |
+ result = executive.run_command( |
+ [AndroidCommands.adb_command_path(executive, |
+ debug_logging=self._debug_logging), 'devices'], |
+ error_handler=executive.ignore_error, |
+ debug_logging=self._debug_logging) |
devices = re_device.findall(result) |
if not devices: |
return [] |
@@ -360,8 +367,8 @@ class AndroidDevices(object): |
for device_serial in sorted(devices): |
commands = AndroidCommands(executive, device_serial, self._debug_logging) |
if self._battery_level_for_device(commands) < AndroidDevices.MINIMUM_BATTERY_PERCENTAGE: |
- _log.warning('Device with serial "%s" skipped because it has less than %d percent battery.' |
- % (commands.get_serial(), AndroidDevices.MINIMUM_BATTERY_PERCENTAGE)) |
+ _log.warning('Device with serial "%s" skipped because it has less than %d percent battery.' % |
+ (commands.get_serial(), AndroidDevices.MINIMUM_BATTERY_PERCENTAGE)) |
continue |
if not self._is_device_screen_on(commands): |
@@ -440,8 +447,8 @@ class AndroidPort(base.Port): |
self._devices = AndroidDevices(self._executive, default_device, self._debug_logging) |
# Tell AndroidCommands where to search for the "adb" command. |
- AndroidCommands.set_adb_command_path_options(['adb', |
- self.path_from_chromium_base('third_party', 'android_tools', 'sdk', 'platform-tools', 'adb')]) |
+ AndroidCommands.set_adb_command_path_options(['adb', self.path_from_chromium_base('third_party', 'android_tools', 'sdk', |
+ 'platform-tools', 'adb')]) |
prepared_devices = self.get_option('prepared_devices', []) |
for serial in prepared_devices: |
@@ -461,7 +468,8 @@ class AndroidPort(base.Port): |
return self._build_path(MD5SUM_HOST_FILE_NAME) |
def additional_driver_flag(self): |
- return super(AndroidPort, self).additional_driver_flag() + self._driver_details.additional_command_line_flags(use_breakpad=not self.get_option('disable_breakpad')) |
+ return super(AndroidPort, self).additional_driver_flag() + self._driver_details.additional_command_line_flags( |
+ use_breakpad=not self.get_option('disable_breakpad')) |
def default_timeout_ms(self): |
# Android platform has less computing power than desktop platforms. |
@@ -476,7 +484,8 @@ class AndroidPort(base.Port): |
def default_child_processes(self): |
usable_devices = self._devices.usable_devices(self._executive) |
if not usable_devices: |
- raise test_run_results.TestRunException(test_run_results.NO_DEVICES_EXIT_STATUS, "Unable to find any attached Android devices.") |
+ raise test_run_results.TestRunException(test_run_results.NO_DEVICES_EXIT_STATUS, |
+ "Unable to find any attached Android devices.") |
return len(usable_devices) |
def max_drivers_per_process(self): |
@@ -599,7 +608,8 @@ class AndroidPort(base.Port): |
exists = True |
break |
if not exists: |
- _log.error('You are missing %s under %s. Try installing %s. See build instructions.' % (font_file, font_dirs, package)) |
+ _log.error('You are missing %s under %s. Try installing %s. See build instructions.' % |
+ (font_file, font_dirs, package)) |
return test_run_results.SYS_DEPS_EXIT_STATUS |
return test_run_results.OK_EXIT_STATUS |
@@ -614,7 +624,9 @@ class AndroidPort(base.Port): |
super(AndroidPort, self).start_http_server(additional_dirs, number_of_drivers) |
def create_driver(self, worker_number, no_timeout=False): |
- return ChromiumAndroidDriver(self, worker_number, pixel_tests=self.get_option('pixel_tests'), |
+ return ChromiumAndroidDriver(self, |
+ worker_number, |
+ pixel_tests=self.get_option('pixel_tests'), |
driver_details=self._driver_details, |
android_devices=self._devices, |
# Force no timeout to avoid test driver timeouts before NRWT. |
@@ -670,8 +682,13 @@ class AndroidPort(base.Port): |
# server_process' stdout and stderr are now unicode file-like objects, |
# not binary file-like objects like all of the other ports are. |
# FIXME: crbug.com/496983. |
- return server_process.ServerProcess(port, server_name, cmd_line, env, |
- universal_newlines=True, treat_no_data_as_crash=True, logging=logging) |
+ return server_process.ServerProcess(port, |
+ server_name, |
+ cmd_line, |
+ env, |
+ universal_newlines=True, |
+ treat_no_data_as_crash=True, |
+ logging=logging) |
class AndroidPerf(SingleFileOutputProfiler): |
@@ -721,8 +738,8 @@ http://goto.google.com/cr-android-perf-howto |
""") |
def attach_to_pid(self, pid): |
- assert(pid) |
- assert(self._perf_process == None) |
+ assert (pid) |
+ assert (self._perf_process is None) |
qyearsley
2016/03/18 00:33:39
== None -> is None was a manual change done in ord
|
# FIXME: This can't be a fixed timeout! |
cmd = self._android_commands.adb_command() + ['shell', 'perf', 'record', '-g', '-p', pid, 'sleep', 30] |
self._perf_process = self._host.executive.popen(cmd) |
@@ -764,9 +781,12 @@ http://goto.google.com/cr-android-perf-howto |
perfhost_path = self._perfhost_path() |
perfhost_report_command = [ |
'report', |
- '--input', self._output_path, |
- '--symfs', self._symfs_path, |
- '--kallsyms', self._kallsyms_path, |
+ '--input', |
+ self._output_path, |
+ '--symfs', |
+ self._symfs_path, |
+ '--kallsyms', |
+ self._kallsyms_path, |
] |
if perfhost_path: |
perfhost_args = [perfhost_path] + perfhost_report_command + ['--call-graph', 'none'] |
@@ -794,7 +814,6 @@ http://crbug.com/165250 discusses making these pre-built binaries externally ava |
class ChromiumAndroidDriver(driver.Driver): |
- |
def __init__(self, port, worker_number, pixel_tests, driver_details, android_devices, no_timeout=False): |
super(ChromiumAndroidDriver, self).__init__(port, worker_number, pixel_tests, no_timeout) |
self._in_fifo_path = driver_details.device_fifo_directory() + 'stdin.fifo' |
@@ -821,7 +840,7 @@ class ChromiumAndroidDriver(driver.Driver): |
kallsyms_path = self._update_kallsyms_cache(symfs_path) |
# FIXME: We should pass this some sort of "Bridge" object abstraction around ADB instead of a path/device pair. |
self._profiler = AndroidPerf(self._port.host, self._port._path_to_driver(), self._port.results_directory(), |
- self._android_commands, symfs_path, kallsyms_path) |
+ self._android_commands, symfs_path, kallsyms_path) |
# FIXME: This is a layering violation and should be moved to Port.check_sys_deps |
# once we have an abstraction around an adb_path/device_serial pair to make it |
# easy to make these class methods on AndroidPerf. |
@@ -865,11 +884,13 @@ class ChromiumAndroidDriver(driver.Driver): |
# find the installed path, and the path of the symboled built library |
# FIXME: We should get the install path from the device! |
- symfs_library_path = fs.join(symfs_path, "data/app-lib/%s-1/%s" % (self._driver_details.package_name(), self._driver_details.library_name())) |
+ symfs_library_path = fs.join(symfs_path, "data/app-lib/%s-1/%s" % |
+ (self._driver_details.package_name(), self._driver_details.library_name())) |
built_library_path = self._port._build_path('lib', self._driver_details.library_name()) |
- assert(fs.exists(built_library_path)) |
+ assert (fs.exists(built_library_path)) |
- # FIXME: Ideally we'd check the sha1's first and make a soft-link instead of copying (since we probably never care about windows). |
+ # FIXME: Ideally we'd check the sha1's first and make a soft-link instead |
+ # of copying (since we probably never care about windows). |
_log.debug("Updating symfs library (%s) from built copy (%s)" % (symfs_library_path, built_library_path)) |
fs.maybe_make_directory(fs.dirname(symfs_library_path)) |
fs.copyfile(built_library_path, symfs_library_path) |
@@ -936,11 +957,13 @@ class ChromiumAndroidDriver(driver.Driver): |
def _files_match(self, host_file, device_file): |
assert self._port.host.filesystem.exists(host_file) |
device_hashes = self._extract_hashes_from_md5sum_output( |
- self._port.host.executive.popen(self._android_commands.adb_command() + ['shell', MD5SUM_DEVICE_PATH, device_file], |
- stdout=subprocess.PIPE).stdout) |
+ self._port.host.executive.popen( |
+ self._android_commands.adb_command() + ['shell', MD5SUM_DEVICE_PATH, device_file], |
+ stdout=subprocess.PIPE).stdout) |
host_hashes = self._extract_hashes_from_md5sum_output( |
- self._port.host.executive.popen(args=['%s_host' % self._md5sum_path, host_file], |
- stdout=subprocess.PIPE).stdout) |
+ self._port.host.executive.popen( |
+ args=['%s_host' % self._md5sum_path, host_file], |
+ stdout=subprocess.PIPE).stdout) |
return host_hashes and device_hashes == host_hashes |
def _push_file_if_needed(self, host_file, device_file, log_callback): |
@@ -953,14 +976,18 @@ class ChromiumAndroidDriver(driver.Driver): |
def _push_executable(self, log_callback): |
self._push_file_if_needed(self._port.path_to_forwarder(), self._driver_details.device_forwarder_path(), log_callback) |
for resource in self._driver_details.additional_resources(): |
- self._push_file_if_needed(self._port._build_path(resource), self._driver_details.device_directory() + resource, log_callback) |
+ self._push_file_if_needed( |
+ self._port._build_path(resource), self._driver_details.device_directory() + resource, log_callback) |
- self._push_file_if_needed(self._port._build_path('android_main_fonts.xml'), self._driver_details.device_directory() + 'android_main_fonts.xml', log_callback) |
- self._push_file_if_needed(self._port._build_path('android_fallback_fonts.xml'), self._driver_details.device_directory() + 'android_fallback_fonts.xml', log_callback) |
+ self._push_file_if_needed( |
+ self._port._build_path('android_main_fonts.xml'), self._driver_details.device_directory() + 'android_main_fonts.xml', |
+ log_callback) |
+ self._push_file_if_needed( |
+ self._port._build_path('android_fallback_fonts.xml'), |
+ self._driver_details.device_directory() + 'android_fallback_fonts.xml', log_callback) |
log_callback("checking apk") |
- if self._files_match(self._port._build_path('apks', 'ContentShell.apk'), |
- '/data/app/org.chromium.content_shell_apk-1.apk'): |
+ if self._files_match(self._port._build_path('apks', 'ContentShell.apk'), '/data/app/org.chromium.content_shell_apk-1.apk'): |
return |
log_callback("uninstalling apk") |
@@ -978,11 +1005,13 @@ class ChromiumAndroidDriver(driver.Driver): |
for host_dir in host_dirs: |
host_font_path = host_dir + font_file |
if self._port._check_file_exists(host_font_path, '', logging=False): |
- self._push_file_if_needed(host_font_path, self._driver_details.device_fonts_directory() + font_file, log_callback) |
+ self._push_file_if_needed(host_font_path, self._driver_details.device_fonts_directory() + font_file, |
+ log_callback) |
def _push_test_resources(self, log_callback): |
for resource in TEST_RESOURCES_TO_PUSH: |
- self._push_file_if_needed(self._port.layout_tests_dir() + '/' + resource, DEVICE_LAYOUT_TESTS_DIR + resource, log_callback) |
+ self._push_file_if_needed(self._port.layout_tests_dir() + '/' + resource, DEVICE_LAYOUT_TESTS_DIR + resource, |
+ log_callback) |
def _get_last_stacktrace(self): |
tombstones = self._android_commands.run(['shell', 'ls', '-n', '/data/tombstones/tombstone_*']) |
@@ -1050,16 +1079,16 @@ class ChromiumAndroidDriver(driver.Driver): |
if not self._port.get_option('disable_breakpad'): |
crashes = self._pull_crash_dumps_from_device() |
for crash in crashes: |
- stderr += '********* [%s] breakpad minidump %s:\n%s' % (self._port.host.filesystem.basename(crash), self._android_commands.get_serial(), self._port._dump_reader._get_stack_from_dump(crash)) |
+ stderr += '********* [%s] breakpad minidump %s:\n%s' % (self._port.host.filesystem.basename(crash), |
+ self._android_commands.get_serial(), |
+ self._port._dump_reader._get_stack_from_dump(crash)) |
# The parent method expects stdout and stderr to be byte streams, but |
# since adb shell does newline conversion, we used universal_newlines |
# when launching the processes, and hence our stdout and stderr are |
# text objects that need to be encoded back into bytes. |
return super(ChromiumAndroidDriver, self)._get_crash_log( |
- stdout.encode('utf8', 'replace'), |
- stderr.encode('utf8', 'replace'), |
- newer_than) |
+ stdout.encode('utf8', 'replace'), stderr.encode('utf8', 'replace'), newer_than) |
def cmd_line(self, pixel_tests, per_test_args): |
# The returned command line is used to start _server_process. In our case, it's an interactive 'adb shell'. |
@@ -1079,8 +1108,7 @@ class ChromiumAndroidDriver(driver.Driver): |
def _all_pipes_created(self): |
return (self._android_commands.file_exists(self._in_fifo_path) and |
- self._android_commands.file_exists(self._out_fifo_path) and |
- self._android_commands.file_exists(self._err_fifo_path)) |
+ self._android_commands.file_exists(self._out_fifo_path) and self._android_commands.file_exists(self._err_fifo_path)) |
def _remove_all_pipes(self): |
for file in [self._in_fifo_path, self._out_fifo_path, self._err_fifo_path]: |
@@ -1126,7 +1154,9 @@ class ChromiumAndroidDriver(driver.Driver): |
self._log_debug('Starting forwarder') |
self._forwarder_process = self._port._server_process_constructor( |
- self._port, 'Forwarder', self._android_commands.adb_command() + ['shell', '%s -no-spawn-daemon %s' % (self._driver_details.device_forwarder_path(), FORWARD_PORTS)]) |
+ self._port, 'Forwarder', |
+ self._android_commands.adb_command() + ['shell', '%s -no-spawn-daemon %s' % |
+ (self._driver_details.device_forwarder_path(), FORWARD_PORTS)]) |
self._forwarder_process.start() |
deadline = time.time() + DRIVER_START_STOP_TIMEOUT_SECS |
@@ -1137,19 +1167,22 @@ class ChromiumAndroidDriver(driver.Driver): |
cmd_line_file_path = self._driver_details.command_line_file() |
original_cmd_line_file_path = cmd_line_file_path + '.orig' |
- if self._android_commands.file_exists(cmd_line_file_path) and not self._android_commands.file_exists(original_cmd_line_file_path): |
+ if self._android_commands.file_exists(cmd_line_file_path) and not self._android_commands.file_exists( |
+ original_cmd_line_file_path): |
# We check for both the normal path and the backup because we do not want to step |
# on the backup. Otherwise, we'd clobber the backup whenever we changed the |
# command line during the run. |
self._android_commands.run(['shell', 'mv', cmd_line_file_path, original_cmd_line_file_path]) |
- self._android_commands.run(['shell', 'echo'] + self._android_driver_cmd_line(pixel_tests, per_test_args) + ['>', self._driver_details.command_line_file()]) |
+ self._android_commands.run(['shell', 'echo'] + self._android_driver_cmd_line(pixel_tests, per_test_args) + |
+ ['>', self._driver_details.command_line_file()]) |
self._created_cmd_line = True |
self._android_commands.run(['shell', 'rm', '-rf', self._driver_details.device_crash_dumps_directory()]) |
self._android_commands.mkdir(self._driver_details.device_crash_dumps_directory(), chmod='777') |
- start_result = self._android_commands.run(['shell', 'am', 'start', '-e', 'RunInSubThread', '-n', self._driver_details.activity_name()]) |
+ start_result = self._android_commands.run(['shell', 'am', 'start', '-e', 'RunInSubThread', '-n', |
+ self._driver_details.activity_name()]) |
if start_result.find('Exception') != -1: |
self._log_error('Failed to start the content_shell application. Exception:\n' + start_result) |
return False |
@@ -1193,8 +1226,10 @@ class ChromiumAndroidDriver(driver.Driver): |
# Start a thread to kill the pipe reading/writing processes on deadlock of the fifos during startup. |
normal_startup_event = threading.Event() |
- threading.Thread(name='DeadlockDetector', target=deadlock_detector, |
- args=([self._server_process, self._read_stdout_process, self._read_stderr_process], normal_startup_event)).start() |
+ threading.Thread( |
+ name='DeadlockDetector', |
+ target=deadlock_detector, |
+ args=([self._server_process, self._read_stdout_process, self._read_stderr_process], normal_startup_event)).start() |
# The test driver might crash during startup or when the deadlock detector hits |
# a deadlock and kills the fifo reading/writing processes. |