Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Lib/test/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
# SCM_RIGHTS control message when several are sent in a single sendmsg().
BSD_COMBINES_SCM_RIGHTS = sys.platform.startswith(
("netbsd", "openbsd", "dragonfly"))
# OpenBSD and DragonFly fail recvmsg() with EMSGSIZE, instead of setting
# MSG_CTRUNC, when the ancillary data buffer is too small for a cmsghdr.
CMSG_TRUNC_RAISES_EMSGSIZE = sys.platform.startswith(("openbsd", "dragonfly"))
WSL = "microsoft-standard-WSL" in platform.release()

try:
Expand Down Expand Up @@ -4351,6 +4354,7 @@ def _testCmsgTrunc0(self):
# (but still too small) buffer sizes.

@skipForRefleakHuntinIf(sys.platform == "darwin", "#80931")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testCmsgTrunc1(self):
self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), 1))

Expand All @@ -4359,6 +4363,7 @@ def _testCmsgTrunc1(self):
self.createAndSendFDs(1)

@skipForRefleakHuntinIf(sys.platform == "darwin", "#80931")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testCmsgTrunc2Int(self):
# The cmsghdr structure has at least three members, two of
# which are ints, so we still shouldn't see any ancillary
Expand All @@ -4371,6 +4376,7 @@ def _testCmsgTrunc2Int(self):
self.createAndSendFDs(1)

@skipForRefleakHuntinIf(sys.platform == "darwin", "#80931")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testCmsgTruncLen0Minus1(self):
self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG),
socket.CMSG_LEN(0) - 1))
Expand Down Expand Up @@ -4408,6 +4414,7 @@ def checkTruncatedArray(self, ancbuf, maxdata, mindata=0):
self.checkFDs(fds)

@skipForRefleakHuntinIf(sys.platform == "darwin", "#80931")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testCmsgTruncLen0(self):
self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0), maxdata=0)

Expand All @@ -4416,6 +4423,7 @@ def _testCmsgTruncLen0(self):
self.createAndSendFDs(1)

@skipForRefleakHuntinIf(sys.platform == "darwin", "#80931")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testCmsgTruncLen0Plus1(self):
self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0) + 1, maxdata=1)

Expand All @@ -4424,6 +4432,7 @@ def _testCmsgTruncLen0Plus1(self):
self.createAndSendFDs(2)

@skipForRefleakHuntinIf(sys.platform == "darwin", "#80931")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testCmsgTruncLen1(self):
self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(SIZEOF_INT),
maxdata=SIZEOF_INT)
Expand All @@ -4434,6 +4443,7 @@ def _testCmsgTruncLen1(self):


@skipForRefleakHuntinIf(sys.platform == "darwin", "#80931")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testCmsgTruncLen2Minus1(self):
self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(2 * SIZEOF_INT) - 1,
maxdata=(2 * SIZEOF_INT) - 1)
Expand Down Expand Up @@ -4706,6 +4716,7 @@ def _testSingleCmsgTrunc0(self):
# (but still too small) buffer sizes.

@requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testSingleCmsgTrunc1(self):
self.checkHopLimitTruncatedHeader(ancbufsize=1)

Expand All @@ -4715,6 +4726,7 @@ def _testSingleCmsgTrunc1(self):
self.sendToServer(MSG)

@requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testSingleCmsgTrunc2Int(self):
self.checkHopLimitTruncatedHeader(ancbufsize=2 * SIZEOF_INT)

Expand All @@ -4724,6 +4736,7 @@ def _testSingleCmsgTrunc2Int(self):
self.sendToServer(MSG)

@requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testSingleCmsgTruncLen0Minus1(self):
self.checkHopLimitTruncatedHeader(ancbufsize=socket.CMSG_LEN(0) - 1)

Expand All @@ -4733,6 +4746,7 @@ def _testSingleCmsgTruncLen0Minus1(self):
self.sendToServer(MSG)

@requireAttrs(socket, "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testSingleCmsgTruncInData(self):
# Test truncation of a control message inside its associated
# data. The message may be returned with its data truncated,
Expand Down Expand Up @@ -4805,6 +4819,7 @@ def _testSecondCmsgTrunc0(self):

@requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT",
"IPV6_RECVTCLASS", "IPV6_TCLASS")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testSecondCmsgTrunc1(self):
self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) + 1)

Expand All @@ -4815,6 +4830,7 @@ def _testSecondCmsgTrunc1(self):

@requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT",
"IPV6_RECVTCLASS", "IPV6_TCLASS")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testSecondCmsgTrunc2Int(self):
self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) +
2 * SIZEOF_INT)
Expand All @@ -4826,6 +4842,7 @@ def _testSecondCmsgTrunc2Int(self):

@requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT",
"IPV6_RECVTCLASS", "IPV6_TCLASS")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testSecondCmsgTruncLen0Minus1(self):
self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) +
socket.CMSG_LEN(0) - 1)
Expand All @@ -4837,6 +4854,7 @@ def _testSecondCmsgTruncLen0Minus1(self):

@requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT",
"IPV6_RECVTCLASS", "IPV6_TCLASS")
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
def testSecondCmsgTruncInData(self):
# Test truncation of the second of two control messages inside
# its associated data.
Expand Down
Loading