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 multiprocessing | 9 import multiprocessing |
10 import optparse | 10 import optparse |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 'AndroidWebView.apk', | 55 'AndroidWebView.apk', |
56 'org.chromium.android_webview.shell', | 56 'org.chromium.android_webview.shell', |
57 'AndroidWebViewTest', | 57 'AndroidWebViewTest', |
58 'webview:android_webview/test/data/device_files', | 58 'webview:android_webview/test/data/device_files', |
59 None), | 59 None), |
60 ]) | 60 ]) |
61 | 61 |
62 VALID_TESTS = set(['chromedriver', 'ui', 'unit', 'webkit', 'webkit_layout']) | 62 VALID_TESTS = set(['chromedriver', 'ui', 'unit', 'webkit', 'webkit_layout']) |
63 | 63 |
64 | 64 |
65 | |
66 def SpawnCmd(command): | 65 def SpawnCmd(command): |
67 """Spawn a process without waiting for termination.""" | 66 """Spawn a process without waiting for termination.""" |
68 print '>', ' '.join(map(pipes.quote, command)) | 67 print '>', ' '.join(map(pipes.quote, command)) |
69 sys.stdout.flush() | 68 sys.stdout.flush() |
70 if TESTING: | 69 if TESTING: |
71 class MockPopen(object): | 70 class MockPopen(object): |
72 @staticmethod | 71 @staticmethod |
73 def wait(): | 72 def wait(): |
74 return 0 | 73 return 0 |
75 return MockPopen() | 74 return MockPopen() |
76 | 75 |
77 return subprocess.Popen(command, cwd=CHROME_SRC) | 76 return subprocess.Popen(command, cwd=CHROME_SRC) |
78 | 77 |
79 def RunCmd(command, flunk_on_failure=True): | 78 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False): |
80 """Run a command relative to the chrome source root.""" | 79 """Run a command relative to the chrome source root.""" |
81 code = SpawnCmd(command).wait() | 80 code = SpawnCmd(command).wait() |
82 print '<', ' '.join(map(pipes.quote, command)) | 81 print '<', ' '.join(map(pipes.quote, command)) |
83 if code != 0: | 82 if code != 0: |
84 print 'ERROR: process exited with code %d' % code | 83 print 'ERROR: process exited with code %d' % code |
85 if flunk_on_failure: | 84 if flunk_on_failure: |
86 buildbot_report.PrintError() | 85 buildbot_report.PrintError() |
87 else: | 86 else: |
88 buildbot_report.PrintWarning() | 87 buildbot_report.PrintWarning() |
| 88 # Allow steps to have both halting (i.e. 1) and non-halting exit codes. |
| 89 if code != 0 and code != 88 and halt_on_failure: |
| 90 raise OSError() |
89 return code | 91 return code |
90 | 92 |
91 | 93 |
92 # multiprocessing map_async requires a top-level function for pickle library. | 94 # multiprocessing map_async requires a top-level function for pickle library. |
93 def RebootDeviceSafe(device): | 95 def RebootDeviceSafe(device): |
94 """Reboot a device, wait for it to start, and squelch timeout exceptions.""" | 96 """Reboot a device, wait for it to start, and squelch timeout exceptions.""" |
95 try: | 97 try: |
96 android_commands.AndroidCommands(device).Reboot(True) | 98 android_commands.AndroidCommands(device).Reboot(True) |
97 except errors.DeviceUnresponsiveError as e: | 99 except errors.DeviceUnresponsiveError as e: |
98 return e | 100 return e |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 buildbot_report.PrintNamedStep(constants.BROWSERTEST_SUITE_NAME) | 156 buildbot_report.PrintNamedStep(constants.BROWSERTEST_SUITE_NAME) |
155 RunCmd(['build/android/run_browser_tests.py'] + args) | 157 RunCmd(['build/android/run_browser_tests.py'] + args) |
156 | 158 |
157 def RunChromeDriverTests(): | 159 def RunChromeDriverTests(): |
158 """Run all the steps for running chromedriver tests.""" | 160 """Run all the steps for running chromedriver tests.""" |
159 buildbot_report.PrintNamedStep('chromedriver_annotation') | 161 buildbot_report.PrintNamedStep('chromedriver_annotation') |
160 RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py', | 162 RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py', |
161 '--android-package=%s' % constants.CHROMIUM_TEST_SHELL_PACKAGE]) | 163 '--android-package=%s' % constants.CHROMIUM_TEST_SHELL_PACKAGE]) |
162 | 164 |
163 | 165 |
| 166 def CheckInstall(): |
| 167 """Build bot step to see if adb install works on attached devices. """ |
| 168 buildbot_report.PrintNamedStep('Check device install') |
| 169 # This step checks if apks can be installed on the devices. |
| 170 args = ['--apk', 'build/android/CheckInstallApk-debug.apk'] |
| 171 RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True) |
| 172 |
| 173 |
164 def InstallApk(options, test, print_step=False): | 174 def InstallApk(options, test, print_step=False): |
165 """Install an apk to all phones. | 175 """Install an apk to all phones. |
166 | 176 |
167 Args: | 177 Args: |
168 options: options object | 178 options: options object |
169 test: An I_TEST namedtuple | 179 test: An I_TEST namedtuple |
170 print_step: Print a buildbot step | 180 print_step: Print a buildbot step |
171 """ | 181 """ |
172 if print_step: | 182 if print_step: |
173 buildbot_report.PrintNamedStep('install_%s' % test.name.lower()) | 183 buildbot_report.PrintNamedStep('install_%s' % test.name.lower()) |
174 args = ['--apk', test.apk, '--apk_package', test.apk_package] | 184 args = ['--apk', test.apk, '--apk_package', test.apk_package] |
175 if options.target == 'Release': | 185 if options.target == 'Release': |
176 args.append('--release') | 186 args.append('--release') |
177 | 187 |
178 RunCmd(['build/android/adb_install_apk.py'] + args) | 188 RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True) |
179 | 189 |
180 | 190 |
181 def RunInstrumentationSuite(options, test): | 191 def RunInstrumentationSuite(options, test): |
182 """Manages an invocation of run_instrumentaiton_tests.py. | 192 """Manages an invocation of run_instrumentaiton_tests.py. |
183 | 193 |
184 Args: | 194 Args: |
185 options: options object | 195 options: options object |
186 test: An I_TEST namedtuple | 196 test: An I_TEST namedtuple |
187 """ | 197 """ |
188 buildbot_report.PrintNamedStep('%s_instrumentation_tests' % test.name.lower()) | 198 buildbot_report.PrintNamedStep('%s_instrumentation_tests' % test.name.lower()) |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 SpawnCmd(['build/android/adb_logcat_monitor.py', logcat_dir]) | 272 SpawnCmd(['build/android/adb_logcat_monitor.py', logcat_dir]) |
263 | 273 |
264 # Wait for logcat_monitor to pull existing logcat | 274 # Wait for logcat_monitor to pull existing logcat |
265 RunCmd(['sleep', '5']) | 275 RunCmd(['sleep', '5']) |
266 | 276 |
267 if options.reboot: | 277 if options.reboot: |
268 RebootDevices() | 278 RebootDevices() |
269 | 279 |
270 # Device check and alert emails | 280 # Device check and alert emails |
271 buildbot_report.PrintNamedStep('device_status_check') | 281 buildbot_report.PrintNamedStep('device_status_check') |
272 RunCmd(['build/android/device_status_check.py']) | 282 RunCmd(['build/android/device_status_check.py'], halt_on_failure=True) |
273 | 283 |
274 # Provision devices | 284 # Provision devices |
275 buildbot_report.PrintNamedStep('provision_devices') | 285 buildbot_report.PrintNamedStep('provision_devices') |
276 target = options.factory_properties.get('target', 'Debug') | 286 target = options.factory_properties.get('target', 'Debug') |
277 RunCmd(['build/android/provision_devices.py', '-t', target]) | 287 RunCmd(['build/android/provision_devices.py', '-t', target]) |
278 | 288 |
| 289 # Check to see if devices can install apks. |
| 290 CheckInstall() |
| 291 |
279 if options.install: | 292 if options.install: |
280 test_obj = INSTRUMENTATION_TESTS[options.install] | 293 test_obj = INSTRUMENTATION_TESTS[options.install] |
281 InstallApk(options, test_obj, print_step=True) | 294 InstallApk(options, test_obj, print_step=True) |
282 | 295 |
283 if 'chromedriver' in options.test_filter: | 296 if 'chromedriver' in options.test_filter: |
284 RunChromeDriverTests() | 297 RunChromeDriverTests() |
285 if 'unit' in options.test_filter: | 298 if 'unit' in options.test_filter: |
286 RunTestSuites(options, gtest_config.STABLE_TEST_SUITES) | 299 RunTestSuites(options, gtest_config.STABLE_TEST_SUITES) |
287 if 'ui' in options.test_filter: | 300 if 'ui' in options.test_filter: |
288 for test in INSTRUMENTATION_TESTS.itervalues(): | 301 for test in INSTRUMENTATION_TESTS.itervalues(): |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 'slave', 'android')) | 380 'slave', 'android')) |
368 if os.path.exists(build_internal_android): | 381 if os.path.exists(build_internal_android): |
369 android_paths.insert(0, build_internal_android) | 382 android_paths.insert(0, build_internal_android) |
370 os.environ['PATH'] = os.pathsep.join(android_paths + [os.environ['PATH']]) | 383 os.environ['PATH'] = os.pathsep.join(android_paths + [os.environ['PATH']]) |
371 | 384 |
372 MainTestWrapper(options) | 385 MainTestWrapper(options) |
373 | 386 |
374 | 387 |
375 if __name__ == '__main__': | 388 if __name__ == '__main__': |
376 sys.exit(main(sys.argv)) | 389 sys.exit(main(sys.argv)) |
OLD | NEW |