Exemplo n.º 1
0
def ProcessOptions(options):
  global VARIANT_FLAGS
  global VARIANTS

  # Architecture and mode related stuff.
  if options.arch_and_mode:
    options.arch_and_mode = [arch_and_mode.split(".")
        for arch_and_mode in options.arch_and_mode.split(",")]
    options.arch = ",".join([tokens[0] for tokens in options.arch_and_mode])
    options.mode = ",".join([tokens[1] for tokens in options.arch_and_mode])
  options.mode = options.mode.split(",")
  for mode in options.mode:
    if not mode.lower() in MODES:
      print "Unknown mode %s" % mode
      return False
  if options.arch in ["auto", "native"]:
    options.arch = ARCH_GUESS
  options.arch = options.arch.split(",")
  for arch in options.arch:
    if not arch in SUPPORTED_ARCHS:
      print "Unknown architecture %s" % arch
      return False

  # Store the final configuration in arch_and_mode list. Don't overwrite
  # predefined arch_and_mode since it is more expressive than arch and mode.
  if not options.arch_and_mode:
    options.arch_and_mode = itertools.product(options.arch, options.mode)

  # Special processing of other options, sorted alphabetically.

  if options.buildbot:
    # Buildbots run presubmit tests as a separate step.
    options.no_presubmit = True
    options.no_network = True
  if options.command_prefix:
    print("Specifying --command-prefix disables network distribution, "
          "running tests locally.")
    options.no_network = True
  options.command_prefix = shlex.split(options.command_prefix)
  options.extra_flags = shlex.split(options.extra_flags)

  if options.gc_stress:
    options.extra_flags += GC_STRESS_FLAGS

  if options.asan:
    options.extra_flags.append("--invoke-weak-callbacks")

  if options.tsan:
    VARIANTS = ["default"]
    suppressions_file = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                     'sanitizers', 'tsan_suppressions.txt')
    tsan_options = '%s suppressions=%s' % (
        os.environ.get('TSAN_OPTIONS', ''), suppressions_file)
    os.environ['TSAN_OPTIONS'] = tsan_options

  if options.j == 0:
    options.j = multiprocessing.cpu_count()

  while options.random_seed == 0:
    options.random_seed = random.SystemRandom().randint(-2147483648, 2147483647)

  def excl(*args):
    """Returns true if zero or one of multiple arguments are true."""
    return reduce(lambda x, y: x + y, args) <= 1

  if not excl(options.no_stress, options.stress_only, options.no_variants,
              bool(options.variants)):
    print("Use only one of --no-stress, --stress-only, --no-variants, "
          "or --variants.")
    return False
  if options.quickcheck:
    VARIANTS = ["default", "stress"]
    options.flaky_tests = "skip"
    options.slow_tests = "skip"
    options.pass_fail_tests = "skip"
  if options.no_stress:
    VARIANTS = ["default", "nocrankshaft"]
  if options.no_variants:
    VARIANTS = ["default"]
  if options.stress_only:
    VARIANTS = ["stress"]
  if options.variants:
    VARIANTS = options.variants.split(",")
    if not set(VARIANTS).issubset(VARIANT_FLAGS.keys()):
      print "All variants must be in %s" % str(VARIANT_FLAGS.keys())
      return False
  if options.predictable:
    VARIANTS = ["default"]
    options.extra_flags.append("--predictable")
    options.extra_flags.append("--verify_predictable")
    options.extra_flags.append("--no-inline-new")

  if not options.shell_dir:
    if options.shell:
      print "Warning: --shell is deprecated, use --shell-dir instead."
      options.shell_dir = os.path.dirname(options.shell)
  if options.valgrind:
    run_valgrind = os.path.join("tools", "run-valgrind.py")
    # This is OK for distributed running, so we don't need to set no_network.
    options.command_prefix = (["python", "-u", run_valgrind] +
                              options.command_prefix)
  def CheckTestMode(name, option):
    if not option in ["run", "skip", "dontcare"]:
      print "Unknown %s mode %s" % (name, option)
      return False
    return True
  if not CheckTestMode("flaky test", options.flaky_tests):
    return False
  if not CheckTestMode("slow test", options.slow_tests):
    return False
  if not CheckTestMode("pass|fail test", options.pass_fail_tests):
    return False
  if not options.no_i18n:
    DEFAULT_TESTS.append("intl")
  return True
Exemplo n.º 2
0
def ProcessOptions(options):
    global VARIANT_FLAGS
    global VARIANTS

    # Architecture and mode related stuff.
    if options.arch_and_mode:
        options.arch_and_mode = [
            arch_and_mode.split(".")
            for arch_and_mode in options.arch_and_mode.split(",")
        ]
        options.arch = ",".join(
            [tokens[0] for tokens in options.arch_and_mode])
        options.mode = ",".join(
            [tokens[1] for tokens in options.arch_and_mode])
    options.mode = options.mode.split(",")
    for mode in options.mode:
        if not mode.lower() in MODES:
            print "Unknown mode %s" % mode
            return False
    if options.arch in ["auto", "native"]:
        options.arch = ARCH_GUESS
    options.arch = options.arch.split(",")
    for arch in options.arch:
        if not arch in SUPPORTED_ARCHS:
            print "Unknown architecture %s" % arch
            return False

    # Store the final configuration in arch_and_mode list. Don't overwrite
    # predefined arch_and_mode since it is more expressive than arch and mode.
    if not options.arch_and_mode:
        options.arch_and_mode = itertools.product(options.arch, options.mode)

    # Special processing of other options, sorted alphabetically.

    if options.buildbot:
        # Buildbots run presubmit tests as a separate step.
        options.no_presubmit = True
        options.no_network = True
    if options.download_data_only:
        options.no_presubmit = True
    if options.command_prefix:
        print(
            "Specifying --command-prefix disables network distribution, "
            "running tests locally.")
        options.no_network = True
    options.command_prefix = shlex.split(options.command_prefix)
    options.extra_flags = shlex.split(options.extra_flags)

    if options.gc_stress:
        options.extra_flags += GC_STRESS_FLAGS

    if options.asan:
        options.extra_flags.append("--invoke-weak-callbacks")
        options.extra_flags.append("--omit-quit")

    if options.msan:
        VARIANTS = ["default"]

    if options.tsan:
        VARIANTS = ["default"]
        suppressions_file = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), 'sanitizers',
            'tsan_suppressions.txt')
        tsan_options = '%s suppressions=%s' % (os.environ.get(
            'TSAN_OPTIONS', ''), suppressions_file)
        os.environ['TSAN_OPTIONS'] = tsan_options

    if options.j == 0:
        options.j = multiprocessing.cpu_count()

    while options.random_seed == 0:
        options.random_seed = random.SystemRandom().randint(
            -2147483648, 2147483647)

    def excl(*args):
        """Returns true if zero or one of multiple arguments are true."""
        return reduce(lambda x, y: x + y, args) <= 1

    if not excl(options.no_stress, options.stress_only, options.no_variants,
                bool(options.variants)):
        print(
            "Use only one of --no-stress, --stress-only, --no-variants, "
            "or --variants.")
        return False
    if options.quickcheck:
        VARIANTS = ["default", "stress"]
        options.flaky_tests = "skip"
        options.slow_tests = "skip"
        options.pass_fail_tests = "skip"
    if options.no_stress:
        VARIANTS = ["default", "nocrankshaft"]
    if options.no_variants:
        VARIANTS = ["default"]
    if options.stress_only:
        VARIANTS = ["stress"]
    if options.variants:
        VARIANTS = options.variants.split(",")
        if not set(VARIANTS).issubset(VARIANT_FLAGS.keys()):
            print "All variants must be in %s" % str(VARIANT_FLAGS.keys())
            return False
    if options.predictable:
        VARIANTS = ["default"]
        options.extra_flags.append("--predictable")
        options.extra_flags.append("--verify_predictable")
        options.extra_flags.append("--no-inline-new")

    if not options.shell_dir:
        if options.shell:
            print "Warning: --shell is deprecated, use --shell-dir instead."
            options.shell_dir = os.path.dirname(options.shell)
    if options.valgrind:
        run_valgrind = os.path.join("tools", "run-valgrind.py")
        # This is OK for distributed running, so we don't need to set no_network.
        options.command_prefix = (["python", "-u", run_valgrind] +
                                  options.command_prefix)

    def CheckTestMode(name, option):
        if not option in ["run", "skip", "dontcare"]:
            print "Unknown %s mode %s" % (name, option)
            return False
        return True

    if not CheckTestMode("flaky test", options.flaky_tests):
        return False
    if not CheckTestMode("slow test", options.slow_tests):
        return False
    if not CheckTestMode("pass|fail test", options.pass_fail_tests):
        return False
    if not options.no_i18n:
        DEFAULT_TESTS.append("intl")
    return True