mirror of
https://github.com/python/cpython.git
synced 2025-09-02 15:07:53 +00:00
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.
This commit is contained in:
parent
2bbbab212f
commit
af29282fce
3 changed files with 20 additions and 9 deletions
|
@ -436,6 +436,14 @@ def skip_if_sanitizer(reason=None, *, address=False, memory=False, ub=False):
|
||||||
return unittest.skipIf(skip, reason)
|
return unittest.skipIf(skip, reason)
|
||||||
|
|
||||||
|
|
||||||
|
def set_sanitizer_env_var(env, option):
|
||||||
|
for name in ('ASAN_OPTIONS', 'MSAN_OPTIONS', 'UBSAN_OPTIONS'):
|
||||||
|
if name in env:
|
||||||
|
env[name] += f':{option}'
|
||||||
|
else:
|
||||||
|
env[name] = option
|
||||||
|
|
||||||
|
|
||||||
def system_must_validate_cert(f):
|
def system_must_validate_cert(f):
|
||||||
"""Skip the test on TLS certificate validation failures."""
|
"""Skip the test on TLS certificate validation failures."""
|
||||||
@functools.wraps(f)
|
@functools.wraps(f)
|
||||||
|
|
|
@ -67,11 +67,7 @@ class FaultHandlerTests(unittest.TestCase):
|
||||||
|
|
||||||
# Sanitizers must not handle SIGSEGV (ex: for test_enable_fd())
|
# Sanitizers must not handle SIGSEGV (ex: for test_enable_fd())
|
||||||
option = 'handle_segv=0'
|
option = 'handle_segv=0'
|
||||||
for name in ('ASAN_OPTIONS', 'MSAN_OPTIONS', 'UBSAN_OPTIONS'):
|
support.set_sanitizer_env_var(env, option)
|
||||||
if name in env:
|
|
||||||
env[name] += f':{option}'
|
|
||||||
else:
|
|
||||||
env[name] = option
|
|
||||||
|
|
||||||
with support.SuppressCrashReport():
|
with support.SuppressCrashReport():
|
||||||
process = script_helper.spawn_python('-c', code,
|
process = script_helper.spawn_python('-c', code,
|
||||||
|
|
|
@ -674,7 +674,7 @@ class BaseTestCase(unittest.TestCase):
|
||||||
if 'stderr' not in kw:
|
if 'stderr' not in kw:
|
||||||
kw['stderr'] = subprocess.STDOUT
|
kw['stderr'] = subprocess.STDOUT
|
||||||
proc = subprocess.run(args,
|
proc = subprocess.run(args,
|
||||||
universal_newlines=True,
|
text=True,
|
||||||
input=input,
|
input=input,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
**kw)
|
**kw)
|
||||||
|
@ -756,8 +756,8 @@ class ProgramsTestCase(BaseTestCase):
|
||||||
self.check_executed_tests(output, self.tests,
|
self.check_executed_tests(output, self.tests,
|
||||||
randomize=True, stats=len(self.tests))
|
randomize=True, stats=len(self.tests))
|
||||||
|
|
||||||
def run_tests(self, args):
|
def run_tests(self, args, env=None):
|
||||||
output = self.run_python(args)
|
output = self.run_python(args, env=env)
|
||||||
self.check_output(output)
|
self.check_output(output)
|
||||||
|
|
||||||
def test_script_regrtest(self):
|
def test_script_regrtest(self):
|
||||||
|
@ -2061,7 +2061,14 @@ class ArgsTestCase(BaseTestCase):
|
||||||
""")
|
""")
|
||||||
testname = self.create_test(code=code)
|
testname = self.create_test(code=code)
|
||||||
|
|
||||||
output = self.run_tests("-j1", testname, exitcode=EXITCODE_BAD_TEST)
|
# Sanitizers must not handle SIGSEGV (ex: for test_enable_fd())
|
||||||
|
env = dict(os.environ)
|
||||||
|
option = 'handle_segv=0'
|
||||||
|
support.set_sanitizer_env_var(env, option)
|
||||||
|
|
||||||
|
output = self.run_tests("-j1", testname,
|
||||||
|
exitcode=EXITCODE_BAD_TEST,
|
||||||
|
env=env)
|
||||||
self.check_executed_tests(output, testname,
|
self.check_executed_tests(output, testname,
|
||||||
failed=[testname],
|
failed=[testname],
|
||||||
stats=0, parallel=True)
|
stats=0, parallel=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue