Commit 79dafc83 authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

[foozzie] Refactoring - add an abstraction for an execution

This adds a class representing all values needed for an execution.
It simplifies the parameters passed to formatting functions and
lifts the restriction of a first/second config pair in the options.

This will allow to run more than two configs in a follow up.

No-Try: true
Bug: chromium:1100114
Change-Id: I568253b8ca3220870b8f5af615108140587680a8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2270550Reviewed-by: 's avatarTamer Tas <tmrts@chromium.org>
Reviewed-by: 's avatarLiviu Rau <liviurau@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68583}
parent 73d56f3c
...@@ -87,6 +87,10 @@ CONFIGS = dict( ...@@ -87,6 +87,10 @@ CONFIGS = dict(
], ],
) )
BASELINE_CONFIG = 'ignition'
DEFAULT_CONFIG = 'ignition_turbo'
DEFAULT_D8 = 'd8'
# Return codes. # Return codes.
RETURN_PASS = 0 RETURN_PASS = 0
RETURN_FAIL = 2 RETURN_FAIL = 2
...@@ -202,7 +206,7 @@ class ExecutionArgumentsConfig(object): ...@@ -202,7 +206,7 @@ class ExecutionArgumentsConfig(object):
'--%s-d8', '--%s-d8',
'optional path to %s d8 executable, ' 'optional path to %s d8 executable, '
'default: bundled in the directory of this script', 'default: bundled in the directory of this script',
default='d8') default=DEFAULT_D8)
def make_options(self, options): def make_options(self, options):
def get(name): def get(name):
...@@ -222,6 +226,21 @@ class ExecutionArgumentsConfig(object): ...@@ -222,6 +226,21 @@ class ExecutionArgumentsConfig(object):
return RunOptions(infer_arch(d8), config, d8, flags) return RunOptions(infer_arch(d8), config, d8, flags)
class ExecutionConfig(object):
def __init__(self, options, label):
self.options = options
self.label = label
self.arch = getattr(options, label).arch
self.config = getattr(options, label).config
d8 = getattr(options, label).d8
flags = getattr(options, label).flags
self.command = Command(options, label, d8, flags)
@property
def flags(self):
return self.command.flags
def parse_args(): def parse_args():
first_config_arguments = ExecutionArgumentsConfig('first') first_config_arguments = ExecutionArgumentsConfig('first')
second_config_arguments = ExecutionArgumentsConfig('second') second_config_arguments = ExecutionArgumentsConfig('second')
...@@ -238,8 +257,8 @@ def parse_args(): ...@@ -238,8 +257,8 @@ def parse_args():
help='skip suppressions to reproduce known issues') help='skip suppressions to reproduce known issues')
# Add arguments for each run configuration. # Add arguments for each run configuration.
first_config_arguments.add_arguments(parser, 'ignition') first_config_arguments.add_arguments(parser, BASELINE_CONFIG)
second_config_arguments.add_arguments(parser, 'ignition_turbo') second_config_arguments.add_arguments(parser, DEFAULT_CONFIG)
parser.add_argument('testcase', help='path to test case') parser.add_argument('testcase', help='path to test case')
options = parser.parse_args() options = parser.parse_args()
...@@ -287,12 +306,12 @@ def fail_bailout(output, ignore_by_output_fun): ...@@ -287,12 +306,12 @@ def fail_bailout(output, ignore_by_output_fun):
def format_difference( def format_difference(
options, source_key, first_command, second_command, source_key, first_config, second_config,
first_config_output, second_config_output, difference, source=None): first_config_output, second_config_output, difference, source=None):
# The first three entries will be parsed by clusterfuzz. Format changes # The first three entries will be parsed by clusterfuzz. Format changes
# will require changes on the clusterfuzz side. # will require changes on the clusterfuzz side.
first_config_label = '%s,%s' % (options.first.arch, options.first.config) first_config_label = '%s,%s' % (first_config.arch, first_config.config)
second_config_label = '%s,%s' % (options.second.arch, options.second.config) second_config_label = '%s,%s' % (second_config.arch, second_config.config)
source_file_text = SOURCE_FILE_TEMPLATE % source if source else '' source_file_text = SOURCE_FILE_TEMPLATE % source if source else ''
if PYTHON3: if PYTHON3:
...@@ -310,8 +329,8 @@ def format_difference( ...@@ -310,8 +329,8 @@ def format_difference(
suppression='', # We can't tie bugs to differences. suppression='', # We can't tie bugs to differences.
first_config_label=first_config_label, first_config_label=first_config_label,
second_config_label=second_config_label, second_config_label=second_config_label,
first_config_flags=' '.join(first_command.flags), first_config_flags=' '.join(first_config.flags),
second_config_flags=' '.join(second_command.flags), second_config_flags=' '.join(second_config.flags),
first_config_output=first_stdout, first_config_output=first_stdout,
second_config_output=second_stdout, second_config_output=second_stdout,
source=source, source=source,
...@@ -348,14 +367,14 @@ def cluster_failures(source, known_failures=None): ...@@ -348,14 +367,14 @@ def cluster_failures(source, known_failures=None):
return long_key[:ORIGINAL_SOURCE_HASH_LENGTH] return long_key[:ORIGINAL_SOURCE_HASH_LENGTH]
def run_sanity_checks(options, suppress, first_cmd, second_cmd): def run_sanity_checks(suppress, first_config, second_config):
"""Run some fixed smoke tests in all configs to ensure nothing """Run some fixed smoke tests in all configs to ensure nothing
is fundamentally wrong, in order to prevent bug flooding. is fundamentally wrong, in order to prevent bug flooding.
""" """
first_config_output = first_cmd.run( first_config_output = first_config.command.run(
SANITY_CHECKS, timeout=SANITY_CHECK_TIMEOUT_SEC) SANITY_CHECKS, timeout=SANITY_CHECK_TIMEOUT_SEC)
second_config_output = second_cmd.run( second_config_output = second_config.command.run(
SANITY_CHECKS, timeout=SANITY_CHECK_TIMEOUT_SEC) SANITY_CHECKS, timeout=SANITY_CHECK_TIMEOUT_SEC)
difference, _ = suppress.diff(first_config_output, second_config_output) difference, _ = suppress.diff(first_config_output, second_config_output)
...@@ -364,7 +383,7 @@ def run_sanity_checks(options, suppress, first_cmd, second_cmd): ...@@ -364,7 +383,7 @@ def run_sanity_checks(options, suppress, first_cmd, second_cmd):
# cases on this in case it's hit. # cases on this in case it's hit.
source_key = 'sanity check failed' source_key = 'sanity check failed'
raise FailException(format_difference( raise FailException(format_difference(
options, source_key, first_cmd, second_cmd, source_key, first_config, second_config,
first_config_output, second_config_output, difference)) first_config_output, second_config_output, difference))
...@@ -381,20 +400,18 @@ def main(): ...@@ -381,20 +400,18 @@ def main():
content_bailout(get_meta_data(content), suppress.ignore_by_metadata) content_bailout(get_meta_data(content), suppress.ignore_by_metadata)
content_bailout(content, suppress.ignore_by_content) content_bailout(content, suppress.ignore_by_content)
first_cmd = Command( first_config = ExecutionConfig(options, 'first')
options, 'first', options.first.d8, options.first.flags) second_config = ExecutionConfig(options, 'second')
second_cmd = Command(
options, 'second', options.second.d8, options.second.flags)
# Sanity checks. Run both configurations with the sanity-checks file only and # Sanity checks. Run both configurations with the sanity-checks file only and
# bail out early if different. # bail out early if different.
if not options.skip_sanity_checks: if not options.skip_sanity_checks:
run_sanity_checks(options, suppress, first_cmd, second_cmd) run_sanity_checks(suppress, first_config, second_config)
first_config_output = first_cmd.run( first_config_output = first_config.command.run(
options.testcase, timeout=TEST_TIMEOUT_SEC, verbose=True) options.testcase, timeout=TEST_TIMEOUT_SEC, verbose=True)
second_config_output = second_cmd.run( second_config_output = second_config.command.run(
options.testcase, timeout=TEST_TIMEOUT_SEC, verbose=True) options.testcase, timeout=TEST_TIMEOUT_SEC, verbose=True)
difference, source = suppress.diff(first_config_output, second_config_output) difference, source = suppress.diff(first_config_output, second_config_output)
...@@ -408,7 +425,7 @@ def main(): ...@@ -408,7 +425,7 @@ def main():
source_key = cluster_failures(source) source_key = cluster_failures(source)
raise FailException(format_difference( raise FailException(format_difference(
options, source_key, first_cmd, second_cmd, source_key, first_config, second_config,
first_config_output, second_config_output, difference, source)) first_config_output, second_config_output, difference, source))
# Show if a crash has happened in one of the runs and no difference was # Show if a crash has happened in one of the runs and no difference was
......
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