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 logging | 7 import logging |
8 import multiprocessing | 8 import multiprocessing |
9 | 9 |
10 from forwarder import Forwarder | |
10 from test_result import TestResults | 11 from test_result import TestResults |
11 | 12 |
12 | 13 |
13 def _ShardedTestRunnable(test): | 14 def _ShardedTestRunnable(test): |
14 """Standalone function needed by multiprocessing.Pool.""" | 15 """Standalone function needed by multiprocessing.Pool.""" |
15 log_format = '[' + test.device + '] # %(asctime)-15s: %(message)s' | 16 log_format = '[' + test.device + '] # %(asctime)-15s: %(message)s' |
16 if logging.getLogger().handlers: | 17 if logging.getLogger().handlers: |
17 logging.getLogger().handlers[0].setFormatter(logging.Formatter(log_format)) | 18 logging.getLogger().handlers[0].setFormatter(logging.Formatter(log_format)) |
18 else: | 19 else: |
19 logging.basicConfig(format=log_format) | 20 logging.basicConfig(format=log_format) |
(...skipping 14 matching lines...) Expand all Loading... | |
34 | 35 |
35 class BaseTestSharder(object): | 36 class BaseTestSharder(object): |
36 """Base class for sharding tests across multiple devices. | 37 """Base class for sharding tests across multiple devices. |
37 | 38 |
38 Args: | 39 Args: |
39 attached_devices: A list of attached devices. | 40 attached_devices: A list of attached devices. |
40 """ | 41 """ |
41 # See more in SetTestsContainer. | 42 # See more in SetTestsContainer. |
42 tests_container = None | 43 tests_container = None |
43 | 44 |
44 def __init__(self, attached_devices): | 45 def __init__(self, attached_devices, build_type='Debug'): |
45 self.attached_devices = attached_devices | 46 self.attached_devices = attached_devices |
46 self.retries = 1 | 47 self.retries = 1 |
47 self.tests = [] | 48 self.tests = [] |
49 self.build_type = build_type | |
48 | 50 |
49 def CreateShardedTestRunner(self, device, index): | 51 def CreateShardedTestRunner(self, device, index): |
50 """Factory function to create a suite-specific test runner. | 52 """Factory function to create a suite-specific test runner. |
51 | 53 |
52 Args: | 54 Args: |
53 device: Device serial where this shard will run | 55 device: Device serial where this shard will run |
54 index: Index of this device in the pool. | 56 index: Index of this device in the pool. |
55 | 57 |
56 Returns: | 58 Returns: |
57 An object of BaseTestRunner type (that can provide a "Run()" method). | 59 An object of BaseTestRunner type (that can provide a "Run()" method). |
58 """ | 60 """ |
59 pass | 61 pass |
60 | 62 |
61 def SetupSharding(self, tests): | 63 def SetupSharding(self, tests): |
62 """Called before starting the shards.""" | 64 """Called before starting the shards.""" |
63 pass | 65 Forwarder(None, self.build_type).KillHostForwarder() |
felipeg
2012/10/30 22:37:30
make it static
| |
64 | 66 |
65 def OnTestsCompleted(self, test_runners, test_results): | 67 def OnTestsCompleted(self, test_runners, test_results): |
66 """Notifies that we completed the tests.""" | 68 """Notifies that we completed the tests.""" |
67 pass | 69 Forwarder(None, self.build_type).KillHostForwarder() |
68 | 70 |
69 def RunShardedTests(self): | 71 def RunShardedTests(self): |
70 """Runs the tests in all connected devices. | 72 """Runs the tests in all connected devices. |
71 | 73 |
72 Returns: | 74 Returns: |
73 A TestResults object. | 75 A TestResults object. |
74 """ | 76 """ |
75 logging.warning('*' * 80) | 77 logging.warning('*' * 80) |
76 logging.warning('Sharding in ' + str(len(self.attached_devices)) + | 78 logging.warning('Sharding in ' + str(len(self.attached_devices)) + |
77 ' devices.') | 79 ' devices.') |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 break | 116 break |
115 else: | 117 else: |
116 final_results.ok += test_results.ok | 118 final_results.ok += test_results.ok |
117 self.tests = [] | 119 self.tests = [] |
118 for t in test_results.GetAllBroken(): | 120 for t in test_results.GetAllBroken(): |
119 self.tests += [t.name] | 121 self.tests += [t.name] |
120 if not self.tests: | 122 if not self.tests: |
121 break | 123 break |
122 self.OnTestsCompleted(test_runners, final_results) | 124 self.OnTestsCompleted(test_runners, final_results) |
123 return final_results | 125 return final_results |
OLD | NEW |