mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
* Cleanup libregrtest code logging ASAN_OPTIONS. * Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".
This commit is contained in:
parent
a0bb4a39d1
commit
3a1ac87f8f
3 changed files with 39 additions and 25 deletions
|
@ -526,26 +526,33 @@ class Regrtest:
|
||||||
print("== CPU count:", cpu_count)
|
print("== CPU count:", cpu_count)
|
||||||
print("== encodings: locale=%s, FS=%s"
|
print("== encodings: locale=%s, FS=%s"
|
||||||
% (locale.getencoding(), sys.getfilesystemencoding()))
|
% (locale.getencoding(), sys.getfilesystemencoding()))
|
||||||
|
self.display_sanitizers()
|
||||||
|
|
||||||
|
def display_sanitizers(self):
|
||||||
|
# This makes it easier to remember what to set in your local
|
||||||
|
# environment when trying to reproduce a sanitizer failure.
|
||||||
asan = support.check_sanitizer(address=True)
|
asan = support.check_sanitizer(address=True)
|
||||||
msan = support.check_sanitizer(memory=True)
|
msan = support.check_sanitizer(memory=True)
|
||||||
ubsan = support.check_sanitizer(ub=True)
|
ubsan = support.check_sanitizer(ub=True)
|
||||||
# This makes it easier to remember what to set in your local
|
sanitizers = []
|
||||||
# environment when trying to reproduce a sanitizer failure.
|
if asan:
|
||||||
if asan or msan or ubsan:
|
sanitizers.append("address")
|
||||||
names = [n for n in (asan and "address",
|
if msan:
|
||||||
msan and "memory",
|
sanitizers.append("memory")
|
||||||
ubsan and "undefined behavior")
|
if ubsan:
|
||||||
if n]
|
sanitizers.append("undefined behavior")
|
||||||
print(f"== sanitizers: {', '.join(names)}")
|
if not sanitizers:
|
||||||
a_opts = os.environ.get("ASAN_OPTIONS")
|
return
|
||||||
if asan and a_opts is not None:
|
|
||||||
print(f"== ASAN_OPTIONS={a_opts}")
|
print(f"== sanitizers: {', '.join(sanitizers)}")
|
||||||
m_opts = os.environ.get("ASAN_OPTIONS")
|
for sanitizer, env_var in (
|
||||||
if msan and m_opts is not None:
|
(asan, "ASAN_OPTIONS"),
|
||||||
print(f"== MSAN_OPTIONS={m_opts}")
|
(msan, "MSAN_OPTIONS"),
|
||||||
ub_opts = os.environ.get("UBSAN_OPTIONS")
|
(ubsan, "UBSAN_OPTIONS"),
|
||||||
if ubsan and ub_opts is not None:
|
):
|
||||||
print(f"== UBSAN_OPTIONS={ub_opts}")
|
options= os.environ.get(env_var)
|
||||||
|
if sanitizer and options is not None:
|
||||||
|
print(f"== {env_var}={options!r}")
|
||||||
|
|
||||||
def no_tests_run(self):
|
def no_tests_run(self):
|
||||||
return not any((self.good, self.bad, self.skipped, self.interrupted,
|
return not any((self.good, self.bad, self.skipped, self.interrupted,
|
||||||
|
|
|
@ -308,6 +308,13 @@ def collect_os(info_add):
|
||||||
"_PYTHON_PROJECT_BASE",
|
"_PYTHON_PROJECT_BASE",
|
||||||
"_PYTHON_SYSCONFIGDATA_NAME",
|
"_PYTHON_SYSCONFIGDATA_NAME",
|
||||||
"__PYVENV_LAUNCHER__",
|
"__PYVENV_LAUNCHER__",
|
||||||
|
|
||||||
|
# Sanitizer options
|
||||||
|
"ASAN_OPTIONS",
|
||||||
|
"LSAN_OPTIONS",
|
||||||
|
"MSAN_OPTIONS",
|
||||||
|
"TSAN_OPTIONS",
|
||||||
|
"UBSAN_OPTIONS",
|
||||||
))
|
))
|
||||||
for name, value in os.environ.items():
|
for name, value in os.environ.items():
|
||||||
uname = name.upper()
|
uname = name.upper()
|
||||||
|
|
|
@ -407,19 +407,19 @@ def check_sanitizer(*, address=False, memory=False, ub=False):
|
||||||
raise ValueError('At least one of address, memory, or ub must be True')
|
raise ValueError('At least one of address, memory, or ub must be True')
|
||||||
|
|
||||||
|
|
||||||
_cflags = sysconfig.get_config_var('CFLAGS') or ''
|
cflags = sysconfig.get_config_var('CFLAGS') or ''
|
||||||
_config_args = sysconfig.get_config_var('CONFIG_ARGS') or ''
|
config_args = sysconfig.get_config_var('CONFIG_ARGS') or ''
|
||||||
memory_sanitizer = (
|
memory_sanitizer = (
|
||||||
'-fsanitize=memory' in _cflags or
|
'-fsanitize=memory' in cflags or
|
||||||
'--with-memory-sanitizer' in _config_args
|
'--with-memory-sanitizer' in config_args
|
||||||
)
|
)
|
||||||
address_sanitizer = (
|
address_sanitizer = (
|
||||||
'-fsanitize=address' in _cflags or
|
'-fsanitize=address' in cflags or
|
||||||
'--with-address-sanitizer' in _config_args
|
'--with-address-sanitizer' in config_args
|
||||||
)
|
)
|
||||||
ub_sanitizer = (
|
ub_sanitizer = (
|
||||||
'-fsanitize=undefined' in _cflags or
|
'-fsanitize=undefined' in cflags or
|
||||||
'--with-undefined-behavior-sanitizer' in _config_args
|
'--with-undefined-behavior-sanitizer' in config_args
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
(memory and memory_sanitizer) or
|
(memory and memory_sanitizer) or
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue