Exemple #1
0
def _compute_chrome_params(parsed_args):
  chrome_path = _get_chrome_path(parsed_args)
  params = [chrome_path]

  if parsed_args.mode in ('perftest', 'atftest'):
    # Do not show the New Tab Page because showing NTP during perftest makes the
    # benchmark score look unnecessarily bad.
    # TODO(crbug.com/315356): Remove the IF once 315356 is fixed.
    params.append('about:blank')
    # Append flags for performance measurement in test modes to stabilize
    # integration tests and perf score. Do not append these flags in run mode
    # because apps that depend on component extensions (e.g. Files.app) will not
    # work with these flags.
    params.extend(_compute_chrome_performance_test_params(parsed_args))
    # Make the window size small on Goobuntu so that it does not cover the whole
    # desktop during perftest/integration_test.
    params.append('--window-size=500,500')

  if parsed_args.lang:
    params.append('--lang=' + parsed_args.lang)
    # LANGUAGE takes priority over --lang option in Linux.
    os.environ['LANGUAGE'] = parsed_args.lang
    # In Mac, there is no handy way to change the locale.
    if platform_util.is_running_on_mac():
      print '\nWARNING: --lang is not supported in Mac.'

  if (parsed_args.mode == 'atftest' and
      not platform_util.is_running_on_chromeos() and
      not platform_util.is_running_on_mac()):
    # This launches ARC without creating a browser window.  We only do it for
    # automated tests, in case the user wants to do something like examine the
    # Chromium settings ("about:flags" for example), which requires using the
    # browser window. Note that this does not work on Mac, and should be
    # unnecessary on a remote Chromebook target.
    params.append('--silent-launch')

  params.extend(_compute_chrome_plugin_params(parsed_args))
  params.extend(_compute_chrome_sandbox_params(parsed_args))
  params.extend(_compute_chrome_graphics_params(parsed_args))
  params.extend(_compute_chrome_debugging_params(parsed_args))
  diagnostic_params, diagnostic_params_startwith = (
      _compute_chrome_diagnostic_params(parsed_args))
  params.extend(diagnostic_params)
  params = diagnostic_params_startwith + params
  remote_executor.maybe_extend_remote_host_chrome_params(parsed_args, params)

  params.append(
      '--load-and-launch-app=' +
      remote_executor.resolve_path(parsed_args.arc_data_dir))

  # This prevents Chrome to add icon to Gnome panel, which current leaks memory.
  # See http://crbug.com/341724 for details.
  params.append('--disable-background-mode')

  if parsed_args.chrome_args:
    params.extend(parsed_args.chrome_args)

  return params
Exemple #2
0
def _get_adb_path_for_localhost():
    root = os.path.join(build_common.get_arc_root(), 'out/adb')
    if platform_util.is_running_on_mac():
        return os.path.join(root, 'mac-x86_64/adb')
    elif platform_util.is_running_on_cygwin():
        return os.path.join(root, 'win-x86_64/adb.exe')
    elif platform_util.is_running_on_chromeos():
        return get_adb_path_for_chromeos(relative=False)
    else:
        # For Linux desktop.
        return 'third_party/android-sdk/platform-tools/adb'
Exemple #3
0
def _get_chrome_exe_path_on_remote_host():
    """If this script is running on remote host, returns the path to Chrome."""
    if platform_util.is_running_on_chromeos():
        return remote_chromeos_executor.get_chrome_exe_path()
    if platform_util.is_running_on_cygwin():
        return _get_win_chrome_exe_path()
    if platform_util.is_running_on_mac():
        return _get_mac_chrome_exe_path()
    raise NotImplementedError(
        'get_chrome_exe_path_on_remote_host is supported only for Chrome OS, '
        'Cygwin, and Mac.')
Exemple #4
0
def _get_adb_path_for_localhost():
  root = os.path.join(build_common.get_arc_root(), 'out/adb')
  if platform_util.is_running_on_mac():
    return os.path.join(root, 'mac-x86_64/adb')
  elif platform_util.is_running_on_cygwin():
    return os.path.join(root, 'win-x86_64/adb.exe')
  elif platform_util.is_running_on_chromeos():
    return get_adb_path_for_chromeos(relative=False)
  else:
    # For Linux desktop.
    return 'third_party/android-sdk/platform-tools/adb'
Exemple #5
0
def _get_chrome_exe_path_on_remote_host():
  """If this script is running on remote host, returns the path to Chrome."""
  if platform_util.is_running_on_chromeos():
    return remote_chromeos_executor.get_chrome_exe_path()
  if platform_util.is_running_on_cygwin():
    return _get_win_chrome_exe_path()
  if platform_util.is_running_on_mac():
    return _get_mac_chrome_exe_path()
  raise NotImplementedError(
      'get_chrome_exe_path_on_remote_host is supported only for Chrome OS, '
      'Cygwin, and Mac.')
Exemple #6
0
def maybe_detect_remote_host_type(parsed_args):
    """Sets remote_host_type if necessary.

  This function ensures that parsed_args has |remote_host_type| value,
  if it has |remote|.
  On remote execution, this function checks if remote_host_type is already
  set or not. If not, detects the remote host type by communicating with the
  remote machine by using |remote| and |ssh_key| values.

  Unfortunately, currently ArgumentParser does not support default values
  evaluated lazily (after actual parsing) with already parsed arguments.
  So, all parsers using add_remote_arguments() defined above need to call
  this function just after its parse_known_args() family.
  """
    if platform_util.is_running_on_remote_host():
        # On remote machine, we expect --remote flag is removed.
        assert parsed_args.remote is None, (
            'Found --remote flag, but the script runs on the remote machine.')

        # Detect the remote_host_type of the machine, and fix up or verify
        # the parsed flag.
        if platform_util.is_running_on_cygwin():
            remote_host_type = 'cygwin'
        elif platform_util.is_running_on_mac():
            remote_host_type = 'mac'
        elif platform_util.is_running_on_chromeos():
            remote_host_type = 'chromeos'
        else:
            raise Exception('Unknown platform')

        if parsed_args.remote_host_type is None:
            parsed_args.remote_host_type = remote_host_type
        assert parsed_args.remote_host_type == remote_host_type, (
            '--remote_host_type is mismatching: "%s" vs "%s"' %
            (parsed_args.remote_host_type, remote_host_type))
        return

    # Hereafter, this runs on the host machine.
    if parsed_args.remote_host_type or not parsed_args.remote:
        # If --remote-host-type is already set, or it is not --remote execution,
        # we do nothing.
        return
    parsed_args.remote_host_type = remote_executor_util.detect_remote_host_type(
        parsed_args.remote, parsed_args.ssh_key)
Exemple #7
0
def maybe_detect_remote_host_type(parsed_args):
  """Sets remote_host_type if necessary.

  This function ensures that parsed_args has |remote_host_type| value,
  if it has |remote|.
  On remote execution, this function checks if remote_host_type is already
  set or not. If not, detects the remote host type by communicating with the
  remote machine by using |remote| and |ssh_key| values.

  Unfortunately, currently ArgumentParser does not support default values
  evaluated lazily (after actual parsing) with already parsed arguments.
  So, all parsers using add_remote_arguments() defined above need to call
  this function just after its parse_known_args() family.
  """
  if platform_util.is_running_on_remote_host():
    # On remote machine, we expect --remote flag is removed.
    assert parsed_args.remote is None, (
        'Found --remote flag, but the script runs on the remote machine.')

    # Detect the remote_host_type of the machine, and fix up or verify
    # the parsed flag.
    if platform_util.is_running_on_cygwin():
      remote_host_type = 'cygwin'
    elif platform_util.is_running_on_mac():
      remote_host_type = 'mac'
    elif platform_util.is_running_on_chromeos():
      remote_host_type = 'chromeos'
    else:
      raise Exception('Unknown platform')

    if parsed_args.remote_host_type is None:
      parsed_args.remote_host_type = remote_host_type
    assert parsed_args.remote_host_type == remote_host_type, (
        '--remote_host_type is mismatching: "%s" vs "%s"' % (
            parsed_args.remote_host_type, remote_host_type))
    return

  # Hereafter, this runs on the host machine.
  if parsed_args.remote_host_type or not parsed_args.remote:
    # If --remote-host-type is already set, or it is not --remote execution,
    # we do nothing.
    return
  parsed_args.remote_host_type = remote_executor_util.detect_remote_host_type(
      parsed_args.remote, parsed_args.ssh_key)
Exemple #8
0
def _is_no_sandbox_needed(parsed_args):
  if parsed_args.disable_nacl_sandbox:
    return True

  # Official Chrome needs setuid + root ownership to run.  --no-sandbox
  # bypasses that.
  if OPTIONS.is_official_chrome():
    return True

  # In some cases, --no-sandbox is needed to work gdb properly.
  if gdb_util.is_no_sandbox_needed(parsed_args.gdb):
    return True

  # Set --no-sandbox on Mac for now because ARC apps crash on Mac Chromium
  # without the flag.
  # TODO(crbug.com/332785): Investigate the cause of crash and remove the flag
  # if possible.
  if platform_util.is_running_on_mac():
    return True

  return False
Exemple #9
0
def _list_child_process(*target_pid):
    """Returns a list of PIDs whose parent PID is |target_pid|."""
    if platform_util.is_running_on_linux():
        # On Linux Workstation or Chrome OS.
        try:
            output = subprocess.check_output([
                'ps', '-o', 'pid=', '--ppid',
                ','.join(str(p) for p in target_pid)
            ])
        except subprocess.CalledProcessError:
            # If not found, ps returns status code 1.
            return []
        return [int(child.strip()) for child in output.splitlines()]

    if platform_util.is_running_on_mac():
        # On Mac.
        try:
            output = subprocess.check_output(['ps', 'x', '-o', 'pid=,ppid='])
        except subprocess.CalledProcessError:
            return []
        result = []
        for line in output.splitlines():
            pid, ppid = line.split()
            if int(ppid) in target_pid:
                result.append(int(pid))
        return result

    if platform_util.is_running_on_cygwin():
        # On Cygwin.
        try:
            output = subprocess.check_output(['ps', 'aux'])
        except subprocess.CalledProcessError:
            return []
        result = []
        for line in output.splitlines()[1:]:
            pid, ppid = line.split(None, 2)[:2]
            if int(ppid) in target_pid:
                result.append(int(pid))
        return result
    raise NotImplementedError('Unknown platform: ' + sys.platform)
Exemple #10
0
def _list_child_process(*target_pid):
  """Returns a list of PIDs whose parent PID is |target_pid|."""
  if platform_util.is_running_on_linux():
    # On Linux Workstation or Chrome OS.
    try:
      output = subprocess.check_output(
          ['ps', '-o', 'pid=', '--ppid', ','.join(str(p) for p in target_pid)])
    except subprocess.CalledProcessError:
      # If not found, ps returns status code 1.
      return []
    return [int(child.strip()) for child in output.splitlines()]

  if platform_util.is_running_on_mac():
    # On Mac.
    try:
      output = subprocess.check_output(['ps', 'x', '-o', 'pid=,ppid='])
    except subprocess.CalledProcessError:
      return []
    result = []
    for line in output.splitlines():
      pid, ppid = line.split()
      if int(ppid) in target_pid:
        result.append(int(pid))
    return result

  if platform_util.is_running_on_cygwin():
    # On Cygwin.
    try:
      output = subprocess.check_output(['ps', 'aux'])
    except subprocess.CalledProcessError:
      return []
    result = []
    for line in output.splitlines()[1:]:
      pid, ppid = line.split(None, 2)[:2]
      if int(ppid) in target_pid:
        result.append(int(pid))
    return result
  raise NotImplementedError('Unknown platform: ' + sys.platform)