From 321060f35b208a54a939c6fdb3b2d55584846e47 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 1 Mar 2022 10:17:00 +0100 Subject: [PATCH 1/2] bpo-46633: Skip tests on ASAN and/or MSAN builds 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 | 10 +--------- Lib/test/_test_multiprocessing.py | 6 ++++++ Lib/test/test___all__.py | 7 +++++++ Lib/test/test_concurrent_futures.py | 6 ++++++ Lib/test/test_decimal.py | 16 +++------------- Lib/test/test_peg_generator/__init__.py | 11 +++++++++-- Lib/test/test_tools/__init__.py | 7 +++++++ 7 files changed, 39 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d36dffa80108b..f6df74357d2f53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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" diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 6b1b1677910d18..bb73d9e7cc75e4 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -73,6 +73,12 @@ 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') diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py index 81293e15f8163e..a1a3d899e4e03c 100644 --- a/Lib/test/test___all__.py +++ b/Lib/test/test___all__.py @@ -11,6 +11,13 @@ _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 diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py index 71c88a3cadd255..8adba36a387ad0 100644 --- a/Lib/test/test_concurrent_futures.py +++ b/Lib/test/test_concurrent_futures.py @@ -32,6 +32,12 @@ 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 diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py index 9ced801afc2e92..b68cfbef23f16d 100644 --- a/Lib/test/test_decimal.py +++ b/Lib/test/test_decimal.py @@ -34,7 +34,7 @@ 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 @@ 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 @@ def __abs__(self): # 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): diff --git a/Lib/test/test_peg_generator/__init__.py b/Lib/test/test_peg_generator/__init__.py index fa855f2104c586..a5c132f977ca28 100644 --- a/Lib/test/test_peg_generator/__init__.py +++ b/Lib/test/test_peg_generator/__init__.py @@ -1,7 +1,14 @@ -import os - +import os.path +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) diff --git a/Lib/test/test_tools/__init__.py b/Lib/test/test_tools/__init__.py index 61af6578e09530..34b0d3b8fb3eb0 100644 --- a/Lib/test/test_tools/__init__.py +++ b/Lib/test/test_tools/__init__.py @@ -6,6 +6,13 @@ 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( # os.path.dirname( # Lib From 7c8e1ebcd8a7a0b9a9dad9b8ee9c897e7642affe Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 1 Mar 2022 14:49:22 +0100 Subject: [PATCH 2/2] fixup! bpo-46633: Skip tests on ASAN and/or MSAN builds Add missing import --- Lib/test/test_peg_generator/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Lib/test/test_peg_generator/__init__.py b/Lib/test/test_peg_generator/__init__.py index a5c132f977ca28..77f72fcc7c6e3b 100644 --- a/Lib/test/test_peg_generator/__init__.py +++ b/Lib/test/test_peg_generator/__init__.py @@ -1,4 +1,5 @@ import os.path +import unittest from test import support from test.support import load_package_tests pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy