Ejemplo n.º 1
0
def _get_processes_to_kill():
  if (platform_util.is_running_on_linux() and
      not platform_util.is_running_on_chromeos()):
    return _KILL_PROCESSES_LINUX
  elif platform_util.is_running_on_cygwin():
    return _KILL_PROCESSES_CYGWIN
  # TODO(mazda): Add the case for Mac.
  return []
Ejemplo n.º 2
0
def _get_processes_to_kill():
  if (platform_util.is_running_on_linux() and
      not platform_util.is_running_on_chromeos()):
    return _KILL_PROCESSES_LINUX
  elif platform_util.is_running_on_cygwin():
    return _KILL_PROCESSES_CYGWIN
  # TODO(mazda): Add the case for Mac.
  return []
Ejemplo n.º 3
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)
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
  def handle_stderr(self, line):
    self._handle_line_common(line)
    if self._parse_pre_plugin_perf_message(line):
      return

    if self._parse_app_start_message(line):
      dash_line = '--------------------------------'
      sys.stderr.write(dash_line + '\n')
      sys.stderr.write(line)
      if platform_util.is_running_on_linux():
        app_mem = _get_nacl_arc_process_memory(self.chrome_process.pid)
        if app_mem:
          self.stats.app_res_mem = self.stats.app_res_mem or app_mem['res']
          self.stats.app_virt_mem = self.stats.app_virt_mem or app_mem['virt']
          self.stats.app_pdirt_mem = (
              self.stats.app_pdirt_mem or app_mem['pdirt'])
      sys.stderr.write(dash_line + '\n')

      self.resumed_time = time.time()
      if self.parsed_args.mode == 'perftest' and self.cache_warming:
        # Wait for NaCl validation cache to flush before killing chrome.
        self.chrome_process.terminate_later(_CACHE_WARMING_CHROME_KILL_DELAY)
        return
      self._finish()