Skip to content

Commit 7291108

Browse files
authored
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.
1 parent f55c64c commit 7291108

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Lib/test/test_socket.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,10 +3223,11 @@ def _testFDPassSeparate(self):
32233223
def testFDPassSeparateMinSpace(self):
32243224
# Pass two FDs in two separate arrays, receiving them into the
32253225
# minimum space for two arrays.
3226-
self.checkRecvmsgFDs(2,
3226+
num_fds = 2
3227+
self.checkRecvmsgFDs(num_fds,
32273228
self.doRecvmsg(self.serv_sock, len(MSG),
32283229
socket.CMSG_SPACE(SIZEOF_INT) +
3229-
socket.CMSG_LEN(SIZEOF_INT)),
3230+
socket.CMSG_LEN(SIZEOF_INT * num_fds)),
32303231
maxcmsgs=2, ignoreflags=socket.MSG_CTRUNC)
32313232

32323233
@testFDPassSeparateMinSpace.client_skip

0 commit comments

Comments
 (0)