Ejemplo n.º 1
0
def FindAllAvailableBrowsers(finder_options, device):
    """Finds all available CrOS browsers, locally and remotely."""
    browsers = []
    if not isinstance(device, cros_device.CrOSDevice):
        return browsers

    if cros_device.IsRunningOnCrOS():
        browsers = [
            PossibleCrOSBrowser('system',
                                finder_options,
                                platform_module.GetHostPlatform(),
                                is_guest=False),
            PossibleCrOSBrowser('system-guest',
                                finder_options,
                                platform_module.GetHostPlatform(),
                                is_guest=True)
        ]

    # Check ssh
    try:
        plat = platform_module.GetPlatformForDevice(device, finder_options)
    except cros_interface.LoginException, ex:
        if isinstance(ex, cros_interface.KeylessLoginRequiredException):
            logging.warn(
                'Could not ssh into %s. Your device must be configured',
                finder_options.cros_remote)
            logging.warn('to allow passwordless login as root.')
            logging.warn('For a test-build device, pass this to your script:')
            logging.warn('   --identity $(CHROMITE)/ssh_keys/testing_rsa')
            logging.warn('')
            logging.warn('For a developer-mode device, the steps are:')
            logging.warn(
                ' - Ensure you have an id_rsa.pub (etc) on this computer')
            logging.warn(' - On the chromebook:')
            logging.warn('   -  Control-Alt-T; shell; sudo -s')
            logging.warn('   -  openssh-server start')
            logging.warn('   -  scp <this machine>:.ssh/id_rsa.pub /tmp/')
            logging.warn('   -  mkdir /root/.ssh')
            logging.warn('   -  chown go-rx /root/.ssh')
            logging.warn(
                '   -  cat /tmp/id_rsa.pub >> /root/.ssh/authorized_keys')
            logging.warn('   -  chown 0600 /root/.ssh/authorized_keys')
        raise browser_finder_exceptions.BrowserFinderException(str(ex))
Ejemplo n.º 2
0
def FindAllAvailableBrowsers(finder_options, device):
    """Finds all the possible browsers on one device.

  The device is either the only device on the host platform,
  or |finder_options| specifies a particular device.
  """
    if not isinstance(device, android_device.AndroidDevice):
        return []

    try:
        android_platform = platform.GetPlatformForDevice(
            device, finder_options)
        return _FindAllPossibleBrowsers(finder_options, android_platform)
    except base_error.BaseError as e:
        logging.error('Unable to find browsers on %s: %s', device.device_id,
                      str(e))
        ps_output = subprocess.check_output(['ps', '-ef'])
        logging.error('Ongoing processes:\n%s', ps_output)
    return []
Ejemplo n.º 3
0
  def __init__(self, test, finder_options, story_set):
    """This method is styled on unittest.TestCase.setUpClass.

    Args:
      test: a web_perf.TimelineBasedMeasurement instance.
      options: a BrowserFinderOptions instance with command line options.
      story_set: a story.StorySet instance.
    """
    super(SharedAndroidState, self).__init__(test, finder_options, story_set)
    if not isinstance(
        test, timeline_based_measurement.TimelineBasedMeasurement):
      raise ValueError(
          'SharedAndroidState only accepts TimelineBasedMeasurement tests'
          ' (not %s).' % test.__class__)
    self._test = test
    self._finder_options = finder_options
    self._android_app = None
    self._current_story = None
    self._android_platform = platform.GetPlatformForDevice(
        android_device.GetDevice(finder_options), finder_options)
    assert self._android_platform, 'Unable to create android platform.'
    assert isinstance(
        self._android_platform, android_platform.AndroidPlatform)
Ejemplo n.º 4
0
  """Finds all available CrOS browsers, locally and remotely."""
  browsers = []
  if not isinstance(presentation.device, cros_device.CrOSDevice):
    return browsers

  if cros_device.IsRunningOnCrOS():
    browsers = [PossibleCrOSBrowser('system', finder_options,
                                    platform_module.GetHostPlatform(),
                                    is_guest=False),
                PossibleCrOSBrowser('system-guest', finder_options,
                                    platform_module.GetHostPlatform(),
                                    is_guest=True)]

  # Check ssh
  try:
    platform = platform_module.GetPlatformForDevice(presentation.device, finder_options)
  except cros_interface.LoginException, ex:
    if isinstance(ex, cros_interface.KeylessLoginRequiredException):
      logging.warn('Could not ssh into %s. Your presentation.device must be configured',
                   finder_options.cros_remote)
      logging.warn('to allow passwordless login as root.')
      logging.warn('For a test-build presentation.device, pass this to your script:')
      logging.warn('   --identity $(CHROMITE)/ssh_keys/testing_rsa')
      logging.warn('')
      logging.warn('For a developer-mode presentation.device, the steps are:')
      logging.warn(' - Ensure you have an id_rsa.pub (etc) on this computer')
      logging.warn(' - On the chromebook:')
      logging.warn('   -  Control-Alt-T; shell; sudo -s')
      logging.warn('   -  openssh-server start')
      logging.warn('   -  scp <this machine>:.ssh/id_rsa.pub /tmp/')
      logging.warn('   -  mkdir /root/.ssh')
Ejemplo n.º 5
0
    package, backend_settings, apk_name = package_info
    if apk_name and not finder_options.chrome_root:
      continue
    b = PossibleAndroidBrowser(name,
                               finder_options,
                               android_platform,
                               backend_settings(package),
                               apk_name)
    if b.platform.CanLaunchApplication(package) or b.HaveLocalAPK():
      possible_browsers.append(b)
  return possible_browsers


def FindAllAvailableBrowsers(finder_options, presentation.device):
  """Finds all the possible browsers on one presentation.device.

  The presentation.device is either the only presentation.device on the host platform,
  or |finder_options| specifies a particular presentation.device.
  """
  if not isinstance(presentation.device, android_device.AndroidDevice):
    return []

  try:
    android_platform = platform.GetPlatformForDevice(presentation.device, finder_options)
    return _FindAllPossibleBrowsers(finder_options, android_platform)
  except base_error.BaseError as e:
    logging.error('Unable to find browsers on %s: %s', presentation.device.device_id, str(e))
    ps_output = subprocess.check_output(['ps', '-ef'])
    logging.error('Ongoing processes:\n%s', ps_output)
  return []