[Python-checkins] cpython: Issue #25122: Fix test_eintr.test_open() on FreeBSD
victor.stinner
python-checkins at python.org
Fri Sep 18 11:31:30 CEST 2015
https://hg.python.org/cpython/rev/90722634f211
changeset: 98037:90722634f211
user: Victor Stinner <victor.stinner at gmail.com>
date: Fri Sep 18 11:23:42 2015 +0200
summary:
Issue #25122: Fix test_eintr.test_open() on FreeBSD
Skip test_open() and test_os_open(): both tests uses a FIFO and signals, but
there is a bug in the FreeBSD kernel which blocks the test. Skip the tests
until the bug is fixed in FreeBSD kernel.
Remove also debug traces from test_eintr:
* stop using faulthandler to have a timeout
* remove print()
Write also open and close on two lines in test_open() and test_os_open()
tests. If these tests block again, we can know if the test is stuck at open or
close.
test_eintr: don't always run the test in debug mode.
files:
Lib/test/eintrdata/eintr_tester.py | 44 ++++++-----------
Lib/test/test_eintr.py | 3 +-
2 files changed, 18 insertions(+), 29 deletions(-)
diff --git a/Lib/test/eintrdata/eintr_tester.py b/Lib/test/eintrdata/eintr_tester.py
--- a/Lib/test/eintrdata/eintr_tester.py
+++ b/Lib/test/eintrdata/eintr_tester.py
@@ -9,7 +9,6 @@
"""
import contextlib
-import faulthandler
import io
import os
import select
@@ -48,19 +47,12 @@
@classmethod
def setUpClass(cls):
cls.orig_handler = signal.signal(signal.SIGALRM, lambda *args: None)
- if hasattr(faulthandler, 'dump_traceback_later'):
- # Most tests take less than 30 seconds, so 5 minutes should be
- # enough. dump_traceback_later() is implemented with a thread, but
- # pthread_sigmask() is used to mask all signaled on this thread.
- faulthandler.dump_traceback_later(5 * 60, exit=True)
signal.setitimer(signal.ITIMER_REAL, cls.signal_delay,
cls.signal_period)
@classmethod
def stop_alarm(cls):
signal.setitimer(signal.ITIMER_REAL, 0, 0)
- if hasattr(faulthandler, 'cancel_dump_traceback_later'):
- faulthandler.cancel_dump_traceback_later()
@classmethod
def tearDownClass(cls):
@@ -307,6 +299,11 @@
client_sock.close()
self.assertEqual(proc.wait(), 0)
+ # Issue #25122: There is a race condition in the FreeBSD kernel on
+ # handling signals in the FIFO device. Skip the test until the bug is
+ # fixed in the kernel. Bet that the bug will be fixed in FreeBSD 11.
+ # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=203162
+ @support.requires_freebsd_version(11)
@unittest.skipUnless(hasattr(os, 'mkfifo'), 'needs mkfifo()')
def _test_open(self, do_open_close_reader, do_open_close_writer):
filename = support.TESTFN
@@ -326,36 +323,29 @@
'# let the parent block',
'time.sleep(sleep_time)',
'',
- 'print("try to open %a fifo for reading, pid %s, ppid %s"'
- ' % (path, os.getpid(), os.getppid()),'
- ' flush=True)',
- '',
do_open_close_reader,
- '',
- 'print("%a fifo opened for reading and closed, pid %s, ppid %s"'
- ' % (path, os.getpid(), os.getppid()),'
- ' flush=True)',
))
proc = self.subprocess(code)
with kill_on_error(proc):
- print("try to open %a fifo for writing, pid %s"
- % (filename, os.getpid()),
- flush=True)
do_open_close_writer(filename)
- print("%a fifo opened for writing and closed, pid %s"
- % (filename, os.getpid()),
- flush=True)
-
self.assertEqual(proc.wait(), 0)
+ def python_open(self, path):
+ fp = open(path, 'w')
+ fp.close()
+
def test_open(self):
- self._test_open("open(path, 'r').close()",
- lambda path: open(path, 'w').close())
+ self._test_open("fp = open(path, 'r')\nfp.close()",
+ self.python_open)
+
+ def os_open(self, path):
+ fd = os.open(path, os.O_WRONLY)
+ os.close(fd)
def test_os_open(self):
- self._test_open("os.close(os.open(path, os.O_RDONLY))",
- lambda path: os.close(os.open(path, os.O_WRONLY)))
+ self._test_open("fd = os.open(path, os.O_RDONLY)\nos.close(fd)",
+ self.os_open)
@unittest.skipUnless(hasattr(signal, "setitimer"), "requires setitimer()")
diff --git a/Lib/test/test_eintr.py b/Lib/test/test_eintr.py
--- a/Lib/test/test_eintr.py
+++ b/Lib/test/test_eintr.py
@@ -17,8 +17,7 @@
# thread (for reliable signal delivery).
tester = support.findfile("eintr_tester.py", subdir="eintrdata")
- # FIXME: Issue #25122, always run in verbose mode to debug hang on FreeBSD
- if True: #support.verbose:
+ if support.verbose:
args = [sys.executable, tester]
with subprocess.Popen(args) as proc:
exitcode = proc.wait()
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list