| OLD | NEW |
| 1 # Copyright (C) 2012 Google Inc. All rights reserved. | 1 # Copyright (C) 2012 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 callback = printer.write_throttled_update | 354 callback = printer.write_throttled_update |
| 355 else: | 355 else: |
| 356 callback = printer.write_update | 356 callback = printer.write_update |
| 357 with lock: | 357 with lock: |
| 358 callback("[%s] %s" % (serial, msg)) | 358 callback("[%s] %s" % (serial, msg)) |
| 359 | 359 |
| 360 log_safely("preparing device", throttled=False) | 360 log_safely("preparing device", throttled=False) |
| 361 try: | 361 try: |
| 362 d._setup_test(log_safely) | 362 d._setup_test(log_safely) |
| 363 log_safely("device prepared", throttled=False) | 363 log_safely("device prepared", throttled=False) |
| 364 except (ScriptError, driver.DeviceFailure) as e: | 364 except (ScriptError, driver.DeviceFailure) as error: |
| 365 with lock: | 365 with lock: |
| 366 _log.warning("[%s] failed to prepare_device: %s", serial, st
r(e)) | 366 _log.warning("[%s] failed to prepare_device: %s", serial, er
ror) |
| 367 except KeyboardInterrupt: | 367 except KeyboardInterrupt: |
| 368 if pool: | 368 if pool: |
| 369 pool.terminate() | 369 pool.terminate() |
| 370 | 370 |
| 371 # FIXME: It would be nice if we knew how many workers we needed. | 371 # FIXME: It would be nice if we knew how many workers we needed. |
| 372 num_workers = self.default_child_processes() | 372 num_workers = self.default_child_processes() |
| 373 num_child_processes = int(self.get_option('child_processes')) | 373 num_child_processes = int(self.get_option('child_processes')) |
| 374 if num_child_processes: | 374 if num_child_processes: |
| 375 num_workers = min(num_workers, num_child_processes) | 375 num_workers = min(num_workers, num_child_processes) |
| 376 if num_workers > 1: | 376 if num_workers > 1: |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 super(ChromiumAndroidDriver, self).start(pixel_tests, per_test_args, dea
dline) | 905 super(ChromiumAndroidDriver, self).start(pixel_tests, per_test_args, dea
dline) |
| 906 | 906 |
| 907 def _start(self, pixel_tests, per_test_args): | 907 def _start(self, pixel_tests, per_test_args): |
| 908 if not self._android_devices.is_device_prepared(self._device.serial): | 908 if not self._android_devices.is_device_prepared(self._device.serial): |
| 909 raise driver.DeviceFailure("%s is not prepared in _start()" % self._
device.serial) | 909 raise driver.DeviceFailure("%s is not prepared in _start()" % self._
device.serial) |
| 910 | 910 |
| 911 for retries in range(3): | 911 for retries in range(3): |
| 912 try: | 912 try: |
| 913 if self._start_once(pixel_tests, per_test_args): | 913 if self._start_once(pixel_tests, per_test_args): |
| 914 return | 914 return |
| 915 except ScriptError as e: | 915 except ScriptError as error: |
| 916 self._abort('ScriptError("%s") in _start()' % str(e)) | 916 self._abort('ScriptError("%s") in _start()' % error) |
| 917 | 917 |
| 918 self._log_error('Failed to start the content_shell application. Retr
ies=%d. Log:%s' % (retries, self._get_logcat())) | 918 self._log_error('Failed to start the content_shell application. Retr
ies=%d. Log:%s' % (retries, self._get_logcat())) |
| 919 self.stop() | 919 self.stop() |
| 920 time.sleep(2) | 920 time.sleep(2) |
| 921 self._abort('Failed to start the content_shell application multiple time
s. Giving up.') | 921 self._abort('Failed to start the content_shell application multiple time
s. Giving up.') |
| 922 | 922 |
| 923 def _start_once(self, pixel_tests, per_test_args): | 923 def _start_once(self, pixel_tests, per_test_args): |
| 924 super(ChromiumAndroidDriver, self)._start(pixel_tests, per_test_args, wa
it_for_ready=False) | 924 super(ChromiumAndroidDriver, self)._start(pixel_tests, per_test_args, wa
it_for_ready=False) |
| 925 | 925 |
| 926 # We delay importing forwarder as long as possible because it uses fcntl
, | 926 # We delay importing forwarder as long as possible because it uses fcntl
, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 return command | 1109 return command |
| 1110 | 1110 |
| 1111 def _read_prompt(self, deadline): | 1111 def _read_prompt(self, deadline): |
| 1112 last_char = '' | 1112 last_char = '' |
| 1113 while True: | 1113 while True: |
| 1114 current_char = self._server_process.read_stdout(deadline, 1) | 1114 current_char = self._server_process.read_stdout(deadline, 1) |
| 1115 if current_char == ' ': | 1115 if current_char == ' ': |
| 1116 if last_char in ('#', '$'): | 1116 if last_char in ('#', '$'): |
| 1117 return | 1117 return |
| 1118 last_char = current_char | 1118 last_char = current_char |
| OLD | NEW |