2012-09-24 09:38:46 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# Copyright 2012 the V8 project authors. All rights reserved.
|
|
|
|
# Redistribution and use in source and binary forms, with or without
|
|
|
|
# modification, are permitted provided that the following conditions are
|
|
|
|
# met:
|
|
|
|
#
|
|
|
|
# * Redistributions of source code must retain the above copyright
|
|
|
|
# notice, this list of conditions and the following disclaimer.
|
|
|
|
# * Redistributions in binary form must reproduce the above
|
|
|
|
# copyright notice, this list of conditions and the following
|
|
|
|
# disclaimer in the documentation and/or other materials provided
|
|
|
|
# with the distribution.
|
|
|
|
# * Neither the name of Google Inc. nor the names of its
|
|
|
|
# contributors may be used to endorse or promote products derived
|
|
|
|
# from this software without specific prior written permission.
|
|
|
|
#
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
2013-11-28 13:18:04 +00:00
|
|
|
import itertools
|
2012-09-24 09:38:46 +00:00
|
|
|
import multiprocessing
|
|
|
|
import optparse
|
|
|
|
import os
|
|
|
|
from os.path import join
|
2014-01-30 18:04:33 +00:00
|
|
|
import platform
|
2014-04-10 07:25:49 +00:00
|
|
|
import random
|
2013-01-23 11:41:56 +00:00
|
|
|
import shlex
|
2012-09-24 09:38:46 +00:00
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
|
|
|
|
from testrunner.local import execution
|
|
|
|
from testrunner.local import progress
|
|
|
|
from testrunner.local import testsuite
|
|
|
|
from testrunner.local import utils
|
|
|
|
from testrunner.local import verbose
|
|
|
|
from testrunner.network import network_execution
|
|
|
|
from testrunner.objects import context
|
|
|
|
|
|
|
|
|
|
|
|
ARCH_GUESS = utils.DefaultArch()
|
|
|
|
DEFAULT_TESTS = ["mjsunit", "cctest", "message", "preparser"]
|
|
|
|
TIMEOUT_DEFAULT = 60
|
|
|
|
TIMEOUT_SCALEFACTOR = {"debug" : 4,
|
|
|
|
"release" : 1 }
|
|
|
|
|
|
|
|
# Use this to run several variants of the tests.
|
2013-11-25 17:34:52 +00:00
|
|
|
VARIANT_FLAGS = {
|
|
|
|
"default": [],
|
|
|
|
"stress": ["--stress-opt", "--always-opt"],
|
|
|
|
"nocrankshaft": ["--nocrankshaft"]}
|
|
|
|
|
|
|
|
VARIANTS = ["default", "stress", "nocrankshaft"]
|
|
|
|
|
2012-09-24 09:38:46 +00:00
|
|
|
MODE_FLAGS = {
|
2014-02-25 13:53:06 +00:00
|
|
|
"debug" : ["--nohard-abort", "--nodead-code-elimination",
|
2013-02-21 11:40:37 +00:00
|
|
|
"--nofold-constants", "--enable-slow-asserts",
|
|
|
|
"--debug-code", "--verify-heap"],
|
2014-02-25 13:53:06 +00:00
|
|
|
"release" : ["--nohard-abort", "--nodead-code-elimination",
|
2013-02-21 11:40:37 +00:00
|
|
|
"--nofold-constants"]}
|
2012-09-24 09:38:46 +00:00
|
|
|
|
2014-01-21 12:41:25 +00:00
|
|
|
GC_STRESS_FLAGS = ["--gc-interval=500", "--stress-compaction",
|
|
|
|
"--concurrent-recompilation-queue-length=64",
|
|
|
|
"--concurrent-recompilation-delay=500",
|
|
|
|
"--concurrent-recompilation"]
|
|
|
|
|
2012-10-19 09:55:27 +00:00
|
|
|
SUPPORTED_ARCHS = ["android_arm",
|
2014-03-27 10:06:53 +00:00
|
|
|
"android_arm64",
|
2012-10-19 09:55:27 +00:00
|
|
|
"android_ia32",
|
|
|
|
"arm",
|
|
|
|
"ia32",
|
2014-04-15 16:39:21 +00:00
|
|
|
"mips",
|
2012-10-19 09:55:27 +00:00
|
|
|
"mipsel",
|
2013-04-09 08:39:01 +00:00
|
|
|
"nacl_ia32",
|
|
|
|
"nacl_x64",
|
2014-02-12 09:19:30 +00:00
|
|
|
"x64",
|
2014-03-21 08:47:03 +00:00
|
|
|
"arm64"]
|
2012-10-22 14:13:01 +00:00
|
|
|
# Double the timeout for these:
|
|
|
|
SLOW_ARCHS = ["android_arm",
|
2014-03-27 10:06:53 +00:00
|
|
|
"android_arm64",
|
2012-10-22 14:13:01 +00:00
|
|
|
"android_ia32",
|
|
|
|
"arm",
|
2014-04-15 16:39:21 +00:00
|
|
|
"mips",
|
2013-04-09 08:39:01 +00:00
|
|
|
"mipsel",
|
|
|
|
"nacl_ia32",
|
2014-02-12 09:19:30 +00:00
|
|
|
"nacl_x64",
|
2014-03-21 09:28:26 +00:00
|
|
|
"arm64"]
|
2012-10-19 09:55:27 +00:00
|
|
|
|
2012-09-24 09:38:46 +00:00
|
|
|
|
|
|
|
def BuildOptions():
|
|
|
|
result = optparse.OptionParser()
|
|
|
|
result.add_option("--arch",
|
|
|
|
help=("The architecture to run tests for, "
|
|
|
|
"'auto' or 'native' for auto-detect"),
|
|
|
|
default="ia32,x64,arm")
|
|
|
|
result.add_option("--arch-and-mode",
|
|
|
|
help="Architecture and mode in the format 'arch.mode'",
|
|
|
|
default=None)
|
2014-01-29 15:30:41 +00:00
|
|
|
result.add_option("--asan",
|
|
|
|
help="Regard test expectations for ASAN",
|
|
|
|
default=False, action="store_true")
|
2012-09-24 09:38:46 +00:00
|
|
|
result.add_option("--buildbot",
|
|
|
|
help="Adapt to path structure used on buildbots",
|
|
|
|
default=False, action="store_true")
|
|
|
|
result.add_option("--cat", help="Print the source of the tests",
|
|
|
|
default=False, action="store_true")
|
2013-08-06 14:39:39 +00:00
|
|
|
result.add_option("--flaky-tests",
|
|
|
|
help="Regard tests marked as flaky (run|skip|dontcare)",
|
|
|
|
default="dontcare")
|
2013-11-25 17:34:52 +00:00
|
|
|
result.add_option("--slow-tests",
|
|
|
|
help="Regard slow tests (run|skip|dontcare)",
|
|
|
|
default="dontcare")
|
|
|
|
result.add_option("--pass-fail-tests",
|
|
|
|
help="Regard pass|fail tests (run|skip|dontcare)",
|
|
|
|
default="dontcare")
|
2014-01-21 12:41:25 +00:00
|
|
|
result.add_option("--gc-stress",
|
|
|
|
help="Switch on GC stress mode",
|
|
|
|
default=False, action="store_true")
|
2012-09-24 09:38:46 +00:00
|
|
|
result.add_option("--command-prefix",
|
|
|
|
help="Prepended to each shell command used to run a test",
|
|
|
|
default="")
|
|
|
|
result.add_option("--download-data", help="Download missing test suite data",
|
|
|
|
default=False, action="store_true")
|
|
|
|
result.add_option("--extra-flags",
|
|
|
|
help="Additional flags to pass to each test command",
|
|
|
|
default="")
|
|
|
|
result.add_option("--isolates", help="Whether to test isolates",
|
|
|
|
default=False, action="store_true")
|
|
|
|
result.add_option("-j", help="The number of parallel tasks to run",
|
|
|
|
default=0, type="int")
|
|
|
|
result.add_option("-m", "--mode",
|
|
|
|
help="The test modes in which to run (comma-separated)",
|
|
|
|
default="release,debug")
|
2013-09-19 12:07:03 +00:00
|
|
|
result.add_option("--no-i18n", "--noi18n",
|
|
|
|
help="Skip internationalization tests",
|
|
|
|
default=False, action="store_true")
|
2012-09-24 09:38:46 +00:00
|
|
|
result.add_option("--no-network", "--nonetwork",
|
|
|
|
help="Don't distribute tests on the network",
|
|
|
|
default=(utils.GuessOS() != "linux"),
|
|
|
|
dest="no_network", action="store_true")
|
|
|
|
result.add_option("--no-presubmit", "--nopresubmit",
|
|
|
|
help='Skip presubmit checks',
|
|
|
|
default=False, dest="no_presubmit", action="store_true")
|
2014-04-09 12:57:43 +00:00
|
|
|
result.add_option("--no-snap", "--nosnap",
|
|
|
|
help='Test a build compiled without snapshot.',
|
|
|
|
default=False, dest="no_snap", action="store_true")
|
2012-09-24 09:38:46 +00:00
|
|
|
result.add_option("--no-stress", "--nostress",
|
|
|
|
help="Don't run crankshaft --always-opt --stress-op test",
|
|
|
|
default=False, dest="no_stress", action="store_true")
|
2013-10-31 10:14:02 +00:00
|
|
|
result.add_option("--no-variants", "--novariants",
|
|
|
|
help="Don't run any testing variants",
|
|
|
|
default=False, dest="no_variants", action="store_true")
|
2013-11-25 17:34:52 +00:00
|
|
|
result.add_option("--variants",
|
|
|
|
help="Comma-separated list of testing variants")
|
2012-09-24 09:38:46 +00:00
|
|
|
result.add_option("--outdir", help="Base directory with compile output",
|
|
|
|
default="out")
|
|
|
|
result.add_option("-p", "--progress",
|
|
|
|
help=("The style of progress indicator"
|
|
|
|
" (verbose, dots, color, mono)"),
|
|
|
|
choices=progress.PROGRESS_INDICATORS.keys(), default="mono")
|
2013-12-03 14:24:40 +00:00
|
|
|
result.add_option("--quickcheck", default=False, action="store_true",
|
|
|
|
help=("Quick check mode (skip slow/flaky tests)"))
|
2012-09-24 09:38:46 +00:00
|
|
|
result.add_option("--report", help="Print a summary of the tests to be run",
|
|
|
|
default=False, action="store_true")
|
|
|
|
result.add_option("--shard-count",
|
|
|
|
help="Split testsuites into this number of shards",
|
|
|
|
default=1, type="int")
|
|
|
|
result.add_option("--shard-run",
|
|
|
|
help="Run this shard from the split up tests.",
|
|
|
|
default=1, type="int")
|
|
|
|
result.add_option("--shell", help="DEPRECATED! use --shell-dir", default="")
|
|
|
|
result.add_option("--shell-dir", help="Directory containing executables",
|
|
|
|
default="")
|
2014-02-12 09:19:30 +00:00
|
|
|
result.add_option("--dont-skip-slow-simulator-tests",
|
|
|
|
help="Don't skip more slow tests when using a simulator.",
|
|
|
|
default=False, action="store_true",
|
|
|
|
dest="dont_skip_simulator_slow_tests")
|
2012-09-24 09:38:46 +00:00
|
|
|
result.add_option("--stress-only",
|
|
|
|
help="Only run tests with --always-opt --stress-opt",
|
|
|
|
default=False, action="store_true")
|
|
|
|
result.add_option("--time", help="Print timing information after running",
|
|
|
|
default=False, action="store_true")
|
|
|
|
result.add_option("-t", "--timeout", help="Timeout in seconds",
|
|
|
|
default= -1, type="int")
|
|
|
|
result.add_option("-v", "--verbose", help="Verbose output",
|
|
|
|
default=False, action="store_true")
|
|
|
|
result.add_option("--valgrind", help="Run tests through valgrind",
|
|
|
|
default=False, action="store_true")
|
|
|
|
result.add_option("--warn-unused", help="Report unused rules",
|
|
|
|
default=False, action="store_true")
|
2013-04-11 00:22:26 +00:00
|
|
|
result.add_option("--junitout", help="File name of the JUnit output")
|
|
|
|
result.add_option("--junittestsuite",
|
|
|
|
help="The testsuite name in the JUnit output file",
|
|
|
|
default="v8tests")
|
2014-04-10 07:25:49 +00:00
|
|
|
result.add_option("--random-seed", default=0, dest="random_seed",
|
|
|
|
help="Default seed for initializing random generator")
|
2012-09-24 09:38:46 +00:00
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def ProcessOptions(options):
|
|
|
|
global VARIANT_FLAGS
|
2013-11-25 17:34:52 +00:00
|
|
|
global VARIANTS
|
2012-09-24 09:38:46 +00:00
|
|
|
|
|
|
|
# Architecture and mode related stuff.
|
|
|
|
if options.arch_and_mode:
|
2013-11-28 13:18:04 +00:00
|
|
|
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])
|
2012-09-24 09:38:46 +00:00
|
|
|
options.mode = options.mode.split(",")
|
|
|
|
for mode in options.mode:
|
2013-12-03 14:24:40 +00:00
|
|
|
if not mode.lower() in ["debug", "release", "optdebug"]:
|
2012-09-24 09:38:46 +00:00
|
|
|
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:
|
2012-10-19 09:55:27 +00:00
|
|
|
if not arch in SUPPORTED_ARCHS:
|
2012-09-24 09:38:46 +00:00
|
|
|
print "Unknown architecture %s" % arch
|
|
|
|
return False
|
|
|
|
|
2013-11-28 13:18:04 +00:00
|
|
|
# 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)
|
|
|
|
|
2012-09-24 09:38:46 +00:00
|
|
|
# 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
|
2013-01-23 11:41:56 +00:00
|
|
|
options.command_prefix = shlex.split(options.command_prefix)
|
2013-01-29 13:27:23 +00:00
|
|
|
options.extra_flags = shlex.split(options.extra_flags)
|
2014-01-21 12:41:25 +00:00
|
|
|
|
|
|
|
if options.gc_stress:
|
|
|
|
options.extra_flags += GC_STRESS_FLAGS
|
|
|
|
|
2012-09-24 09:38:46 +00:00
|
|
|
if options.j == 0:
|
|
|
|
options.j = multiprocessing.cpu_count()
|
2013-10-31 10:14:02 +00:00
|
|
|
|
2014-04-10 07:25:49 +00:00
|
|
|
while options.random_seed == 0:
|
|
|
|
options.random_seed = random.SystemRandom().randint(-2147483648, 2147483647)
|
|
|
|
|
2013-10-31 10:14:02 +00:00
|
|
|
def excl(*args):
|
|
|
|
"""Returns true if zero or one of multiple arguments are true."""
|
|
|
|
return reduce(lambda x, y: x + y, args) <= 1
|
|
|
|
|
2013-11-25 17:34:52 +00:00
|
|
|
if not excl(options.no_stress, options.stress_only, options.no_variants,
|
2013-12-03 14:24:40 +00:00
|
|
|
bool(options.variants), options.quickcheck):
|
|
|
|
print("Use only one of --no-stress, --stress-only, --no-variants, "
|
|
|
|
"--variants, or --quickcheck.")
|
2013-10-31 10:14:02 +00:00
|
|
|
return False
|
2012-09-24 09:38:46 +00:00
|
|
|
if options.no_stress:
|
2013-11-25 17:34:52 +00:00
|
|
|
VARIANTS = ["default", "nocrankshaft"]
|
2013-10-31 10:14:02 +00:00
|
|
|
if options.no_variants:
|
2013-11-25 17:34:52 +00:00
|
|
|
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
|
2013-12-03 14:24:40 +00:00
|
|
|
if options.quickcheck:
|
|
|
|
VARIANTS = ["default", "stress"]
|
|
|
|
options.flaky_tests = "skip"
|
|
|
|
options.slow_tests = "skip"
|
|
|
|
options.pass_fail_tests = "skip"
|
|
|
|
|
2012-09-24 09:38:46 +00:00
|
|
|
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.
|
2013-01-23 11:41:56 +00:00
|
|
|
options.command_prefix = (["python", "-u", run_valgrind] +
|
2012-09-24 09:38:46 +00:00
|
|
|
options.command_prefix)
|
2013-11-25 17:34:52 +00:00
|
|
|
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):
|
2013-08-06 14:39:39 +00:00
|
|
|
return False
|
2013-09-19 12:07:03 +00:00
|
|
|
if not options.no_i18n:
|
|
|
|
DEFAULT_TESTS.append("intl")
|
2012-09-24 09:38:46 +00:00
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def ShardTests(tests, shard_count, shard_run):
|
|
|
|
if shard_count < 2:
|
|
|
|
return tests
|
|
|
|
if shard_run < 1 or shard_run > shard_count:
|
|
|
|
print "shard-run not a valid number, should be in [1:shard-count]"
|
|
|
|
print "defaulting back to running all tests"
|
|
|
|
return tests
|
|
|
|
count = 0
|
|
|
|
shard = []
|
|
|
|
for test in tests:
|
|
|
|
if count % shard_count == shard_run - 1:
|
|
|
|
shard.append(test)
|
|
|
|
count += 1
|
|
|
|
return shard
|
|
|
|
|
|
|
|
|
|
|
|
def Main():
|
|
|
|
parser = BuildOptions()
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
if not ProcessOptions(options):
|
|
|
|
parser.print_help()
|
|
|
|
return 1
|
|
|
|
|
|
|
|
exit_code = 0
|
|
|
|
workspace = os.path.abspath(join(os.path.dirname(sys.argv[0]), ".."))
|
|
|
|
if not options.no_presubmit:
|
|
|
|
print ">>> running presubmit tests"
|
|
|
|
code = subprocess.call(
|
|
|
|
[sys.executable, join(workspace, "tools", "presubmit.py")])
|
|
|
|
exit_code = code
|
|
|
|
|
|
|
|
suite_paths = utils.GetSuitePaths(join(workspace, "test"))
|
|
|
|
|
|
|
|
if len(args) == 0:
|
2013-11-26 16:53:04 +00:00
|
|
|
suite_paths = [ s for s in DEFAULT_TESTS if s in suite_paths ]
|
2012-09-24 09:38:46 +00:00
|
|
|
else:
|
|
|
|
args_suites = set()
|
|
|
|
for arg in args:
|
|
|
|
suite = arg.split(os.path.sep)[0]
|
|
|
|
if not suite in args_suites:
|
|
|
|
args_suites.add(suite)
|
2013-11-26 16:53:04 +00:00
|
|
|
suite_paths = [ s for s in args_suites if s in suite_paths ]
|
2012-09-24 09:38:46 +00:00
|
|
|
|
|
|
|
suites = []
|
|
|
|
for root in suite_paths:
|
|
|
|
suite = testsuite.TestSuite.LoadTestSuite(
|
|
|
|
os.path.join(workspace, "test", root))
|
|
|
|
if suite:
|
|
|
|
suites.append(suite)
|
|
|
|
|
|
|
|
if options.download_data:
|
|
|
|
for s in suites:
|
|
|
|
s.DownloadData()
|
|
|
|
|
2013-11-28 13:18:04 +00:00
|
|
|
for (arch, mode) in options.arch_and_mode:
|
2013-12-05 12:37:24 +00:00
|
|
|
try:
|
|
|
|
code = Execute(arch, mode, args, options, suites, workspace)
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
return 2
|
2013-11-28 13:18:04 +00:00
|
|
|
exit_code = exit_code or code
|
2012-09-24 09:38:46 +00:00
|
|
|
return exit_code
|
|
|
|
|
|
|
|
|
|
|
|
def Execute(arch, mode, args, options, suites, workspace):
|
|
|
|
print(">>> Running tests for %s.%s" % (arch, mode))
|
|
|
|
|
|
|
|
shell_dir = options.shell_dir
|
|
|
|
if not shell_dir:
|
|
|
|
if options.buildbot:
|
|
|
|
shell_dir = os.path.join(workspace, options.outdir, mode)
|
|
|
|
mode = mode.lower()
|
|
|
|
else:
|
|
|
|
shell_dir = os.path.join(workspace, options.outdir,
|
|
|
|
"%s.%s" % (arch, mode))
|
|
|
|
shell_dir = os.path.relpath(shell_dir)
|
|
|
|
|
2013-12-03 14:24:40 +00:00
|
|
|
if mode == "optdebug":
|
|
|
|
mode = "debug" # "optdebug" is just an alias.
|
|
|
|
|
2012-09-24 09:38:46 +00:00
|
|
|
# Populate context object.
|
|
|
|
mode_flags = MODE_FLAGS[mode]
|
2012-10-18 14:21:35 +00:00
|
|
|
timeout = options.timeout
|
|
|
|
if timeout == -1:
|
|
|
|
# Simulators are slow, therefore allow a longer default timeout.
|
2012-10-22 14:13:01 +00:00
|
|
|
if arch in SLOW_ARCHS:
|
2013-09-12 07:39:44 +00:00
|
|
|
timeout = 2 * TIMEOUT_DEFAULT;
|
2012-10-18 14:21:35 +00:00
|
|
|
else:
|
|
|
|
timeout = TIMEOUT_DEFAULT;
|
|
|
|
|
2012-10-22 14:13:01 +00:00
|
|
|
timeout *= TIMEOUT_SCALEFACTOR[mode]
|
2012-09-24 09:38:46 +00:00
|
|
|
ctx = context.Context(arch, mode, shell_dir,
|
|
|
|
mode_flags, options.verbose,
|
2012-10-18 14:21:35 +00:00
|
|
|
timeout, options.isolates,
|
2012-09-24 09:38:46 +00:00
|
|
|
options.command_prefix,
|
2013-09-20 09:26:25 +00:00
|
|
|
options.extra_flags,
|
2014-04-10 07:25:49 +00:00
|
|
|
options.no_i18n,
|
|
|
|
options.random_seed)
|
2012-09-24 09:38:46 +00:00
|
|
|
|
2014-02-12 09:19:30 +00:00
|
|
|
# TODO(all): Combine "simulator" and "simulator_run".
|
|
|
|
simulator_run = not options.dont_skip_simulator_slow_tests and \
|
2014-03-21 09:28:26 +00:00
|
|
|
arch in ['arm64', 'arm', 'mips'] and ARCH_GUESS and arch != ARCH_GUESS
|
2012-09-24 09:38:46 +00:00
|
|
|
# Find available test suites and read test cases from them.
|
|
|
|
variables = {
|
|
|
|
"arch": arch,
|
2014-01-29 15:30:41 +00:00
|
|
|
"asan": options.asan,
|
2013-07-24 12:04:29 +00:00
|
|
|
"deopt_fuzzer": False,
|
2014-01-21 12:41:25 +00:00
|
|
|
"gc_stress": options.gc_stress,
|
|
|
|
"isolates": options.isolates,
|
|
|
|
"mode": mode,
|
2013-09-20 13:13:57 +00:00
|
|
|
"no_i18n": options.no_i18n,
|
2014-04-09 12:57:43 +00:00
|
|
|
"no_snap": options.no_snap,
|
2014-02-12 09:19:30 +00:00
|
|
|
"simulator_run": simulator_run,
|
2014-01-31 09:10:56 +00:00
|
|
|
"simulator": utils.UseSimulator(arch),
|
2014-01-21 12:41:25 +00:00
|
|
|
"system": utils.GuessOS(),
|
2012-09-24 09:38:46 +00:00
|
|
|
}
|
|
|
|
all_tests = []
|
|
|
|
num_tests = 0
|
|
|
|
test_id = 0
|
|
|
|
for s in suites:
|
|
|
|
s.ReadStatusFile(variables)
|
|
|
|
s.ReadTestCases(ctx)
|
|
|
|
if len(args) > 0:
|
|
|
|
s.FilterTestCasesByArgs(args)
|
2012-10-23 08:59:53 +00:00
|
|
|
all_tests += s.tests
|
2013-11-25 17:34:52 +00:00
|
|
|
s.FilterTestCasesByStatus(options.warn_unused, options.flaky_tests,
|
|
|
|
options.slow_tests, options.pass_fail_tests)
|
2012-09-24 09:38:46 +00:00
|
|
|
if options.cat:
|
|
|
|
verbose.PrintTestSource(s.tests)
|
|
|
|
continue
|
2013-11-25 17:34:52 +00:00
|
|
|
variant_flags = [VARIANT_FLAGS[var] for var in VARIANTS]
|
2013-10-17 13:09:28 +00:00
|
|
|
s.tests = [ t.CopyAddingFlags(v)
|
|
|
|
for t in s.tests
|
2013-11-25 17:34:52 +00:00
|
|
|
for v in s.VariantFlags(t, variant_flags) ]
|
2012-09-24 09:38:46 +00:00
|
|
|
s.tests = ShardTests(s.tests, options.shard_count, options.shard_run)
|
|
|
|
num_tests += len(s.tests)
|
|
|
|
for t in s.tests:
|
|
|
|
t.id = test_id
|
|
|
|
test_id += 1
|
|
|
|
|
|
|
|
if options.cat:
|
|
|
|
return 0 # We're done here.
|
|
|
|
|
|
|
|
if options.report:
|
|
|
|
verbose.PrintReport(all_tests)
|
|
|
|
|
|
|
|
if num_tests == 0:
|
|
|
|
print "No tests to run."
|
|
|
|
return 0
|
|
|
|
|
|
|
|
# Run the tests, either locally or distributed on the network.
|
|
|
|
try:
|
|
|
|
start_time = time.time()
|
|
|
|
progress_indicator = progress.PROGRESS_INDICATORS[options.progress]()
|
2013-04-11 00:22:26 +00:00
|
|
|
if options.junitout:
|
|
|
|
progress_indicator = progress.JUnitTestProgressIndicator(
|
|
|
|
progress_indicator, options.junitout, options.junittestsuite)
|
2012-09-24 09:38:46 +00:00
|
|
|
|
|
|
|
run_networked = not options.no_network
|
|
|
|
if not run_networked:
|
|
|
|
print("Network distribution disabled, running tests locally.")
|
|
|
|
elif utils.GuessOS() != "linux":
|
|
|
|
print("Network distribution is only supported on Linux, sorry!")
|
|
|
|
run_networked = False
|
|
|
|
peers = []
|
|
|
|
if run_networked:
|
|
|
|
peers = network_execution.GetPeers()
|
|
|
|
if not peers:
|
|
|
|
print("No connection to distribution server; running tests locally.")
|
|
|
|
run_networked = False
|
|
|
|
elif len(peers) == 1:
|
|
|
|
print("No other peers on the network; running tests locally.")
|
|
|
|
run_networked = False
|
|
|
|
elif num_tests <= 100:
|
|
|
|
print("Less than 100 tests, running them locally.")
|
|
|
|
run_networked = False
|
|
|
|
|
|
|
|
if run_networked:
|
|
|
|
runner = network_execution.NetworkedRunner(suites, progress_indicator,
|
|
|
|
ctx, peers, workspace)
|
|
|
|
else:
|
|
|
|
runner = execution.Runner(suites, progress_indicator, ctx)
|
|
|
|
|
|
|
|
exit_code = runner.Run(options.j)
|
|
|
|
if runner.terminate:
|
|
|
|
return exit_code
|
|
|
|
overall_duration = time.time() - start_time
|
|
|
|
except KeyboardInterrupt:
|
2013-12-05 12:37:24 +00:00
|
|
|
raise
|
2012-09-24 09:38:46 +00:00
|
|
|
|
|
|
|
if options.time:
|
|
|
|
verbose.PrintTestDurations(suites, overall_duration)
|
|
|
|
return exit_code
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
sys.exit(Main())
|