[Python-checkins] Fix tests in test_socket to use correctly CMSG_LEN (GH-9594)

Miss Islington (bot) webhook-mailer at python.org
Thu Sep 27 09:30:59 EDT 2018


https://github.com/python/cpython/commit/fe48b6df101aac10dc846fa6fd1a41f877e77025
commit: fe48b6df101aac10dc846fa6fd1a41f877e77025
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-09-27T06:30:55-07:00
summary:

Fix tests in test_socket to use correctly CMSG_LEN (GH-9594)


After some failures in AMD64 FreeBSD CURRENT Debug 3.x buildbots
regarding tests in test_socket that are using
testFDPassSeparateMinSpace(), FreeBDS revision 337423 was pointed
out to be the reason the test started to fail.

A close examination of the manpage for cmsg_space(3) reveals that
the number of file descriptors needs to be taken into account when
using CMSG_LEN().

This commit fixes tests in test_socket to use correctly CMSG_LEN, taking
into account the number of FDs.
(cherry picked from commit 7291108d88ea31d205da4db19d202d6cbffc6d93)

Co-authored-by: Pablo Galindo <Pablogsal at gmail.com>

files:
M Lib/test/test_socket.py

diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index f8559ac4eab9..fbbc9f9abfb0 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -2858,10 +2858,11 @@ def _testFDPassSeparate(self):
     def testFDPassSeparateMinSpace(self):
         # Pass two FDs in two separate arrays, receiving them into the
         # minimum space for two arrays.
-        self.checkRecvmsgFDs(2,
+        num_fds = 2
+        self.checkRecvmsgFDs(num_fds,
                              self.doRecvmsg(self.serv_sock, len(MSG),
                                             socket.CMSG_SPACE(SIZEOF_INT) +
-                                            socket.CMSG_LEN(SIZEOF_INT)),
+                                            socket.CMSG_LEN(SIZEOF_INT * num_fds)),
                              maxcmsgs=2, ignoreflags=socket.MSG_CTRUNC)
 
     @testFDPassSeparateMinSpace.client_skip



More information about the Python-checkins mailing list