Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import itertools | 5 import itertools |
| 6 import os | 6 import os |
| 7 import posixpath | 7 import posixpath |
| 8 | 8 |
| 9 from devil.android import device_errors | 9 from devil.android import device_errors |
| 10 from devil.android import device_temp_file | 10 from devil.android import device_temp_file |
| 11 from devil.android import ports | 11 from devil.android import ports |
| 12 from pylib import constants | 12 from pylib import constants |
| 13 from pylib.gtest import gtest_test_instance | 13 from pylib.gtest import gtest_test_instance |
| 14 from pylib.local import local_test_server_spawner | 14 from pylib.local import local_test_server_spawner |
| 15 from pylib.local.device import local_device_environment | 15 from pylib.local.device import local_device_environment |
| 16 from pylib.local.device import local_device_test_run | 16 from pylib.local.device import local_device_test_run |
| 17 | 17 |
| 18 _COMMAND_LINE_FLAGS_SUPPORTED = True | 18 _COMMAND_LINE_FLAGS_SUPPORTED = True |
| 19 | 19 |
| 20 _EXTRA_COMMAND_LINE_FILE = ( | 20 _EXTRA_COMMAND_LINE_FILE = ( |
| 21 'org.chromium.native_test.NativeTestActivity.CommandLineFile') | 21 'org.chromium.native_test.NativeTestActivity.CommandLineFile') |
| 22 _EXTRA_COMMAND_LINE_FLAGS = ( | 22 _EXTRA_COMMAND_LINE_FLAGS = ( |
| 23 'org.chromium.native_test.NativeTestActivity.CommandLineFlags') | 23 'org.chromium.native_test.NativeTestActivity.CommandLineFlags') |
| 24 _EXTRA_SHARD_NANO_TIMEOUT = ( | |
| 25 'org.chromium.native_test.NativeTestInstrumentationTestRunner' | |
| 26 '.ShardNanoTimeout') | |
| 24 _EXTRA_TEST_LIST = ( | 27 _EXTRA_TEST_LIST = ( |
| 25 'org.chromium.native_test.NativeTestInstrumentationTestRunner' | 28 'org.chromium.native_test.NativeTestInstrumentationTestRunner' |
| 26 '.TestList') | 29 '.TestList') |
| 27 | 30 |
| 28 _MAX_SHARD_SIZE = 256 | 31 _MAX_SHARD_SIZE = 256 |
| 32 _SECONDS_TO_NANOS = int(1e9) | |
| 29 | 33 |
| 30 # TODO(jbudorick): Move this up to the test instance if the net test server is | 34 # TODO(jbudorick): Move this up to the test instance if the net test server is |
| 31 # handled outside of the APK for the remote_device environment. | 35 # handled outside of the APK for the remote_device environment. |
| 32 _SUITE_REQUIRES_TEST_SERVER_SPAWNER = [ | 36 _SUITE_REQUIRES_TEST_SERVER_SPAWNER = [ |
| 33 'components_browsertests', 'content_unittests', 'content_browsertests', | 37 'components_browsertests', 'content_unittests', 'content_browsertests', |
| 34 'net_unittests', 'unit_tests' | 38 'net_unittests', 'unit_tests' |
| 35 ] | 39 ] |
| 36 | 40 |
| 37 # TODO(jbudorick): Move this inside _ApkDelegate once TestPackageApk is gone. | 41 # TODO(jbudorick): Move this inside _ApkDelegate once TestPackageApk is gone. |
| 38 def PullAppFilesImpl(device, package, files, directory): | 42 def PullAppFilesImpl(device, package, files, directory): |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 58 | 62 |
| 59 self._component = '%s/%s' % (self._package, self._runner) | 63 self._component = '%s/%s' % (self._package, self._runner) |
| 60 self._extras = test_instance.extras | 64 self._extras = test_instance.extras |
| 61 | 65 |
| 62 def Install(self, device): | 66 def Install(self, device): |
| 63 device.Install(self._apk, permissions=self._permissions) | 67 device.Install(self._apk, permissions=self._permissions) |
| 64 | 68 |
| 65 def Run(self, test, device, flags=None, **kwargs): | 69 def Run(self, test, device, flags=None, **kwargs): |
| 66 extras = dict(self._extras) | 70 extras = dict(self._extras) |
| 67 | 71 |
| 72 if 'timeout' in kwargs: | |
| 73 # Make sure the instrumentation doesn't kill the test before the | |
| 74 # scripts do. The provided timeout value is in seconds, but the | |
| 75 # instrumentation deals with nanoseconds because that's how Android | |
| 76 # handles time. | |
| 77 extras[_EXTRA_SHARD_NANO_TIMEOUT] = int( | |
|
jbudorick
2015/09/23 20:36:45
kjellander: this is the change that should prevent
| |
| 78 kwargs['timeout'] * _SECONDS_TO_NANOS) | |
| 79 | |
| 68 with device_temp_file.DeviceTempFile(device.adb) as command_line_file: | 80 with device_temp_file.DeviceTempFile(device.adb) as command_line_file: |
| 69 device.WriteFile(command_line_file.name, '_ %s' % flags if flags else '_') | 81 device.WriteFile(command_line_file.name, '_ %s' % flags if flags else '_') |
| 70 extras[_EXTRA_COMMAND_LINE_FILE] = command_line_file.name | 82 extras[_EXTRA_COMMAND_LINE_FILE] = command_line_file.name |
| 71 | 83 |
| 72 with device_temp_file.DeviceTempFile(device.adb) as test_list_file: | 84 with device_temp_file.DeviceTempFile(device.adb) as test_list_file: |
| 73 if test: | 85 if test: |
| 74 device.WriteFile(test_list_file.name, '\n'.join(test)) | 86 device.WriteFile(test_list_file.name, '\n'.join(test)) |
| 75 extras[_EXTRA_TEST_LIST] = test_list_file.name | 87 extras[_EXTRA_TEST_LIST] = test_list_file.name |
| 76 | 88 |
| 77 return device.StartInstrumentation( | 89 return device.StartInstrumentation( |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 tests = gtest_test_instance.ParseGTestListTests(tests) | 223 tests = gtest_test_instance.ParseGTestListTests(tests) |
| 212 tests = self._test_instance.FilterTests(tests) | 224 tests = self._test_instance.FilterTests(tests) |
| 213 return tests | 225 return tests |
| 214 | 226 |
| 215 test_lists = self._env.parallel_devices.pMap(list_tests).pGet(None) | 227 test_lists = self._env.parallel_devices.pMap(list_tests).pGet(None) |
| 216 tests = list(sorted(set().union(*[set(tl) for tl in test_lists if tl]))) | 228 tests = list(sorted(set().union(*[set(tl) for tl in test_lists if tl]))) |
| 217 return tests | 229 return tests |
| 218 | 230 |
| 219 #override | 231 #override |
| 220 def _RunTest(self, device, test): | 232 def _RunTest(self, device, test): |
| 221 # Run the test. | 233 if self._test_instance.suite in gtest_test_instance.BROWSER_TEST_SUITES: |
| 222 timeout = 900 * self.GetTool(device).GetTimeoutScale() | 234 timeout = 900 |
| 235 else: | |
| 236 timeout = 60 | |
| 237 timeout *= self.GetTool(device).GetTimeoutScale() | |
| 238 | |
| 223 output = self._delegate.Run( | 239 output = self._delegate.Run( |
| 224 test, device, timeout=timeout, retries=0) | 240 test, device, timeout=timeout, retries=0) |
| 225 for s in self._servers[str(device)]: | 241 for s in self._servers[str(device)]: |
| 226 s.Reset() | 242 s.Reset() |
| 227 if self._test_instance.app_files: | 243 if self._test_instance.app_files: |
| 228 self._delegate.PullAppFiles(device, self._test_instance.app_files, | 244 self._delegate.PullAppFiles(device, self._test_instance.app_files, |
| 229 self._test_instance.app_file_dir) | 245 self._test_instance.app_file_dir) |
| 230 self._delegate.Clear(device) | 246 self._delegate.Clear(device) |
| 231 | 247 |
| 232 # Parse the output. | |
| 233 # TODO(jbudorick): Transition test scripts away from parsing stdout. | 248 # TODO(jbudorick): Transition test scripts away from parsing stdout. |
| 234 results = self._test_instance.ParseGTestOutput(output) | 249 results = self._test_instance.ParseGTestOutput(output) |
| 235 return results | 250 return results |
| 236 | 251 |
| 237 #override | 252 #override |
| 238 def TearDown(self): | 253 def TearDown(self): |
| 239 @local_device_test_run.handle_shard_failures | 254 @local_device_test_run.handle_shard_failures |
| 240 def individual_device_tear_down(dev): | 255 def individual_device_tear_down(dev): |
| 241 for s in self._servers[str(dev)]: | 256 for s in self._servers.get(str(dev), []): |
| 242 s.TearDown() | 257 s.TearDown() |
| 243 | 258 |
| 244 self._env.parallel_devices.pMap(individual_device_tear_down) | 259 self._env.parallel_devices.pMap(individual_device_tear_down) |
| 245 | 260 |
| OLD | NEW |