Beispiel #1
0
def _FinalizeLog(log_entry, build_ids_files):
    log_entry.log_file.close()

    if log_entry.symbolize:
        input_file = open(log_entry.path, 'r')
        output_file = open(log_entry.path + SYMBOLIZED_SUFFIX, 'w')
        proc = RunSymbolizer(input_file, output_file, build_ids_files)
        proc.wait()
        output_file.close()
        input_file.close()
Beispiel #2
0
    def Start(self, target, package_paths, system_log_file):
        """Start a system log reader as a long-running SSH task."""
        logging.debug('Writing fuchsia system log to %s' % system_log_file)

        self._listener_proc = target.RunCommandPiped(['log_listener'],
                                                     stdout=subprocess.PIPE,
                                                     stderr=subprocess.STDOUT)

        self._system_log = open(system_log_file, 'w', buffering=1)
        self._symbolizer_proc = RunSymbolizer(self._listener_proc.stdout,
                                              self._system_log,
                                              BuildIdsPaths(package_paths))
Beispiel #3
0
 def StartSystemLog(self, package_paths):
   """Start a system log reader as a long-running SSH task."""
   system_log = self._log_manager.Open('system_log')
   if package_paths:
     self._log_listener_proc = self.RunCommandPiped(['log_listener'],
                                                    stdout=subprocess.PIPE,
                                                    stderr=subprocess.STDOUT)
     self._symbolizer_proc = RunSymbolizer(self._log_listener_proc.stdout,
                                           system_log,
                                           BuildIdsPaths(package_paths))
   else:
     self._log_listener_proc = self.RunCommandPiped(['log_listener'],
                                                    stdout=system_log,
                                                    stderr=subprocess.STDOUT)
Beispiel #4
0
def StartSystemLogReader(target, package_paths, isolated_outputs_dir):
    """Start a system log reader as a long-running SSH task.

  Returns listener and symbolizer popen objects so that the caller can control
  the popen process lifetimes."""
    logging.info('Starting system log reader')

    listener_proc = target.RunCommandPiped(['log_listener'],
                                           stdout=subprocess.PIPE,
                                           stderr=subprocess.STDOUT)

    listener_log_path = os.path.join(isolated_outputs_dir, 'log_listener_log')
    build_ids_paths = _BuildIdsPaths(package_paths)
    listener_log = open(listener_log_path, 'w', buffering=1)
    symbolizer_proc = RunSymbolizer(listener_proc.stdout, listener_log,
                                    build_ids_paths)

    return (listener_proc, symbolizer_proc)
Beispiel #5
0
def main():
  parser = argparse.ArgumentParser()
  AddCommonArgs(parser)
  args, gpu_test_args = parser.parse_known_args()
  ConfigureLogging(args)

  additional_target_args = {}

  # If output_dir is not set, assume the script is being launched
  # from the output directory.
  if not args.out_dir:
    args.out_dir = os.getcwd()
    additional_target_args['out_dir'] = args.out_dir

  # Create a temporary log file that Telemetry will look to use to build
  # an artifact when tests fail.
  temp_log_file = False
  if not args.system_log_file:
    args.system_log_file = os.path.join(tempfile.mkdtemp(), 'system-log')
    temp_log_file = True
    additional_target_args['system_log_file'] = args.system_log_file

  package_names = ['web_engine_with_webui', 'web_engine_shell']
  web_engine_dir = os.path.join(args.out_dir, 'gen', 'fuchsia', 'engine')
  gpu_script = [
      os.path.join(path_util.GetChromiumSrcDir(), 'content', 'test', 'gpu',
                   'run_gpu_integration_test.py')
  ]

  # Pass all other arguments to the gpu integration tests.
  gpu_script.extend(gpu_test_args)
  try:
    with GetDeploymentTargetForArgs(additional_target_args) as target:
      target.Start()
      fuchsia_device_address, fuchsia_ssh_port = target._GetEndpoint()
      gpu_script.extend(['--chromium-output-directory', args.out_dir])
      gpu_script.extend(['--fuchsia-device-address', fuchsia_device_address])
      gpu_script.extend(['--fuchsia-ssh-config', target._GetSshConfigPath()])
      if fuchsia_ssh_port:
        gpu_script.extend(['--fuchsia-ssh-port', str(fuchsia_ssh_port)])
      gpu_script.extend(['--fuchsia-system-log-file', args.system_log_file])
      if args.verbose:
        gpu_script.append('-v')

      # Set up logging of WebEngine
      listener = target.RunCommandPiped(['log_listener'],
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.STDOUT)
      build_ids_paths = map(
          lambda package_name: os.path.join(
              web_engine_dir, package_name, 'ids.txt'),
          package_names)
      RunSymbolizer(listener.stdout, open(args.system_log_file, 'w'),
                    build_ids_paths)

      # Keep the Amber repository live while the test runs.
      with target.GetAmberRepo():
        # Install necessary packages on the device.
        far_files = map(
            lambda package_name: os.path.join(
                web_engine_dir, package_name, package_name + '.far'),
            package_names)
        target.InstallPackage(far_files)
        return subprocess.call(gpu_script)
  finally:
    if temp_log_file:
      shutil.rmtree(os.path.dirname(args.system_log_file))
Beispiel #6
0
def RunTestOnFuchsiaDevice(script_cmd):
  """Preps Fuchsia device with pave and package update, then runs script."""

  parser = argparse.ArgumentParser()
  AddCommonArgs(parser)
  AddTargetSpecificArgs(parser)
  runner_script_args, test_args = parser.parse_known_args()
  ConfigureLogging(runner_script_args)

  # If out_dir is not set, assume the script is being launched
  # from the output directory.
  if not runner_script_args.out_dir:
    runner_script_args.out_dir = os.getcwd()

  # Create a temporary log file that Telemetry will look to use to build
  # an artifact when tests fail.
  temp_log_file = False
  if not runner_script_args.system_log_file:
    runner_script_args.system_log_file = os.path.join(tempfile.mkdtemp(),
                                                      'system-log')
    temp_log_file = True

  package_names = ['web_engine_with_webui', 'web_engine_shell']
  web_engine_dir = os.path.join(runner_script_args.out_dir, 'gen', 'fuchsia',
                                'engine')

  # Pass all other arguments to the gpu integration tests.
  script_cmd.extend(test_args)
  listener_process = None
  symbolizer_process = None
  try:
    with GetDeploymentTargetForArgs(runner_script_args) as target:
      target.Start()
      fuchsia_device_address, fuchsia_ssh_port = target._GetEndpoint()
      script_cmd.extend(
          ['--chromium-output-directory', runner_script_args.out_dir])
      script_cmd.extend(['--fuchsia-device-address', fuchsia_device_address])
      script_cmd.extend(['--fuchsia-ssh-config', target._GetSshConfigPath()])
      if fuchsia_ssh_port:
        script_cmd.extend(['--fuchsia-ssh-port', str(fuchsia_ssh_port)])
      script_cmd.extend(
          ['--fuchsia-system-log-file', runner_script_args.system_log_file])
      # Add to the script
      if runner_script_args.verbose:
        script_cmd.append('-v')

      # Set up logging of WebEngine
      listener_process = target.RunCommandPiped(['log_listener'],
                                                stdout=subprocess.PIPE,
                                                stderr=subprocess.STDOUT)
      build_ids_paths = map(
          lambda package_name: os.path.join(web_engine_dir, package_name,
                                            'ids.txt'), package_names)
      symbolizer_process = RunSymbolizer(
          listener_process.stdout, open(runner_script_args.system_log_file,
                                        'w'), build_ids_paths)

      # Keep the Amber repository live while the test runs.
      with target.GetAmberRepo():
        # Install necessary packages on the device.
        far_files = map(
            lambda package_name: os.path.join(web_engine_dir, package_name,
                                              package_name + '.far'),
            package_names)
        target.InstallPackage(far_files)
        return subprocess.call(script_cmd)
  finally:
    if temp_log_file:
      shutil.rmtree(os.path.dirname(runner_script_args.system_log_file))
    if listener_process:
      listener_process.kill()
    if symbolizer_process:
      symbolizer_process.kill()
Beispiel #7
0
def _SymbolizeStream(input_fd, ids_txt_files):
  """Returns a Popen object for a symbolizer process invocation.
  input_fd: The data to symbolize.
  ids_txt_files: A list of ids.txt files which contain symbol data."""

  return RunSymbolizer(input_fd, subprocess.PIPE, ids_txt_files)