Пример #1
0
 def testRestartServerAlreadyRunning(self):
     if cmd_helper.RunCmd(['pgrep', 'adb']) != 0:
         device_utils.RestartServer()
     code, original_pid = cmd_helper.GetCmdStatusAndOutput(['pgrep', 'adb'])
     self.assertEqual(0, code)
     device_utils.RestartServer()
     code, new_pid = cmd_helper.GetCmdStatusAndOutput(['pgrep', 'adb'])
     self.assertEqual(0, code)
     self.assertNotEqual(original_pid, new_pid)
Пример #2
0
 def testRestartServerNotRunning(self):
     self.assertEqual(0,
                      cmd_helper.RunCmd(['pkill', 'adb']),
                      msg='Unable to kill adb during setup.')
     self.assertNotEqual(0,
                         cmd_helper.RunCmd(['pgrep', 'adb']),
                         msg='Unexpectedly found adb during setup.')
     device_utils.RestartServer()
     self.assertEqual(0, cmd_helper.RunCmd(['pgrep', 'adb']))
Пример #3
0
def ProvisionDevices(options):
  bb_annotations.PrintNamedStep('provision_devices')

  if not bb_utils.TESTING:
    # Restart adb to work around bugs, sleep to wait for usb discovery.
    device_utils.RestartServer()
    RunCmd(['sleep', '1'])
  provision_cmd = ['build/android/provision_devices.py', '-t', options.target]
  if options.auto_reconnect:
    provision_cmd.append('--auto-reconnect')
  RunCmd(provision_cmd)
Пример #4
0
def CleanupLeftoverProcesses():
    """Clean up the test environment, restarting fresh adb and HTTP daemons."""
    _KillWebServers()
    device_utils.RestartServer()
    p = device_utils.DeviceUtils.parallel()
    p.old_interface.RestartAdbdOnDevice()
    try:
        p.EnableRoot()
    except device_errors.CommandFailedError as e:
        # TODO(jbudorick) Handle this exception appropriately after interface
        #                 conversions are finished.
        logging.error(str(e))
    p.WaitUntilFullyBooted()
def CleanupLeftoverProcesses():
    """Clean up the test environment, restarting fresh adb and HTTP daemons."""
    _KillWebServers()
    device_utils.RestartServer()

    def cleanup_device(d):
        d.RestartAdbd()
        try:
            d.EnableRoot()
        except device_errors.CommandFailedError as e:
            logging.error(str(e))
        d.WaitUntilFullyBooted()

    device_utils.DeviceUtils.parallel().pMap(cleanup_device)
Пример #6
0
def CleanupLeftoverProcesses():
    """Clean up the test environment, restarting fresh adb and HTTP daemons."""
    _KillWebServers()
    did_restart_host_adb = False
    for device_serial in android_commands.GetAttachedDevices():
        device = device_utils.DeviceUtils(device_serial)
        # Make sure we restart the host adb server only once.
        if not did_restart_host_adb:
            device_utils.RestartServer()
            did_restart_host_adb = True
        device.old_interface.RestartAdbdOnDevice()
        try:
            device.EnableRoot()
        except device_errors.CommandFailedError as e:
            # TODO(jbudorick) Handle this exception appropriately after interface
            #                 conversions are finished.
            logging.error(str(e))
        device.old_interface.WaitForDevicePm()
Пример #7
0
def CleanupLeftoverProcesses(devices):
    """Clean up the test environment, restarting fresh adb and HTTP daemons.

  Args:
    devices: The devices to clean.
  """
    _KillWebServers()
    device_utils.RestartServer()

    def cleanup_device(d):
        d.RestartAdbd()
        try:
            d.EnableRoot()
        except device_errors.CommandFailedError:
            logging.exception('Failed to enable root')
        d.WaitUntilFullyBooted()

    device_utils.DeviceUtils.parallel(devices).pMap(cleanup_device)