From: Charles-François Natali Date: Tue, 22 Nov 2011 17:36:39 +0000 (+0100) Subject: Issue #12156: Skip test_multiprocessing on systems which don't support enough X-Git-Tag: v3.3.0a1~748^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3be00953b29b880c9924c3ccf05df0aef0f9ba30;p=python Issue #12156: Skip test_multiprocessing on systems which don't support enough POSIX semaphores (among which FreeBSD < 8). --- diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index 45bf4549fe..de894f3087 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -98,6 +98,22 @@ except ImportError: Structure = object c_int = c_double = None + +def check_enough_semaphores(): + """Check that the system supports enough semaphores to run the test.""" + # minimum number of semaphores available according to POSIX + nsems_min = 256 + try: + nsems = os.sysconf("SC_SEM_NSEMS_MAX") + except (AttributeError, ValueError): + # sysconf not available or setting not available + return + if nsems == -1 or nsems >= nsems_min: + return + raise unittest.SkipTest("The OS doesn't support enough semaphores " + "to run the test (required: %d)." % nsems_min) + + # # Creates a wrapper for a function which records the time it takes to finish # @@ -2294,6 +2310,8 @@ def test_main(run=None): except OSError: raise unittest.SkipTest("OSError raises on RLock creation, see issue 3111!") + check_enough_semaphores() + if run is None: from test.support import run_unittest as run