Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,3 @@
# Copyright 2018 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.

232
deps/v8/tools/testrunner/outproc/base.py vendored Normal file
View File

@ -0,0 +1,232 @@
# 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.
from itertools import zip_longest
from ..testproc.base import (
DROP_RESULT, DROP_OUTPUT, DROP_PASS_OUTPUT, DROP_PASS_STDOUT)
from ..local import statusfile
from ..testproc.result import Result
import difflib
OUTCOMES_PASS = [statusfile.PASS]
OUTCOMES_FAIL = [statusfile.FAIL]
OUTCOMES_TIMEOUT = [statusfile.TIMEOUT]
OUTCOMES_PASS_OR_TIMEOUT = [statusfile.PASS, statusfile.TIMEOUT]
OUTCOMES_FAIL_OR_TIMEOUT = [statusfile.FAIL, statusfile.TIMEOUT]
OUTCOMES_FAIL_OR_PASS = [statusfile.FAIL, statusfile.PASS]
class BaseOutProc(object):
def process(self, output, reduction=None):
has_unexpected_output = self.has_unexpected_output(output)
if has_unexpected_output:
self.regenerate_expected_files(output)
return self._create_result(has_unexpected_output, output, reduction)
def regenerate_expected_files(self, output):
return
def has_unexpected_output(self, output):
return self.get_outcome(output) not in self.expected_outcomes
def _create_result(self, has_unexpected_output, output, reduction):
"""Creates Result instance. When reduction is passed it tries to drop some
parts of the result to save memory and time needed to send the result
across process boundary. None disables reduction and full result is created.
"""
if reduction == DROP_RESULT:
return None
error_details = \
self._get_error_details(output) if has_unexpected_output else None
if reduction == DROP_OUTPUT:
return Result(has_unexpected_output, None, error_details=error_details)
if not has_unexpected_output:
if reduction == DROP_PASS_OUTPUT:
return Result(has_unexpected_output, None)
if reduction == DROP_PASS_STDOUT:
return Result(has_unexpected_output, output.without_text())
return Result(has_unexpected_output, output, error_details=error_details)
def get_outcome(self, output):
if output.HasCrashed():
return statusfile.CRASH
elif output.HasTimedOut():
return statusfile.TIMEOUT
elif self._has_failed(output):
return statusfile.FAIL
else:
return statusfile.PASS
def _has_failed(self, output):
execution_failed = self._is_failure_output(output)
if self.negative:
return not execution_failed
return execution_failed
def _is_failure_output(self, output):
return output.exit_code != 0
def _get_error_details(self, output):
return None
@property
def negative(self):
return False
@property
def expected_outcomes(self):
raise NotImplementedError()
class Negative(object):
@property
def negative(self):
return True
class PassOutProc(BaseOutProc):
"""Output processor optimized for positive tests expected to PASS."""
def has_unexpected_output(self, output):
return self.get_outcome(output) != statusfile.PASS
@property
def expected_outcomes(self):
return OUTCOMES_PASS
class NegPassOutProc(Negative, PassOutProc):
"""Output processor optimized for negative tests expected to PASS"""
pass
class OutProc(BaseOutProc):
"""Output processor optimized for positive tests with expected outcomes
different than a single PASS.
"""
def __init__(self, expected_outcomes):
self._expected_outcomes = expected_outcomes
@property
def expected_outcomes(self):
return self._expected_outcomes
# TODO(majeski): Inherit from PassOutProc in case of OUTCOMES_PASS and remove
# custom get/set state.
def __getstate__(self):
d = self.__dict__
if self._expected_outcomes is OUTCOMES_PASS:
d = d.copy()
del d['_expected_outcomes']
return d
def __setstate__(self, d):
if '_expected_outcomes' not in d:
d['_expected_outcomes'] = OUTCOMES_PASS
self.__dict__.update(d)
# TODO(majeski): Override __reduce__ to make it deserialize as one instance.
DEFAULT = PassOutProc()
DEFAULT_NEGATIVE = NegPassOutProc()
class ExpectedOutProc(OutProc):
"""Output processor that has is_failure_output depending on comparing the
output with the expected output.
"""
def __init__(self, expected_outcomes, expected_filename,
regenerate_expected_files=False):
super(ExpectedOutProc, self).__init__(expected_outcomes)
self._expected_filename = expected_filename
self._regenerate_expected_files = regenerate_expected_files
def _is_failure_output(self, output):
if output.exit_code != 0:
return True
with open(self._expected_filename, 'r', encoding='utf-8') as f:
expected_lines = f.readlines()
for act_iterator in self._act_block_iterator(output):
for expected, actual in zip_longest(
self._expected_iterator(expected_lines),
act_iterator,
fillvalue=''
):
if expected != actual:
return True
return False
def regenerate_expected_files(self, output):
if not self._regenerate_expected_files:
return
lines = output.stdout.splitlines()
with open(self._expected_filename, 'w') as f:
for _, line in enumerate(lines):
f.write(line+'\n')
def _get_error_details(self, output):
"""Return diff between expected and actual output."""
expected = open(self._expected_filename, 'r', encoding='utf-8').readlines()
actual = output.stdout.splitlines(True)
if expected == actual:
return None
lines = difflib.unified_diff(
expected, actual, fromfile=str(self._expected_filename),
tofile='<actual>')
return 'Output does not match expectation:\n' + ''.join(lines)
def _act_block_iterator(self, output):
"""Iterates over blocks of actual output lines."""
lines = output.stdout.splitlines()
start_index = 0
found_eqeq = False
for index, line in enumerate(lines):
# If a stress test separator is found:
if line.startswith('=='):
# Iterate over all lines before a separator except the first.
if not found_eqeq:
found_eqeq = True
else:
yield self._actual_iterator(lines[start_index:index])
# The next block of output lines starts after the separator.
start_index = index + 1
# Iterate over complete output if no separator was found.
if not found_eqeq:
yield self._actual_iterator(lines)
def _actual_iterator(self, lines):
return self._iterator(lines, self._ignore_actual_line)
def _expected_iterator(self, lines):
return self._iterator(lines, self._ignore_expected_line)
def _ignore_actual_line(self, line):
"""Ignore empty lines, valgrind output, Android output and trace
incremental marking output.
"""
if not line:
return True
return (line.startswith('==') or
line.startswith('**') or
line.startswith('ANDROID') or
line.startswith('###') or
# Android linker warning.
line.startswith('WARNING: linker:') or
# FIXME(machenbach): The test driver shouldn't try to use slow
# asserts if they weren't compiled. This fails in optdebug=2.
line == 'Warning: unknown flag --enable-slow-asserts.' or
line == 'Try --help for options')
def _ignore_expected_line(self, line):
return not line
def _iterator(self, lines, ignore_predicate):
for line in lines:
line = line.strip()
if not ignore_predicate(line):
yield line

View File

@ -0,0 +1,19 @@
# Copyright 2025 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.
import platform
from . import base
# -1 gets converted to 0xff on POSIX and 0xffffffff on Windows.
MINUS_ONE_EXIT_CODE = 0xffffffff if platform.system() == 'Windows' else 0xff
class OutProc(base.OutProc):
"""
Fuzzers are allowed to return -1 or 0 (see
https://llvm.org/docs/LibFuzzer.html#rejecting-unwanted-inputs).
"""
def _is_failure_output(self, output):
return output.exit_code != 0 and output.exit_code != MINUS_ONE_EXIT_CODE

View File

@ -0,0 +1,74 @@
# Copyright 2018 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.
import re
from itertools import zip_longest
from . import base
class OutProc(base.ExpectedOutProc):
def __init__(self, expected_outcomes, basepath, expected_fail,
expected_filename, regenerate_expected_files):
super(OutProc, self).__init__(expected_outcomes, expected_filename,
regenerate_expected_files)
self._basepath = basepath
self._expected_fail = expected_fail
def _is_failure_output(self, output):
fail = output.exit_code != 0
if fail != self._expected_fail:
return True
expected_lines = []
# Can't use utils.ReadLinesFrom() here because it strips whitespace.
with open(self._basepath.with_suffix('.out')) as f:
for line in f:
if line.startswith("#") or not line.strip():
continue
expected_lines.append(line)
raw_lines = output.stdout.splitlines()
actual_lines = [ s for s in raw_lines if not self._ignore_line(s) ]
if len(expected_lines) != len(actual_lines):
return True
# Try .js first, and fall back to .mjs.
# TODO(v8:9406): clean this up by never separating the path from
# the extension in the first place.
base_path = self._basepath.with_suffix('.js')
if not base_path.exists():
base_path = self._basepath.with_suffix('.mjs')
env = {
'basename': base_path.name,
}
for (expected, actual) in zip_longest(
expected_lines, actual_lines, fillvalue=''):
pattern = re.escape(expected.rstrip() % env)
pattern = pattern.replace('\\*', '.*')
pattern = pattern.replace('\\{NUMBER\\}', r'-?\d+(?:\.\d*)?')
# Note: The character sequence for printing an address in C++ is
# implementation defined.
pattern = pattern.replace('\\{ADDRESS\\}', r'(0x)?[0-9A-Fa-f]+')
pattern = '^%s$' % pattern
if not re.match(pattern, actual):
return True
return False
def _ignore_line(self, string):
"""Ignore empty lines, valgrind output, Android output."""
return (
not string or #
not string.strip() or #
string.startswith("==") or #
string.startswith("**") or #
string.startswith("ANDROID") or #
# Android linker warning.
string.startswith('WARNING: linker:') or #
# Testing on Android devices mixes stderr into stdout.
string ==
"V8 is running with experimental features enabled. Stability and security will suffer."
or #
string == "Concurrent maglev has been disabled for tracing.")

View File

@ -0,0 +1,39 @@
# Copyright 2018 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.
import difflib
from . import base
class OutProc(base.OutProc):
def __init__(self, expected_outcomes):
super(OutProc, self).__init__(expected_outcomes)
def _is_failure_output(self, output):
MIN_EXPECTED_LINE_COUNT = 300 # Currently the actual count is 652.
if len(output.stdout.splitlines()) < MIN_EXPECTED_LINE_COUNT:
output.stdout = ("Plausibility check failed. Output too short.\n\n" +
output.stdout)
return True
PLAUSIBILITY_CHECK_EXPECTED_STRINGS = [
"INSTANCE_TYPES = {",
"HEAP_NUMBER_TYPE",
"KNOWN_MAPS = {",
"HeapNumberMap",
"KNOWN_OBJECTS = {",
"TrueValue",
"HEAP_FIRST_PAGES = {",
"FRAME_MARKERS = (",
"INTERPRETED",
]
for expected_string in PLAUSIBILITY_CHECK_EXPECTED_STRINGS:
if not expected_string in output.stdout:
output.stdout = (
"Plausibility check failed. Expected string "
f"'{expected_string}' not found in output.\n") + output.stdout
return True
return False

View File

@ -0,0 +1,33 @@
# Copyright 2018 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.
from . import base
def _is_failure_output(self, output):
return (
output.exit_code != 0 or
'FAILED!' in output.stdout
)
class OutProc(base.OutProc):
"""Optimized for positive tests."""
OutProc._is_failure_output = _is_failure_output
class PassOutProc(base.PassOutProc):
"""Optimized for positive tests expected to PASS."""
PassOutProc._is_failure_output = _is_failure_output
class NegOutProc(base.Negative, OutProc):
pass
class NegPassOutProc(base.Negative, PassOutProc):
pass
MOZILLA_PASS_DEFAULT = PassOutProc()
MOZILLA_PASS_NEGATIVE = NegPassOutProc()

View File

@ -0,0 +1,70 @@
# Copyright 2018 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.
import re
from . import base
def _is_failure_output(output, is_async):
return (output.exit_code != 0 or 'FAILED!' in output.stdout or
(is_async and 'Test262:AsyncTestComplete' not in output.stdout))
class ExceptionOutProc(base.OutProc):
"""Output processor for tests with expected exception."""
def __init__(self,
expected_outcomes,
expected_exception=None,
negative=False,
is_async=False):
super(ExceptionOutProc, self).__init__(expected_outcomes)
self._expected_exception = expected_exception
self._negative = negative
self._async = is_async
@property
def negative(self):
return self._negative
def _is_failure_output(self, output):
if self._expected_exception != self._parse_exception(output.stdout):
return True
return _is_failure_output(output, self._async)
def _parse_exception(self, string):
# somefile:somelinenumber: someerror[: sometext]
# somefile might include an optional drive letter on windows e.g. "e:".
match = re.search(
'^(?:\w:)?[^:]*:[0-9]+: ([^: ]+?)($|: )', string, re.MULTILINE)
if match:
return match.group(1).strip()
else:
return None
class NoExceptionOutProc(base.OutProc):
"""Output processor optimized for tests without expected exception."""
def __init__(self, expected_outcomes, is_async=False):
super(NoExceptionOutProc, self).__init__(expected_outcomes)
self._async = is_async
def _is_failure_output(self, output):
return _is_failure_output(output, self._async)
class PassNoExceptionOutProc(base.PassOutProc):
"""
Output processor optimized for tests expected to PASS without expected
exception.
"""
def __init__(self, is_async=False):
super(PassNoExceptionOutProc, self).__init__()
self._async = is_async
def _is_failure_output(self, output):
return _is_failure_output(output, self._async)

View File

@ -0,0 +1,22 @@
# Copyright 2018 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.
from . import base
class OutProc(base.ExpectedOutProc):
def _is_failure_output(self, output):
if output.exit_code != 0:
return True
if output.exit_code == 0 and not output.stdout.strip():
# Special case for --exit-on-contradictory-flags. It lets tests exit
# fast with exit code 0. Normally passing webkit tests all have output.
return False
return super(OutProc, self)._is_failure_output(output)
def _ignore_expected_line(self, line):
return (
line.startswith('#') or
super(OutProc, self)._ignore_expected_line(line)
)