| 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 logging |
| 5 | 6 |
| 6 from pylib import valgrind_tools | 7 from pylib import valgrind_tools |
| 7 from pylib.base import base_test_result | 8 from pylib.base import base_test_result |
| 8 from pylib.base import test_run | 9 from pylib.base import test_run |
| 9 from pylib.base import test_collection | 10 from pylib.base import test_collection |
| 10 | 11 |
| 11 | 12 |
| 12 class LocalDeviceTestRun(test_run.TestRun): | 13 class LocalDeviceTestRun(test_run.TestRun): |
| 13 | 14 |
| 14 def __init__(self, env, test_instance): | 15 def __init__(self, env, test_instance): |
| (...skipping 13 matching lines...) Expand all Loading... |
| 28 elif isinstance(result, list): | 29 elif isinstance(result, list): |
| 29 r.AddResults(result) | 30 r.AddResults(result) |
| 30 else: | 31 else: |
| 31 raise Exception('Unexpected result type: %s' % type(result).__name__) | 32 raise Exception('Unexpected result type: %s' % type(result).__name__) |
| 32 if isinstance(tests, test_collection.TestCollection): | 33 if isinstance(tests, test_collection.TestCollection): |
| 33 tests.test_completed() | 34 tests.test_completed() |
| 34 return r | 35 return r |
| 35 | 36 |
| 36 tries = 0 | 37 tries = 0 |
| 37 results = base_test_result.TestRunResults() | 38 results = base_test_result.TestRunResults() |
| 38 fail_results = [] | 39 all_fail_results = {} |
| 39 while tries < self._env.max_tries and tests: | 40 while tries < self._env.max_tries and tests: |
| 41 logging.debug('try %d, will run %d tests:', tries, len(tests)) |
| 42 for t in tests: |
| 43 logging.debug(' %s', t) |
| 44 |
| 40 if self._ShouldShard(): | 45 if self._ShouldShard(): |
| 41 tc = test_collection.TestCollection(self._CreateShards(tests)) | 46 tc = test_collection.TestCollection(self._CreateShards(tests)) |
| 42 try_results = self._env.parallel_devices.pMap( | 47 try_results = self._env.parallel_devices.pMap( |
| 43 run_tests_on_device, tc).pGet(None) | 48 run_tests_on_device, tc).pGet(None) |
| 44 else: | 49 else: |
| 45 try_results = self._env.parallel_devices.pMap( | 50 try_results = self._env.parallel_devices.pMap( |
| 46 run_tests_on_device, tests).pGet(None) | 51 run_tests_on_device, tests).pGet(None) |
| 47 fail_results = [] | |
| 48 for try_result in try_results: | 52 for try_result in try_results: |
| 49 for result in try_result.GetAll(): | 53 for result in try_result.GetAll(): |
| 50 if result.GetType() in (base_test_result.ResultType.PASS, | 54 if result.GetType() in (base_test_result.ResultType.PASS, |
| 51 base_test_result.ResultType.SKIP): | 55 base_test_result.ResultType.SKIP): |
| 52 results.AddResult(result) | 56 results.AddResult(result) |
| 53 else: | 57 else: |
| 54 fail_results.append(result) | 58 all_fail_results[result.GetName()] = result |
| 55 | 59 |
| 56 results_names = set(r.GetName() for r in results.GetAll()) | 60 results_names = set(r.GetName() for r in results.GetAll()) |
| 57 tests = [t for t in tests if t not in results_names] | 61 tests = [t for t in tests if t not in results_names] |
| 58 tries += 1 | 62 tries += 1 |
| 59 | 63 |
| 60 if tests: | 64 all_unknown_test_names = set(tests) |
| 65 all_failed_test_names = set(all_fail_results.iterkeys()) |
| 66 |
| 67 unknown_tests = all_unknown_test_names.difference(all_failed_test_names) |
| 68 failed_tests = all_failed_test_names.intersection(all_unknown_test_names) |
| 69 |
| 70 if unknown_tests: |
| 61 results.AddResults( | 71 results.AddResults( |
| 62 base_test_result.BaseTestResult( | 72 base_test_result.BaseTestResult( |
| 63 t, base_test_result.ResultType.UNKNOWN) | 73 t, base_test_result.ResultType.UNKNOWN) |
| 64 for t in tests) | 74 for t in tests) |
| 65 if fail_results: | 75 if failed_tests: |
| 66 results.AddResults(fail_results) | 76 results.AddResults(all_fail_results[f] for f in failed_tests) |
| 67 return results | 77 return results |
| 68 | 78 |
| 69 def GetTool(self, device): | 79 def GetTool(self, device): |
| 70 if not str(device) in self._tools: | 80 if not str(device) in self._tools: |
| 71 self._tools[str(device)] = valgrind_tools.CreateTool( | 81 self._tools[str(device)] = valgrind_tools.CreateTool( |
| 72 self._env.tool, device) | 82 self._env.tool, device) |
| 73 return self._tools[str(device)] | 83 return self._tools[str(device)] |
| 74 | 84 |
| 75 def _CreateShards(self, tests): | 85 def _CreateShards(self, tests): |
| 76 raise NotImplementedError | 86 raise NotImplementedError |
| 77 | 87 |
| 78 def _GetTests(self): | 88 def _GetTests(self): |
| 79 raise NotImplementedError | 89 raise NotImplementedError |
| 80 | 90 |
| 81 def _RunTest(self, device, test): | 91 def _RunTest(self, device, test): |
| 82 raise NotImplementedError | 92 raise NotImplementedError |
| 83 | 93 |
| 84 def _ShouldShard(self): | 94 def _ShouldShard(self): |
| 85 raise NotImplementedError | 95 raise NotImplementedError |
| OLD | NEW |