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

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: Created 7 years, 8 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 | « no previous file | 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 == 1 and halt_on_failure:
Isaac (away) 2013/04/30 20:01:16 How about if "code != 88"
navabi 2013/04/30 21:41:46 Done (assuming you mean != 88 and != 0).
92 exit(1)
Isaac (away) 2013/04/30 20:01:16 How about an exception instead of sys.exit: raise
Isaac (away) 2013/04/30 20:03:38 actually looks like that exception takes arguments
navabi 2013/04/30 21:41:46 Done.
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. The apk installed
172 # is not important. SDK Controller is checked out as part of the Android SDK.
173 args = ['--apk',
174 'third_party/android_tools/sdk/tools/apps/SdkController/bin/'
175 'SdkControllerApp.apk']
176 for _ in range(NUM_CHECK_INSTALL):
177 RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True)
178
179
164 def InstallApk(options, test, print_step=False): 180 def InstallApk(options, test, print_step=False):
165 """Install an apk to all phones. 181 """Install an apk to all phones.
166 182
167 Args: 183 Args:
168 options: options object 184 options: options object
169 test: An I_TEST namedtuple 185 test: An I_TEST namedtuple
170 print_step: Print a buildbot step 186 print_step: Print a buildbot step
171 """ 187 """
172 if print_step: 188 if print_step:
173 buildbot_report.PrintNamedStep('install_%s' % test.name.lower()) 189 buildbot_report.PrintNamedStep('install_%s' % test.name.lower())
174 args = ['--apk', test.apk, '--apk_package', test.apk_package] 190 args = ['--apk', test.apk, '--apk_package', test.apk_package]
175 if options.target == 'Release': 191 if options.target == 'Release':
176 args.append('--release') 192 args.append('--release')
177 193
178 RunCmd(['build/android/adb_install_apk.py'] + args) 194 RunCmd(['build/android/adb_install_apk.py'] + args, halt_on_failure=True)
navabi 2013/04/27 00:25:46 This will make the build stop if an apk install fa
Isaac (away) 2013/04/30 20:01:16 I'm confused why this isn't sufficient -- why do w
navabi 2013/04/30 21:41:46 Because not all test suites install apk's with adb
navabi 2013/04/30 21:43:55 For more information see the Note on the comment a
Isaac (away) 2013/04/30 21:53:17 That makes sense. Maybe in those cases we could ch
179 195
180 196
181 def RunInstrumentationSuite(options, test): 197 def RunInstrumentationSuite(options, test):
182 """Manages an invocation of run_instrumentaiton_tests.py. 198 """Manages an invocation of run_instrumentaiton_tests.py.
183 199
184 Args: 200 Args:
185 options: options object 201 options: options object
186 test: An I_TEST namedtuple 202 test: An I_TEST namedtuple
187 """ 203 """
188 buildbot_report.PrintNamedStep('%s_instrumentation_tests' % test.name.lower()) 204 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]) 278 SpawnCmd(['build/android/adb_logcat_monitor.py', logcat_dir])
263 279
264 # Wait for logcat_monitor to pull existing logcat 280 # Wait for logcat_monitor to pull existing logcat
265 RunCmd(['sleep', '5']) 281 RunCmd(['sleep', '5'])
266 282
267 if options.reboot: 283 if options.reboot:
268 RebootDevices() 284 RebootDevices()
269 285
270 # Device check and alert emails 286 # Device check and alert emails
271 buildbot_report.PrintNamedStep('device_status_check') 287 buildbot_report.PrintNamedStep('device_status_check')
272 RunCmd(['build/android/device_status_check.py']) 288 RunCmd(['build/android/device_status_check.py'], halt_on_failure=True)
Isaac (away) 2013/04/30 21:53:17 devise_status_check returns error codes on things
navabi 2013/04/30 21:59:56 I don't think that is the case. The main function
Isaac (away) 2013/04/30 22:07:08 Sorry, yes you're right. I forgot Siva changed th
273 289
274 # Provision devices 290 # Provision devices
275 buildbot_report.PrintNamedStep('provision_devices') 291 buildbot_report.PrintNamedStep('provision_devices')
276 target = options.factory_properties.get('target', 'Debug') 292 target = options.factory_properties.get('target', 'Debug')
277 RunCmd(['build/android/provision_devices.py', '-t', target]) 293 RunCmd(['build/android/provision_devices.py', '-t', target])
278 294
295 # Check to see if devices can install apks.
296 CheckInstall()
297
279 if options.install: 298 if options.install:
280 test_obj = INSTRUMENTATION_TESTS[options.install] 299 test_obj = INSTRUMENTATION_TESTS[options.install]
281 InstallApk(options, test_obj, print_step=True) 300 InstallApk(options, test_obj, print_step=True)
282 301
283 if 'chromedriver' in options.test_filter: 302 if 'chromedriver' in options.test_filter:
284 RunChromeDriverTests() 303 RunChromeDriverTests()
285 if 'unit' in options.test_filter: 304 if 'unit' in options.test_filter:
286 RunTestSuites(options, gtest_config.STABLE_TEST_SUITES) 305 RunTestSuites(options, gtest_config.STABLE_TEST_SUITES)
287 RunBrowserTestSuite(options) 306 RunBrowserTestSuite(options)
288 if 'ui' in options.test_filter: 307 if 'ui' in options.test_filter:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 'slave', 'android')) 386 'slave', 'android'))
368 if os.path.exists(build_internal_android): 387 if os.path.exists(build_internal_android):
369 android_paths.insert(0, build_internal_android) 388 android_paths.insert(0, build_internal_android)
370 os.environ['PATH'] = os.pathsep.join(android_paths + [os.environ['PATH']]) 389 os.environ['PATH'] = os.pathsep.join(android_paths + [os.environ['PATH']])
371 390
372 MainTestWrapper(options) 391 MainTestWrapper(options)
373 392
374 393
375 if __name__ == '__main__': 394 if __name__ == '__main__':
376 sys.exit(main(sys.argv)) 395 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698