2022-03-17 08:29:34 +00:00
|
|
|
#!/usr/bin/env python3
|
2017-10-13 08:13:39 +00:00
|
|
|
#
|
|
|
|
# Copyright 2017 the V8 project authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2019-02-18 14:01:33 +00:00
|
|
|
from functools import reduce
|
2017-10-13 08:13:39 +00:00
|
|
|
|
2019-09-16 10:43:46 +00:00
|
|
|
import datetime
|
|
|
|
import json
|
2017-10-13 08:13:39 +00:00
|
|
|
import os
|
|
|
|
import sys
|
2019-09-16 10:43:46 +00:00
|
|
|
import tempfile
|
2017-10-13 08:13:39 +00:00
|
|
|
|
|
|
|
# Adds testrunner to the path hence it has to be imported at the beggining.
|
2021-09-29 14:45:12 +00:00
|
|
|
import testrunner.base_runner as base_runner
|
2017-10-13 08:13:39 +00:00
|
|
|
|
|
|
|
from testrunner.local import utils
|
|
|
|
from testrunner.local.variants import ALL_VARIANTS
|
2018-01-04 10:42:49 +00:00
|
|
|
from testrunner.objects import predictable
|
2018-01-09 17:52:34 +00:00
|
|
|
from testrunner.testproc.execution import ExecutionProc
|
2018-01-15 17:43:18 +00:00
|
|
|
from testrunner.testproc.filter import StatusFileFilterProc, NameFilterProc
|
2018-01-09 17:52:34 +00:00
|
|
|
from testrunner.testproc.loader import LoadProc
|
2018-01-31 09:18:13 +00:00
|
|
|
from testrunner.testproc.seed import SeedProc
|
2021-05-21 12:08:41 +00:00
|
|
|
from testrunner.testproc.sequence import SequenceProc
|
2018-01-12 10:07:56 +00:00
|
|
|
from testrunner.testproc.variant import VariantProc
|
2017-10-13 08:13:39 +00:00
|
|
|
|
|
|
|
|
2019-04-11 08:55:30 +00:00
|
|
|
VARIANTS = ['default']
|
2017-10-13 08:13:39 +00:00
|
|
|
|
|
|
|
MORE_VARIANTS = [
|
2019-04-11 08:55:30 +00:00
|
|
|
'jitless',
|
|
|
|
'stress',
|
2019-05-02 09:16:12 +00:00
|
|
|
'stress_js_bg_compile_wasm_code_gc',
|
2019-04-11 08:55:30 +00:00
|
|
|
'stress_incremental_marking',
|
2017-10-13 08:13:39 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
VARIANT_ALIASES = {
|
2022-06-10 14:25:33 +00:00
|
|
|
# The default for developer workstations.
|
|
|
|
'dev':
|
|
|
|
VARIANTS,
|
|
|
|
# Additional variants, run on all bots.
|
|
|
|
'more':
|
|
|
|
MORE_VARIANTS,
|
|
|
|
# Shortcut for the two above ('more' first - it has the longer running tests)
|
|
|
|
'exhaustive':
|
|
|
|
MORE_VARIANTS + VARIANTS,
|
|
|
|
# Additional variants, run on a subset of bots.
|
|
|
|
'extra': [
|
|
|
|
'nooptimization', 'future', 'no_wasm_traps', 'instruction_scheduling',
|
|
|
|
'always_sparkplug', 'turboshaft'
|
|
|
|
],
|
2017-10-13 08:13:39 +00:00
|
|
|
}
|
|
|
|
|
2020-02-19 13:52:16 +00:00
|
|
|
# Extra flags passed to all tests using the standard test runner.
|
|
|
|
EXTRA_DEFAULT_FLAGS = ['--testing-d8-test-runner']
|
|
|
|
|
2019-04-11 08:55:30 +00:00
|
|
|
GC_STRESS_FLAGS = ['--gc-interval=500', '--stress-compaction',
|
|
|
|
'--concurrent-recompilation-queue-length=64',
|
|
|
|
'--concurrent-recompilation-delay=500',
|
|
|
|
'--concurrent-recompilation',
|
2021-08-03 11:27:54 +00:00
|
|
|
'--stress-flush-code', '--flush-bytecode',
|
2019-04-29 13:53:17 +00:00
|
|
|
'--wasm-code-gc', '--stress-wasm-code-gc']
|
2017-10-13 08:13:39 +00:00
|
|
|
|
2019-04-11 08:55:30 +00:00
|
|
|
RANDOM_GC_STRESS_FLAGS = ['--random-gc-interval=5000',
|
|
|
|
'--stress-compaction-random']
|
2018-01-19 10:41:44 +00:00
|
|
|
|
2017-10-13 08:13:39 +00:00
|
|
|
class StandardTestRunner(base_runner.BaseTestRunner):
|
2019-04-11 08:55:30 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
2019-07-11 14:01:58 +00:00
|
|
|
super(StandardTestRunner, self).__init__(*args, **kwargs)
|
2019-04-11 08:55:30 +00:00
|
|
|
|
2019-07-11 14:01:58 +00:00
|
|
|
self.sancov_dir = None
|
|
|
|
self._variants = None
|
2019-04-11 08:55:30 +00:00
|
|
|
|
2019-04-11 08:58:47 +00:00
|
|
|
@property
|
|
|
|
def framework_name(self):
|
|
|
|
return 'standard_runner'
|
|
|
|
|
2019-04-11 08:55:30 +00:00
|
|
|
def _get_default_suite_names(self):
|
|
|
|
return ['default']
|
|
|
|
|
|
|
|
def _add_parser_options(self, parser):
|
|
|
|
parser.add_option('--novfp3',
|
|
|
|
help='Indicates that V8 was compiled without VFP3'
|
|
|
|
' support',
|
|
|
|
default=False, action='store_true')
|
|
|
|
|
|
|
|
# Variants
|
|
|
|
parser.add_option('--no-variants', '--novariants',
|
|
|
|
help='Deprecated. '
|
|
|
|
'Equivalent to passing --variants=default',
|
|
|
|
default=False, dest='no_variants', action='store_true')
|
2022-05-24 11:18:56 +00:00
|
|
|
parser.add_option(
|
|
|
|
'--variants',
|
|
|
|
help='Comma-separated list of testing variants;'
|
|
|
|
' default: "%s"' % ','.join(ALL_VARIANTS))
|
2019-04-11 08:55:30 +00:00
|
|
|
parser.add_option('--exhaustive-variants',
|
|
|
|
default=False, action='store_true',
|
|
|
|
help='Deprecated. '
|
|
|
|
'Equivalent to passing --variants=exhaustive')
|
|
|
|
|
|
|
|
# Filters
|
|
|
|
parser.add_option('--slow-tests', default='dontcare',
|
|
|
|
help='Regard slow tests (run|skip|dontcare)')
|
|
|
|
parser.add_option('--pass-fail-tests', default='dontcare',
|
|
|
|
help='Regard pass|fail tests (run|skip|dontcare)')
|
|
|
|
parser.add_option('--quickcheck', default=False, action='store_true',
|
|
|
|
help=('Quick check mode (skip slow tests)'))
|
|
|
|
|
|
|
|
# Stress modes
|
|
|
|
parser.add_option('--gc-stress',
|
|
|
|
help='Switch on GC stress mode',
|
|
|
|
default=False, action='store_true')
|
|
|
|
parser.add_option('--random-gc-stress',
|
|
|
|
help='Switch on random GC stress mode',
|
|
|
|
default=False, action='store_true')
|
|
|
|
parser.add_option('--random-seed-stress-count', default=1, type='int',
|
|
|
|
dest='random_seed_stress_count',
|
|
|
|
help='Number of runs with different random seeds. Only '
|
|
|
|
'with test processors: 0 means infinite '
|
|
|
|
'generation.')
|
|
|
|
|
2019-09-16 10:43:46 +00:00
|
|
|
# Extra features.
|
2021-05-21 12:08:41 +00:00
|
|
|
parser.add_option('--max-heavy-tests', default=1, type='int',
|
|
|
|
help='Maximum number of heavy tests run in parallel')
|
2019-09-16 10:43:46 +00:00
|
|
|
parser.add_option('--time', help='Print timing information after running',
|
|
|
|
default=False, action='store_true')
|
|
|
|
|
2019-04-11 08:55:30 +00:00
|
|
|
# Noop
|
|
|
|
parser.add_option('--cfi-vptr',
|
|
|
|
help='Run tests with UBSAN cfi_vptr option.',
|
|
|
|
default=False, action='store_true')
|
|
|
|
parser.add_option('--no-sorting', '--nosorting',
|
|
|
|
help='Don\'t sort tests according to duration of last'
|
|
|
|
' run.',
|
|
|
|
default=False, dest='no_sorting', action='store_true')
|
|
|
|
parser.add_option('--no-presubmit', '--nopresubmit',
|
|
|
|
help='Skip presubmit checks (deprecated)',
|
|
|
|
default=False, dest='no_presubmit', action='store_true')
|
|
|
|
|
|
|
|
# Unimplemented for test processors
|
|
|
|
parser.add_option('--sancov-dir',
|
|
|
|
help='Directory where to collect coverage data')
|
|
|
|
parser.add_option('--flakiness-results',
|
|
|
|
help='Path to a file for storing flakiness json.')
|
|
|
|
|
2022-06-01 07:46:16 +00:00
|
|
|
def _predictable_wrapper(self):
|
|
|
|
return os.path.join(self.v8_root, 'tools', 'predictable_wrapper.py')
|
|
|
|
|
2019-04-11 08:55:30 +00:00
|
|
|
def _process_options(self, options):
|
|
|
|
if options.sancov_dir:
|
|
|
|
self.sancov_dir = options.sancov_dir
|
|
|
|
if not os.path.exists(self.sancov_dir):
|
|
|
|
print('sancov-dir %s doesn\'t exist' % self.sancov_dir)
|
|
|
|
raise base_runner.TestRunnerError()
|
|
|
|
|
|
|
|
if options.gc_stress:
|
|
|
|
options.extra_flags += GC_STRESS_FLAGS
|
|
|
|
|
|
|
|
if options.random_gc_stress:
|
|
|
|
options.extra_flags += RANDOM_GC_STRESS_FLAGS
|
|
|
|
|
|
|
|
if self.build_config.asan:
|
|
|
|
options.extra_flags.append('--invoke-weak-callbacks')
|
|
|
|
|
|
|
|
if options.novfp3:
|
|
|
|
options.extra_flags.append('--noenable-vfp3')
|
|
|
|
|
|
|
|
if options.no_variants: # pragma: no cover
|
|
|
|
print ('Option --no-variants is deprecated. '
|
|
|
|
'Pass --variants=default instead.')
|
|
|
|
assert not options.variants
|
|
|
|
options.variants = 'default'
|
|
|
|
|
|
|
|
if options.exhaustive_variants: # pragma: no cover
|
|
|
|
# TODO(machenbach): Switch infra to --variants=exhaustive after M65.
|
|
|
|
print ('Option --exhaustive-variants is deprecated. '
|
|
|
|
'Pass --variants=exhaustive instead.')
|
|
|
|
# This is used on many bots. It includes a larger set of default
|
|
|
|
# variants.
|
|
|
|
# Other options for manipulating variants still apply afterwards.
|
|
|
|
assert not options.variants
|
|
|
|
options.variants = 'exhaustive'
|
|
|
|
|
|
|
|
if options.quickcheck:
|
|
|
|
assert not options.variants
|
|
|
|
options.variants = 'stress,default'
|
|
|
|
options.slow_tests = 'skip'
|
|
|
|
options.pass_fail_tests = 'skip'
|
|
|
|
|
|
|
|
if self.build_config.predictable:
|
|
|
|
options.variants = 'default'
|
|
|
|
options.extra_flags.append('--predictable')
|
|
|
|
options.extra_flags.append('--verify-predictable')
|
|
|
|
options.extra_flags.append('--no-inline-new')
|
|
|
|
# Add predictable wrapper to command prefix.
|
|
|
|
options.command_prefix = (
|
2022-06-01 07:46:16 +00:00
|
|
|
[sys.executable, self._predictable_wrapper()] + options.command_prefix)
|
2019-04-11 08:55:30 +00:00
|
|
|
|
|
|
|
# TODO(machenbach): Figure out how to test a bigger subset of variants on
|
|
|
|
# msan.
|
|
|
|
if self.build_config.msan:
|
|
|
|
options.variants = 'default'
|
|
|
|
|
|
|
|
if options.variants == 'infra_staging':
|
|
|
|
options.variants = 'exhaustive'
|
|
|
|
|
|
|
|
self._variants = self._parse_variants(options.variants)
|
|
|
|
|
|
|
|
def CheckTestMode(name, option): # pragma: no cover
|
2019-07-11 14:01:58 +00:00
|
|
|
if option not in ['run', 'skip', 'dontcare']:
|
2019-04-11 08:55:30 +00:00
|
|
|
print('Unknown %s mode %s' % (name, option))
|
|
|
|
raise base_runner.TestRunnerError()
|
|
|
|
CheckTestMode('slow test', options.slow_tests)
|
|
|
|
CheckTestMode('pass|fail test', options.pass_fail_tests)
|
|
|
|
if self.build_config.no_i18n:
|
|
|
|
base_runner.TEST_MAP['bot_default'].remove('intl')
|
|
|
|
base_runner.TEST_MAP['default'].remove('intl')
|
|
|
|
# TODO(machenbach): uncomment after infra side lands.
|
|
|
|
# base_runner.TEST_MAP['d8_default'].remove('intl')
|
|
|
|
|
2019-09-16 10:43:46 +00:00
|
|
|
if options.time and not options.json_test_results:
|
|
|
|
# We retrieve the slowest tests from the JSON output file, so create
|
|
|
|
# a temporary output file (which will automatically get deleted on exit)
|
|
|
|
# if the user didn't specify one.
|
|
|
|
self._temporary_json_output_file = tempfile.NamedTemporaryFile(
|
|
|
|
prefix="v8-test-runner-")
|
|
|
|
options.json_test_results = self._temporary_json_output_file.name
|
|
|
|
|
2020-02-19 13:52:16 +00:00
|
|
|
def _runner_flags(self):
|
|
|
|
return EXTRA_DEFAULT_FLAGS
|
|
|
|
|
2019-04-11 08:55:30 +00:00
|
|
|
def _parse_variants(self, aliases_str):
|
|
|
|
# Use developer defaults if no variant was specified.
|
|
|
|
aliases_str = aliases_str or 'dev'
|
|
|
|
aliases = aliases_str.split(',')
|
|
|
|
user_variants = set(reduce(
|
|
|
|
list.__add__, [VARIANT_ALIASES.get(a, [a]) for a in aliases]))
|
|
|
|
|
|
|
|
result = [v for v in ALL_VARIANTS if v in user_variants]
|
|
|
|
if len(result) == len(user_variants):
|
|
|
|
return result
|
|
|
|
|
|
|
|
for v in user_variants:
|
|
|
|
if v not in ALL_VARIANTS:
|
|
|
|
print('Unknown variant: %s' % v)
|
2020-04-07 11:46:07 +00:00
|
|
|
print(' Available variants: %s' % ALL_VARIANTS)
|
|
|
|
print(' Available variant aliases: %s' % VARIANT_ALIASES.keys());
|
2019-04-11 08:55:30 +00:00
|
|
|
raise base_runner.TestRunnerError()
|
|
|
|
assert False, 'Unreachable'
|
|
|
|
|
|
|
|
def _setup_env(self):
|
|
|
|
super(StandardTestRunner, self)._setup_env()
|
|
|
|
|
|
|
|
symbolizer_option = self._get_external_symbolizer_option()
|
|
|
|
|
|
|
|
if self.sancov_dir:
|
|
|
|
os.environ['ASAN_OPTIONS'] = ':'.join([
|
|
|
|
'coverage=1',
|
|
|
|
'coverage_dir=%s' % self.sancov_dir,
|
|
|
|
symbolizer_option,
|
|
|
|
'allow_user_segv_handler=1',
|
|
|
|
])
|
|
|
|
|
|
|
|
def _get_statusfile_variables(self, options):
|
|
|
|
variables = (
|
|
|
|
super(StandardTestRunner, self)._get_statusfile_variables(options))
|
|
|
|
|
|
|
|
variables.update({
|
|
|
|
'gc_stress': options.gc_stress or options.random_gc_stress,
|
|
|
|
'gc_fuzzer': options.random_gc_stress,
|
|
|
|
'novfp3': options.novfp3,
|
|
|
|
})
|
|
|
|
return variables
|
|
|
|
|
2021-06-28 07:36:20 +00:00
|
|
|
def _create_sequence_proc(self, options):
|
|
|
|
"""Create processor for sequencing heavy tests on swarming."""
|
|
|
|
return SequenceProc(options.max_heavy_tests) if options.swarming else None
|
|
|
|
|
2019-04-11 08:55:30 +00:00
|
|
|
def _do_execute(self, tests, args, options):
|
|
|
|
jobs = options.j
|
|
|
|
|
|
|
|
print('>>> Running with test processors')
|
|
|
|
loader = LoadProc(tests)
|
|
|
|
results = self._create_result_tracker(options)
|
|
|
|
indicators = self._create_progress_indicators(
|
|
|
|
tests.test_count_estimate, options)
|
|
|
|
|
|
|
|
outproc_factory = None
|
|
|
|
if self.build_config.predictable:
|
|
|
|
outproc_factory = predictable.get_outproc
|
|
|
|
execproc = ExecutionProc(jobs, outproc_factory)
|
|
|
|
sigproc = self._create_signal_proc()
|
|
|
|
|
|
|
|
procs = [
|
|
|
|
loader,
|
|
|
|
NameFilterProc(args) if args else None,
|
|
|
|
StatusFileFilterProc(options.slow_tests, options.pass_fail_tests),
|
|
|
|
VariantProc(self._variants),
|
|
|
|
StatusFileFilterProc(options.slow_tests, options.pass_fail_tests),
|
|
|
|
self._create_predictable_filter(),
|
|
|
|
self._create_shard_proc(options),
|
|
|
|
self._create_seed_proc(options),
|
2021-06-28 07:36:20 +00:00
|
|
|
self._create_sequence_proc(options),
|
2019-04-11 08:55:30 +00:00
|
|
|
sigproc,
|
|
|
|
] + indicators + [
|
|
|
|
results,
|
|
|
|
self._create_timeout_proc(options),
|
|
|
|
self._create_rerun_proc(options),
|
|
|
|
execproc,
|
|
|
|
]
|
|
|
|
|
|
|
|
self._prepare_procs(procs)
|
|
|
|
|
2019-07-11 14:01:58 +00:00
|
|
|
loader.load_initial_tests(initial_batch_size=options.j * 2)
|
2019-04-11 08:55:30 +00:00
|
|
|
|
|
|
|
# This starts up worker processes and blocks until all tests are
|
|
|
|
# processed.
|
|
|
|
execproc.run()
|
|
|
|
|
|
|
|
for indicator in indicators:
|
|
|
|
indicator.finished()
|
|
|
|
|
|
|
|
if tests.test_count_estimate:
|
|
|
|
percentage = float(results.total) / tests.test_count_estimate * 100
|
|
|
|
else:
|
|
|
|
percentage = 0
|
|
|
|
|
|
|
|
print (('>>> %d base tests produced %d (%d%s)'
|
|
|
|
' non-filtered tests') % (
|
|
|
|
tests.test_count_estimate, results.total, percentage, '%'))
|
|
|
|
|
|
|
|
print('>>> %d tests ran' % (results.total - results.remaining))
|
|
|
|
|
|
|
|
exit_code = utils.EXIT_CODE_PASS
|
|
|
|
if results.failed:
|
|
|
|
exit_code = utils.EXIT_CODE_FAILURES
|
|
|
|
if not results.total:
|
|
|
|
exit_code = utils.EXIT_CODE_NO_TESTS
|
|
|
|
|
2019-09-16 10:43:46 +00:00
|
|
|
if options.time:
|
|
|
|
self._print_durations(options)
|
|
|
|
|
2019-04-11 08:55:30 +00:00
|
|
|
# Indicate if a SIGINT or SIGTERM happened.
|
|
|
|
return max(exit_code, sigproc.exit_code)
|
|
|
|
|
2019-09-16 10:43:46 +00:00
|
|
|
def _print_durations(self, options):
|
|
|
|
|
|
|
|
def format_duration(duration_in_seconds):
|
|
|
|
duration = datetime.timedelta(seconds=duration_in_seconds)
|
|
|
|
time = (datetime.datetime.min + duration).time()
|
|
|
|
return time.strftime('%M:%S:') + '%03i' % int(time.microsecond / 1000)
|
|
|
|
|
|
|
|
def _duration_results_text(test):
|
|
|
|
return [
|
|
|
|
'Test: %s' % test['name'],
|
|
|
|
'Flags: %s' % ' '.join(test['flags']),
|
|
|
|
'Command: %s' % test['command'],
|
|
|
|
'Duration: %s' % format_duration(test['duration']),
|
|
|
|
]
|
|
|
|
|
|
|
|
assert os.path.exists(options.json_test_results)
|
|
|
|
with open(options.json_test_results, "r") as f:
|
2020-10-07 16:43:41 +00:00
|
|
|
output = json.load(f)
|
2019-09-16 10:43:46 +00:00
|
|
|
lines = []
|
|
|
|
for test in output['slowest_tests']:
|
|
|
|
suffix = ''
|
|
|
|
if test.get('marked_slow') is False:
|
|
|
|
suffix = ' *'
|
|
|
|
lines.append(
|
|
|
|
'%s %s%s' % (format_duration(test['duration']),
|
|
|
|
test['name'], suffix))
|
|
|
|
|
|
|
|
# Slowest tests duration details.
|
|
|
|
lines.extend(['', 'Details:', ''])
|
|
|
|
for test in output['slowest_tests']:
|
|
|
|
lines.extend(_duration_results_text(test))
|
|
|
|
print("\n".join(lines))
|
|
|
|
|
2019-04-11 08:55:30 +00:00
|
|
|
def _create_predictable_filter(self):
|
|
|
|
if not self.build_config.predictable:
|
|
|
|
return None
|
|
|
|
return predictable.PredictableFilterProc()
|
|
|
|
|
|
|
|
def _create_seed_proc(self, options):
|
|
|
|
if options.random_seed_stress_count == 1:
|
|
|
|
return None
|
|
|
|
return SeedProc(options.random_seed_stress_count, options.random_seed,
|
|
|
|
options.j * 4)
|
2018-01-31 09:18:13 +00:00
|
|
|
|
2017-10-13 08:13:39 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys.exit(StandardTestRunner().execute())
|