Example #1
0
    def test_nacl_exe(self):
        nacl_stdout = file_util.create_tempfile_deleted_at_exit(
            prefix='NACL_STDOUT').name
        nacl_stderr = file_util.create_tempfile_deleted_at_exit(
            prefix='NACL_STDERR').name
        with open(nacl_stdout, 'w') as f:
            f.write('NACL STDOUT DATA\n')
        with open(nacl_stderr, 'w') as f:
            f.write('NACL STDERR DATA\n')
        p = chrome_process._TailProxyChromePopen(
            ['python', '-c', _SIMPLE_TEST_PROGRAM],
            stdout=subprocess.PIPE,
            stderr=subprocess.PIPE,
            env={
                'NACL_EXE_STDOUT': nacl_stdout,
                'NACL_EXE_STDERR': nacl_stderr
            })
        _wait_by_busy_loop(p)
        self.assertEqual(0, p.returncode)

        with contextlib.closing(p.stdout), contextlib.closing(p.stderr):
            stdout = p.stdout.read()
            stderr = p.stderr.read()
        self.assertIn('PROGRAM STDOUT DATA\n', stdout)
        self.assertIn('NACL STDOUT DATA\n', stdout)
        self.assertIn('PROGRAM STDERR DATA\n', stderr)
        self.assertIn('NACL STDERR DATA\n', stderr)
Example #2
0
def _create_command_file(command):
    # After gdb is finished, we expect SIGINT is sent to this process.
    command = command + [';', 'kill', '-INT', str(os.getpid())]

    with file_util.create_tempfile_deleted_at_exit(
            prefix='arc-gdb-', suffix='.sh') as command_file:
        # Escape by wrapping double-quotes if an argument contains a white space.
        command_file.write(' '.join('"%s"' % arg if ' ' in arg else arg
                                    for arg in command))
    os.chmod(command_file.name, stat.S_IRWXU)
    return command_file
Example #3
0
def _create_command_file(command):
  # After gdb is finished, we expect SIGINT is sent to this process.
  command = command + [';', 'kill', '-INT', str(os.getpid())]

  with file_util.create_tempfile_deleted_at_exit(
      prefix='arc-gdb-', suffix='.sh') as command_file:
    # Escape by wrapping double-quotes if an argument contains a white space.
    command_file.write(' '.join(
        '"%s"' % arg if ' ' in arg else arg for arg in command))
  os.chmod(command_file.name, stat.S_IRWXU)
  return command_file
Example #4
0
  def test_nacl_exe(self):
    nacl_stdout = file_util.create_tempfile_deleted_at_exit(
        prefix='NACL_STDOUT').name
    nacl_stderr = file_util.create_tempfile_deleted_at_exit(
        prefix='NACL_STDERR').name
    with open(nacl_stdout, 'w') as f:
      f.write('NACL STDOUT DATA\n')
    with open(nacl_stderr, 'w') as f:
      f.write('NACL STDERR DATA\n')
    p = chrome_process._TailProxyChromePopen(
        ['python', '-c', _SIMPLE_TEST_PROGRAM],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE,
        env={'NACL_EXE_STDOUT': nacl_stdout, 'NACL_EXE_STDERR': nacl_stderr})
    _wait_by_busy_loop(p)
    self.assertEqual(0, p.returncode)

    with contextlib.closing(p.stdout), contextlib.closing(p.stderr):
      stdout = p.stdout.read()
      stderr = p.stderr.read()
    self.assertIn('PROGRAM STDOUT DATA\n', stdout)
    self.assertIn('NACL STDOUT DATA\n', stdout)
    self.assertIn('PROGRAM STDERR DATA\n', stderr)
    self.assertIn('NACL STDERR DATA\n', stderr)
Example #5
0
def _generate_apk_to_crx_args(parsed_args, metadata=None,
                              combined_metadata_file=None):
  crx_args = []
  crx_args.extend(parsed_args.apk_path_list)
  if parsed_args.verbose:
    crx_args.extend(['--verbose'])
  if parsed_args.use_test_app:
    crx_args.extend(['--use-test-app'])
  if parsed_args.use_all_play_services:
    crx_args.extend(['--use-all-play-services'])
  if parsed_args.obb_main:
    crx_args.extend(['--obb-main', parsed_args.obb_main])
  if parsed_args.obb_patch:
    crx_args.extend(['--obb-patch', parsed_args.obb_patch])
  if parsed_args.mode == 'system':
    crx_args.extend(['--system'])
  crx_args.extend(['--badging-check', 'suppress'])
  crx_args.extend(['--destructive'])
  if parsed_args.app_template:
    crx_args.extend(['--template', parsed_args.app_template])
  if metadata:
    with file_util.create_tempfile_deleted_at_exit() as metadata_file:
      json.dump(metadata, metadata_file)
    crx_args.extend(['--metadata', metadata_file.name])
  if combined_metadata_file:
    crx_args.extend(['--combined-metadata', combined_metadata_file])
  crx_args.extend(['-o', parsed_args.arc_data_dir])
  additional_permissions = []
  if parsed_args.additional_android_permissions:
    additional_permissions.extend(
        parsed_args.additional_android_permissions.split(','))
  # All Android apps now have an implicit INTERNET permission.
  additional_permissions.append('INTERNET')
  if additional_permissions:
    crx_args.extend(['--additional-android-permissions',
                     ','.join(additional_permissions)])
  return crx_args
Example #6
0
def _maybe_create_output_file(output, prefix):
    """Creates a temporary file if |output| is PIPE."""
    if output != subprocess.PIPE:
        return None
    return file_util.create_tempfile_deleted_at_exit(prefix=prefix)
Example #7
0
def _maybe_create_output_file(output, prefix):
  """Creates a temporary file if |output| is PIPE."""
  if output != subprocess.PIPE:
    return None
  return file_util.create_tempfile_deleted_at_exit(prefix=prefix)