OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 | 5 |
6 import android_commands | 6 import android_commands |
7 import atexit | |
7 import logging | 8 import logging |
8 import multiprocessing | 9 import multiprocessing |
9 | 10 |
10 from android_commands import errors | 11 from android_commands import errors |
11 from forwarder import Forwarder | 12 from forwarder import Forwarder |
12 from test_result import TestResults | 13 from test_result import TestResults |
13 | 14 |
14 | 15 |
15 def _ShardedTestRunnable(test): | 16 def _ShardedTestRunnable(test): |
16 """Standalone function needed by multiprocessing.Pool.""" | 17 """Standalone function needed by multiprocessing.Pool.""" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 device: Device serial where this shard will run | 60 device: Device serial where this shard will run |
60 index: Index of this device in the pool. | 61 index: Index of this device in the pool. |
61 | 62 |
62 Returns: | 63 Returns: |
63 An object of BaseTestRunner type (that can provide a "Run()" method). | 64 An object of BaseTestRunner type (that can provide a "Run()" method). |
64 """ | 65 """ |
65 pass | 66 pass |
66 | 67 |
67 def SetupSharding(self, tests): | 68 def SetupSharding(self, tests): |
68 """Called before starting the shards.""" | 69 """Called before starting the shards.""" |
69 Forwarder.KillHost(self.build_type) | |
70 | 70 |
71 def OnTestsCompleted(self, test_runners, test_results): | 71 def OnTestsCompleted(self, test_runners, test_results): |
72 """Notifies that we completed the tests.""" | 72 """Notifies that we completed the tests.""" |
bulach
2012/11/29 15:50:30
add a "pass" here..
Philippe
2012/11/29 17:53:32
Oops :)
| |
73 | |
74 def _KillHostForwarder(self): | |
73 Forwarder.KillHost(self.build_type) | 75 Forwarder.KillHost(self.build_type) |
74 | 76 |
75 def RunShardedTests(self): | 77 def RunShardedTests(self): |
76 """Runs the tests in all connected devices. | 78 """Runs the tests in all connected devices. |
77 | 79 |
78 Returns: | 80 Returns: |
79 A TestResults object. | 81 A TestResults object. |
80 """ | 82 """ |
81 logging.warning('*' * 80) | 83 logging.warning('*' * 80) |
82 logging.warning('Sharding in ' + str(len(self.attached_devices)) + | 84 logging.warning('Sharding in ' + str(len(self.attached_devices)) + |
83 ' devices.') | 85 ' devices.') |
84 logging.warning('Note that the output is not synchronized.') | 86 logging.warning('Note that the output is not synchronized.') |
85 logging.warning('Look for the "Final result" banner in the end.') | 87 logging.warning('Look for the "Final result" banner in the end.') |
86 logging.warning('*' * 80) | 88 logging.warning('*' * 80) |
87 final_results = TestResults() | 89 final_results = TestResults() |
90 atexit.register(self._KillHostForwarder) | |
bulach
2012/11/29 15:50:30
does this work? self._KillHostForwarder is a metho
Philippe
2012/11/29 17:53:32
This seems to work, it is one of the ways to pass
| |
91 self._KillHostForwarder() | |
88 for retry in xrange(self.retries): | 92 for retry in xrange(self.retries): |
89 logging.warning('Try %d of %d', retry + 1, self.retries) | 93 logging.warning('Try %d of %d', retry + 1, self.retries) |
90 self.SetupSharding(self.tests) | 94 self.SetupSharding(self.tests) |
91 test_runners = [] | 95 test_runners = [] |
92 | 96 |
93 # Try to create N shards, and retrying on failure. | 97 # Try to create N shards, and retrying on failure. |
94 try: | 98 try: |
95 for index, device in enumerate(self.attached_devices): | 99 for index, device in enumerate(self.attached_devices): |
96 logging.warning('*' * 80) | 100 logging.warning('*' * 80) |
97 logging.warning('Creating shard %d for %s', index, device) | 101 logging.warning('Creating shard %d for %s', index, device) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
136 for t in test_results.GetAllBroken(): | 140 for t in test_results.GetAllBroken(): |
137 self.tests += [t.name] | 141 self.tests += [t.name] |
138 if not self.tests: | 142 if not self.tests: |
139 break | 143 break |
140 else: | 144 else: |
141 # We ran out retries, possibly out of healthy devices. | 145 # We ran out retries, possibly out of healthy devices. |
142 # There's no recovery at this point. | 146 # There's no recovery at this point. |
143 raise Exception('Unrecoverable error while retrying test runs.') | 147 raise Exception('Unrecoverable error while retrying test runs.') |
144 self.OnTestsCompleted(test_runners, final_results) | 148 self.OnTestsCompleted(test_runners, final_results) |
145 return final_results | 149 return final_results |
OLD | NEW |