| 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 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 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 for step in steps: | 275 for step in steps: |
| 276 step() | 276 step() |
| 277 | 277 |
| 278 self._env.parallel_devices.pMap(individual_device_set_up) | 278 self._env.parallel_devices.pMap(individual_device_set_up) |
| 279 | 279 |
| 280 #override | 280 #override |
| 281 def _ShouldShard(self): | 281 def _ShouldShard(self): |
| 282 return True | 282 return True |
| 283 | 283 |
| 284 #override | 284 #override |
| 285 def _CreateShards(self, tests): | 285 def _CreateShards(self, tests, suspects = []): |
| 286 # Suspects are tests that might crash and make the tests in the same shard |
| 287 # following the supect not run. Thus we need to create separate shards for |
| 288 # each suspects, so that other tests can be run. |
| 286 device_count = len(self._env.devices) | 289 device_count = len(self._env.devices) |
| 287 shards = [] | 290 shards = [] |
| 291 |
| 292 # Add shards with only one suspect testcase. |
| 293 shards += [[suspect] for suspect in suspects] |
| 294 |
| 295 # Delete suspect testcase from tests. |
| 296 tests = [test for test in tests if not test in suspects] |
| 297 |
| 288 for i in xrange(0, device_count): | 298 for i in xrange(0, device_count): |
| 289 unbounded_shard = tests[i::device_count] | 299 unbounded_shard = tests[i::device_count] |
| 290 shards += [unbounded_shard[j:j+_MAX_SHARD_SIZE] | 300 shards += [unbounded_shard[j:j+_MAX_SHARD_SIZE] |
| 291 for j in xrange(0, len(unbounded_shard), _MAX_SHARD_SIZE)] | 301 for j in xrange(0, len(unbounded_shard), _MAX_SHARD_SIZE)] |
| 292 return shards | 302 return shards |
| 293 | 303 |
| 294 #override | 304 #override |
| 295 def _GetTests(self): | 305 def _GetTests(self): |
| 296 if self._test_instance.extract_test_list_from_filter: | 306 if self._test_instance.extract_test_list_from_filter: |
| 297 # When the exact list of tests to run is given via command-line (e.g. when | 307 # When the exact list of tests to run is given via command-line (e.g. when |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 def TearDown(self): | 354 def TearDown(self): |
| 345 @local_device_test_run.handle_shard_failures | 355 @local_device_test_run.handle_shard_failures |
| 346 def individual_device_tear_down(dev): | 356 def individual_device_tear_down(dev): |
| 347 for s in self._servers.get(str(dev), []): | 357 for s in self._servers.get(str(dev), []): |
| 348 s.TearDown() | 358 s.TearDown() |
| 349 | 359 |
| 350 tool = self.GetTool(dev) | 360 tool = self.GetTool(dev) |
| 351 tool.CleanUpEnvironment() | 361 tool.CleanUpEnvironment() |
| 352 | 362 |
| 353 self._env.parallel_devices.pMap(individual_device_tear_down) | 363 self._env.parallel_devices.pMap(individual_device_tear_down) |
| OLD | NEW |