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 imp | 5 import imp |
6 import itertools | 6 import itertools |
7 import os | 7 import os |
8 import posixpath | 8 import posixpath |
9 | 9 |
10 from devil.android import device_errors | 10 from devil.android import device_errors |
11 from devil.android import device_temp_file | 11 from devil.android import device_temp_file |
12 from devil.android import ports | 12 from devil.android import ports |
| 13 from devil.utils import reraiser_thread |
13 from incremental_install import installer | 14 from incremental_install import installer |
14 from pylib import constants | 15 from pylib import constants |
15 from pylib.gtest import gtest_test_instance | 16 from pylib.gtest import gtest_test_instance |
16 from pylib.local import local_test_server_spawner | 17 from pylib.local import local_test_server_spawner |
17 from pylib.local.device import local_device_environment | 18 from pylib.local.device import local_device_environment |
18 from pylib.local.device import local_device_test_run | 19 from pylib.local.device import local_device_test_run |
19 | 20 |
20 _COMMAND_LINE_FLAGS_SUPPORTED = True | 21 _COMMAND_LINE_FLAGS_SUPPORTED = True |
21 | 22 |
22 _EXTRA_COMMAND_LINE_FILE = ( | 23 _EXTRA_COMMAND_LINE_FILE = ( |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 self._delegate = _ExeDelegate(self, self._test_instance.exe) | 218 self._delegate = _ExeDelegate(self, self._test_instance.exe) |
218 | 219 |
219 self._servers = {} | 220 self._servers = {} |
220 | 221 |
221 #override | 222 #override |
222 def TestPackage(self): | 223 def TestPackage(self): |
223 return self._test_instance.suite | 224 return self._test_instance.suite |
224 | 225 |
225 #override | 226 #override |
226 def SetUp(self): | 227 def SetUp(self): |
| 228 @local_device_test_run.handle_shard_failures |
| 229 def individual_device_set_up(dev): |
| 230 def install_apk(): |
| 231 # Install test APK. |
| 232 self._delegate.Install(dev, incremental=self._env.incremental_install) |
227 | 233 |
228 @local_device_test_run.handle_shard_failures | 234 def push_test_data(): |
229 def individual_device_set_up(dev, host_device_tuples): | 235 # Push data dependencies. |
230 # Install test APK. | 236 external_storage = dev.GetExternalStoragePath() |
231 self._delegate.Install(dev, incremental=self._env.incremental_install) | 237 data_deps = self._test_instance.GetDataDependencies() |
| 238 host_device_tuples = [ |
| 239 (h, d if d is not None else external_storage) |
| 240 for h, d in data_deps] |
| 241 dev.PushChangedFiles(host_device_tuples) |
232 | 242 |
233 # Push data dependencies. | 243 def init_tool_and_start_servers(): |
234 external_storage = dev.GetExternalStoragePath() | 244 tool = self.GetTool(dev) |
235 host_device_tuples = [ | 245 tool.CopyFiles(dev) |
236 (h, d if d is not None else external_storage) | 246 tool.SetupEnvironment() |
237 for h, d in host_device_tuples] | |
238 dev.PushChangedFiles(host_device_tuples) | |
239 | 247 |
240 tool = self.GetTool(dev) | 248 self._servers[str(dev)] = [] |
241 tool.CopyFiles(dev) | 249 if self.TestPackage() in _SUITE_REQUIRES_TEST_SERVER_SPAWNER: |
242 tool.SetupEnvironment() | 250 self._servers[str(dev)].append( |
| 251 local_test_server_spawner.LocalTestServerSpawner( |
| 252 ports.AllocateTestServerPort(), dev, tool)) |
243 | 253 |
244 self._servers[str(dev)] = [] | 254 for s in self._servers[str(dev)]: |
245 if self.TestPackage() in _SUITE_REQUIRES_TEST_SERVER_SPAWNER: | 255 s.SetUp() |
246 self._servers[str(dev)].append( | |
247 local_test_server_spawner.LocalTestServerSpawner( | |
248 ports.AllocateTestServerPort(), dev, tool)) | |
249 | 256 |
250 for s in self._servers[str(dev)]: | 257 steps = (install_apk, push_test_data, init_tool_and_start_servers) |
251 s.SetUp() | 258 if self._env.concurrent_adb: |
| 259 reraiser_thread.RunAsync(steps) |
| 260 else: |
| 261 for step in steps: |
| 262 step() |
252 | 263 |
253 self._env.parallel_devices.pMap(individual_device_set_up, | 264 self._env.parallel_devices.pMap(individual_device_set_up) |
254 self._test_instance.GetDataDependencies()) | |
255 | 265 |
256 #override | 266 #override |
257 def _ShouldShard(self): | 267 def _ShouldShard(self): |
258 return True | 268 return True |
259 | 269 |
260 #override | 270 #override |
261 def _CreateShards(self, tests): | 271 def _CreateShards(self, tests): |
262 device_count = len(self._env.devices) | 272 device_count = len(self._env.devices) |
263 shards = [] | 273 shards = [] |
264 for i in xrange(0, device_count): | 274 for i in xrange(0, device_count): |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 def TearDown(self): | 327 def TearDown(self): |
318 @local_device_test_run.handle_shard_failures | 328 @local_device_test_run.handle_shard_failures |
319 def individual_device_tear_down(dev): | 329 def individual_device_tear_down(dev): |
320 for s in self._servers.get(str(dev), []): | 330 for s in self._servers.get(str(dev), []): |
321 s.TearDown() | 331 s.TearDown() |
322 | 332 |
323 tool = self.GetTool(dev) | 333 tool = self.GetTool(dev) |
324 tool.CleanUpEnvironment() | 334 tool.CleanUpEnvironment() |
325 | 335 |
326 self._env.parallel_devices.pMap(individual_device_tear_down) | 336 self._env.parallel_devices.pMap(individual_device_tear_down) |
OLD | NEW |