Skip to content

Commit 5d764de

Browse files
gpsheadvstinner
authored andcommitted
Display the sanitizer config in the regrtest header. (python#105301)
Display the sanitizers present in libregrtest. Having this in the CI output for tests with the relevant environment variable displayed will help make it easier to do what we need to create an equivalent local test run. (cherry picked from commit 852348a)
1 parent ec875d5 commit 5d764de

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Lib/test/libregrtest/main.py

+20
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,26 @@ def display_header(self):
526526
print("== CPU count:", cpu_count)
527527
print("== encodings: locale=%s, FS=%s"
528528
% (locale.getencoding(), sys.getfilesystemencoding()))
529+
asan = support.check_sanitizer(address=True)
530+
msan = support.check_sanitizer(memory=True)
531+
ubsan = support.check_sanitizer(ub=True)
532+
# This makes it easier to remember what to set in your local
533+
# environment when trying to reproduce a sanitizer failure.
534+
if asan or msan or ubsan:
535+
names = [n for n in (asan and "address",
536+
msan and "memory",
537+
ubsan and "undefined behavior")
538+
if n]
539+
print(f"== sanitizers: {', '.join(names)}")
540+
a_opts = os.environ.get("ASAN_OPTIONS")
541+
if asan and a_opts is not None:
542+
print(f"== ASAN_OPTIONS={a_opts}")
543+
m_opts = os.environ.get("ASAN_OPTIONS")
544+
if msan and m_opts is not None:
545+
print(f"== MSAN_OPTIONS={m_opts}")
546+
ub_opts = os.environ.get("UBSAN_OPTIONS")
547+
if ubsan and ub_opts is not None:
548+
print(f"== UBSAN_OPTIONS={ub_opts}")
529549

530550
def no_tests_run(self):
531551
return not any((self.good, self.bad, self.skipped, self.interrupted,

Lib/test/support/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def check_sanitizer(*, address=False, memory=False, ub=False):
408408
)
409409
address_sanitizer = (
410410
'-fsanitize=address' in _cflags or
411-
'--with-memory-sanitizer' in _config_args
411+
'--with-address-sanitizer' in _config_args
412412
)
413413
ub_sanitizer = (
414414
'-fsanitize=undefined' in _cflags or

0 commit comments

Comments
 (0)