[test] Add random seed stress mode to test runner.

NOTRY=true

Review URL: https://codereview.chromium.org/1180473003

Cr-Commit-Position: refs/heads/master@{#28936}
This commit is contained in:
machenbach 2015-06-11 04:42:32 -07:00 committed by Commit bot
parent 84f208949b
commit f3e8c11afd
2 changed files with 37 additions and 7 deletions

View File

@ -301,14 +301,24 @@ def BuildOptions():
result.add_option("--junittestsuite",
help="The testsuite name in the JUnit output file",
default="v8tests")
result.add_option("--random-seed", default=0, dest="random_seed",
result.add_option("--random-seed", default=0, dest="random_seed", type="int",
help="Default seed for initializing random generator")
result.add_option("--random-seed-stress-count", default=1, type="int",
dest="random_seed_stress_count",
help="Number of runs with different random seeds")
result.add_option("--msan",
help="Regard test expectations for MSAN",
default=False, action="store_true")
return result
def RandomSeed():
seed = 0
while not seed:
seed = random.SystemRandom().randint(-2147483648, 2147483647)
return seed
def ProcessOptions(options):
global VARIANT_FLAGS
global VARIANTS
@ -373,8 +383,8 @@ def ProcessOptions(options):
if options.j == 0:
options.j = multiprocessing.cpu_count()
while options.random_seed == 0:
options.random_seed = random.SystemRandom().randint(-2147483648, 2147483647)
if options.random_seed_stress_count <= 1 and options.random_seed == 0:
options.random_seed = RandomSeed()
def excl(*args):
"""Returns true if zero or one of multiple arguments are true."""
@ -596,9 +606,28 @@ def Execute(arch, mode, args, options, suites, workspace):
verbose.PrintTestSource(s.tests)
continue
variant_flags = [VARIANT_FLAGS[var] for var in VARIANTS]
s.tests = [ t.CopyAddingFlags(v)
variant_tests = [ t.CopyAddingFlags(v)
for t in s.tests
for v in s.VariantFlags(t, variant_flags) ]
if options.random_seed_stress_count > 1:
# Duplicate test for random seed stress mode.
def iter_seed_flags():
for i in range(0, options.random_seed_stress_count):
# Use given random seed for all runs (set by default in execution.py)
# or a new random seed if none is specified.
if options.random_seed:
yield []
else:
yield ["--random-seed=%d" % RandomSeed()]
s.tests = [
t.CopyAddingFlags(v)
for t in variant_tests
for v in iter_seed_flags()
]
else:
s.tests = variant_tests
s.tests = ShardTests(s.tests, options.shard_count, options.shard_run)
num_tests += len(s.tests)

View File

@ -277,10 +277,11 @@ class Runner(object):
d8testflag = ["--test"]
if utils.IsWindows():
shell += ".exe"
if self.context.random_seed:
d8testflag += ["--random-seed=%s" % self.context.random_seed]
cmd = (self.context.command_prefix +
[os.path.abspath(os.path.join(self.context.shell_dir, shell))] +
d8testflag +
["--random-seed=%s" % self.context.random_seed] +
test.suite.GetFlagsForTestCase(test, self.context) +
self.context.extra_flags)
return cmd