diff options
Diffstat (limited to 'build')
-rwxr-xr-x | build/android/buildbot/bb_device_steps.py | 7 | ||||
-rwxr-xr-x | build/android/provision_devices.py | 66 |
2 files changed, 36 insertions, 37 deletions
diff --git a/build/android/buildbot/bb_device_steps.py b/build/android/buildbot/bb_device_steps.py index a0d0d19..04d49c2 100755 --- a/build/android/buildbot/bb_device_steps.py +++ b/build/android/buildbot/bb_device_steps.py @@ -272,10 +272,9 @@ def MainTestWrapper(options): RunCmd(['build/android/device_status_check.py']) # Provision devices - if options.auto_reconnect: - buildbot_report.PrintNamedStep('provision_devices') - target = options.factory_properties.get('target', 'Debug') - RunCmd(['build/android/provision_devices.py', '-t', target]) + buildbot_report.PrintNamedStep('provision_devices') + target = options.factory_properties.get('target', 'Debug') + RunCmd(['build/android/provision_devices.py', '-t', target]) if options.install: test_obj = INSTRUMENTATION_TESTS[options.install] diff --git a/build/android/provision_devices.py b/build/android/provision_devices.py index 6ca53b1..6646556 100755 --- a/build/android/provision_devices.py +++ b/build/android/provision_devices.py @@ -21,30 +21,6 @@ from pylib import android_commands from pylib import constants -def PushAndLaunchAdbReboot(device, target): - """Pushes and launches the adb_reboot binary on the device. - - Arguments: - device: The serial number of the device to which the - adb_reboot binary should be pushed. - target: The build target (example, Debug or Release) which helps in - locating the adb_reboot binary. - """ - print 'Will push and launch adb_reboot on %s' % device - android_cmd = android_commands.AndroidCommands(device) - # Kill if adb_reboot is already running. - android_cmd.KillAllBlocking('adb_reboot', 2) - # Push adb_reboot - print ' Pushing adb_reboot ...' - adb_reboot = os.path.join(constants.CHROME_DIR, - 'out/%s/adb_reboot' % target) - android_cmd.PushIfNeeded(adb_reboot, '/data/local/') - # Launch adb_reboot - print ' Launching adb_reboot ...' - p = subprocess.Popen(['adb', '-s', device, 'shell'], stdin=subprocess.PIPE) - p.communicate('/data/local/adb_reboot; exit\n') - - def LaunchHostHeartbeat(): ps = subprocess.Popen(['ps', 'aux'], stdout = subprocess.PIPE) stdout, _ = ps.communicate() @@ -54,11 +30,37 @@ def LaunchHostHeartbeat(): pid = re.findall('(\d+)', match)[1] subprocess.call(['kill', str(pid)]) # Launch a new host_heartbeat - print 'Spawing host heartbeat...' + print 'Spawning host heartbeat...' subprocess.Popen([os.path.join(constants.CHROME_DIR, 'build/android/host_heartbeat.py')]) +def PushAndLaunchAdbReboot(devices, target): + """Pushes and launches the adb_reboot binary on the device. + + Arguments: + devices: The list of serial numbers of the device to which the + adb_reboot binary should be pushed. + target : The build target (example, Debug or Release) which helps in + locating the adb_reboot binary. + """ + for device in devices: + print 'Will push and launch adb_reboot on %s' % device + android_cmd = android_commands.AndroidCommands(device) + # Kill if adb_reboot is already running. + android_cmd.KillAllBlocking('adb_reboot', 2) + # Push adb_reboot + print ' Pushing adb_reboot ...' + adb_reboot = os.path.join(constants.CHROME_DIR, + 'out/%s/adb_reboot' % target) + android_cmd.PushIfNeeded(adb_reboot, '/data/local/') + # Launch adb_reboot + print ' Launching adb_reboot ...' + p = subprocess.Popen(['adb', '-s', device, 'shell'], stdin=subprocess.PIPE) + p.communicate('/data/local/adb_reboot; exit\n') + LaunchHostHeartbeat() + + def ProvisionDevices(options): if options.device is not None: devices = [options.device] @@ -67,26 +69,24 @@ def ProvisionDevices(options): for device in devices: android_cmd = android_commands.AndroidCommands(device) android_cmd.RunShellCommand('su -c date -u %f' % time.time()) - PushAndLaunchAdbReboot(device, options.target) - LaunchHostHeartbeat() + if options.auto_reconnect: + PushAndLaunchAdbReboot(devices, options.target) def main(argv): parser = optparse.OptionParser() parser.add_option('-d', '--device', help='The serial number of the device to be provisioned') - parser.add_option('-t', '--target', - help='Path to the adb_reboot binary') + parser.add_option('-t', '--target', default='Debug', help='The build target') + parser.add_option( + '-r', '--auto-reconnect', action='store_true', + help='Push binary which will reboot the device on adb disconnections.') options, args = parser.parse_args(argv[1:]) if args: print >> sys.stderr, 'Unused args %s' % args return 1 - if not options.target: - print >> sys.stderr, 'Build target not specified' - return 1 - ProvisionDevices(options) |