Skip to content

Commit eca3b26

Browse files
gh-154240: Skip cmsg truncation socket tests on OpenBSD and DragonFly (GH-154244)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent fc4d93d commit eca3b26

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lib/test/test_socket.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@
5959
# SCM_RIGHTS control message when several are sent in a single sendmsg().
6060
BSD_COMBINES_SCM_RIGHTS = sys.platform.startswith(
6161
("netbsd", "openbsd", "dragonfly"))
62+
# OpenBSD and DragonFly fail recvmsg() with EMSGSIZE, instead of setting
63+
# MSG_CTRUNC, when the ancillary data buffer is too small for a cmsghdr.
64+
CMSG_TRUNC_RAISES_EMSGSIZE = sys.platform.startswith(("openbsd", "dragonfly"))
6265
WSL = "microsoft-standard-WSL" in platform.release()
6366

6467
try:
@@ -4351,6 +4354,7 @@ def _testCmsgTrunc0(self):
43514354
# (but still too small) buffer sizes.
43524355

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

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

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

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

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

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

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

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

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

44354444

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

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

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

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

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

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

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

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

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

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

48164831
@requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT",
48174832
"IPV6_RECVTCLASS", "IPV6_TCLASS")
4833+
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
48184834
def testSecondCmsgTrunc2Int(self):
48194835
self.checkTruncatedSecondHeader(socket.CMSG_SPACE(SIZEOF_INT) +
48204836
2 * SIZEOF_INT)
@@ -4826,6 +4842,7 @@ def _testSecondCmsgTrunc2Int(self):
48264842

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

48384855
@requireAttrs(socket, "CMSG_SPACE", "IPV6_RECVHOPLIMIT", "IPV6_HOPLIMIT",
48394856
"IPV6_RECVTCLASS", "IPV6_TCLASS")
4857+
@unittest.skipIf(CMSG_TRUNC_RAISES_EMSGSIZE, "skipping, see gh-154240")
48404858
def testSecondCmsgTruncInData(self):
48414859
# Test truncation of the second of two control messages inside
48424860
# its associated data.

0 commit comments

Comments
 (0)