Commit baf5a217 authored by machenbach's avatar machenbach Committed by Commit bot

[foozzie] Fix failure state for non-existing source output

BUG=chromium:673246
NOTRY=true
TBR=tandrii@chromium.org,mbarbella@chromium.org

Review-Url: https://codereview.chromium.org/2632623002
Cr-Commit-Position: refs/heads/master@{#42306}
parent 00e98a39
......@@ -8,7 +8,6 @@ V8 correctness fuzzer launcher script.
"""
import argparse
import hashlib
import itertools
import json
import os
......@@ -37,10 +36,6 @@ TIMEOUT = 3
RETURN_PASS = 0
RETURN_FAIL = 2
# The number of hex digits used from the hash of the original source file path.
# Keep the number small to avoid duplicate explosion.
SOURCE_HASH_LENGTH = 3
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
PREAMBLE = [
os.path.join(BASE_PATH, 'v8_mock.js'),
......@@ -248,7 +243,7 @@ def main():
if fail_bailout(second_config_output, suppress.ignore_by_output2):
return RETURN_FAIL
difference, source = suppress.diff(
difference, source_key = suppress.diff(
first_config_output.stdout, second_config_output.stdout)
if difference:
# The first three entries will be parsed by clusterfuzz. Format changes
......@@ -257,7 +252,7 @@ def main():
second_config_label = '%s,%s' % (options.second_arch, options.second_config)
print FAILURE_TEMPLATE % dict(
configs='%s:%s' % (first_config_label, second_config_label),
sources=hashlib.sha1(source).hexdigest()[:SOURCE_HASH_LENGTH],
sources=source_key,
suppression='', # We can't tie bugs to differences.
first_config_label=first_config_label,
second_config_label=second_config_label,
......
......@@ -24,6 +24,7 @@ Alternatively, think about adding a behavior change to v8_suppressions.js
to silence a particular class of problems.
"""
import hashlib
import itertools
import re
......@@ -148,6 +149,10 @@ IGNORE_LINES = [
ALLOWED_LINE_DIFFS = [re.compile(exp) for exp in ALLOWED_LINE_DIFFS]
IGNORE_LINES = [re.compile(exp) for exp in IGNORE_LINES]
# The number of hex digits used from the hash of the original source file path.
# Keep the number small to avoid duplicate explosion.
SOURCE_HASH_LENGTH = 3
ORIGINAL_SOURCE_PREFIX = 'v8-foozzie source: '
def line_pairs(lines):
......@@ -186,13 +191,13 @@ def ignore_by_regexp(line1, line2, allowed):
def diff_output(output1, output2, allowed, ignore1, ignore2):
"""Returns a tuple (difference, source).
"""Returns a tuple (difference, source_key).
The difference is None if there's no difference, otherwise a string
with a readable diff.
The source is a string with the last source output within the test case.
It is the string 'none' if no such output existed.
The source_key is a short hash of the last source output within the test
case. It is the string 'none' if no such output existed.
"""
def useful_line(ignore):
def fun(line):
......@@ -204,7 +209,7 @@ def diff_output(output1, output2, allowed, ignore1, ignore2):
# This keeps track where we are in the original source file of the fuzz
# test case.
source = 'none'
source_key = 'none'
for ((line1, lookahead1), (line2, lookahead2)) in itertools.izip_longest(
line_pairs(lines1), line_pairs(lines2), fillvalue=(None, None)):
......@@ -214,9 +219,9 @@ def diff_output(output1, output2, allowed, ignore1, ignore2):
# One iterator ends earlier.
if line1 is None:
return '+ %s' % short_line_output(line2), source
return '+ %s' % short_line_output(line2), source_key
if line2 is None:
return '- %s' % short_line_output(line1), source
return '- %s' % short_line_output(line1), source_key
# If lines are equal, no further checks are necessary.
if line1 == line2:
......@@ -225,6 +230,7 @@ def diff_output(output1, output2, allowed, ignore1, ignore2):
# are equal.
if line1.startswith(ORIGINAL_SOURCE_PREFIX):
source = line1[len(ORIGINAL_SOURCE_PREFIX):]
source_key = hashlib.sha1(source).hexdigest()[:SOURCE_HASH_LENGTH]
continue
# Look ahead. If next line is a caret, ignore this line.
......@@ -238,11 +244,11 @@ def diff_output(output1, output2, allowed, ignore1, ignore2):
# Lines are different.
return (
'- %s\n+ %s' % (short_line_output(line1), short_line_output(line2)),
source,
source_key,
)
# No difference found.
return None, source
return None, source_key
def get_suppression(arch1, config1, arch2, config2):
......
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