Commit 73bbdbfd authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

[test] Clean-up: Fix indentation and quotation

This has no logic changes intended.

Bug: v8:8971
Change-Id: I6d35096cd5e0ea189006ba7a5663606f101ccab9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1564051Reviewed-by: 's avatarSergiy Belozorov <sergiyb@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60766}
parent cda583a7
...@@ -29,34 +29,34 @@ from testrunner.utils import random_utils ...@@ -29,34 +29,34 @@ from testrunner.utils import random_utils
ARCH_GUESS = utils.DefaultArch() ARCH_GUESS = utils.DefaultArch()
VARIANTS = ["default"] VARIANTS = ['default']
MORE_VARIANTS = [ MORE_VARIANTS = [
"jitless", 'jitless',
"stress", 'stress',
"stress_background_compile", 'stress_background_compile',
"stress_incremental_marking", 'stress_incremental_marking',
] ]
VARIANT_ALIASES = { VARIANT_ALIASES = {
# The default for developer workstations. # The default for developer workstations.
"dev": VARIANTS, 'dev': VARIANTS,
# Additional variants, run on all bots. # Additional variants, run on all bots.
"more": MORE_VARIANTS, 'more': MORE_VARIANTS,
# Shortcut for the two above ("more" first - it has the longer running tests). # Shortcut for the two above ('more' first - it has the longer running tests).
"exhaustive": MORE_VARIANTS + VARIANTS, 'exhaustive': MORE_VARIANTS + VARIANTS,
# Additional variants, run on a subset of bots. # Additional variants, run on a subset of bots.
"extra": ["nooptimization", "future", "no_wasm_traps"], 'extra': ['nooptimization', 'future', 'no_wasm_traps'],
} }
GC_STRESS_FLAGS = ["--gc-interval=500", "--stress-compaction", GC_STRESS_FLAGS = ['--gc-interval=500', '--stress-compaction',
"--concurrent-recompilation-queue-length=64", '--concurrent-recompilation-queue-length=64',
"--concurrent-recompilation-delay=500", '--concurrent-recompilation-delay=500',
"--concurrent-recompilation", '--concurrent-recompilation',
"--stress-flush-bytecode"] '--stress-flush-bytecode']
RANDOM_GC_STRESS_FLAGS = ["--random-gc-interval=5000", RANDOM_GC_STRESS_FLAGS = ['--random-gc-interval=5000',
"--stress-compaction-random"] '--stress-compaction-random']
PREDICTABLE_WRAPPER = os.path.join( PREDICTABLE_WRAPPER = os.path.join(
...@@ -64,296 +64,296 @@ PREDICTABLE_WRAPPER = os.path.join( ...@@ -64,296 +64,296 @@ PREDICTABLE_WRAPPER = os.path.join(
class StandardTestRunner(base_runner.BaseTestRunner): class StandardTestRunner(base_runner.BaseTestRunner):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(StandardTestRunner, self).__init__(*args, **kwargs) super(StandardTestRunner, self).__init__(*args, **kwargs)
self.sancov_dir = None self.sancov_dir = None
self._variants = None self._variants = None
def _get_default_suite_names(self): def _get_default_suite_names(self):
return ['default'] return ['default']
def _add_parser_options(self, parser): def _add_parser_options(self, parser):
parser.add_option("--novfp3", parser.add_option('--novfp3',
help="Indicates that V8 was compiled without VFP3" help='Indicates that V8 was compiled without VFP3'
" support", ' support',
default=False, action="store_true") default=False, action='store_true')
# Variants # Variants
parser.add_option("--no-variants", "--novariants", parser.add_option('--no-variants', '--novariants',
help="Deprecated. " help='Deprecated. '
"Equivalent to passing --variants=default", 'Equivalent to passing --variants=default',
default=False, dest="no_variants", action="store_true") default=False, dest='no_variants', action='store_true')
parser.add_option("--variants", parser.add_option('--variants',
help="Comma-separated list of testing variants;" help='Comma-separated list of testing variants;'
" default: \"%s\"" % ",".join(VARIANTS)) ' default: "%s"' % ','.join(VARIANTS))
parser.add_option("--exhaustive-variants", parser.add_option('--exhaustive-variants',
default=False, action="store_true", default=False, action='store_true',
help="Deprecated. " help='Deprecated. '
"Equivalent to passing --variants=exhaustive") 'Equivalent to passing --variants=exhaustive')
# Filters # Filters
parser.add_option("--slow-tests", default="dontcare", parser.add_option('--slow-tests', default='dontcare',
help="Regard slow tests (run|skip|dontcare)") help='Regard slow tests (run|skip|dontcare)')
parser.add_option("--pass-fail-tests", default="dontcare", parser.add_option('--pass-fail-tests', default='dontcare',
help="Regard pass|fail tests (run|skip|dontcare)") help='Regard pass|fail tests (run|skip|dontcare)')
parser.add_option("--quickcheck", default=False, action="store_true", parser.add_option('--quickcheck', default=False, action='store_true',
help=("Quick check mode (skip slow tests)")) help=('Quick check mode (skip slow tests)'))
parser.add_option("--dont-skip-slow-simulator-tests", parser.add_option('--dont-skip-slow-simulator-tests',
help="Don't skip more slow tests when using a" help='Don\'t skip more slow tests when using a'
" simulator.", ' simulator.',
default=False, action="store_true", default=False, action='store_true',
dest="dont_skip_simulator_slow_tests") dest='dont_skip_simulator_slow_tests')
# Stress modes # Stress modes
parser.add_option("--gc-stress", parser.add_option('--gc-stress',
help="Switch on GC stress mode", help='Switch on GC stress mode',
default=False, action="store_true") default=False, action='store_true')
parser.add_option("--random-gc-stress", parser.add_option('--random-gc-stress',
help="Switch on random GC stress mode", help='Switch on random GC stress mode',
default=False, action="store_true") default=False, action='store_true')
parser.add_option("--random-seed-stress-count", default=1, type="int", parser.add_option('--random-seed-stress-count', default=1, type='int',
dest="random_seed_stress_count", dest='random_seed_stress_count',
help="Number of runs with different random seeds. Only " help='Number of runs with different random seeds. Only '
"with test processors: 0 means infinite " 'with test processors: 0 means infinite '
"generation.") 'generation.')
# Noop # Noop
parser.add_option("--cfi-vptr", parser.add_option('--cfi-vptr',
help="Run tests with UBSAN cfi_vptr option.", help='Run tests with UBSAN cfi_vptr option.',
default=False, action="store_true") default=False, action='store_true')
parser.add_option("--infra-staging", help="Use new test runner features", parser.add_option('--infra-staging', help='Use new test runner features',
dest='infra_staging', default=None, dest='infra_staging', default=None,
action="store_true") action='store_true')
parser.add_option("--no-infra-staging", parser.add_option('--no-infra-staging',
help="Opt out of new test runner features", help='Opt out of new test runner features',
dest='infra_staging', default=None, dest='infra_staging', default=None,
action="store_false") action='store_false')
parser.add_option("--no-sorting", "--nosorting", parser.add_option('--no-sorting', '--nosorting',
help="Don't sort tests according to duration of last" help='Don\'t sort tests according to duration of last'
" run.", ' run.',
default=False, dest="no_sorting", action="store_true") default=False, dest='no_sorting', action='store_true')
parser.add_option("--no-presubmit", "--nopresubmit", parser.add_option('--no-presubmit', '--nopresubmit',
help='Skip presubmit checks (deprecated)', help='Skip presubmit checks (deprecated)',
default=False, dest="no_presubmit", action="store_true") default=False, dest='no_presubmit', action='store_true')
# Unimplemented for test processors # Unimplemented for test processors
parser.add_option("--sancov-dir", parser.add_option('--sancov-dir',
help="Directory where to collect coverage data") help='Directory where to collect coverage data')
parser.add_option("--cat", help="Print the source of the tests", parser.add_option('--cat', help='Print the source of the tests',
default=False, action="store_true") default=False, action='store_true')
parser.add_option("--flakiness-results", parser.add_option('--flakiness-results',
help="Path to a file for storing flakiness json.") help='Path to a file for storing flakiness json.')
parser.add_option("--time", help="Print timing information after running", parser.add_option('--time', help='Print timing information after running',
default=False, action="store_true") default=False, action='store_true')
parser.add_option("--warn-unused", help="Report unused rules", parser.add_option('--warn-unused', help='Report unused rules',
default=False, action="store_true") default=False, action='store_true')
parser.add_option("--report", default=False, action="store_true", parser.add_option('--report', default=False, action='store_true',
help="Print a summary of the tests to be run") help='Print a summary of the tests to be run')
def _process_options(self, options): def _process_options(self, options):
if options.sancov_dir: if options.sancov_dir:
self.sancov_dir = options.sancov_dir self.sancov_dir = options.sancov_dir
if not os.path.exists(self.sancov_dir): if not os.path.exists(self.sancov_dir):
print("sancov-dir %s doesn't exist" % self.sancov_dir) print('sancov-dir %s doesn\'t exist' % self.sancov_dir)
raise base_runner.TestRunnerError() raise base_runner.TestRunnerError()
if options.gc_stress: if options.gc_stress:
options.extra_flags += GC_STRESS_FLAGS options.extra_flags += GC_STRESS_FLAGS
if options.random_gc_stress: if options.random_gc_stress:
options.extra_flags += RANDOM_GC_STRESS_FLAGS options.extra_flags += RANDOM_GC_STRESS_FLAGS
if self.build_config.asan: if self.build_config.asan:
options.extra_flags.append("--invoke-weak-callbacks") options.extra_flags.append('--invoke-weak-callbacks')
options.extra_flags.append("--omit-quit") options.extra_flags.append('--omit-quit')
if self.build_config.no_snap: if self.build_config.no_snap:
# Speed up slow nosnap runs. Allocation verification is covered by # Speed up slow nosnap runs. Allocation verification is covered by
# running mksnapshot on other builders. # running mksnapshot on other builders.
options.extra_flags.append("--no-turbo-verify-allocation") options.extra_flags.append('--no-turbo-verify-allocation')
if options.novfp3: if options.novfp3:
options.extra_flags.append("--noenable-vfp3") options.extra_flags.append('--noenable-vfp3')
if options.no_variants: # pragma: no cover if options.no_variants: # pragma: no cover
print ("Option --no-variants is deprecated. " print ('Option --no-variants is deprecated. '
"Pass --variants=default instead.") 'Pass --variants=default instead.')
assert not options.variants assert not options.variants
options.variants = "default" options.variants = 'default'
if options.exhaustive_variants: # pragma: no cover if options.exhaustive_variants: # pragma: no cover
# TODO(machenbach): Switch infra to --variants=exhaustive after M65. # TODO(machenbach): Switch infra to --variants=exhaustive after M65.
print ("Option --exhaustive-variants is deprecated. " print ('Option --exhaustive-variants is deprecated. '
"Pass --variants=exhaustive instead.") 'Pass --variants=exhaustive instead.')
# This is used on many bots. It includes a larger set of default # This is used on many bots. It includes a larger set of default
# variants. # variants.
# Other options for manipulating variants still apply afterwards. # Other options for manipulating variants still apply afterwards.
assert not options.variants assert not options.variants
options.variants = "exhaustive" options.variants = 'exhaustive'
if options.quickcheck: if options.quickcheck:
assert not options.variants assert not options.variants
options.variants = "stress,default" options.variants = 'stress,default'
options.slow_tests = "skip" options.slow_tests = 'skip'
options.pass_fail_tests = "skip" options.pass_fail_tests = 'skip'
if self.build_config.predictable: if self.build_config.predictable:
options.variants = "default" options.variants = 'default'
options.extra_flags.append("--predictable") options.extra_flags.append('--predictable')
options.extra_flags.append("--verify-predictable") options.extra_flags.append('--verify-predictable')
options.extra_flags.append("--no-inline-new") options.extra_flags.append('--no-inline-new')
# Add predictable wrapper to command prefix. # Add predictable wrapper to command prefix.
options.command_prefix = ( options.command_prefix = (
[sys.executable, PREDICTABLE_WRAPPER] + options.command_prefix) [sys.executable, PREDICTABLE_WRAPPER] + options.command_prefix)
# TODO(machenbach): Figure out how to test a bigger subset of variants on # TODO(machenbach): Figure out how to test a bigger subset of variants on
# msan. # msan.
if self.build_config.msan: if self.build_config.msan:
options.variants = "default" options.variants = 'default'
if options.variants == "infra_staging": if options.variants == 'infra_staging':
options.variants = "exhaustive" options.variants = 'exhaustive'
self._variants = self._parse_variants(options.variants) self._variants = self._parse_variants(options.variants)
def CheckTestMode(name, option): # pragma: no cover def CheckTestMode(name, option): # pragma: no cover
if not option in ["run", "skip", "dontcare"]: if not option in ['run', 'skip', 'dontcare']:
print("Unknown %s mode %s" % (name, option)) print('Unknown %s mode %s' % (name, option))
raise base_runner.TestRunnerError() raise base_runner.TestRunnerError()
CheckTestMode("slow test", options.slow_tests) CheckTestMode('slow test', options.slow_tests)
CheckTestMode("pass|fail test", options.pass_fail_tests) CheckTestMode('pass|fail test', options.pass_fail_tests)
if self.build_config.no_i18n: if self.build_config.no_i18n:
base_runner.TEST_MAP["bot_default"].remove("intl") base_runner.TEST_MAP['bot_default'].remove('intl')
base_runner.TEST_MAP["default"].remove("intl") base_runner.TEST_MAP['default'].remove('intl')
# TODO(machenbach): uncomment after infra side lands. # TODO(machenbach): uncomment after infra side lands.
# base_runner.TEST_MAP["d8_default"].remove("intl") # base_runner.TEST_MAP['d8_default'].remove('intl')
def _parse_variants(self, aliases_str): def _parse_variants(self, aliases_str):
# Use developer defaults if no variant was specified. # Use developer defaults if no variant was specified.
aliases_str = aliases_str or 'dev' aliases_str = aliases_str or 'dev'
aliases = aliases_str.split(',') aliases = aliases_str.split(',')
user_variants = set(reduce( user_variants = set(reduce(
list.__add__, [VARIANT_ALIASES.get(a, [a]) for a in aliases])) list.__add__, [VARIANT_ALIASES.get(a, [a]) for a in aliases]))
result = [v for v in ALL_VARIANTS if v in user_variants] result = [v for v in ALL_VARIANTS if v in user_variants]
if len(result) == len(user_variants): if len(result) == len(user_variants):
return result return result
for v in user_variants: for v in user_variants:
if v not in ALL_VARIANTS: if v not in ALL_VARIANTS:
print('Unknown variant: %s' % v) print('Unknown variant: %s' % v)
raise base_runner.TestRunnerError() raise base_runner.TestRunnerError()
assert False, 'Unreachable' assert False, 'Unreachable'
def _setup_env(self): def _setup_env(self):
super(StandardTestRunner, self)._setup_env() super(StandardTestRunner, self)._setup_env()
symbolizer_option = self._get_external_symbolizer_option() symbolizer_option = self._get_external_symbolizer_option()
if self.sancov_dir: if self.sancov_dir:
os.environ['ASAN_OPTIONS'] = ":".join([ os.environ['ASAN_OPTIONS'] = ':'.join([
'coverage=1', 'coverage=1',
'coverage_dir=%s' % self.sancov_dir, 'coverage_dir=%s' % self.sancov_dir,
symbolizer_option, symbolizer_option,
"allow_user_segv_handler=1", 'allow_user_segv_handler=1',
]) ])
def _get_statusfile_variables(self, options): def _get_statusfile_variables(self, options):
variables = ( variables = (
super(StandardTestRunner, self)._get_statusfile_variables(options)) super(StandardTestRunner, self)._get_statusfile_variables(options))
simulator_run = ( simulator_run = (
not options.dont_skip_simulator_slow_tests and not options.dont_skip_simulator_slow_tests and
self.build_config.arch in [ self.build_config.arch in [
'arm64', 'arm', 'mipsel', 'mips', 'mips64', 'mips64el', 'ppc', 'arm64', 'arm', 'mipsel', 'mips', 'mips64', 'mips64el', 'ppc',
'ppc64', 's390', 's390x'] and 'ppc64', 's390', 's390x'] and
bool(ARCH_GUESS) and bool(ARCH_GUESS) and
self.build_config.arch != ARCH_GUESS) self.build_config.arch != ARCH_GUESS)
variables.update({ variables.update({
'gc_stress': options.gc_stress or options.random_gc_stress, 'gc_stress': options.gc_stress or options.random_gc_stress,
'gc_fuzzer': options.random_gc_stress, 'gc_fuzzer': options.random_gc_stress,
'novfp3': options.novfp3, 'novfp3': options.novfp3,
'simulator_run': simulator_run, 'simulator_run': simulator_run,
}) })
return variables return variables
def _do_execute(self, tests, args, options): def _do_execute(self, tests, args, options):
jobs = options.j jobs = options.j
print('>>> Running with test processors') print('>>> Running with test processors')
loader = LoadProc(tests) loader = LoadProc(tests)
results = self._create_result_tracker(options) results = self._create_result_tracker(options)
indicators = self._create_progress_indicators( indicators = self._create_progress_indicators(
tests.test_count_estimate, options) tests.test_count_estimate, options)
outproc_factory = None outproc_factory = None
if self.build_config.predictable: if self.build_config.predictable:
outproc_factory = predictable.get_outproc outproc_factory = predictable.get_outproc
execproc = ExecutionProc(jobs, outproc_factory) execproc = ExecutionProc(jobs, outproc_factory)
sigproc = self._create_signal_proc() sigproc = self._create_signal_proc()
procs = [ procs = [
loader, loader,
NameFilterProc(args) if args else None, NameFilterProc(args) if args else None,
StatusFileFilterProc(options.slow_tests, options.pass_fail_tests), StatusFileFilterProc(options.slow_tests, options.pass_fail_tests),
VariantProc(self._variants), VariantProc(self._variants),
StatusFileFilterProc(options.slow_tests, options.pass_fail_tests), StatusFileFilterProc(options.slow_tests, options.pass_fail_tests),
self._create_predictable_filter(), self._create_predictable_filter(),
self._create_shard_proc(options), self._create_shard_proc(options),
self._create_seed_proc(options), self._create_seed_proc(options),
sigproc, sigproc,
] + indicators + [ ] + indicators + [
results, results,
self._create_timeout_proc(options), self._create_timeout_proc(options),
self._create_rerun_proc(options), self._create_rerun_proc(options),
execproc, execproc,
] ]
self._prepare_procs(procs) self._prepare_procs(procs)
loader.load_initial_tests(initial_batch_size=options.j*2) loader.load_initial_tests(initial_batch_size=options.j*2)
# This starts up worker processes and blocks until all tests are # This starts up worker processes and blocks until all tests are
# processed. # processed.
execproc.run() execproc.run()
for indicator in indicators: for indicator in indicators:
indicator.finished() indicator.finished()
if tests.test_count_estimate: if tests.test_count_estimate:
percentage = float(results.total) / tests.test_count_estimate * 100 percentage = float(results.total) / tests.test_count_estimate * 100
else: else:
percentage = 0 percentage = 0
print (('>>> %d base tests produced %d (%d%s)' print (('>>> %d base tests produced %d (%d%s)'
' non-filtered tests') % ( ' non-filtered tests') % (
tests.test_count_estimate, results.total, percentage, '%')) tests.test_count_estimate, results.total, percentage, '%'))
print('>>> %d tests ran' % (results.total - results.remaining)) print('>>> %d tests ran' % (results.total - results.remaining))
exit_code = utils.EXIT_CODE_PASS exit_code = utils.EXIT_CODE_PASS
if results.failed: if results.failed:
exit_code = utils.EXIT_CODE_FAILURES exit_code = utils.EXIT_CODE_FAILURES
if not results.total: if not results.total:
exit_code = utils.EXIT_CODE_NO_TESTS exit_code = utils.EXIT_CODE_NO_TESTS
# Indicate if a SIGINT or SIGTERM happened. # Indicate if a SIGINT or SIGTERM happened.
return max(exit_code, sigproc.exit_code) return max(exit_code, sigproc.exit_code)
def _create_predictable_filter(self): def _create_predictable_filter(self):
if not self.build_config.predictable: if not self.build_config.predictable:
return None return None
return predictable.PredictableFilterProc() return predictable.PredictableFilterProc()
def _create_seed_proc(self, options): def _create_seed_proc(self, options):
if options.random_seed_stress_count == 1: if options.random_seed_stress_count == 1:
return None return None
return SeedProc(options.random_seed_stress_count, options.random_seed, return SeedProc(options.random_seed_stress_count, options.random_seed,
options.j * 4) options.j * 4)
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment