Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: build/android/buildbot/bb_device_steps.py

Issue 14283017: Stop build on failed device status check, apk install and add CheckInstall step. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added HelloWorld apk to install instead of SdkController. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/CheckInstallApk-debug.apk ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 I_TEST('AndroidWebView', 54 I_TEST('AndroidWebView',
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 NUM_CHECK_INSTALL = 3
64 65
65 66
66 def SpawnCmd(command): 67 def SpawnCmd(command):
67 """Spawn a process without waiting for termination.""" 68 """Spawn a process without waiting for termination."""
68 print '>', ' '.join(map(pipes.quote, command)) 69 print '>', ' '.join(map(pipes.quote, command))
69 sys.stdout.flush() 70 sys.stdout.flush()
70 if TESTING: 71 if TESTING:
71 class MockPopen(object): 72 class MockPopen(object):
72 @staticmethod 73 @staticmethod
73 def wait(): 74 def wait():
74 return 0 75 return 0
75 return MockPopen() 76 return MockPopen()
76 77
77 return subprocess.Popen(command, cwd=CHROME_SRC) 78 return subprocess.Popen(command, cwd=CHROME_SRC)
78 79
79 def RunCmd(command, flunk_on_failure=True): 80 def RunCmd(command, flunk_on_failure=True, halt_on_failure=False):
80 """Run a command relative to the chrome source root.""" 81 """Run a command relative to the chrome source root."""
81 code = SpawnCmd(command).wait() 82 code = SpawnCmd(command).wait()
82 print '<', ' '.join(map(pipes.quote, command)) 83 print '<', ' '.join(map(pipes.quote, command))
83 if code != 0: 84 if code != 0:
84 print 'ERROR: process exited with code %d' % code 85 print 'ERROR: process exited with code %d' % code
85 if flunk_on_failure: 86 if flunk_on_failure:
86 buildbot_report.PrintError() 87 buildbot_report.PrintError()
87 else: 88 else:
88 buildbot_report.PrintWarning() 89 buildbot_report.PrintWarning()
90 # Allow steps to have both halting (i.e. 1) and non-halting exit codes.
91 if code != 0 and code != 88 and halt_on_failure:
92 raise OSError()
89 return code 93 return code
90 94
91 95
92 # multiprocessing map_async requires a top-level function for pickle library. 96 # multiprocessing map_async requires a top-level function for pickle library.
93 def RebootDeviceSafe(device): 97 def RebootDeviceSafe(device):
94 """Reboot a device, wait for it to start, and squelch timeout exceptions.""" 98 """Reboot a device, wait for it to start, and squelch timeout exceptions."""
95 try: 99 try:
96 android_commands.AndroidCommands(device).Reboot(True) 100 android_commands.AndroidCommands(device).Reboot(True)
97 except errors.DeviceUnresponsiveError as e: 101 except errors.DeviceUnresponsiveError as e:
98 return e 102 return e
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 buildbot_report.PrintNamedStep(constants.BROWSERTEST_SUITE_NAME) 158 buildbot_report.PrintNamedStep(constants.BROWSERTEST_SUITE_NAME)
155 RunCmd(['build/android/run_browser_tests.py'] + args) 159 RunCmd(['build/android/run_browser_tests.py'] + args)
156 160
157 def RunChromeDriverTests(): 161 def RunChromeDriverTests():
158 """Run all the steps for running chromedriver tests.""" 162 """Run all the steps for running chromedriver tests."""
159 buildbot_report.PrintNamedStep('chromedriver_annotation') 163 buildbot_report.PrintNamedStep('chromedriver_annotation')
160 RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py', 164 RunCmd(['chrome/test/chromedriver/run_buildbot_steps.py',
161 '--android-package=%s' % constants.CHROMIUM_TEST_SHELL_PACKAGE]) 165 '--android-package=%s' % constants.CHROMIUM_TEST_SHELL_PACKAGE])
162 166
163 167
168 def CheckInstall():
169 """Build bot step to see if adb install works on attached devices. """
170 buildbot_report.PrintNamedStep('Check device install')
171 # This step checks if apks can be installed on the devices.
172 args = ['--apk', 'build/android/CheckInstallApk-debug.apk']
173 for _ in range(NUM_CHECK_INSTALL):
Isaac (away) 2013/05/07 18:08:47 Actually, why try to install multiple times? If w
174 RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True)
175
176
164 def InstallApk(options, test, print_step=False): 177 def InstallApk(options, test, print_step=False):
165 """Install an apk to all phones. 178 """Install an apk to all phones.
166 179
167 Args: 180 Args:
168 options: options object 181 options: options object
169 test: An I_TEST namedtuple 182 test: An I_TEST namedtuple
170 print_step: Print a buildbot step 183 print_step: Print a buildbot step
171 """ 184 """
172 if print_step: 185 if print_step:
173 buildbot_report.PrintNamedStep('install_%s' % test.name.lower()) 186 buildbot_report.PrintNamedStep('install_%s' % test.name.lower())
174 args = ['--apk', test.apk, '--apk_package', test.apk_package] 187 args = ['--apk', test.apk, '--apk_package', test.apk_package]
175 if options.target == 'Release': 188 if options.target == 'Release':
176 args.append('--release') 189 args.append('--release')
177 190
178 RunCmd(['build/android/adb_install_apk.py'] + args) 191 RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True)
179 192
180 193
181 def RunInstrumentationSuite(options, test): 194 def RunInstrumentationSuite(options, test):
182 """Manages an invocation of run_instrumentaiton_tests.py. 195 """Manages an invocation of run_instrumentaiton_tests.py.
183 196
184 Args: 197 Args:
185 options: options object 198 options: options object
186 test: An I_TEST namedtuple 199 test: An I_TEST namedtuple
187 """ 200 """
188 buildbot_report.PrintNamedStep('%s_instrumentation_tests' % test.name.lower()) 201 buildbot_report.PrintNamedStep('%s_instrumentation_tests' % test.name.lower())
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 SpawnCmd(['build/android/adb_logcat_monitor.py', logcat_dir]) 275 SpawnCmd(['build/android/adb_logcat_monitor.py', logcat_dir])
263 276
264 # Wait for logcat_monitor to pull existing logcat 277 # Wait for logcat_monitor to pull existing logcat
265 RunCmd(['sleep', '5']) 278 RunCmd(['sleep', '5'])
266 279
267 if options.reboot: 280 if options.reboot:
268 RebootDevices() 281 RebootDevices()
269 282
270 # Device check and alert emails 283 # Device check and alert emails
271 buildbot_report.PrintNamedStep('device_status_check') 284 buildbot_report.PrintNamedStep('device_status_check')
272 RunCmd(['build/android/device_status_check.py']) 285 RunCmd(['build/android/device_status_check.py'], halt_on_failure=True)
273 286
274 # Provision devices 287 # Provision devices
275 buildbot_report.PrintNamedStep('provision_devices') 288 buildbot_report.PrintNamedStep('provision_devices')
276 target = options.factory_properties.get('target', 'Debug') 289 target = options.factory_properties.get('target', 'Debug')
277 RunCmd(['build/android/provision_devices.py', '-t', target]) 290 RunCmd(['build/android/provision_devices.py', '-t', target])
278 291
292 # Check to see if devices can install apks.
293 CheckInstall()
294
279 if options.install: 295 if options.install:
280 test_obj = INSTRUMENTATION_TESTS[options.install] 296 test_obj = INSTRUMENTATION_TESTS[options.install]
281 InstallApk(options, test_obj, print_step=True) 297 InstallApk(options, test_obj, print_step=True)
282 298
283 if 'chromedriver' in options.test_filter: 299 if 'chromedriver' in options.test_filter:
284 RunChromeDriverTests() 300 RunChromeDriverTests()
285 if 'unit' in options.test_filter: 301 if 'unit' in options.test_filter:
286 RunTestSuites(options, gtest_config.STABLE_TEST_SUITES) 302 RunTestSuites(options, gtest_config.STABLE_TEST_SUITES)
287 RunBrowserTestSuite(options) 303 RunBrowserTestSuite(options)
288 if 'ui' in options.test_filter: 304 if 'ui' in options.test_filter:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 'slave', 'android')) 383 'slave', 'android'))
368 if os.path.exists(build_internal_android): 384 if os.path.exists(build_internal_android):
369 android_paths.insert(0, build_internal_android) 385 android_paths.insert(0, build_internal_android)
370 os.environ['PATH'] = os.pathsep.join(android_paths + [os.environ['PATH']]) 386 os.environ['PATH'] = os.pathsep.join(android_paths + [os.environ['PATH']])
371 387
372 MainTestWrapper(options) 388 MainTestWrapper(options)
373 389
374 390
375 if __name__ == '__main__': 391 if __name__ == '__main__':
376 sys.exit(main(sys.argv)) 392 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/android/CheckInstallApk-debug.apk ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698