Example #1
0
def _AddTargetSpecificationArgs(arg_parser):
    """Returns a parser that handles the target type used for the test run."""

    device_args = arg_parser.add_argument_group(
        'target',
        'Arguments specifying the Fuchsia target type. To see a list of '
        'arguments available for a specific target type, specify the desired '
        'target to use and add the --help flag.')
    device_args.add_argument(
        '--target-cpu',
        default=GetHostArchFromPlatform(),
        help='GN target_cpu setting for the build. Defaults '
        'to the same architecture as host cpu.')
    device_args.add_argument('--device',
                             default=None,
                             choices=['aemu', 'qemu', 'device', 'custom'],
                             help='Choose to run on aemu|qemu|device. '
                             'By default, Fuchsia will run on AEMU on x64 '
                             'hosts and QEMU on arm64 hosts. Alternatively, '
                             'setting to custom will require specifying the '
                             'subclass of Target class used via the '
                             '--custom-device-target flag.')
    device_args.add_argument('-d',
                             action='store_const',
                             dest='device',
                             const='device',
                             help='Run on device instead of emulator.')
    device_args.add_argument('--custom-device-target',
                             default=None,
                             help='Specify path to file that contains the '
                             'subclass of Target that will be used. Only '
                             'needed if device specific operations such as '
                             'paving is required.')
Example #2
0
def RunSymbolizer(input_file, output_file, build_ids_files):
  """Starts a symbolizer process.

  input_file: Input file to be symbolized.
  output_file: Output file for symbolizer stdout and stderr.
  build_ids_file: Path to the ids.txt file which maps build IDs to
                  unstripped binaries on the filesystem.
  Returns a Popen object for the started process."""

  if (GetHostArchFromPlatform() == 'arm64' and
      os.path.isfile(ARM64_DOCKER_LLVM_SYMBOLIZER_PATH)):
    llvm_symbolizer_path = ARM64_DOCKER_LLVM_SYMBOLIZER_PATH
  else:
    llvm_symbolizer_path = os.path.join(SDK_ROOT, os.pardir, os.pardir,
                                        'llvm-build', 'Release+Asserts', 'bin',
                                        'llvm-symbolizer')

  symbolizer = GetHostToolPathFromPlatform('symbolize')
  symbolizer_cmd = [symbolizer,
                    '-ids-rel', '-llvm-symbolizer', llvm_symbolizer_path,
                    '-build-id-dir', os.path.join(SDK_ROOT, '.build-id')]
  for build_ids_file in build_ids_files:
    symbolizer_cmd.extend(['-ids', build_ids_file])

  logging.info('Running "%s".' % ' '.join(symbolizer_cmd))
  return subprocess.Popen(symbolizer_cmd, stdin=input_file, stdout=output_file,
                          stderr=subprocess.STDOUT, close_fds=True)
Example #3
0
def _GetDefaultEmulatedCpuCoreCount():
    # Revise the processor count on arm64, the trybots on arm64 are in
    # dockers and cannot use all processors.
    # For x64, fvdl always assumes hyperthreading is supported by intel
    # processors, but the cpu_count returns the number regarding if the core
    # is a physical one or a hyperthreading one, so the number should be
    # divided by 2 to avoid creating more threads than the processor
    # supports.
    if GetHostArchFromPlatform() == 'x64':
        return max(int(multiprocessing.cpu_count() / 2) - 1, 4)
    return 4
Example #4
0
def GetZstdPathFromPlatform():
  """Returns path to zstd compression utility based on the current platform."""

  arch = GetHostArchFromPlatform()
  if arch == 'arm64':
    zstd_arch_dir = 'zstd-linux-arm64'
  elif arch == 'x64':
    zstd_arch_dir = 'zstd-linux-x64'
  else:
    raise Exception('zstd path unknown for architecture "%s"' % arch)

  return os.path.join(DIR_SOURCE_ROOT, 'third_party', zstd_arch_dir, 'bin',
                      'zstd')
Example #5
0
def _GetLLVMSymbolizerPath():
  """Determines the path to the LLVM symbolizer executable based on test host
  architecture and Ubuntu distro."""

  if GetHostArchFromPlatform() == 'x64':
    return X64_LLVM_SYMBOLIZER_PATH

  # Get distro codename from /etc/os-release.
  with open(os.path.join('/', 'etc', 'os-release')) as os_release_file:
    os_release_text = os_release_file.read()
  version_codename_re = r'^VERSION_CODENAME=(?P<codename>[\w.-]+)$'
  match = re.search(version_codename_re, os_release_text, re.MULTILINE)
  codename = match.group('codename') if match else None

  if codename == 'xenial':
    return ARM64_XENIAL_LLVM_SYMBOLIZER_PATH
  elif codename == 'bionic':
    return ARM64_BIONIC_LLVM_SYMBOLIZER_PATH
  else:
    raise Exception('Unknown Ubuntu release "%s"' % codename)
Example #6
0
def AddCommonArgs(arg_parser):
    """Adds command line arguments to |arg_parser| for options which are shared
  across test and executable target types.

  Args:
    arg_parser: an ArgumentParser object."""

    package_args = arg_parser.add_argument_group('package', 'Fuchsia Packages')
    package_args.add_argument(
        '--package',
        action='append',
        help='Paths of the packages to install, including '
        'all dependencies.')
    package_args.add_argument(
        '--package-name',
        help='Name of the package to execute, defined in ' +
        'package metadata.')

    common_args = arg_parser.add_argument_group('common', 'Common arguments')
    common_args.add_argument(
        '--output-directory',
        type=os.path.realpath,
        default=None,
        help=('Path to the directory in which build files are located. '))
    common_args.add_argument(
        '--target-cpu',
        default=GetHostArchFromPlatform(),
        help=('GN target_cpu setting for the build. Defaults to the same '
              'architecture as host cpu.'))
    common_args.add_argument('--target-staging-path',
                             help='target path under which to stage packages '
                             'during deployment.',
                             default='/data')
    common_args.add_argument('--device',
                             default=None,
                             choices=['aemu', 'qemu', 'device'],
                             help='Choose to run on aemu|qemu|device. ' +
                             'By default, Fuchsia will run in QEMU.')
    common_args.add_argument('-d',
                             action='store_const',
                             dest='device',
                             const='device',
                             help='Run on device instead of emulator.')
    common_args.add_argument('--host',
                             help='The IP of the target device. ' +
                             'Optional.')
    common_args.add_argument(
        '--node-name',
        help='The node-name of the device to boot or deploy '
        'to. Optional, will use the first discovered '
        'device if omitted.')
    common_args.add_argument(
        '--port',
        '-p',
        type=int,
        default=22,
        help='The port of the SSH service running on the ' +
        'device. Optional.')
    common_args.add_argument('--ssh-config',
                             '-F',
                             help='The path to the SSH configuration used for '
                             'connecting to the target device.')
    common_args.add_argument('--enable-fuchsia-system-log',
                             action='store_true',
                             help='Write the Fuchsia system log to the test '
                             'system_log instead of the Fuchsia kernel log.')
    common_args.add_argument('--fuchsia-out-dir',
                             help='Path to a Fuchsia build output directory. '
                             'Equivalent to setting --ssh_config and '
                             '---os-check=ignore')
    common_args.add_argument('--system-log-file',
                             help='File to write system logs to. Specify - to '
                             'log to stdout.')
    common_args.add_argument('--exclude-system-logs',
                             action='store_false',
                             dest='include_system_logs',
                             help='Do not show system log data.')
    common_args.add_argument('--verbose',
                             '-v',
                             default=False,
                             action='store_true',
                             help='Enable debug-level logging.')
    common_args.add_argument(
        '--qemu-cpu-cores',
        type=int,
        default=4,
        help='Sets the number of CPU cores to provide if launching in a VM.')
    common_args.add_argument(
        '--memory',
        type=int,
        default=2048,
        help='Sets the RAM size (MB) if launching in a VM'),
    common_args.add_argument(
        '--allow-no-kvm',
        action='store_false',
        dest='require_kvm',
        default=True,
        help='Do not require KVM acceleration for emulators.')
    common_args.add_argument(
        '--os_check',
        choices=['check', 'update', 'ignore'],
        default='update',
        help='Sets the OS version enforcement policy. If \'check\', then the '
        'deployment process will halt if the target\'s version doesn\'t '
        'match. If \'update\', then the target device will automatically '
        'be repaved. If \'ignore\', then the OS version won\'t be checked.')

    aemu_args = arg_parser.add_argument_group('aemu', 'AEMU Arguments')
    aemu_args.add_argument(
        '--enable-graphics',
        action='store_true',
        default=False,
        help='Start AEMU with graphics instead of headless.')
    aemu_args.add_argument(
        '--hardware-gpu',
        action='store_true',
        default=False,
        help='Use local GPU hardware instead of Swiftshader.')