Skip to content

Commit 56a3086

Browse files
committed
gh-110367: Fix regrtest test_worker_output_on_failure() on ASAN build
Set ASAN_OPTIONS="handle_segv=0" env var to run the test.
1 parent 6592976 commit 56a3086

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

Lib/test/support/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,14 @@ def skip_if_sanitizer(reason=None, *, address=False, memory=False, ub=False):
436436
return unittest.skipIf(skip, reason)
437437

438438

439+
def set_sanitizer_env_var(env, option):
440+
for name in ('ASAN_OPTIONS', 'MSAN_OPTIONS', 'UBSAN_OPTIONS'):
441+
if name in env:
442+
env[name] += f':{option}'
443+
else:
444+
env[name] = option
445+
446+
439447
def system_must_validate_cert(f):
440448
"""Skip the test on TLS certificate validation failures."""
441449
@functools.wraps(f)

Lib/test/test_faulthandler.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ def get_output(self, code, filename=None, fd=None):
6767

6868
# Sanitizers must not handle SIGSEGV (ex: for test_enable_fd())
6969
option = 'handle_segv=0'
70-
for name in ('ASAN_OPTIONS', 'MSAN_OPTIONS', 'UBSAN_OPTIONS'):
71-
if name in env:
72-
env[name] += f':{option}'
73-
else:
74-
env[name] = option
70+
support.set_sanitizer_env_var(env, option)
7571

7672
with support.SuppressCrashReport():
7773
process = script_helper.spawn_python('-c', code,

Lib/test/test_regrtest.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,8 @@ def check_output(self, output):
756756
self.check_executed_tests(output, self.tests,
757757
randomize=True, stats=len(self.tests))
758758

759-
def run_tests(self, args):
760-
output = self.run_python(args)
759+
def run_tests(self, args, env=None):
760+
output = self.run_python(args, env=env)
761761
self.check_output(output)
762762

763763
def test_script_regrtest(self):
@@ -1188,6 +1188,11 @@ def test_crashed(self):
11881188
code = 'import faulthandler; faulthandler._sigsegv()'
11891189
crash_test = self.create_test(name="crash", code=code)
11901190

1191+
# Sanitizers must not handle SIGSEGV (ex: for test_enable_fd())
1192+
env = dict(os.environ)
1193+
option = 'handle_segv=0'
1194+
support.set_sanitizer_env_var(env, option)
1195+
11911196
tests = [crash_test]
11921197
output = self.run_tests("-j2", *tests, exitcode=EXITCODE_BAD_TEST)
11931198
self.check_executed_tests(output, tests, failed=crash_test,

0 commit comments

Comments
 (0)