[Python-checkins] cpython (3.2): Issue #12156: Skip test_multiprocessing on systems which don't support enough

charles-francois.natali python-checkins at python.org
Tue Nov 22 18:56:42 CET 2011


http://hg.python.org/cpython/rev/311bb5e65b02
changeset:   73691:311bb5e65b02
branch:      3.2
parent:      73680:f29d7d597fae
user:        Charles-François Natali <neologix at free.fr>
date:        Tue Nov 22 18:36:39 2011 +0100
summary:
  Issue #12156: Skip test_multiprocessing on systems which don't support enough
POSIX semaphores (among which FreeBSD < 8).

files:
  Lib/test/test_multiprocessing.py |  18 ++++++++++++++++++
  1 files changed, 18 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -98,6 +98,22 @@
     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 @@
         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
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list