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 itertools | 6 import itertools |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 | 10 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 self._servers = collections.defaultdict(list) | 244 self._servers = collections.defaultdict(list) |
245 | 245 |
246 #override | 246 #override |
247 def TestPackage(self): | 247 def TestPackage(self): |
248 return self._test_instance.suite | 248 return self._test_instance.suite |
249 | 249 |
250 #override | 250 #override |
251 def SetUp(self): | 251 def SetUp(self): |
252 @local_device_environment.handle_shard_failures_with( | 252 @local_device_environment.handle_shard_failures_with( |
253 on_failure=self._env.BlacklistDevice) | 253 on_failure=self._env.BlacklistDevice) |
254 def individual_device_set_up(dev): | 254 def individual_device_set_up(dev, host_device_tuples): |
255 def install_apk(): | 255 def install_apk(): |
256 # Install test APK. | 256 # Install test APK. |
257 self._delegate.Install(dev) | 257 self._delegate.Install(dev) |
258 | 258 |
259 def push_test_data(): | 259 def push_test_data(): |
260 # Push data dependencies. | 260 # Push data dependencies. |
261 device_root = self._delegate.GetTestDataRoot(dev) | 261 device_root = self._delegate.GetTestDataRoot(dev) |
262 data_deps = self._test_instance.GetDataDependencies() | 262 host_device_tuples_substituted = [ |
263 host_device_tuples = [ | 263 (h, local_device_test_run.SubstituteDeviceRoot(d, device_root)) |
264 (h, d if d is not None else device_root) | 264 for h, d in host_device_tuples] |
265 for h, d in data_deps] | 265 dev.PushChangedFiles( |
266 dev.PushChangedFiles(host_device_tuples, delete_device_stale=True) | 266 host_device_tuples_substituted, |
| 267 delete_device_stale=True) |
267 if not host_device_tuples: | 268 if not host_device_tuples: |
268 dev.RunShellCommand(['rm', '-rf', device_root], check_return=True) | 269 dev.RunShellCommand(['rm', '-rf', device_root], check_return=True) |
269 dev.RunShellCommand(['mkdir', '-p', device_root], check_return=True) | 270 dev.RunShellCommand(['mkdir', '-p', device_root], check_return=True) |
270 | 271 |
271 def init_tool_and_start_servers(): | 272 def init_tool_and_start_servers(): |
272 tool = self.GetTool(dev) | 273 tool = self.GetTool(dev) |
273 tool.CopyFiles(dev) | 274 tool.CopyFiles(dev) |
274 tool.SetupEnvironment() | 275 tool.SetupEnvironment() |
275 | 276 |
276 self._servers[str(dev)] = [] | 277 self._servers[str(dev)] = [] |
277 if self.TestPackage() in _SUITE_REQUIRES_TEST_SERVER_SPAWNER: | 278 if self.TestPackage() in _SUITE_REQUIRES_TEST_SERVER_SPAWNER: |
278 self._servers[str(dev)].append( | 279 self._servers[str(dev)].append( |
279 local_test_server_spawner.LocalTestServerSpawner( | 280 local_test_server_spawner.LocalTestServerSpawner( |
280 ports.AllocateTestServerPort(), dev, tool)) | 281 ports.AllocateTestServerPort(), dev, tool)) |
281 | 282 |
282 for s in self._servers[str(dev)]: | 283 for s in self._servers[str(dev)]: |
283 s.SetUp() | 284 s.SetUp() |
284 | 285 |
285 steps = (install_apk, push_test_data, init_tool_and_start_servers) | 286 steps = (install_apk, push_test_data, init_tool_and_start_servers) |
286 if self._env.concurrent_adb: | 287 if self._env.concurrent_adb: |
287 reraiser_thread.RunAsync(steps) | 288 reraiser_thread.RunAsync(steps) |
288 else: | 289 else: |
289 for step in steps: | 290 for step in steps: |
290 step() | 291 step() |
291 | 292 |
292 self._env.parallel_devices.pMap(individual_device_set_up) | 293 self._env.parallel_devices.pMap( |
| 294 individual_device_set_up, |
| 295 self._test_instance.GetDataDependencies()) |
293 | 296 |
294 #override | 297 #override |
295 def _ShouldShard(self): | 298 def _ShouldShard(self): |
296 return True | 299 return True |
297 | 300 |
298 #override | 301 #override |
299 def _CreateShards(self, tests): | 302 def _CreateShards(self, tests): |
300 # _crashes are tests that might crash and make the tests in the same shard | 303 # _crashes are tests that might crash and make the tests in the same shard |
301 # following the crashed testcase not run. | 304 # following the crashed testcase not run. |
302 # Thus we need to create separate shards for each crashed testcase, | 305 # Thus we need to create separate shards for each crashed testcase, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 def TearDown(self): | 416 def TearDown(self): |
414 @local_device_environment.handle_shard_failures | 417 @local_device_environment.handle_shard_failures |
415 def individual_device_tear_down(dev): | 418 def individual_device_tear_down(dev): |
416 for s in self._servers.get(str(dev), []): | 419 for s in self._servers.get(str(dev), []): |
417 s.TearDown() | 420 s.TearDown() |
418 | 421 |
419 tool = self.GetTool(dev) | 422 tool = self.GetTool(dev) |
420 tool.CleanUpEnvironment() | 423 tool.CleanUpEnvironment() |
421 | 424 |
422 self._env.parallel_devices.pMap(individual_device_tear_down) | 425 self._env.parallel_devices.pMap(individual_device_tear_down) |
OLD | NEW |