def main(): options = parse_args() # Suppressions are architecture and configuration specific. suppress = v8_suppressions.get_suppression( options.first.arch, options.first.config, options.second.arch, options.second.config, ) # Static bailout based on test case content or metadata. with open(options.testcase) as f: content = f.read() if content_bailout(get_meta_data(content), suppress.ignore_by_metadata): return RETURN_FAIL if content_bailout(content, suppress.ignore_by_content): return RETURN_FAIL first_cmd = v8_commands.Command(options, 'first', options.first.d8, options.first.flags) second_cmd = v8_commands.Command(options, 'second', options.second.d8, options.second.flags) # Sanity checks. Run both configurations with the sanity-checks file only and # bail out early if different. if not options.skip_sanity_checks: first_config_output = first_cmd.run(SANITY_CHECKS) second_config_output = second_cmd.run(SANITY_CHECKS) difference, _ = suppress.diff(first_config_output.stdout, second_config_output.stdout) if difference: # Special source key for sanity checks so that clusterfuzz dedupes all # cases on this in case it's hit. source_key = 'sanity check failed' print_difference(options, source_key, first_cmd, second_cmd, first_config_output, second_config_output, difference) return RETURN_FAIL first_config_output = first_cmd.run(options.testcase, verbose=True) # Early bailout based on first run's output. if pass_bailout(first_config_output, 1): return RETURN_PASS second_config_output = second_cmd.run(options.testcase, verbose=True) # Bailout based on second run's output. if pass_bailout(second_config_output, 2): return RETURN_PASS difference, source = suppress.diff(first_config_output.stdout, second_config_output.stdout) if source: source_key = hashlib.sha1( source).hexdigest()[:ORIGINAL_SOURCE_HASH_LENGTH] else: source_key = ORIGINAL_SOURCE_DEFAULT if difference: # Only bail out due to suppressed output if there was a difference. If a # suppression doesn't show up anymore in the statistics, we might want to # remove it. if fail_bailout(first_config_output, suppress.ignore_by_output1): return RETURN_FAIL if fail_bailout(second_config_output, suppress.ignore_by_output2): return RETURN_FAIL print_difference(options, source_key, first_cmd, second_cmd, first_config_output, second_config_output, difference, source) return RETURN_FAIL # TODO(machenbach): Figure out if we could also return a bug in case there's # no difference, but one of the line suppressions has matched - and without # the match there would be a difference. print('# V8 correctness - pass') return RETURN_PASS
def main(): options = parse_args() # Suppressions are architecture and configuration specific. suppress = v8_suppressions.get_suppression( options.first.arch, options.first.config, options.second.arch, options.second.config, options.skip_suppressions, ) # Static bailout based on test case content or metadata. kwargs = {} if PYTHON3: kwargs['encoding'] = 'utf-8' with open(options.testcase, 'r', **kwargs) as f: content = f.read() if content_bailout(get_meta_data(content), suppress.ignore_by_metadata): return RETURN_FAIL if content_bailout(content, suppress.ignore_by_content): return RETURN_FAIL first_cmd = v8_commands.Command(options, 'first', options.first.d8, options.first.flags) second_cmd = v8_commands.Command(options, 'second', options.second.d8, options.second.flags) # Sanity checks. Run both configurations with the sanity-checks file only and # bail out early if different. if not options.skip_sanity_checks: first_config_output = first_cmd.run(SANITY_CHECKS) second_config_output = second_cmd.run(SANITY_CHECKS) difference, _ = suppress.diff(first_config_output, second_config_output) if difference: # Special source key for sanity checks so that clusterfuzz dedupes all # cases on this in case it's hit. source_key = 'sanity check failed' print_difference(options, source_key, first_cmd, second_cmd, first_config_output, second_config_output, difference) return RETURN_FAIL first_config_output = first_cmd.run(options.testcase, verbose=True) # Early bailout if first run was a timeout. if timeout_bailout(first_config_output, 1): return RETURN_PASS second_config_output = second_cmd.run(options.testcase, verbose=True) # Bailout if second run was a timeout. if timeout_bailout(second_config_output, 2): return RETURN_PASS difference, source = suppress.diff(first_config_output, second_config_output) if difference: # Only bail out due to suppressed output if there was a difference. If a # suppression doesn't show up anymore in the statistics, we might want to # remove it. if fail_bailout(first_config_output, suppress.ignore_by_output1): return RETURN_FAIL if fail_bailout(second_config_output, suppress.ignore_by_output2): return RETURN_FAIL source_key = cluster_failures(source) print_difference(options, source_key, first_cmd, second_cmd, first_config_output, second_config_output, difference, source) return RETURN_FAIL # Show if a crash has happened in one of the runs and no difference was # detected. if first_config_output.HasCrashed(): print('# V8 correctness - C-R-A-S-H 1') elif second_config_output.HasCrashed(): print('# V8 correctness - C-R-A-S-H 2') else: # TODO(machenbach): Figure out if we could also return a bug in case # there's no difference, but one of the line suppressions has matched - # and without the match there would be a difference. print('# V8 correctness - pass') return RETURN_PASS