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 json | 8 import json |
9 import optparse | 9 import optparse |
10 import os | 10 import os |
11 import pipes | 11 import pipes |
12 import shutil | 12 import shutil |
13 import subprocess | 13 import subprocess |
14 import sys | 14 import sys |
15 | 15 |
16 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) | 16 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
17 from pylib import buildbot_report | 17 from pylib import buildbot_report |
18 from pylib import constants | 18 from pylib import constants |
| 19 from pylib.gtest import gtest_config |
19 | 20 |
20 | 21 |
21 TESTING = 'BUILDBOT_TESTING' in os.environ | 22 TESTING = 'BUILDBOT_TESTING' in os.environ |
22 | 23 |
23 CHROME_SRC = constants.CHROME_DIR | 24 CHROME_SRC = constants.CHROME_DIR |
24 | 25 |
25 # Describes an instrumation test suite: | 26 # Describes an instrumation test suite: |
26 # test: Name of test we're running. | 27 # test: Name of test we're running. |
27 # apk: apk to be installed. | 28 # apk: apk to be installed. |
28 # apk_package: package for the apk to be installed. | 29 # apk_package: package for the apk to be installed. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 print '<', ' '.join(map(pipes.quote, command)) | 76 print '<', ' '.join(map(pipes.quote, command)) |
76 if code != 0: | 77 if code != 0: |
77 print 'ERROR: non-zero status %d from %s' % (code, command) | 78 print 'ERROR: non-zero status %d from %s' % (code, command) |
78 if flunk_on_failure: | 79 if flunk_on_failure: |
79 buildbot_report.PrintError() | 80 buildbot_report.PrintError() |
80 else: | 81 else: |
81 buildbot_report.PrintWarning() | 82 buildbot_report.PrintWarning() |
82 return code | 83 return code |
83 | 84 |
84 | 85 |
85 def RunTestSuites(options, suite): | 86 def RunTestSuites(options, suites): |
86 """Manages an invocation of run_tests.py. | 87 """Manages an invocation of run_tests.py. |
87 | 88 |
88 Args: | 89 Args: |
89 options: options object. | 90 options: options object. |
90 suite: The suite to pass to run_tests or None to run default suites. | 91 suites: List of suites to run. |
91 """ | 92 """ |
92 args = ['--verbose'] | 93 args = ['--verbose'] |
93 if suite: | |
94 args.extend(['-s', suite]) | |
95 if options.target == 'Release': | 94 if options.target == 'Release': |
96 args.append('--release') | 95 args.append('--release') |
97 if options.asan: | 96 if options.asan: |
98 args.append('--tool=asan') | 97 args.append('--tool=asan') |
99 RunCmd(['build/android/run_tests.py'] + args) | 98 for suite in suites: |
| 99 buildbot_report.PrintNamedStep(suite) |
| 100 RunCmd(['build/android/run_tests.py', '-s', suite] + args) |
100 | 101 |
101 | 102 |
102 def InstallApk(options, test, print_step=False): | 103 def InstallApk(options, test, print_step=False): |
103 """Install an apk to all phones. | 104 """Install an apk to all phones. |
104 | 105 |
105 Args: | 106 Args: |
106 options: options object | 107 options: options object |
107 test: An I_TEST namedtuple | 108 test: An I_TEST namedtuple |
108 print_step: Print a buildbot step | 109 print_step: Print a buildbot step |
109 """ | 110 """ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 '--build-number', options.build_properties.get('buildnumber', ''), | 163 '--build-number', options.build_properties.get('buildnumber', ''), |
163 '--master-name', options.build_properties.get('mastername', ''), | 164 '--master-name', options.build_properties.get('mastername', ''), |
164 '--build-name', options.build_properties.get('buildername', ''), | 165 '--build-name', options.build_properties.get('buildername', ''), |
165 '--platform=chromium-android', | 166 '--platform=chromium-android', |
166 '--test-results-server', | 167 '--test-results-server', |
167 options.factory_properties.get('test_results_server', '')]) | 168 options.factory_properties.get('test_results_server', '')]) |
168 | 169 |
169 | 170 |
170 def MainTestWrapper(options): | 171 def MainTestWrapper(options): |
171 # Device check and alert emails | 172 # Device check and alert emails |
| 173 buildbot_report.PrintNamedStep('device_status_check') |
172 RunCmd(['build/android/device_status_check.py'], flunk_on_failure=False) | 174 RunCmd(['build/android/device_status_check.py'], flunk_on_failure=False) |
173 | 175 |
174 if options.install: | 176 if options.install: |
175 test_obj = INSTRUMENTATION_TESTS[options.install] | 177 test_obj = INSTRUMENTATION_TESTS[options.install] |
176 InstallApk(options, test_obj, print_step=True) | 178 InstallApk(options, test_obj, print_step=True) |
177 | 179 |
178 if not options.test_filter: | 180 if not options.test_filter: |
179 return | 181 return |
180 | 182 |
181 # Spawn logcat monitor | 183 # Spawn logcat monitor |
182 logcat_dir = os.path.join(CHROME_SRC, 'out/logcat') | 184 logcat_dir = os.path.join(CHROME_SRC, 'out/logcat') |
183 shutil.rmtree(logcat_dir, ignore_errors=True) | 185 shutil.rmtree(logcat_dir, ignore_errors=True) |
184 SpawnCmd(['build/android/adb_logcat_monitor.py', logcat_dir]) | 186 SpawnCmd(['build/android/adb_logcat_monitor.py', logcat_dir]) |
185 | 187 |
186 if 'unit' in options.test_filter: | 188 if 'unit' in options.test_filter: |
187 RunTestSuites(options, None) | 189 RunTestSuites(options, gtest_config.STABLE_TEST_SUITES) |
188 if 'ui' in options.test_filter: | 190 if 'ui' in options.test_filter: |
189 for test in INSTRUMENTATION_TESTS.itervalues(): | 191 for test in INSTRUMENTATION_TESTS.itervalues(): |
190 RunInstrumentationSuite(options, test) | 192 RunInstrumentationSuite(options, test) |
191 if 'webkit' in options.test_filter: | 193 if 'webkit' in options.test_filter: |
192 RunTestSuites(options, 'webkit_unit_tests') | 194 RunTestSuites(options, ['webkit_unit_tests', 'TestWebKitAPI']) |
193 RunTestSuites(options, 'TestWebKitAPI') | |
194 RunWebkitLint(options.target) | 195 RunWebkitLint(options.target) |
195 if 'webkit_layout' in options.test_filter: | 196 if 'webkit_layout' in options.test_filter: |
196 RunWebkitLayoutTests(options) | 197 RunWebkitLayoutTests(options) |
197 | 198 |
198 if options.experimental: | 199 if options.experimental: |
199 RunTestSuites(options, 'sandbox_linux_unittests') | 200 RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES) |
200 | 201 |
201 # Print logcat, kill logcat monitor | 202 # Print logcat, kill logcat monitor |
202 buildbot_report.PrintNamedStep('Logcat dump') | 203 buildbot_report.PrintNamedStep('logcat_dump') |
203 RunCmd(['build/android/adb_logcat_printer.py', logcat_dir]) | 204 RunCmd(['build/android/adb_logcat_printer.py', logcat_dir]) |
204 | 205 |
205 buildbot_report.PrintNamedStep('Test report') | 206 buildbot_report.PrintNamedStep('test_report') |
206 for report in glob.glob( | 207 for report in glob.glob( |
207 os.path.join(CHROME_SRC, 'out', options.target, 'test_logs', '*.log')): | 208 os.path.join(CHROME_SRC, 'out', options.target, 'test_logs', '*.log')): |
208 subprocess.Popen(['cat', report]).wait() | 209 subprocess.Popen(['cat', report]).wait() |
209 os.remove(report) | 210 os.remove(report) |
210 | 211 |
211 | 212 |
212 def main(argv): | 213 def main(argv): |
213 parser = optparse.OptionParser() | 214 parser = optparse.OptionParser() |
214 | 215 |
215 def convert_json(option, _, value, parser): | 216 def convert_json(option, _, value, parser): |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 if unknown_tests: | 249 if unknown_tests: |
249 return ParserError('Unknown tests %s' % list(unknown_tests)) | 250 return ParserError('Unknown tests %s' % list(unknown_tests)) |
250 | 251 |
251 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) | 252 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |
252 | 253 |
253 MainTestWrapper(options) | 254 MainTestWrapper(options) |
254 | 255 |
255 | 256 |
256 if __name__ == '__main__': | 257 if __name__ == '__main__': |
257 sys.exit(main(sys.argv)) | 258 sys.exit(main(sys.argv)) |
OLD | NEW |