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

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

Issue 255783008: Add option to wipe device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix nits. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | build/android/provision_devices.py » ('j') | 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 hashlib 8 import hashlib
9 import json 9 import json
10 import multiprocessing
11 import os 10 import os
12 import random 11 import random
13 import re 12 import re
14 import shutil 13 import shutil
15 import sys 14 import sys
16 15
17 import bb_utils 16 import bb_utils
18 import bb_annotations 17 import bb_annotations
19 18
20 sys.path.append(os.path.join(os.path.dirname(__file__), '..')) 19 sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
21 import provision_devices 20 import provision_devices
22 from pylib import android_commands 21 from pylib import android_commands
23 from pylib import constants 22 from pylib import constants
24 from pylib.device import device_utils 23 from pylib.device import device_utils
25 from pylib.gtest import gtest_config 24 from pylib.gtest import gtest_config
26 25
27 CHROME_SRC_DIR = bb_utils.CHROME_SRC 26 CHROME_SRC_DIR = bb_utils.CHROME_SRC
28 DIR_BUILD_ROOT = os.path.dirname(CHROME_SRC_DIR) 27 DIR_BUILD_ROOT = os.path.dirname(CHROME_SRC_DIR)
29 CHROME_OUT_DIR = bb_utils.CHROME_OUT_DIR 28 CHROME_OUT_DIR = bb_utils.CHROME_OUT_DIR
30 sys.path.append(os.path.join(
31 CHROME_SRC_DIR, 'third_party', 'android_testrunner'))
32 import errors
33
34 29
35 SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave') 30 SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave')
36 LOGCAT_DIR = os.path.join(bb_utils.CHROME_OUT_DIR, 'logcat') 31 LOGCAT_DIR = os.path.join(bb_utils.CHROME_OUT_DIR, 'logcat')
37 GS_URL = 'https://storage.googleapis.com' 32 GS_URL = 'https://storage.googleapis.com'
38 GS_AUTH_URL = 'https://storage.cloud.google.com' 33 GS_AUTH_URL = 'https://storage.cloud.google.com'
39 34
40 # Describes an instrumation test suite: 35 # Describes an instrumation test suite:
41 # test: Name of test we're running. 36 # test: Name of test we're running.
42 # apk: apk to be installed. 37 # apk: apk to be installed.
43 # apk_package: package for the apk to be installed. 38 # apk_package: package for the apk to be installed.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 89
95 Returns: 90 Returns:
96 The revision number. 91 The revision number.
97 """ 92 """
98 revision = options.build_properties.get('got_revision') 93 revision = options.build_properties.get('got_revision')
99 if not revision: 94 if not revision:
100 revision = options.build_properties.get('revision', 'testing') 95 revision = options.build_properties.get('revision', 'testing')
101 return revision 96 return revision
102 97
103 98
104 # multiprocessing map_async requires a top-level function for pickle library.
105 def RebootDeviceSafe(device):
106 """Reboot a device, wait for it to start, and squelch timeout exceptions."""
107 try:
108 device_utils.DeviceUtils(device).old_interface.Reboot(True)
109 except errors.DeviceUnresponsiveError as e:
110 return e
111
112
113 def RebootDevices():
114 """Reboot all attached and online devices."""
115 # Early return here to avoid presubmit dependence on adb,
116 # which might not exist in this checkout.
117 if bb_utils.TESTING:
118 return
119 devices = android_commands.GetAttachedDevices()
120 print 'Rebooting: %s' % devices
121 if devices:
122 pool = multiprocessing.Pool(len(devices))
123 results = pool.map_async(RebootDeviceSafe, devices).get(99999)
124
125 for device, result in zip(devices, results):
126 if result:
127 print '%s failed to startup.' % device
128
129 if any(results):
130 bb_annotations.PrintWarning()
131 else:
132 print 'Reboots complete.'
133
134
135 def RunTestSuites(options, suites): 99 def RunTestSuites(options, suites):
136 """Manages an invocation of test_runner.py for gtests. 100 """Manages an invocation of test_runner.py for gtests.
137 101
138 Args: 102 Args:
139 options: options object. 103 options: options object.
140 suites: List of suite names to run. 104 suites: List of suite names to run.
141 """ 105 """
142 args = ['--verbose'] 106 args = ['--verbose']
143 if options.target == 'Release': 107 if options.target == 'Release':
144 args.append('--release') 108 args.append('--release')
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 RunCmd(['sleep', '5']) 391 RunCmd(['sleep', '5'])
428 392
429 393
430 def ProvisionDevices(options): 394 def ProvisionDevices(options):
431 bb_annotations.PrintNamedStep('provision_devices') 395 bb_annotations.PrintNamedStep('provision_devices')
432 396
433 if not bb_utils.TESTING: 397 if not bb_utils.TESTING:
434 # Restart adb to work around bugs, sleep to wait for usb discovery. 398 # Restart adb to work around bugs, sleep to wait for usb discovery.
435 device_utils.DeviceUtils(None).old_interface.RestartAdbServer() 399 device_utils.DeviceUtils(None).old_interface.RestartAdbServer()
436 RunCmd(['sleep', '1']) 400 RunCmd(['sleep', '1'])
437
438 if not options.no_reboot:
439 RebootDevices()
440 provision_cmd = ['build/android/provision_devices.py', '-t', options.target] 401 provision_cmd = ['build/android/provision_devices.py', '-t', options.target]
441 if options.auto_reconnect: 402 if options.auto_reconnect:
442 provision_cmd.append('--auto-reconnect') 403 provision_cmd.append('--auto-reconnect')
443 RunCmd(provision_cmd) 404 RunCmd(provision_cmd)
444 405
445 406
446 def DeviceStatusCheck(options): 407 def DeviceStatusCheck(options):
447 bb_annotations.PrintNamedStep('device_status_check') 408 bb_annotations.PrintNamedStep('device_status_check')
448 cmd = ['build/android/buildbot/bb_device_status_check.py'] 409 cmd = ['build/android/buildbot/bb_device_status_check.py']
449 if options.restart_usb: 410 if options.restart_usb:
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) 651 setattr(options, 'target', options.factory_properties.get('target', 'Debug'))
691 if options.coverage_bucket: 652 if options.coverage_bucket:
692 setattr(options, 'coverage_dir', 653 setattr(options, 'coverage_dir',
693 os.path.join(CHROME_OUT_DIR, options.target, 'coverage')) 654 os.path.join(CHROME_OUT_DIR, options.target, 'coverage'))
694 655
695 MainTestWrapper(options) 656 MainTestWrapper(options)
696 657
697 658
698 if __name__ == '__main__': 659 if __name__ == '__main__':
699 sys.exit(main(sys.argv)) 660 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | build/android/provision_devices.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698