| 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 collections | 5 import collections |
| 6 import imp | |
| 7 import itertools | 6 import itertools |
| 8 import os | 7 import os |
| 9 import posixpath | 8 import posixpath |
| 10 | 9 |
| 11 from devil.android import device_errors | 10 from devil.android import device_errors |
| 12 from devil.android import device_temp_file | 11 from devil.android import device_temp_file |
| 13 from devil.android import ports | 12 from devil.android import ports |
| 14 from devil.utils import reraiser_thread | 13 from devil.utils import reraiser_thread |
| 15 from incremental_install import installer | |
| 16 from pylib import constants | 14 from pylib import constants |
| 17 from pylib.gtest import gtest_test_instance | 15 from pylib.gtest import gtest_test_instance |
| 18 from pylib.local import local_test_server_spawner | 16 from pylib.local import local_test_server_spawner |
| 19 from pylib.local.device import local_device_environment | 17 from pylib.local.device import local_device_environment |
| 20 from pylib.local.device import local_device_test_run | 18 from pylib.local.device import local_device_test_run |
| 21 | 19 |
| 22 _COMMAND_LINE_FLAGS_SUPPORTED = True | 20 _COMMAND_LINE_FLAGS_SUPPORTED = True |
| 23 | 21 |
| 24 _MAX_INLINE_FLAGS_LENGTH = 50 # Arbitrarily chosen. | 22 _MAX_INLINE_FLAGS_LENGTH = 50 # Arbitrarily chosen. |
| 25 _EXTRA_COMMAND_LINE_FILE = ( | 23 _EXTRA_COMMAND_LINE_FILE = ( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 90 |
| 93 if '*' in gtest_filter: | 91 if '*' in gtest_filter: |
| 94 return None | 92 return None |
| 95 return patterns | 93 return patterns |
| 96 | 94 |
| 97 | 95 |
| 98 class _ApkDelegate(object): | 96 class _ApkDelegate(object): |
| 99 def __init__(self, test_instance): | 97 def __init__(self, test_instance): |
| 100 self._activity = test_instance.activity | 98 self._activity = test_instance.activity |
| 101 self._apk_helper = test_instance.apk_helper | 99 self._apk_helper = test_instance.apk_helper |
| 100 self._test_apk_install_script = test_instance.test_apk_install_script |
| 102 self._package = test_instance.package | 101 self._package = test_instance.package |
| 103 self._runner = test_instance.runner | 102 self._runner = test_instance.runner |
| 104 self._permissions = test_instance.permissions | 103 self._permissions = test_instance.permissions |
| 105 self._suite = test_instance.suite | 104 self._suite = test_instance.suite |
| 106 self._component = '%s/%s' % (self._package, self._runner) | 105 self._component = '%s/%s' % (self._package, self._runner) |
| 107 self._extras = test_instance.extras | 106 self._extras = test_instance.extras |
| 108 | 107 |
| 109 def Install(self, device, incremental=False): | 108 def Install(self, device): |
| 110 if not incremental: | 109 if self._test_apk_install_script: |
| 110 local_device_test_run.IncrementalInstall(device, self._apk_helper, |
| 111 self._test_apk_install_script) |
| 112 else: |
| 111 device.Install(self._apk_helper, reinstall=True, | 113 device.Install(self._apk_helper, reinstall=True, |
| 112 permissions=self._permissions) | 114 permissions=self._permissions) |
| 113 return | |
| 114 | |
| 115 installer_script = os.path.join(constants.GetOutDirectory(), 'bin', | |
| 116 'install_%s_apk_incremental' % self._suite) | |
| 117 try: | |
| 118 install_wrapper = imp.load_source('install_wrapper', installer_script) | |
| 119 except IOError: | |
| 120 raise Exception(('Incremental install script not found: %s\n' | |
| 121 'Make sure to first build "%s_incremental"') % | |
| 122 (installer_script, self._suite)) | |
| 123 params = install_wrapper.GetInstallParameters() | |
| 124 | |
| 125 installer.Install(device, self._apk_helper, split_globs=params['splits'], | |
| 126 native_libs=params['native_libs'], | |
| 127 dex_files=params['dex_files']) | |
| 128 | 115 |
| 129 def Run(self, test, device, flags=None, **kwargs): | 116 def Run(self, test, device, flags=None, **kwargs): |
| 130 extras = dict(self._extras) | 117 extras = dict(self._extras) |
| 131 | 118 |
| 132 if ('timeout' in kwargs | 119 if ('timeout' in kwargs |
| 133 and gtest_test_instance.EXTRA_SHARD_NANO_TIMEOUT not in extras): | 120 and gtest_test_instance.EXTRA_SHARD_NANO_TIMEOUT not in extras): |
| 134 # Make sure the instrumentation doesn't kill the test before the | 121 # Make sure the instrumentation doesn't kill the test before the |
| 135 # scripts do. The provided timeout value is in seconds, but the | 122 # scripts do. The provided timeout value is in seconds, but the |
| 136 # instrumentation deals with nanoseconds because that's how Android | 123 # instrumentation deals with nanoseconds because that's how Android |
| 137 # handles time. | 124 # handles time. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 self._exe_device_path = '%s/%s' % ( | 165 self._exe_device_path = '%s/%s' % ( |
| 179 constants.TEST_EXECUTABLE_DIR, self._exe_file_name) | 166 constants.TEST_EXECUTABLE_DIR, self._exe_file_name) |
| 180 deps_host_path = self._exe_host_path + '_deps' | 167 deps_host_path = self._exe_host_path + '_deps' |
| 181 if os.path.exists(deps_host_path): | 168 if os.path.exists(deps_host_path): |
| 182 self._deps_host_path = deps_host_path | 169 self._deps_host_path = deps_host_path |
| 183 self._deps_device_path = self._exe_device_path + '_deps' | 170 self._deps_device_path = self._exe_device_path + '_deps' |
| 184 else: | 171 else: |
| 185 self._deps_host_path = None | 172 self._deps_host_path = None |
| 186 self._test_run = tr | 173 self._test_run = tr |
| 187 | 174 |
| 188 def Install(self, device, incremental=False): | 175 def Install(self, device): |
| 189 assert not incremental | |
| 190 # TODO(jbudorick): Look into merging this with normal data deps pushing if | 176 # TODO(jbudorick): Look into merging this with normal data deps pushing if |
| 191 # executables become supported on nonlocal environments. | 177 # executables become supported on nonlocal environments. |
| 192 host_device_tuples = [(self._exe_host_path, self._exe_device_path)] | 178 host_device_tuples = [(self._exe_host_path, self._exe_device_path)] |
| 193 if self._deps_host_path: | 179 if self._deps_host_path: |
| 194 host_device_tuples.append((self._deps_host_path, self._deps_device_path)) | 180 host_device_tuples.append((self._deps_host_path, self._deps_device_path)) |
| 195 device.PushChangedFiles(host_device_tuples) | 181 device.PushChangedFiles(host_device_tuples) |
| 196 | 182 |
| 197 def Run(self, test, device, flags=None, **kwargs): | 183 def Run(self, test, device, flags=None, **kwargs): |
| 198 tool = self._test_run.GetTool(device).GetTestWrapper() | 184 tool = self._test_run.GetTool(device).GetTestWrapper() |
| 199 if tool: | 185 if tool: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 def TestPackage(self): | 235 def TestPackage(self): |
| 250 return self._test_instance.suite | 236 return self._test_instance.suite |
| 251 | 237 |
| 252 #override | 238 #override |
| 253 def SetUp(self): | 239 def SetUp(self): |
| 254 @local_device_test_run.handle_shard_failures_with( | 240 @local_device_test_run.handle_shard_failures_with( |
| 255 on_failure=self._env.BlacklistDevice) | 241 on_failure=self._env.BlacklistDevice) |
| 256 def individual_device_set_up(dev): | 242 def individual_device_set_up(dev): |
| 257 def install_apk(): | 243 def install_apk(): |
| 258 # Install test APK. | 244 # Install test APK. |
| 259 self._delegate.Install(dev, incremental=self._env.incremental_install) | 245 self._delegate.Install(dev) |
| 260 | 246 |
| 261 def push_test_data(): | 247 def push_test_data(): |
| 262 # Push data dependencies. | 248 # Push data dependencies. |
| 263 external_storage = dev.GetExternalStoragePath() | 249 external_storage = dev.GetExternalStoragePath() |
| 264 data_deps = self._test_instance.GetDataDependencies() | 250 data_deps = self._test_instance.GetDataDependencies() |
| 265 host_device_tuples = [ | 251 host_device_tuples = [ |
| 266 (h, d if d is not None else external_storage) | 252 (h, d if d is not None else external_storage) |
| 267 for h, d in data_deps] | 253 for h, d in data_deps] |
| 268 dev.PushChangedFiles(host_device_tuples) | 254 dev.PushChangedFiles(host_device_tuples) |
| 269 | 255 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 def TearDown(self): | 343 def TearDown(self): |
| 358 @local_device_test_run.handle_shard_failures | 344 @local_device_test_run.handle_shard_failures |
| 359 def individual_device_tear_down(dev): | 345 def individual_device_tear_down(dev): |
| 360 for s in self._servers.get(str(dev), []): | 346 for s in self._servers.get(str(dev), []): |
| 361 s.TearDown() | 347 s.TearDown() |
| 362 | 348 |
| 363 tool = self.GetTool(dev) | 349 tool = self.GetTool(dev) |
| 364 tool.CleanUpEnvironment() | 350 tool.CleanUpEnvironment() |
| 365 | 351 |
| 366 self._env.parallel_devices.pMap(individual_device_tear_down) | 352 self._env.parallel_devices.pMap(individual_device_tear_down) |
| OLD | NEW |