Skip to content

Commit af29282

Browse files
authored
gh-110367: Fix regrtest test_worker_output_on_failure() on ASAN build (#110387)
Set ASAN_OPTIONS="handle_segv=0" env var to run the test.
1 parent 2bbbab2 commit af29282

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

Lib/test/support/__init__.py

+8
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

+1-5
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

+11-4
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ def run_command(self, args, input=None, exitcode=0, **kw):
674674
if 'stderr' not in kw:
675675
kw['stderr'] = subprocess.STDOUT
676676
proc = subprocess.run(args,
677-
universal_newlines=True,
677+
text=True,
678678
input=input,
679679
stdout=subprocess.PIPE,
680680
**kw)
@@ -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):
@@ -2061,7 +2061,14 @@ def test_crash(self):
20612061
""")
20622062
testname = self.create_test(code=code)
20632063

2064-
output = self.run_tests("-j1", testname, exitcode=EXITCODE_BAD_TEST)
2064+
# Sanitizers must not handle SIGSEGV (ex: for test_enable_fd())
2065+
env = dict(os.environ)
2066+
option = 'handle_segv=0'
2067+
support.set_sanitizer_env_var(env, option)
2068+
2069+
output = self.run_tests("-j1", testname,
2070+
exitcode=EXITCODE_BAD_TEST,
2071+
env=env)
20652072
self.check_executed_tests(output, testname,
20662073
failed=[testname],
20672074
stats=0, parallel=True)

0 commit comments

Comments
 (0)