Chromium Code Reviews| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 222 |
| 223 def __init__(self, env, test_instance): | 223 def __init__(self, env, test_instance): |
| 224 assert isinstance(env, local_device_environment.LocalDeviceEnvironment) | 224 assert isinstance(env, local_device_environment.LocalDeviceEnvironment) |
| 225 assert isinstance(test_instance, gtest_test_instance.GtestTestInstance) | 225 assert isinstance(test_instance, gtest_test_instance.GtestTestInstance) |
| 226 super(LocalDeviceGtestRun, self).__init__(env, test_instance) | 226 super(LocalDeviceGtestRun, self).__init__(env, test_instance) |
| 227 | 227 |
| 228 if self._test_instance.apk: | 228 if self._test_instance.apk: |
| 229 self._delegate = _ApkDelegate(self._test_instance) | 229 self._delegate = _ApkDelegate(self._test_instance) |
| 230 elif self._test_instance.exe: | 230 elif self._test_instance.exe: |
| 231 self._delegate = _ExeDelegate(self, self._test_instance.exe) | 231 self._delegate = _ExeDelegate(self, self._test_instance.exe) |
| 232 | 232 self.suspects = set() |
|
jbudorick
2016/02/27 00:31:38
suspects here should probably be _suspects
BigBossZhiling
2016/02/29 22:19:28
Done.
| |
| 233 self._servers = collections.defaultdict(list) | 233 self._servers = collections.defaultdict(list) |
| 234 | 234 |
| 235 #override | 235 #override |
| 236 def TestPackage(self): | 236 def TestPackage(self): |
| 237 return self._test_instance.suite | 237 return self._test_instance.suite |
| 238 | 238 |
| 239 #override | 239 #override |
| 240 def SetUp(self): | 240 def SetUp(self): |
| 241 @local_device_test_run.handle_shard_failures_with( | 241 @local_device_test_run.handle_shard_failures_with( |
| 242 on_failure=self._env.BlacklistDevice) | 242 on_failure=self._env.BlacklistDevice) |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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): |
| 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. | |
|
jbudorick
2016/02/27 00:31:38
nit: suspect
BigBossZhiling
2016/02/29 22:19:28
Done.
| |
| 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 self.suspects if suspect in tests] | |
|
jbudorick
2016/02/27 00:31:38
will suspect ever not be in tests...?
BigBossZhiling
2016/02/29 22:19:27
I am not sure. Is there a case where multiple test
| |
| 294 | |
| 295 # Delete suspect testcase from tests. | |
| 296 tests = [test for test in tests if not test in self.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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 for s in self._servers[str(device)]: | 340 for s in self._servers[str(device)]: |
| 331 s.Reset() | 341 s.Reset() |
| 332 if self._test_instance.app_files: | 342 if self._test_instance.app_files: |
| 333 self._delegate.PullAppFiles(device, self._test_instance.app_files, | 343 self._delegate.PullAppFiles(device, self._test_instance.app_files, |
| 334 self._test_instance.app_file_dir) | 344 self._test_instance.app_file_dir) |
| 335 if not self._test_instance.skip_clear_data: | 345 if not self._test_instance.skip_clear_data: |
| 336 self._delegate.Clear(device) | 346 self._delegate.Clear(device) |
| 337 | 347 |
| 338 # Parse the output. | 348 # Parse the output. |
| 339 # TODO(jbudorick): Transition test scripts away from parsing stdout. | 349 # TODO(jbudorick): Transition test scripts away from parsing stdout. |
| 350 crashed_test_case = self._test_instance.GetCrashedTestCase(output) | |
| 351 if crashed_test_case: | |
| 352 self.suspects.add(crashed_test_case) | |
| 340 results = self._test_instance.ParseGTestOutput(output) | 353 results = self._test_instance.ParseGTestOutput(output) |
|
jbudorick
2016/02/27 00:31:38
What if we did crash parsing in ParseGTestOutput a
| |
| 341 return results | 354 return results |
| 342 | 355 |
| 343 #override | 356 #override |
| 344 def TearDown(self): | 357 def TearDown(self): |
| 345 @local_device_test_run.handle_shard_failures | 358 @local_device_test_run.handle_shard_failures |
| 346 def individual_device_tear_down(dev): | 359 def individual_device_tear_down(dev): |
| 347 for s in self._servers.get(str(dev), []): | 360 for s in self._servers.get(str(dev), []): |
| 348 s.TearDown() | 361 s.TearDown() |
| 349 | 362 |
| 350 tool = self.GetTool(dev) | 363 tool = self.GetTool(dev) |
| 351 tool.CleanUpEnvironment() | 364 tool.CleanUpEnvironment() |
| 352 | 365 |
| 353 self._env.parallel_devices.pMap(individual_device_tear_down) | 366 self._env.parallel_devices.pMap(individual_device_tear_down) |
| OLD | NEW |