]> granicus.if.org Git - python/commitdiff
Fix tests in test_socket to use correctly CMSG_LEN (GH-9594)
authorPablo Galindo <Pablogsal@gmail.com>
Thu, 27 Sep 2018 09:25:03 +0000 (10:25 +0100)
committerGitHub <noreply@github.com>
Thu, 27 Sep 2018 09:25:03 +0000 (10:25 +0100)
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.

Lib/test/test_socket.py

index bbbf27b60978ebe80c846fbb9826f718b955064d..663a018dcfda0a1bdb28ea7c176dcadb168085ff 100644 (file)
@@ -3223,10 +3223,11 @@ class SCMRightsTest(SendrecvmsgServerTimeoutBase):
     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