Lines Matching refs:self

149     def device_cache_directory(self):
150 return self.device_directory() + 'cache/'
152 def device_fonts_directory(self):
153 return self.device_directory() + 'fonts/'
155 def device_forwarder_path(self):
156 return self.device_directory() + 'forwarder'
158 def device_fifo_directory(self):
159 return '/data/data/' + self.package_name() + '/files/'
161 def apk_name(self):
164 def package_name(self):
167 def activity_name(self):
168 return self.package_name() + '/.ContentShellActivity'
170 def library_name(self):
173 def additional_resources(self):
176 def command_line_file(self):
179 def device_crash_dumps_directory(self):
182 def additional_command_line_flags(self, use_breakpad):
185 flags.extend(['--enable-crash-reporter', '--crash-dumps-dir=%s' % self.device_crash_dumps_directory()])
188 def device_directory(self):
197 def __init__(self, executive, device_serial, debug_logging):
198 self._executive = executive
199 self._device_serial = device_serial
200 self._debug_logging = debug_logging
204 def file_exists(self, full_path):
206 return self.run(['shell', 'ls', '-d', full_path]).strip() == full_path
208 def push(self, host_path, device_path, ignore_error=False):
209 return self.run(['push', host_path, device_path], ignore_error=ignore_error)
211 def pull(self, device_path, host_path, ignore_error=False):
212 return self.run(['pull', device_path, host_path], ignore_error=ignore_error)
214 def mkdir(self, device_path, chmod=None):
215 self.run(['shell', 'mkdir', '-p', device_path])
217 self.run(['shell', 'chmod', chmod, device_path])
219 def restart_adb(self):
220 pids = self.extract_pids('adbd')
222 output = self.run(['shell', 'kill', '-' + str(signal.SIGTERM)] + pids)
223 self.run(['wait-for-device'])
225 def restart_as_root(self):
226 output = self.run(['root'])
231 self._log_error('Unrecognized output from adb root: %s' % output)
233 self.run(['wait-for-device'])
235 def extract_pids(self, process_name):
237 output = self.run(['shell', 'ps'])
250 def run(self, command, ignore_error=False):
251 self._log_debug('Run adb command: ' + str(command))
253 error_handler = self._executive.ignore_error
257 result = self._executive.run_command(self.adb_command() + command, error_handler=error_handler, debug_logging=self._debug_logging)
262 self._log_debug('Run adb result: ' + result[:80].encode('ascii', errors='replace'))
265 def get_serial(self):
266 return self._device_serial
268 def adb_command(self):
269 return [AndroidCommands.adb_command_path(self._executive, self._debug_logging), '-s', self._device_serial]
301 def _log_error(self, message):
302 _log.error('[%s] %s' % (self._device_serial, message))
304 def _log_info(self, message):
305 _log.info('[%s] %s' % (self._device_serial, message))
307 def _log_debug(self, message):
308 if self._debug_logging:
309 _log.debug('[%s] %s' % (self._device_serial, message))
334 def __init__(self, executive, default_device=None, debug_logging=False):
335 self._usable_devices = []
336 self._default_device = default_device
337 self._prepared_devices = []
338 self._debug_logging = debug_logging
340 def prepared_devices(self):
341 return self._prepared_devices
343 def usable_devices(self, executive):
344 if self._usable_devices:
345 return self._usable_devices
347 if self._default_device:
348 self._usable_devices = [AndroidCommands(executive, self._default_device, self._debug_logging)]
349 return self._usable_devices
356 result = executive.run_command([AndroidCommands.adb_command_path(executive, debug_logging=self._debug_logging), 'devices'],
357 error_handler=executive.ignore_error, debug_logging=self._debug_logging)
363 commands = AndroidCommands(executive, device_serial, self._debug_logging)
364 if self._battery_level_for_device(commands) < AndroidDevices.MINIMUM_BATTERY_PERCENTAGE:
369 if not self._is_device_screen_on(commands):
373 self._usable_devices.append(commands)
375 return self._usable_devices
377 def get_device(self, executive, device_index):
378 devices = self.usable_devices(executive)
384 def is_device_prepared(self, device_serial):
385 return device_serial in self._prepared_devices
387 def set_device_prepared(self, device_serial):
388 self._prepared_devices.append(device_serial)
391 def _battery_level_for_device(self, commands):
399 def _is_device_screen_on(self, commands):
419 def __init__(self, host, port_name, **kwargs):
420 super(AndroidPort, self).__init__(host, port_name, **kwargs)
422 self._operating_system = 'android'
423 self._version = 'icecreamsandwich'
425 self._host_port = factory.PortFactory(host).get('chromium', **kwargs)
426 self._server_process_constructor = self._android_server_process_constructor
428 if not self.get_option('disable_breakpad'):
429 self._dump_reader = DumpReaderAndroid(host, self._build_path())
431 if self.driver_name() != self.CONTENT_SHELL_NAME:
434 self._driver_details = ContentShellDriverDetails()
438 if hasattr(self._options, 'adb_device') and len(self._options.adb_device):
439 default_device = self._options.adb_device
441 self._debug_logging = self.get_option('android_logging')
442 self._devices = AndroidDevices(self._executive, default_device, self._debug_logging)
446 self.path_from_chromium_base('third_party', 'android_tools', 'sdk', 'platform-tools', 'adb')])
448 prepared_devices = self.get_option('prepared_devices', [])
450 self._devices.set_device_prepared(serial)
452 def default_smoke_test_only(self):
456 def path_to_forwarder(self):
457 return self._build_path('forwarder')
459 def path_to_md5sum(self):
460 return self._build_path(MD5SUM_DEVICE_FILE_NAME)
462 def path_to_md5sum_host(self):
463 return self._build_path(MD5SUM_HOST_FILE_NAME)
465 def additional_drt_flag(self):
466 return self._driver_details.additional_command_line_flags(use_breakpad=not self.get_option('disable_breakpad'))
468 def default_timeout_ms(self):
474 def driver_stop_timeout(self):
478 def default_child_processes(self):
479 usable_devices = self._devices.usable_devices(self._executive)
484 def check_wdiff(self, logging=True):
485 return self._host_port.check_wdiff(logging)
487 def check_build(self, needs_http, printer):
488 exit_status = super(AndroidPort, self).check_build(needs_http, printer)
492 result = self._check_file_exists(self.path_to_md5sum(), 'md5sum utility')
493 result = self._check_file_exists(self.path_to_md5sum_host(), 'md5sum host utility') and result
494 result = self._check_file_exists(self.path_to_forwarder(), 'forwarder utility') and result
500 if self.host.platform.is_linux():
501 pids = self._executive.running_pids(lambda name: 'adb' in name)
504 self._executive.run_command(['adb', 'devices'])
505 pids = self._executive.running_pids(lambda name: 'adb' in name)
511 self._executive.run_command(['taskset', '-p', '-c', '0', str(pid)])
519 return self._check_devices(printer)
521 def _check_devices(self, printer):
530 d = self.create_driver(worker_number)
557 num_workers = self.default_child_processes()
558 num_child_processes = int(self.get_option('child_processes'))
571 if not self._devices.prepared_devices():
576 def setup_test_run(self):
577 super(AndroidPort, self).setup_test_run()
581 if self._devices._prepared_devices:
582 self._options.prepared_devices = self._devices.prepared_devices()
585 self._options.prepared_devices = [d.get_serial() for d in self._devices.usable_devices(self.host.executive)]
587 def num_workers(self, requested_num_workers):
588 return min(len(self._options.prepared_devices), requested_num_workers)
590 def check_sys_deps(self, needs_http):
595 if self._check_file_exists(font_path, '', logging=False):
603 def requires_http_server(self):
608 def start_http_server(self, additional_dirs, number_of_drivers):
609 additional_dirs[PERF_TEST_PATH_PREFIX] = self.perf_tests_dir()
610 additional_dirs[LAYOUT_TEST_PATH_PREFIX] = self.layout_tests_dir()
611 super(AndroidPort, self).start_http_server(additional_dirs, number_of_drivers)
613 def create_driver(self, worker_number, no_timeout=False):
614 return ChromiumAndroidDriver(self, worker_number, pixel_tests=self.get_option('pixel_tests'),
615 driver_details=self._driver_details,
616 android_devices=self._devices,
620 def driver_cmd_line(self):
622 return self.create_driver(0)._android_driver_cmd_line(self.get_option('pixel_tests'), [])
624 def clobber_old_port_specific_results(self):
625 if not self.get_option('disable_breakpad'):
626 self._dump_reader.clobber_old_results()
630 def _build_path(self, *comps):
631 return self._host_port._build_path(*comps)
633 def _build_path_with_configuration(self, configuration, *comps):
634 return self._host_port._build_path_with_configuration(configuration, *comps)
636 def path_to_apache(self):
637 return self._host_port.path_to_apache()
639 def path_to_apache_config_file(self):
640 return self._host_port.path_to_apache_config_file()
642 def _path_to_driver(self, configuration=None):
643 return self._build_path_with_configuration(configuration, self._driver_details.apk_name())
645 def _path_to_helper(self):
648 def _path_to_image_diff(self):
649 return self._host_port._path_to_image_diff()
651 def _path_to_wdiff(self):
652 return self._host_port._path_to_wdiff()
654 def _shut_down_http_server(self, pid):
655 return self._host_port._shut_down_http_server(pid)
657 def _driver_class(self):
672 def __init__(self, host, executable_path, output_dir, android_commands, symfs_path, kallsyms_path, identifier=None):
673 super(AndroidPerf, self).__init__(host, executable_path, output_dir, "data", identifier)
674 self._android_commands = android_commands
675 self._perf_process = None
676 self._symfs_path = symfs_path
677 self._kallsyms_path = kallsyms_path
679 def check_configuration(self):
681 if not self._android_commands.file_exists('/system/bin/perf'):
682 print "Cannot find /system/bin/perf on device %s" % self._android_commands.get_serial()
686 if self._android_commands.run(['shell', 'getprop', 'ro.build.type']).strip() != 'userdebug':
687 print "Device %s is not flashed with a userdebug build of Android" % self._android_commands.get_serial()
695 def print_setup_instructions(self):
714 def attach_to_pid(self, pid):
716 assert(self._perf_process == None)
718 cmd = self._android_commands.adb_command() + ['shell', 'perf', 'record', '-g', '-p', pid, 'sleep', 30]
719 self._perf_process = self._host.executive.popen(cmd)
721 def _perf_version_string(self, perf_path):
723 return self._host.executive.run_command([perf_path, '--version'])
727 def _find_perfhost_binary(self):
728 perfhost_version = self._perf_version_string('perfhost_linux')
731 perf_version = self._perf_version_string('perf')
736 def _perfhost_path(self):
737 if self._have_searched_for_perf_host:
738 return self._cached_perf_host_path
739 self._have_searched_for_perf_host = True
740 self._cached_perf_host_path = self._find_perfhost_binary()
741 return self._cached_perf_host_path
743 def _first_ten_lines_of_profile(self, perf_output):
747 def profile_after_exit(self):
748 perf_exitcode = self._perf_process.wait()
753 self._android_commands.pull('/data/perf.data', self._output_path)
755 perfhost_path = self._perfhost_path()
758 '--input', self._output_path,
759 '--symfs', self._symfs_path,
760 '--kallsyms', self._kallsyms_path,
764 perf_output = self._host.executive.run_command(perfhost_args)
766 print self._first_ten_lines_of_profile(perf_output)
788 def __init__(self, port, worker_number, pixel_tests, driver_details, android_devices, no_timeout=False):
789 super(ChromiumAndroidDriver, self).__init__(port, worker_number, pixel_tests, no_timeout)
790 self._in_fifo_path = driver_details.device_fifo_directory() + 'stdin.fifo'
791 self._out_fifo_path = driver_details.device_fifo_directory() + 'test.fifo'
792 self._err_fifo_path = driver_details.device_fifo_directory() + 'stderr.fifo'
793 self._read_stdout_process = None
794 self._read_stderr_process = None
795 self._forwarder_process = None
796 self._original_governors = {}
797 self._original_kptr_restrict = None
799 self._android_devices = android_devices
800 self._android_commands = android_devices.get_device(port._executive, worker_number)
801 self._driver_details = driver_details
802 self._debug_logging = self._port._debug_logging
803 self._created_cmd_line = False
804 self._device_failed = False
808 if self._port.get_option("profile"):
810 symfs_path = self._find_or_create_symfs()
811 kallsyms_path = self._update_kallsyms_cache(symfs_path)
813 self._profiler = AndroidPerf(self._port.host, self._port._path_to_driver(), self._port.results_directory(),
814 self._android_commands, symfs_path, kallsyms_path)
818 if not self._profiler.check_configuration():
819 self._profiler.print_setup_instructions()
822 self._profiler = None
824 def __del__(self):
825 self._teardown_performance()
826 self._clean_up_cmd_line()
827 super(ChromiumAndroidDriver, self).__del__()
829 def _update_kallsyms_cache(self, output_dir):
830 kallsyms_name = "%s-kallsyms" % self._android_commands.get_serial()
831 kallsyms_cache_path = self._port.host.filesystem.join(output_dir, kallsyms_name)
833 self._android_commands.restart_as_root()
835 saved_kptr_restrict = self._android_commands.run(['shell', 'cat', KPTR_RESTRICT_PATH]).strip()
836 self._android_commands.run(['shell', 'echo', '0', '>', KPTR_RESTRICT_PATH])
839 self._android_commands.pull("/proc/kallsyms", kallsyms_cache_path)
841 self._android_commands.run(['shell', 'echo', saved_kptr_restrict, '>', KPTR_RESTRICT_PATH])
845 def _find_or_create_symfs(self):
846 environment = self._port.host.copy_current_environment()
848 fs = self._port.host.filesystem
853 symfs_path = fs.join(self._port.results_directory(), 'symfs')
858 symfs_library_path = fs.join(symfs_path, "data/app-lib/%s-1/%s" % (self._driver_details.package_name(), self._driver_details.library_name()))
859 built_library_path = self._port._build_path('lib', self._driver_details.library_name())
869 def _setup_md5sum_and_push_data_if_needed(self, log_callback):
870 self._md5sum_path = self._port.path_to_md5sum()
871 if not self._android_commands.file_exists(MD5SUM_DEVICE_PATH):
872 if not self._android_commands.push(self._md5sum_path, MD5SUM_DEVICE_PATH):
873 self._abort('Could not push md5sum to device')
875 self._push_executable(log_callback)
876 self._push_fonts(log_callback)
877 self._push_test_resources(log_callback)
879 def _setup_test(self, log_callback):
884 if self._android_devices.is_device_prepared(self._android_commands.get_serial()):
887 self._android_commands.restart_adb()
888 self._android_commands.restart_as_root()
889 self._setup_md5sum_and_push_data_if_needed(log_callback)
890 self._setup_performance()
894 self._android_commands.mkdir(DEVICE_SOURCE_ROOT_DIR + 'chrome')
898 self._android_commands.mkdir(self._driver_details.device_directory(), chmod='777')
899 self._android_commands.mkdir(self._driver_details.device_fifo_directory(), chmod='777')
902 self._android_commands.run(['shell', 'rm', '-r', self._driver_details.device_cache_directory()])
905 self._android_devices.set_device_prepared(self._android_commands.get_serial())
907 def _log_error(self, message):
908 _log.error('[%s] %s' % (self._android_commands.get_serial(), message))
910 def _log_warning(self, message):
911 _log.warning('[%s] %s' % (self._android_commands.get_serial(), message))
913 def _log_debug(self, message):
914 if self._debug_logging:
915 _log.debug('[%s] %s' % (self._android_commands.get_serial(), message))
917 def _abort(self, message):
918 self._device_failed = True
919 raise driver.DeviceFailure('[%s] %s' % (self._android_commands.get_serial(), message))
926 def _files_match(self, host_file, device_file):
927 assert self._port.host.filesystem.exists(host_file)
928 device_hashes = self._extract_hashes_from_md5sum_output(
929 self._port.host.executive.popen(self._android_commands.adb_command() + ['shell', MD5SUM_DEVICE_PATH, device_file],
931 host_hashes = self._extract_hashes_from_md5sum_output(
932 self._port.host.executive.popen(args=['%s_host' % self._md5sum_path, host_file],
936 def _push_file_if_needed(self, host_file, device_file, log_callback):
937 basename = self._port.host.filesystem.basename(host_file)
939 if not self._files_match(host_file, device_file):
941 self._android_commands.push(host_file, device_file)
943 def _push_executable(self, log_callback):
944 self._push_file_if_needed(self._port.path_to_forwarder(), self._driver_details.device_forwarder_path(), log_callback)
945 for resource in self._driver_details.additional_resources():
946 self._push_file_if_needed(self._port._build_path(resource), self._driver_details.device_directory() + resource, log_callback)
948 self._push_file_if_needed(self._port._build_path('android_main_fonts.xml'), self._driver_details.device_directory() + 'android_main_fonts.xml', log_callback)
949 self._push_file_if_needed(self._port._build_path('android_fallback_fonts.xml'), self._driver_details.device_directory() + 'android_fallback_fonts.xml', log_callback)
952 if self._files_match(self._port._build_path('apks', 'ContentShell.apk'),
957 self._android_commands.run(['uninstall', self._driver_details.package_name()])
958 driver_host_path = self._port._path_to_driver()
960 install_result = self._android_commands.run(['install', driver_host_path])
962 self._abort('Failed to install %s onto device: %s' % (driver_host_path, install_result))
964 def _push_fonts(self, log_callback):
965 path_to_ahem_font = self._port._build_path('AHEM____.TTF')
966 self._push_file_if_needed(path_to_ahem_font, self._driver_details.device_fonts_directory() + 'AHEM____.TTF', log_callback)
970 if self._port._check_file_exists(host_font_path, '', logging=False):
971 self._push_file_if_needed(host_font_path, self._driver_details.device_fonts_directory() + font_file, log_callback)
973 def _push_test_resources(self, log_callback):
975 self._push_file_if_needed(self._port.layout_tests_dir() + '/' + resource, DEVICE_LAYOUT_TESTS_DIR + resource, log_callback)
977 def _get_last_stacktrace(self):
978 tombstones = self._android_commands.run(['shell', 'ls', '-n', '/data/tombstones/tombstone_*'])
980 self._log_error('The driver crashed, but no tombstone found!')
985 self._log_error('The driver crashed, but we could not read the tombstones!')
997 self._log_warning("unexpected line in tombstone output, skipping: '%s'" % tombstone)
1006 self._log_error('The driver crashed, but we could not find any valid tombstone!')
1013 self._android_commands.run(['shell', 'cat', '/data/tombstones/' + last_tombstone[6]]))
1015 def _get_logcat(self):
1016 return self._android_commands.run(['logcat', '-d', '-v', 'threadtime'])
1018 def _setup_performance(self):
1020 if not self._original_governors:
1021 governor_files = self._android_commands.run(['shell', 'ls', SCALING_GOVERNORS_PATTERN])
1024 self._original_governors[file] = self._android_commands.run(['shell', 'cat', file]).strip()
1025 self._android_commands.run(['shell', 'echo', 'performance', '>', file])
1027 def _teardown_performance(self):
1028 for file, original_content in self._original_governors.items():
1029 self._android_commands.run(['shell', 'echo', original_content, '>', file])
1030 self._original_governors = {}
1032 def _get_crash_log(self, stdout, stderr, newer_than):
1035 stdout += '********* [%s] Logcat:\n%s' % (self._android_commands.get_serial(), self._get_logcat())
1038 stderr += '********* [%s] Tombstone file:\n%s' % (self._android_commands.get_serial(), self._get_last_stacktrace())
1040 if not self._port.get_option('disable_breakpad'):
1041 crashes = self._pull_crash_dumps_from_device()
1043 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))
1045 return super(ChromiumAndroidDriver, self)._get_crash_log(stdout, stderr, newer_than)
1047 def cmd_line(self, pixel_tests, per_test_args):
1050 return self._android_commands.adb_command() + ['shell']
1052 def _android_driver_cmd_line(self, pixel_tests, per_test_args):
1053 return driver.Driver.cmd_line(self, pixel_tests, per_test_args)
1063 def _all_pipes_created(self):
1064 return (self._android_commands.file_exists(self._in_fifo_path) and
1065 self._android_commands.file_exists(self._out_fifo_path) and
1066 self._android_commands.file_exists(self._err_fifo_path))
1068 def _remove_all_pipes(self):
1069 for file in [self._in_fifo_path, self._out_fifo_path, self._err_fifo_path]:
1070 self._android_commands.run(['shell', 'rm', file])
1072 return (not self._android_commands.file_exists(self._in_fifo_path) and
1073 not self._android_commands.file_exists(self._out_fifo_path) and
1074 not self._android_commands.file_exists(self._err_fifo_path))
1076 def start(self, pixel_tests, per_test_args, deadline):
1079 new_cmd_line = self._android_driver_cmd_line(pixel_tests, per_test_args)
1083 if self._current_cmd_line is None:
1084 self._current_android_cmd_line = None
1085 if new_cmd_line != self._current_android_cmd_line:
1086 self.stop()
1087 self._current_android_cmd_line = new_cmd_line
1089 super(ChromiumAndroidDriver, self).start(pixel_tests, per_test_args, deadline)
1091 def _start(self, pixel_tests, per_test_args):
1092 if not self._android_devices.is_device_prepared(self._android_commands.get_serial()):
1093 raise driver.DeviceFailure("%s is not prepared in _start()" % self._android_commands.get_serial())
1097 if self._start_once(pixel_tests, per_test_args):
1100 self._abort('ScriptError("%s") in _start()' % str(e))
1102 self._log_error('Failed to start the content_shell application. Retries=%d. Log:%s' % (retries, self._get_logcat()))
1103 self.stop()
1105 self._abort('Failed to start the content_shell application multiple times. Giving up.')
1107 def _start_once(self, pixel_tests, per_test_args):
1108 super(ChromiumAndroidDriver, self)._start(pixel_tests, per_test_args, wait_for_ready=False)
1110 self._log_debug('Starting forwarder')
1111 self._forwarder_process = self._port._server_process_constructor(
1112 self._port, 'Forwarder', self._android_commands.adb_command() + ['shell', '%s -D %s' % (self._driver_details.device_forwarder_path(), FORWARD_PORTS)])
1113 self._forwarder_process.start()
1116 if not self._wait_for_server_process_output(self._forwarder_process, deadline, 'Forwarding device port'):
1119 self._android_commands.run(['logcat', '-c'])
1121 cmd_line_file_path = self._driver_details.command_line_file()
1123 if self._android_commands.file_exists(cmd_line_file_path) and not self._android_commands.file_exists(original_cmd_line_file_path):
1127 self._android_commands.run(['shell', 'mv', cmd_line_file_path, original_cmd_line_file_path])
1129 self._android_commands.run(['shell', 'echo'] + self._android_driver_cmd_line(pixel_tests, per_test_args) + ['>', self._driver_details.command_line_file()])
1130 self._created_cmd_line = True
1132 self._android_commands.run(['shell', 'rm', '-rf', self._driver_details.device_crash_dumps_directory()])
1133 self._android_commands.mkdir(self._driver_details.device_crash_dumps_directory(), chmod='777')
1135 start_result = self._android_commands.run(['shell', 'am', 'start', '-e', 'RunInSubThread', '-n', self._driver_details.activity_name()])
1137 self._log_error('Failed to start the content_shell application. Exception:\n' + start_result)
1140 if not ChromiumAndroidDriver._loop_with_timeout(self._all_pipes_created, DRIVER_START_STOP_TIMEOUT_SECS):
1145 self._server_process.start()
1146 self._read_prompt(deadline)
1147 self._log_debug('Interactive shell started')
1150 self._log_debug('Redirecting stdout to ' + self._out_fifo_path)
1151 self._read_stdout_process = self._port._server_process_constructor(
1152 self._port, 'ReadStdout', self._android_commands.adb_command() + ['shell', 'cat', self._out_fifo_path])
1153 self._read_stdout_process.start()
1156 self._log_debug('Redirecting stderr to ' + self._err_fifo_path)
1157 self._read_stderr_process = self._port._server_process_constructor(
1158 self._port, 'ReadStderr', self._android_commands.adb_command() + ['shell', 'cat', self._err_fifo_path])
1159 self._read_stderr_process.start()
1161 self._log_debug('Redirecting stdin to ' + self._in_fifo_path)
1162 self._server_process.write('cat >%s\n' % self._in_fifo_path)
1164 # Combine the stdout and stderr pipes into self._server_process.
1165 self._server_process.replace_outputs(self._read_stdout_process._proc.stdout, self._read_stderr_process._proc.stdout)
1173 self._log_error('Deadlock detected. Processes killed.')
1180 args=([self._server_process, self._read_stdout_process, self._read_stderr_process], normal_startup_event)).start()
1184 if not self._wait_for_server_process_output(self._server_process, deadline, '#READY'):
1189 self._log_debug("content_shell is ready")
1192 def _pid_from_android_ps_output(self, ps_output, package_name):
1196 if line.find(self._driver_details.package_name()) != -1:
1200 def _pid_on_target(self):
1202 ps_output = self._android_commands.run(['shell', 'ps'])
1203 return self._pid_from_android_ps_output(ps_output, self._driver_details.package_name())
1205 def stop(self):
1206 if not self._device_failed:
1209 self._android_commands.run(['shell', 'am', 'force-stop', self._driver_details.package_name()])
1211 if self._read_stdout_process:
1212 self._read_stdout_process.kill()
1213 self._read_stdout_process = None
1215 if self._read_stderr_process:
1216 self._read_stderr_process.kill()
1217 self._read_stderr_process = None
1219 super(ChromiumAndroidDriver, self).stop()
1221 if self._forwarder_process:
1222 self._forwarder_process.kill()
1223 self._forwarder_process = None
1225 if self._android_devices.is_device_prepared(self._android_commands.get_serial()):
1226 if not ChromiumAndroidDriver._loop_with_timeout(self._remove_all_pipes, DRIVER_START_STOP_TIMEOUT_SECS):
1227 self._abort('Failed to remove fifo files. May be locked.')
1229 self._clean_up_cmd_line()
1231 def _pull_crash_dumps_from_device(self):
1233 if not self._android_commands.file_exists(self._driver_details.device_crash_dumps_directory()):
1235 dumps = self._android_commands.run(['shell', 'ls', self._driver_details.device_crash_dumps_directory()])
1237 device_dump = '%s/%s' % (self._driver_details.device_crash_dumps_directory(), dump)
1238 local_dump = self._port._filesystem.join(self._port._dump_reader.crash_dumps_directory(), dump)
1241 err = self._android_commands.run(['shell', 'chmod', '777', device_dump])
1243 self._android_commands.pull(device_dump, local_dump)
1245 self._android_commands.run(['shell', 'rm', '-f', device_dump])
1247 if self._port._filesystem.exists(local_dump):
1251 def _clean_up_cmd_line(self):
1252 if not self._created_cmd_line:
1255 cmd_line_file_path = self._driver_details.command_line_file()
1257 if self._android_commands.file_exists(original_cmd_line_file_path):
1258 self._android_commands.run(['shell', 'mv', original_cmd_line_file_path, cmd_line_file_path])
1259 elif self._android_commands.file_exists(cmd_line_file_path):
1260 self._android_commands.run(['shell', 'rm', cmd_line_file_path])
1261 self._created_cmd_line = False
1263 def _command_from_driver_input(self, driver_input):
1264 command = super(ChromiumAndroidDriver, self)._command_from_driver_input(driver_input)
1266 fs = self._port._filesystem
1268 relative_test_filename = fs.relpath(command, fs.dirname(self._port.layout_tests_dir()))
1272 def _read_prompt(self, deadline):
1275 current_char = self._server_process.read_stdout(deadline, 1)