]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-110367: Fix regrtest test_worker_output_on_failure() on ASAN build (#110387)
authorVictor Stinner <vstinner@python.org>
Thu, 5 Oct 2023 12:42:36 +0000 (14:42 +0200)
committerGitHub <noreply@github.com>
Thu, 5 Oct 2023 12:42:36 +0000 (14:42 +0200)
Set ASAN_OPTIONS="handle_segv=0" env var to run the test.

Lib/test/support/__init__.py
Lib/test/test_faulthandler.py
Lib/test/test_regrtest.py

index 38d5012ba46c0894fbfb63a15b93448d0c95aae7..900b9c96d08a6468755a2252e8617afdc0e50ce6 100644 (file)
@@ -436,6 +436,14 @@ def skip_if_sanitizer(reason=None, *, address=False, memory=False, ub=False):
     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):
     """Skip the test on TLS certificate validation failures."""
     @functools.wraps(f)
index 4dce7a7dd8c8df1ea8235e8b5933fb7d75a18cf4..0b8299a32b03c0e1b4797e1296d54c1e1d7e5cb3 100644 (file)
@@ -67,11 +67,7 @@ class FaultHandlerTests(unittest.TestCase):
 
         # Sanitizers must not handle SIGSEGV (ex: for test_enable_fd())
         option = 'handle_segv=0'
-        for name in ('ASAN_OPTIONS', 'MSAN_OPTIONS', 'UBSAN_OPTIONS'):
-            if name in env:
-                env[name] += f':{option}'
-            else:
-                env[name] = option
+        support.set_sanitizer_env_var(env, option)
 
         with support.SuppressCrashReport():
             process = script_helper.spawn_python('-c', code,
index 66463fd2bbea226dec735cc20e92be84c19b673f..de2c4317e7143937353d0c5d425d8c918d595744 100644 (file)
@@ -674,7 +674,7 @@ class BaseTestCase(unittest.TestCase):
         if 'stderr' not in kw:
             kw['stderr'] = subprocess.STDOUT
         proc = subprocess.run(args,
-                              universal_newlines=True,
+                              text=True,
                               input=input,
                               stdout=subprocess.PIPE,
                               **kw)
@@ -756,8 +756,8 @@ class ProgramsTestCase(BaseTestCase):
         self.check_executed_tests(output, self.tests,
                                   randomize=True, stats=len(self.tests))
 
-    def run_tests(self, args):
-        output = self.run_python(args)
+    def run_tests(self, args, env=None):
+        output = self.run_python(args, env=env)
         self.check_output(output)
 
     def test_script_regrtest(self):
@@ -2061,7 +2061,14 @@ class ArgsTestCase(BaseTestCase):
         """)
         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,
                                   failed=[testname],
                                   stats=0, parallel=True)