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_incremental_install_script = ( |
| 101 test_instance.test_apk_incremental_install_script) |
102 self._package = test_instance.package | 102 self._package = test_instance.package |
103 self._runner = test_instance.runner | 103 self._runner = test_instance.runner |
104 self._permissions = test_instance.permissions | 104 self._permissions = test_instance.permissions |
105 self._suite = test_instance.suite | 105 self._suite = test_instance.suite |
106 self._component = '%s/%s' % (self._package, self._runner) | 106 self._component = '%s/%s' % (self._package, self._runner) |
107 self._extras = test_instance.extras | 107 self._extras = test_instance.extras |
108 | 108 |
109 def Install(self, device, incremental=False): | 109 def Install(self, device): |
110 if not incremental: | 110 if self._test_apk_incremental_install_script: |
| 111 local_device_test_run.IncrementalInstall(device, self._apk_helper, |
| 112 self._test_apk_incremental_install_script) |
| 113 else: |
111 device.Install(self._apk_helper, reinstall=True, | 114 device.Install(self._apk_helper, reinstall=True, |
112 permissions=self._permissions) | 115 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 | 116 |
129 def Run(self, test, device, flags=None, **kwargs): | 117 def Run(self, test, device, flags=None, **kwargs): |
130 extras = dict(self._extras) | 118 extras = dict(self._extras) |
131 | 119 |
132 if ('timeout' in kwargs | 120 if ('timeout' in kwargs |
133 and gtest_test_instance.EXTRA_SHARD_NANO_TIMEOUT not in extras): | 121 and gtest_test_instance.EXTRA_SHARD_NANO_TIMEOUT not in extras): |
134 # Make sure the instrumentation doesn't kill the test before the | 122 # Make sure the instrumentation doesn't kill the test before the |
135 # scripts do. The provided timeout value is in seconds, but the | 123 # scripts do. The provided timeout value is in seconds, but the |
136 # instrumentation deals with nanoseconds because that's how Android | 124 # instrumentation deals with nanoseconds because that's how Android |
137 # handles time. | 125 # handles time. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 self._exe_device_path = '%s/%s' % ( | 166 self._exe_device_path = '%s/%s' % ( |
179 constants.TEST_EXECUTABLE_DIR, self._exe_file_name) | 167 constants.TEST_EXECUTABLE_DIR, self._exe_file_name) |
180 deps_host_path = self._exe_host_path + '_deps' | 168 deps_host_path = self._exe_host_path + '_deps' |
181 if os.path.exists(deps_host_path): | 169 if os.path.exists(deps_host_path): |
182 self._deps_host_path = deps_host_path | 170 self._deps_host_path = deps_host_path |
183 self._deps_device_path = self._exe_device_path + '_deps' | 171 self._deps_device_path = self._exe_device_path + '_deps' |
184 else: | 172 else: |
185 self._deps_host_path = None | 173 self._deps_host_path = None |
186 self._test_run = tr | 174 self._test_run = tr |
187 | 175 |
188 def Install(self, device, incremental=False): | 176 def Install(self, device): |
189 assert not incremental | |
190 # TODO(jbudorick): Look into merging this with normal data deps pushing if | 177 # TODO(jbudorick): Look into merging this with normal data deps pushing if |
191 # executables become supported on nonlocal environments. | 178 # executables become supported on nonlocal environments. |
192 host_device_tuples = [(self._exe_host_path, self._exe_device_path)] | 179 host_device_tuples = [(self._exe_host_path, self._exe_device_path)] |
193 if self._deps_host_path: | 180 if self._deps_host_path: |
194 host_device_tuples.append((self._deps_host_path, self._deps_device_path)) | 181 host_device_tuples.append((self._deps_host_path, self._deps_device_path)) |
195 device.PushChangedFiles(host_device_tuples) | 182 device.PushChangedFiles(host_device_tuples) |
196 | 183 |
197 def Run(self, test, device, flags=None, **kwargs): | 184 def Run(self, test, device, flags=None, **kwargs): |
198 tool = self._test_run.GetTool(device).GetTestWrapper() | 185 tool = self._test_run.GetTool(device).GetTestWrapper() |
199 if tool: | 186 if tool: |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 def TestPackage(self): | 236 def TestPackage(self): |
250 return self._test_instance.suite | 237 return self._test_instance.suite |
251 | 238 |
252 #override | 239 #override |
253 def SetUp(self): | 240 def SetUp(self): |
254 @local_device_test_run.handle_shard_failures_with( | 241 @local_device_test_run.handle_shard_failures_with( |
255 on_failure=self._env.BlacklistDevice) | 242 on_failure=self._env.BlacklistDevice) |
256 def individual_device_set_up(dev): | 243 def individual_device_set_up(dev): |
257 def install_apk(): | 244 def install_apk(): |
258 # Install test APK. | 245 # Install test APK. |
259 self._delegate.Install(dev, incremental=self._env.incremental_install) | 246 self._delegate.Install(dev) |
260 | 247 |
261 def push_test_data(): | 248 def push_test_data(): |
262 # Push data dependencies. | 249 # Push data dependencies. |
263 external_storage = dev.GetExternalStoragePath() | 250 external_storage = dev.GetExternalStoragePath() |
264 data_deps = self._test_instance.GetDataDependencies() | 251 data_deps = self._test_instance.GetDataDependencies() |
265 host_device_tuples = [ | 252 host_device_tuples = [ |
266 (h, d if d is not None else external_storage) | 253 (h, d if d is not None else external_storage) |
267 for h, d in data_deps] | 254 for h, d in data_deps] |
268 dev.PushChangedFiles(host_device_tuples) | 255 dev.PushChangedFiles(host_device_tuples) |
269 | 256 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 def TearDown(self): | 344 def TearDown(self): |
358 @local_device_test_run.handle_shard_failures | 345 @local_device_test_run.handle_shard_failures |
359 def individual_device_tear_down(dev): | 346 def individual_device_tear_down(dev): |
360 for s in self._servers.get(str(dev), []): | 347 for s in self._servers.get(str(dev), []): |
361 s.TearDown() | 348 s.TearDown() |
362 | 349 |
363 tool = self.GetTool(dev) | 350 tool = self.GetTool(dev) |
364 tool.CleanUpEnvironment() | 351 tool.CleanUpEnvironment() |
365 | 352 |
366 self._env.parallel_devices.pMap(individual_device_tear_down) | 353 self._env.parallel_devices.pMap(individual_device_tear_down) |
OLD | NEW |