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

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: Add parallel device reboot after wipe. 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
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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 RunCmd(['sleep', '5']) 375 RunCmd(['sleep', '5'])
412 376
413 377
414 def ProvisionDevices(options): 378 def ProvisionDevices(options):
415 bb_annotations.PrintNamedStep('provision_devices') 379 bb_annotations.PrintNamedStep('provision_devices')
416 380
417 if not bb_utils.TESTING: 381 if not bb_utils.TESTING:
418 # Restart adb to work around bugs, sleep to wait for usb discovery. 382 # Restart adb to work around bugs, sleep to wait for usb discovery.
419 device_utils.DeviceUtils(None).old_interface.RestartAdbServer() 383 device_utils.DeviceUtils(None).old_interface.RestartAdbServer()
420 RunCmd(['sleep', '1']) 384 RunCmd(['sleep', '1'])
421
422 if not options.no_reboot:
423 RebootDevices()
424 provision_cmd = ['build/android/provision_devices.py', '-t', options.target] 385 provision_cmd = ['build/android/provision_devices.py', '-t', options.target]
425 if options.auto_reconnect: 386 if options.auto_reconnect:
426 provision_cmd.append('--auto-reconnect') 387 provision_cmd.append('--auto-reconnect')
427 RunCmd(provision_cmd) 388 RunCmd(provision_cmd)
428 389
429 390
430 def DeviceStatusCheck(options): 391 def DeviceStatusCheck(options):
431 bb_annotations.PrintNamedStep('device_status_check') 392 bb_annotations.PrintNamedStep('device_status_check')
432 cmd = ['build/android/buildbot/bb_device_status_check.py'] 393 cmd = ['build/android/buildbot/bb_device_status_check.py']
433 if options.restart_usb: 394 if options.restart_usb:
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 setattr(options, 'target', options.factory_properties.get('target', 'Debug')) 634 setattr(options, 'target', options.factory_properties.get('target', 'Debug'))
674 if options.coverage_bucket: 635 if options.coverage_bucket:
675 setattr(options, 'coverage_dir', 636 setattr(options, 'coverage_dir',
676 os.path.join(CHROME_OUT_DIR, options.target, 'coverage')) 637 os.path.join(CHROME_OUT_DIR, options.target, 'coverage'))
677 638
678 MainTestWrapper(options) 639 MainTestWrapper(options)
679 640
680 641
681 if __name__ == '__main__': 642 if __name__ == '__main__':
682 sys.exit(main(sys.argv)) 643 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | build/android/provision_devices.py » ('j') | build/android/pylib/content_settings.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698