summaryrefslogtreecommitdiff
path: root/Lib/test/test_multiprocessing.py
diff options
context:
space:
mode:
authorCharles-François Natali <neologix@free.fr>2011-11-22 18:35:18 +0100
committerCharles-François Natali <neologix@free.fr>2011-11-22 18:35:18 +0100
commit6392d7f68bbc11e3ad3417f52c93f33dcc0c4cd0 (patch)
tree48dc100c144582442350ebea0cad7b0af5562498 /Lib/test/test_multiprocessing.py
parent975134e2a233db5d7a28de63d0e4047894379490 (diff)
downloadcpython-git-6392d7f68bbc11e3ad3417f52c93f33dcc0c4cd0.tar.gz
Issue #12156: Skip test_multiprocessing on systems which don't support enough
POSIX semaphores (among which FreeBSD < 8).
Diffstat (limited to 'Lib/test/test_multiprocessing.py')
-rw-r--r--Lib/test/test_multiprocessing.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 14847d92a1..e5258bb9d8 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -95,6 +95,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
#
@@ -2236,6 +2252,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.test_support import run_unittest as run