33from test .support import os_helper
44from test .support import socket_helper
55from test .support import threading_helper
6+ from test .support import refleak_helper
67
78import _thread as thread
89import array
5253except ImportError :
5354 _socket = None
5455
56+ def skipForRefleakHuntinIf (condition , issueref ):
57+ if not condition :
58+ def decorator (f ):
59+ f .client_skip = lambda f : f
60+ return f
61+
62+ else :
63+ def decorator (f ):
64+ @contextlib .wraps (f )
65+ def wrapper (* args , ** kwds ):
66+ if refleak_helper .hunting_for_refleaks ():
67+ raise unittest .SkipTest (f"ignore while hunting for refleaks, see { issueref } " )
68+
69+ return f (* args , ** kwds )
70+
71+ def client_skip (f ):
72+ @contextlib .wraps (f )
73+ def wrapper (* args , ** kwds ):
74+ if refleak_helper .hunting_for_refleaks ():
75+ return
76+
77+ return f (* args , ** kwds )
78+
79+ return wrapper
80+ wrapper .client_skip = client_skip
81+ return wrapper
82+
83+ return decorator
84+
5585def get_cid ():
5686 if fcntl is None :
5787 return None
@@ -3814,6 +3844,7 @@ def checkTruncatedHeader(self, result, ignoreflags=0):
38143844 self .checkFlags (flags , eor = True , checkset = socket .MSG_CTRUNC ,
38153845 ignore = ignoreflags )
38163846
3847+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
38173848 def testCmsgTruncNoBufSize (self ):
38183849 # Check that no ancillary data is received when no buffer size
38193850 # is specified.
@@ -3823,40 +3854,49 @@ def testCmsgTruncNoBufSize(self):
38233854 # received.
38243855 ignoreflags = socket .MSG_CTRUNC )
38253856
3857+ @testCmsgTruncNoBufSize .client_skip
38263858 def _testCmsgTruncNoBufSize (self ):
38273859 self .createAndSendFDs (1 )
38283860
3861+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
38293862 def testCmsgTrunc0 (self ):
38303863 # Check that no ancillary data is received when buffer size is 0.
38313864 self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ), 0 ),
38323865 ignoreflags = socket .MSG_CTRUNC )
38333866
3867+ @testCmsgTrunc0 .client_skip
38343868 def _testCmsgTrunc0 (self ):
38353869 self .createAndSendFDs (1 )
38363870
38373871 # Check that no ancillary data is returned for various non-zero
38383872 # (but still too small) buffer sizes.
38393873
3874+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
38403875 def testCmsgTrunc1 (self ):
38413876 self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ), 1 ))
38423877
3878+ @testCmsgTrunc1 .client_skip
38433879 def _testCmsgTrunc1 (self ):
38443880 self .createAndSendFDs (1 )
38453881
3882+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
38463883 def testCmsgTrunc2Int (self ):
38473884 # The cmsghdr structure has at least three members, two of
38483885 # which are ints, so we still shouldn't see any ancillary
38493886 # data.
38503887 self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ),
38513888 SIZEOF_INT * 2 ))
38523889
3890+ @testCmsgTrunc2Int .client_skip
38533891 def _testCmsgTrunc2Int (self ):
38543892 self .createAndSendFDs (1 )
38553893
3894+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
38563895 def testCmsgTruncLen0Minus1 (self ):
38573896 self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ),
38583897 socket .CMSG_LEN (0 ) - 1 ))
38593898
3899+ @testCmsgTruncLen0Minus1 .client_skip
38603900 def _testCmsgTruncLen0Minus1 (self ):
38613901 self .createAndSendFDs (1 )
38623902
@@ -3887,29 +3927,38 @@ def checkTruncatedArray(self, ancbuf, maxdata, mindata=0):
38873927 len (cmsg_data ) - (len (cmsg_data ) % fds .itemsize )])
38883928 self .checkFDs (fds )
38893929
3930+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
38903931 def testCmsgTruncLen0 (self ):
38913932 self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (0 ), maxdata = 0 )
38923933
3934+ @testCmsgTruncLen0 .client_skip
38933935 def _testCmsgTruncLen0 (self ):
38943936 self .createAndSendFDs (1 )
38953937
3938+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
38963939 def testCmsgTruncLen0Plus1 (self ):
38973940 self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (0 ) + 1 , maxdata = 1 )
38983941
3942+ @testCmsgTruncLen0Plus1 .client_skip
38993943 def _testCmsgTruncLen0Plus1 (self ):
39003944 self .createAndSendFDs (2 )
39013945
3946+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
39023947 def testCmsgTruncLen1 (self ):
39033948 self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (SIZEOF_INT ),
39043949 maxdata = SIZEOF_INT )
39053950
3951+ @testCmsgTruncLen1 .client_skip
39063952 def _testCmsgTruncLen1 (self ):
39073953 self .createAndSendFDs (2 )
39083954
3955+
3956+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
39093957 def testCmsgTruncLen2Minus1 (self ):
39103958 self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (2 * SIZEOF_INT ) - 1 ,
39113959 maxdata = (2 * SIZEOF_INT ) - 1 )
39123960
3961+ @testCmsgTruncLen2Minus1 .client_skip
39133962 def _testCmsgTruncLen2Minus1 (self ):
39143963 self .createAndSendFDs (2 )
39153964
0 commit comments