]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46633: Skip tests on ASAN and/or MSAN builds (GH-31632)
authorVictor Stinner <vstinner@python.org>
Tue, 1 Mar 2022 14:44:08 +0000 (15:44 +0100)
committerGitHub <noreply@github.com>
Tue, 1 Mar 2022 14:44:08 +0000 (15:44 +0100)
Skip tests on ASAN and/or MSAN builds:

* multiprocessing tests
* test___all__
* test_concurrent_futures
* test_decimal
* test_peg_generator
* test_tools

The ASAN job of GitHub Actions no longer excludes these tests.

.github/workflows/build.yml
Lib/test/_test_multiprocessing.py
Lib/test/test___all__.py
Lib/test/test_concurrent_futures.py
Lib/test/test_decimal.py
Lib/test/test_peg_generator/__init__.py
Lib/test/test_tools/__init__.py

index 5d36dffa80108b40d5397ff2e1d0da44058c53bf..f6df74357d2f53d153c0a8c5c8283ea908ab297b 100644 (file)
@@ -306,12 +306,4 @@ jobs:
     - name: Display build info
       run: make pythoninfo
     - name: Tests
-      # Skip test_tools test_peg_generator test_concurrent_futures because
-      # there are too slow: between 5 and 20 minutes on this CI.
-      #
-      # Skip multiprocessing and concurrent.futures tests which are affected by
-      # bpo-45200 bug: libasan dead lock in pthread_create().
-      #
-      # test___all__ is skipped because importing some modules directly can trigger
-      # known problems with ASAN (like tk or crypt).
-      run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu -x test___all__ test_multiprocessing_fork test_multiprocessing_forkserver test_multiprocessing_spawn test_tools test_peg_generator test_concurrent_futures"
+      run: xvfb-run make buildbottest TESTOPTS="-j4 -uall,-cpu"
index 6b1b1677910d180ce16b024ae073bf96945a8d96..bb73d9e7cc75e4a22b4e9d7ac8f01aee61af768f 100644 (file)
@@ -73,6 +73,12 @@ except ImportError:
     msvcrt = None
 
 
+if support.check_sanitizer(address=True):
+    # bpo-45200: Skip multiprocessing tests if Python is built with ASAN to
+    # work around a libasan race condition: dead lock in pthread_create().
+    raise unittest.SkipTest("libasan has a pthread_create() dead lock")
+
+
 def latin(s):
     return s.encode('latin')
 
index 81293e15f8163e54f142db0a2030f61abcc0c218..a1a3d899e4e03cdcf2ae5783dcb23e665b2fcca6 100644 (file)
@@ -11,6 +11,13 @@ except ModuleNotFoundError:
     _multiprocessing = None
 
 
+if support.check_sanitizer(address=True, memory=True):
+    # bpo-46633: test___all__ is skipped because importing some modules
+    # directly can trigger known problems with ASAN (like tk or crypt).
+    raise unittest.SkipTest("workaround ASAN build issues on loading tests "
+                            "like tk or crypt")
+
+
 class NoAll(RuntimeError):
     pass
 
index 71c88a3cadd25586cc3d7ae9ab7dd1a0ba7c8327..8adba36a387ad0dec365ffeb5f5e6e3ff43ce411 100644 (file)
@@ -32,6 +32,12 @@ import multiprocessing.process
 import multiprocessing.util
 
 
+if support.check_sanitizer(address=True, memory=True):
+    # bpo-46633: Skip the test because it is too slow when Python is built
+    # with ASAN/MSAN: between 5 and 20 minutes on GitHub Actions.
+    raise unittest.SkipTest("test too slow on ASAN/MSAN build")
+
+
 def create_future(state=PENDING, exception=None, result=None):
     f = Future()
     f._state = state
index 9ced801afc2e9215c853361f9b5ecc40117c0bcf..b68cfbef23f16d50b77a2a0b6c65c9a4f48e84ed 100644 (file)
@@ -34,7 +34,7 @@ import numbers
 import locale
 from test.support import (run_unittest, run_doctest, is_resource_enabled,
                           requires_IEEE_754, requires_docstrings,
-                          requires_legacy_unicode_capi)
+                          requires_legacy_unicode_capi, check_sanitizer)
 from test.support import (TestFailed,
                           run_with_locale, cpython_only,
                           darwin_malloc_err_warning)
@@ -43,17 +43,6 @@ from test.support import warnings_helper
 import random
 import inspect
 import threading
-import sysconfig
-_cflags = sysconfig.get_config_var('CFLAGS') or ''
-_config_args = sysconfig.get_config_var('CONFIG_ARGS') or ''
-MEMORY_SANITIZER = (
-    '-fsanitize=memory' in _cflags or
-    '--with-memory-sanitizer' in _config_args
-)
-
-ADDRESS_SANITIZER = (
-    '-fsanitize=address' in _cflags
-)
 
 
 if sys.platform == 'darwin':
@@ -5518,7 +5507,8 @@ class CWhitebox(unittest.TestCase):
     # Issue 41540:
     @unittest.skipIf(sys.platform.startswith("aix"),
                      "AIX: default ulimit: test is flaky because of extreme over-allocation")
-    @unittest.skipIf(MEMORY_SANITIZER or ADDRESS_SANITIZER, "sanitizer defaults to crashing "
+    @unittest.skipIf(check_sanitizer(address=True, memory=True),
+                     "ASAN/MSAN sanitizer defaults to crashing "
                      "instead of returning NULL for malloc failure.")
     def test_maxcontext_exact_arith(self):
 
index fa855f2104c586e77b35a66635113387499ac818..77f72fcc7c6e3bb4e0669307e63d000e397572e0 100644 (file)
@@ -1,7 +1,15 @@
-import os
-
+import os.path
+import unittest
+from test import support
 from test.support import load_package_tests
 
+
+if support.check_sanitizer(address=True, memory=True):
+    # bpo-46633: Skip the test because it is too slow when Python is built
+    # with ASAN/MSAN: between 5 and 20 minutes on GitHub Actions.
+    raise unittest.SkipTest("test too slow on ASAN/MSAN build")
+
+
 # Load all tests in package
 def load_tests(*args):
     return load_package_tests(os.path.dirname(__file__), *args)
index 61af6578e09530eac0d2e6ebb9e634a2f3450db7..34b0d3b8fb3eb08dc505ad66f00af7b73d33931c 100644 (file)
@@ -6,6 +6,13 @@ import unittest
 from test import support
 from test.support import import_helper
 
+
+if support.check_sanitizer(address=True, memory=True):
+    # bpo-46633: Skip the test because it is too slow when Python is built
+    # with ASAN/MSAN: between 5 and 20 minutes on GitHub Actions.
+    raise unittest.SkipTest("test too slow on ASAN/MSAN build")
+
+
 basepath = os.path.normpath(
         os.path.dirname(                 # <src/install dir>
             os.path.dirname(                # Lib