summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_multiprocessing.py
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2011-09-21 01:53:25 (GMT)
committerJesus Cea <jcea@jcea.es>2011-09-21 01:53:25 (GMT)
commit4507e6456e6170f92e14d7ecb68f2617a3b48412 (patch)
tree1bcd9a9cc702bf911d39fd3df5168b2837eb534b /Lib/test/test_multiprocessing.py
parentd0b10a64351069aa9246d40cb8bd207cc9209cee (diff)
downloadcpython-4507e6456e6170f92e14d7ecb68f2617a3b48412.zip
cpython-4507e6456e6170f92e14d7ecb68f2617a3b48412.tar.gz
cpython-4507e6456e6170f92e14d7ecb68f2617a3b48412.tar.bz2
Close #13022: _multiprocessing.recvfd() doesn't check that file descriptor was actually received
Diffstat (limited to 'Lib/test/test_multiprocessing.py')
-rw-r--r--Lib/test/test_multiprocessing.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 5d734ed..1d84ca8 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1632,6 +1632,23 @@ class _TestConnection(BaseTestCase):
with open(test.support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"bar")
+ @classmethod
+ def _send_data_without_fd(self, conn):
+ os.write(conn.fileno(), b"\0")
+
+ @unittest.skipIf(sys.platform == "win32", "doesn't make sense on Windows")
+ def test_missing_fd_transfer(self):
+ # Check that exception is raised when received data is not
+ # accompanied by a file descriptor in ancillary data.
+ if self.TYPE != 'processes':
+ self.skipTest("only makes sense with processes")
+ conn, child_conn = self.Pipe(duplex=True)
+
+ p = self.Process(target=self._send_data_without_fd, args=(child_conn,))
+ p.daemon = True
+ p.start()
+ self.assertRaises(RuntimeError, reduction.recv_handle, conn)
+ p.join()
class _TestListenerClient(BaseTestCase):