OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import collections | 6 import collections |
7 import glob | 7 import glob |
8 import multiprocessing | 8 import multiprocessing |
9 import os | 9 import os |
10 import shutil | 10 import shutil |
11 import sys | 11 import sys |
12 | 12 |
13 import bb_utils | 13 import bb_utils |
| 14 import bb_annotations |
14 | 15 |
15 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 16 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
16 from pylib import android_commands | 17 from pylib import android_commands |
17 from pylib import buildbot_report | |
18 from pylib import constants | 18 from pylib import constants |
19 from pylib.gtest import gtest_config | 19 from pylib.gtest import gtest_config |
20 | 20 |
21 sys.path.append(os.path.join( | 21 sys.path.append(os.path.join( |
22 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner')) | 22 constants.DIR_SOURCE_ROOT, 'third_party', 'android_testrunner')) |
23 import errors | 23 import errors |
24 | 24 |
25 | 25 |
26 CHROME_SRC = constants.DIR_SOURCE_ROOT | 26 CHROME_SRC = constants.DIR_SOURCE_ROOT |
27 LOGCAT_DIR = os.path.join(CHROME_SRC, 'out', 'logcat') | 27 LOGCAT_DIR = os.path.join(CHROME_SRC, 'out', 'logcat') |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 print 'Rebooting: %s' % devices | 87 print 'Rebooting: %s' % devices |
88 if devices: | 88 if devices: |
89 pool = multiprocessing.Pool(len(devices)) | 89 pool = multiprocessing.Pool(len(devices)) |
90 results = pool.map_async(RebootDeviceSafe, devices).get(99999) | 90 results = pool.map_async(RebootDeviceSafe, devices).get(99999) |
91 | 91 |
92 for device, result in zip(devices, results): | 92 for device, result in zip(devices, results): |
93 if result: | 93 if result: |
94 print '%s failed to startup.' % device | 94 print '%s failed to startup.' % device |
95 | 95 |
96 if any(results): | 96 if any(results): |
97 buildbot_report.PrintWarning() | 97 bb_annotations.PrintWarning() |
98 else: | 98 else: |
99 print 'Reboots complete.' | 99 print 'Reboots complete.' |
100 | 100 |
101 | 101 |
102 def RunTestSuites(options, suites): | 102 def RunTestSuites(options, suites): |
103 """Manages an invocation of test_runner.py for gtests. | 103 """Manages an invocation of test_runner.py for gtests. |
104 | 104 |
105 Args: | 105 Args: |
106 options: options object. | 106 options: options object. |
107 suites: List of suites to run. | 107 suites: List of suites to run. |
108 """ | 108 """ |
109 args = ['--verbose'] | 109 args = ['--verbose'] |
110 if options.target == 'Release': | 110 if options.target == 'Release': |
111 args.append('--release') | 111 args.append('--release') |
112 if options.asan: | 112 if options.asan: |
113 args.append('--tool=asan') | 113 args.append('--tool=asan') |
114 for suite in suites: | 114 for suite in suites: |
115 buildbot_report.PrintNamedStep(suite.name) | 115 bb_annotations.PrintNamedStep(suite.name) |
116 cmd = ['build/android/test_runner.py', 'gtest', '-s', suite.name] + args | 116 cmd = ['build/android/test_runner.py', 'gtest', '-s', suite.name] + args |
117 if suite.is_suite_exe: | 117 if suite.is_suite_exe: |
118 cmd.append('--exe') | 118 cmd.append('--exe') |
119 RunCmd(cmd) | 119 RunCmd(cmd) |
120 | 120 |
121 def RunBrowserTestSuite(options): | 121 def RunBrowserTestSuite(options): |
122 """Manages an invocation of test_runner.py for content_browsertests. | 122 """Manages an invocation of test_runner.py for content_browsertests. |
123 | 123 |
124 Args: | 124 Args: |
125 options: options object. | 125 options: options object. |
126 """ | 126 """ |
127 args = ['--verbose', '--num_retries=1'] | 127 args = ['--verbose', '--num_retries=1'] |
128 if options.target == 'Release': | 128 if options.target == 'Release': |
129 args.append('--release') | 129 args.append('--release') |
130 if options.asan: | 130 if options.asan: |
131 args.append('--tool=asan') | 131 args.append('--tool=asan') |
132 buildbot_report.PrintNamedStep(constants.BROWSERTEST_SUITE_NAME) | 132 bb_annotations.PrintNamedStep(constants.BROWSERTEST_SUITE_NAME) |
133 RunCmd(['build/android/test_runner.py', 'content_browsertests'] + args) | 133 RunCmd(['build/android/test_runner.py', 'content_browsertests'] + args) |
134 | 134 |
135 def RunChromeDriverTests(_): | 135 def RunChromeDriverTests(_): |
136 """Run all the steps for running chromedriver tests.""" | 136 """Run all the steps for running chromedriver tests.""" |
137 buildbot_report.PrintNamedStep('chromedriver_annotation') | 137 bb_annotations.PrintNamedStep('chromedriver_annotation') |
138 RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py', | 138 RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py', |
139 '--android-package=%s' % constants.CHROMIUM_TEST_SHELL_PACKAGE]) | 139 '--android-package=%s' % constants.CHROMIUM_TEST_SHELL_PACKAGE]) |
140 | 140 |
141 def InstallApk(options, test, print_step=False): | 141 def InstallApk(options, test, print_step=False): |
142 """Install an apk to all phones. | 142 """Install an apk to all phones. |
143 | 143 |
144 Args: | 144 Args: |
145 options: options object | 145 options: options object |
146 test: An I_TEST namedtuple | 146 test: An I_TEST namedtuple |
147 print_step: Print a buildbot step | 147 print_step: Print a buildbot step |
148 """ | 148 """ |
149 if print_step: | 149 if print_step: |
150 buildbot_report.PrintNamedStep('install_%s' % test.name.lower()) | 150 bb_annotations.PrintNamedStep('install_%s' % test.name.lower()) |
151 args = ['--apk', test.apk, '--apk_package', test.apk_package] | 151 args = ['--apk', test.apk, '--apk_package', test.apk_package] |
152 if options.target == 'Release': | 152 if options.target == 'Release': |
153 args.append('--release') | 153 args.append('--release') |
154 | 154 |
155 RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True) | 155 RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True) |
156 | 156 |
157 | 157 |
158 def RunInstrumentationSuite(options, test): | 158 def RunInstrumentationSuite(options, test): |
159 """Manages an invocation of test_runner.py for instrumentation tests. | 159 """Manages an invocation of test_runner.py for instrumentation tests. |
160 | 160 |
161 Args: | 161 Args: |
162 options: options object | 162 options: options object |
163 test: An I_TEST namedtuple | 163 test: An I_TEST namedtuple |
164 """ | 164 """ |
165 buildbot_report.PrintNamedStep('%s_instrumentation_tests' % test.name.lower()) | 165 bb_annotations.PrintNamedStep('%s_instrumentation_tests' % test.name.lower()) |
166 | 166 |
167 InstallApk(options, test) | 167 InstallApk(options, test) |
168 args = ['--test-apk', test.test_apk, '--test_data', test.test_data, | 168 args = ['--test-apk', test.test_apk, '--test_data', test.test_data, |
169 '--verbose', '-I'] | 169 '--verbose', '-I'] |
170 if options.target == 'Release': | 170 if options.target == 'Release': |
171 args.append('--release') | 171 args.append('--release') |
172 if options.asan: | 172 if options.asan: |
173 args.append('--tool=asan') | 173 args.append('--tool=asan') |
174 if options.upload_to_flakiness_server: | 174 if options.upload_to_flakiness_server: |
175 args.append('--flakiness-dashboard-server=%s' % | 175 args.append('--flakiness-dashboard-server=%s' % |
176 constants.UPSTREAM_FLAKINESS_SERVER) | 176 constants.UPSTREAM_FLAKINESS_SERVER) |
177 if test.host_driven_root: | 177 if test.host_driven_root: |
178 args.append('--python_test_root=%s' % test.host_driven_root) | 178 args.append('--python_test_root=%s' % test.host_driven_root) |
179 if test.annotation: | 179 if test.annotation: |
180 args.extend(['-A', test.annotation]) | 180 args.extend(['-A', test.annotation]) |
181 if test.exclude_annotation: | 181 if test.exclude_annotation: |
182 args.extend(['-E', test.exclude_annotation]) | 182 args.extend(['-E', test.exclude_annotation]) |
183 if test.extra_flags: | 183 if test.extra_flags: |
184 args.extend(test.extra_flags) | 184 args.extend(test.extra_flags) |
185 | 185 |
186 RunCmd(['build/android/test_runner.py', 'instrumentation'] + args) | 186 RunCmd(['build/android/test_runner.py', 'instrumentation'] + args) |
187 | 187 |
188 | 188 |
189 def RunWebkitLint(target): | 189 def RunWebkitLint(target): |
190 """Lint WebKit's TestExpectation files.""" | 190 """Lint WebKit's TestExpectation files.""" |
191 buildbot_report.PrintNamedStep('webkit_lint') | 191 bb_annotations.PrintNamedStep('webkit_lint') |
192 RunCmd(['webkit/tools/layout_tests/run_webkit_tests.py', | 192 RunCmd(['webkit/tools/layout_tests/run_webkit_tests.py', |
193 '--lint-test-files', | 193 '--lint-test-files', |
194 '--chromium', | 194 '--chromium', |
195 '--target', target]) | 195 '--target', target]) |
196 | 196 |
197 | 197 |
198 def RunWebkitLayoutTests(options): | 198 def RunWebkitLayoutTests(options): |
199 """Run layout tests on an actual device.""" | 199 """Run layout tests on an actual device.""" |
200 buildbot_report.PrintNamedStep('webkit_tests') | 200 bb_annotations.PrintNamedStep('webkit_tests') |
201 cmd_args = [ | 201 cmd_args = [ |
202 '--no-show-results', | 202 '--no-show-results', |
203 '--no-new-test-results', | 203 '--no-new-test-results', |
204 '--full-results-html', | 204 '--full-results-html', |
205 '--clobber-old-results', | 205 '--clobber-old-results', |
206 '--exit-after-n-failures', '5000', | 206 '--exit-after-n-failures', '5000', |
207 '--exit-after-n-crashes-or-timeouts', '100', | 207 '--exit-after-n-crashes-or-timeouts', '100', |
208 '--debug-rwt-logging', | 208 '--debug-rwt-logging', |
209 '--results-directory', '..layout-test-results', | 209 '--results-directory', '..layout-test-results', |
210 '--target', options.target, | 210 '--target', options.target, |
(...skipping 30 matching lines...) Expand all Loading... |
241 | 241 |
242 # Wait for logcat_monitor to pull existing logcat | 242 # Wait for logcat_monitor to pull existing logcat |
243 RunCmd(['sleep', '5']) | 243 RunCmd(['sleep', '5']) |
244 | 244 |
245 def ProvisionDevices(options): | 245 def ProvisionDevices(options): |
246 # Restart adb to work around bugs, sleep to wait for usb discovery. | 246 # Restart adb to work around bugs, sleep to wait for usb discovery. |
247 RunCmd(['adb', 'kill-server']) | 247 RunCmd(['adb', 'kill-server']) |
248 RunCmd(['adb', 'start-server']) | 248 RunCmd(['adb', 'start-server']) |
249 RunCmd(['sleep', '1']) | 249 RunCmd(['sleep', '1']) |
250 | 250 |
251 buildbot_report.PrintNamedStep('provision_devices') | 251 bb_annotations.PrintNamedStep('provision_devices') |
252 if options.reboot: | 252 if options.reboot: |
253 RebootDevices() | 253 RebootDevices() |
254 RunCmd(['build/android/provision_devices.py', '-t', options.target]) | 254 RunCmd(['build/android/provision_devices.py', '-t', options.target]) |
255 | 255 |
256 | 256 |
257 def DeviceStatusCheck(_): | 257 def DeviceStatusCheck(_): |
258 buildbot_report.PrintNamedStep('device_status_check') | 258 bb_annotations.PrintNamedStep('device_status_check') |
259 RunCmd(['build/android/device_status_check.py'], halt_on_failure=True) | 259 RunCmd(['build/android/device_status_check.py'], halt_on_failure=True) |
260 | 260 |
261 | 261 |
262 def GetDeviceSetupStepCmds(): | 262 def GetDeviceSetupStepCmds(): |
263 return [ | 263 return [ |
264 ('provision_devices', ProvisionDevices), | 264 ('provision_devices', ProvisionDevices), |
265 ('device_status_check', DeviceStatusCheck) | 265 ('device_status_check', DeviceStatusCheck) |
266 ] | 266 ] |
267 | 267 |
268 | 268 |
(...skipping 16 matching lines...) Expand all Loading... |
285 ('chromedriver', RunChromeDriverTests), | 285 ('chromedriver', RunChromeDriverTests), |
286 ('unit', RunUnitTests), | 286 ('unit', RunUnitTests), |
287 ('ui', RunInstrumentationTests), | 287 ('ui', RunInstrumentationTests), |
288 ('webkit', RunWebkitTests), | 288 ('webkit', RunWebkitTests), |
289 ('webkit_layout', RunWebkitLayoutTests) | 289 ('webkit_layout', RunWebkitLayoutTests) |
290 ] | 290 ] |
291 | 291 |
292 | 292 |
293 def LogcatDump(options): | 293 def LogcatDump(options): |
294 # Print logcat, kill logcat monitor | 294 # Print logcat, kill logcat monitor |
295 buildbot_report.PrintNamedStep('logcat_dump') | 295 bb_annotations.PrintNamedStep('logcat_dump') |
296 logcat_file = os.path.join(CHROME_SRC, 'out', options.target, 'full_log') | 296 logcat_file = os.path.join(CHROME_SRC, 'out', options.target, 'full_log') |
297 with open(logcat_file, 'w') as f: | 297 with open(logcat_file, 'w') as f: |
298 RunCmd([ | 298 RunCmd([ |
299 os.path.join(CHROME_SRC, 'build', 'android', 'adb_logcat_printer.py'), | 299 os.path.join(CHROME_SRC, 'build', 'android', 'adb_logcat_printer.py'), |
300 LOGCAT_DIR], stdout=f) | 300 LOGCAT_DIR], stdout=f) |
301 RunCmd(['cat', logcat_file]) | 301 RunCmd(['cat', logcat_file]) |
302 | 302 |
303 | 303 |
304 def GenerateTestReport(options): | 304 def GenerateTestReport(options): |
305 buildbot_report.PrintNamedStep('test_report') | 305 bb_annotations.PrintNamedStep('test_report') |
306 for report in glob.glob( | 306 for report in glob.glob( |
307 os.path.join(CHROME_SRC, 'out', options.target, 'test_logs', '*.log')): | 307 os.path.join(CHROME_SRC, 'out', options.target, 'test_logs', '*.log')): |
308 RunCmd(['cat', report]) | 308 RunCmd(['cat', report]) |
309 os.remove(report) | 309 os.remove(report) |
310 | 310 |
311 | 311 |
312 def GetPostTestStepCmds(): | 312 def GetPostTestStepCmds(): |
313 return [ | 313 return [ |
314 ('logcat_dump', LogcatDump), | 314 ('logcat_dump', LogcatDump), |
315 ('test_report', GenerateTestReport) | 315 ('test_report', GenerateTestReport) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 if unknown_tests: | 376 if unknown_tests: |
377 return sys.exit('Unknown tests %s' % list(unknown_tests)) | 377 return sys.exit('Unknown tests %s' % list(unknown_tests)) |
378 | 378 |
379 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) | 379 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |
380 | 380 |
381 MainTestWrapper(options) | 381 MainTestWrapper(options) |
382 | 382 |
383 | 383 |
384 if __name__ == '__main__': | 384 if __name__ == '__main__': |
385 sys.exit(main(sys.argv)) | 385 sys.exit(main(sys.argv)) |
OLD | NEW |