OLD | NEW |
1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 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 import sys | 4 import sys |
5 | 5 |
6 from telemetry import decorators | 6 from telemetry import decorators |
7 from telemetry.core import browser_finder | 7 from telemetry.core import browser_finder |
8 from telemetry.core import browser_finder_exceptions | 8 from telemetry.core import browser_finder_exceptions |
9 from telemetry.core import browser_options | 9 from telemetry.core import browser_options |
10 from telemetry.core import command_line | 10 from telemetry.core import command_line |
| 11 from telemetry.core import device_finder |
11 from telemetry.core import util | 12 from telemetry.core import util |
12 from telemetry.unittest_util import options_for_unittests | 13 from telemetry.unittest_util import options_for_unittests |
13 from telemetry.unittest_util import browser_test_case | 14 from telemetry.unittest_util import browser_test_case |
14 | 15 |
15 util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'third_party', 'typ') | 16 util.AddDirToPythonPath(util.GetChromiumSrcDir(), 'third_party', 'typ') |
16 | 17 |
17 import typ | 18 import typ |
18 | 19 |
19 | 20 |
20 class RunTestsCommand(command_line.OptparseCommand): | 21 class RunTestsCommand(command_line.OptparseCommand): |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 90 |
90 runner = typ.Runner() | 91 runner = typ.Runner() |
91 if self.stream: | 92 if self.stream: |
92 runner.host.stdout = self.stream | 93 runner.host.stdout = self.stream |
93 | 94 |
94 # Telemetry seems to overload the system if we run one test per core, | 95 # Telemetry seems to overload the system if we run one test per core, |
95 # so we scale things back a fair amount. Many of the telemetry tests | 96 # so we scale things back a fair amount. Many of the telemetry tests |
96 # are long-running, so there's a limit to how much parallelism we | 97 # are long-running, so there's a limit to how much parallelism we |
97 # can effectively use for now anyway. | 98 # can effectively use for now anyway. |
98 # | 99 # |
99 # It should be possible to handle multiple devices if we adjust | 100 # It should be possible to handle multiple devices if we adjust the |
100 # the browser_finder code properly, but for now we only handle the one | 101 # browser_finder code properly, but for now we only handle one on ChromeOS. |
101 # on Android and ChromeOS. | 102 if possible_browser.platform.GetOSName() == 'chromeos': |
102 if possible_browser.platform.GetOSName() in ('android', 'chromeos'): | |
103 runner.args.jobs = 1 | 103 runner.args.jobs = 1 |
| 104 elif possible_browser.platform.GetOSName() == 'android': |
| 105 runner.args.jobs = len(device_finder.GetDevicesMatchingOptions(args)) |
| 106 print 'Running tests with %d Android device(s).' % runner.args.jobs |
104 elif possible_browser.platform.GetOSVersionName() == 'xp': | 107 elif possible_browser.platform.GetOSVersionName() == 'xp': |
105 # For an undiagnosed reason, XP falls over with more parallelism. | 108 # For an undiagnosed reason, XP falls over with more parallelism. |
106 # See crbug.com/388256 | 109 # See crbug.com/388256 |
107 runner.args.jobs = max(int(args.jobs) // 4, 1) | 110 runner.args.jobs = max(int(args.jobs) // 4, 1) |
108 else: | 111 else: |
109 runner.args.jobs = max(int(args.jobs) // 2, 1) | 112 runner.args.jobs = max(int(args.jobs) // 2, 1) |
110 | 113 |
111 runner.args.metadata = args.metadata | 114 runner.args.metadata = args.metadata |
112 runner.args.passthrough = args.passthrough | 115 runner.args.passthrough = args.passthrough |
113 runner.args.path = args.path | 116 runner.args.path = args.path |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 if not selected_tests: | 168 if not selected_tests: |
166 return False | 169 return False |
167 if selected_tests_are_exact: | 170 if selected_tests_are_exact: |
168 return any(name in selected_tests) | 171 return any(name in selected_tests) |
169 else: | 172 else: |
170 return any(test in name for test in selected_tests) | 173 return any(test in name for test in selected_tests) |
171 | 174 |
172 | 175 |
173 def _SetUpProcess(child, context): # pylint: disable=W0613 | 176 def _SetUpProcess(child, context): # pylint: disable=W0613 |
174 args = context | 177 args = context |
| 178 if args.device and args.device == 'android': |
| 179 android_devices = device_finder.GetDevicesMatchingOptions(args) |
| 180 args.device = android_devices[child.worker_num-1].guid |
175 options_for_unittests.Push(args) | 181 options_for_unittests.Push(args) |
176 | 182 |
177 | 183 |
178 def _TearDownProcess(child, context): # pylint: disable=W0613 | 184 def _TearDownProcess(child, context): # pylint: disable=W0613 |
179 browser_test_case.teardown_browser() | 185 browser_test_case.teardown_browser() |
180 options_for_unittests.Pop() | 186 options_for_unittests.Pop() |
181 | 187 |
182 | 188 |
183 if __name__ == '__main__': | 189 if __name__ == '__main__': |
184 ret_code = RunTestsCommand.main() | 190 ret_code = RunTestsCommand.main() |
185 sys.exit(ret_code) | 191 sys.exit(ret_code) |
OLD | NEW |