3
3
from test .support import os_helper
4
4
from test .support import socket_helper
5
5
from test .support import threading_helper
6
+ from test .support import refleak_helper
6
7
7
8
import _thread as thread
8
9
import array
52
53
except ImportError :
53
54
_socket = None
54
55
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
+
55
85
def get_cid ():
56
86
if fcntl is None :
57
87
return None
@@ -3814,6 +3844,7 @@ def checkTruncatedHeader(self, result, ignoreflags=0):
3814
3844
self .checkFlags (flags , eor = True , checkset = socket .MSG_CTRUNC ,
3815
3845
ignore = ignoreflags )
3816
3846
3847
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3817
3848
def testCmsgTruncNoBufSize (self ):
3818
3849
# Check that no ancillary data is received when no buffer size
3819
3850
# is specified.
@@ -3823,40 +3854,49 @@ def testCmsgTruncNoBufSize(self):
3823
3854
# received.
3824
3855
ignoreflags = socket .MSG_CTRUNC )
3825
3856
3857
+ @testCmsgTruncNoBufSize .client_skip
3826
3858
def _testCmsgTruncNoBufSize (self ):
3827
3859
self .createAndSendFDs (1 )
3828
3860
3861
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3829
3862
def testCmsgTrunc0 (self ):
3830
3863
# Check that no ancillary data is received when buffer size is 0.
3831
3864
self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ), 0 ),
3832
3865
ignoreflags = socket .MSG_CTRUNC )
3833
3866
3867
+ @testCmsgTrunc0 .client_skip
3834
3868
def _testCmsgTrunc0 (self ):
3835
3869
self .createAndSendFDs (1 )
3836
3870
3837
3871
# Check that no ancillary data is returned for various non-zero
3838
3872
# (but still too small) buffer sizes.
3839
3873
3874
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3840
3875
def testCmsgTrunc1 (self ):
3841
3876
self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ), 1 ))
3842
3877
3878
+ @testCmsgTrunc1 .client_skip
3843
3879
def _testCmsgTrunc1 (self ):
3844
3880
self .createAndSendFDs (1 )
3845
3881
3882
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3846
3883
def testCmsgTrunc2Int (self ):
3847
3884
# The cmsghdr structure has at least three members, two of
3848
3885
# which are ints, so we still shouldn't see any ancillary
3849
3886
# data.
3850
3887
self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ),
3851
3888
SIZEOF_INT * 2 ))
3852
3889
3890
+ @testCmsgTrunc2Int .client_skip
3853
3891
def _testCmsgTrunc2Int (self ):
3854
3892
self .createAndSendFDs (1 )
3855
3893
3894
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3856
3895
def testCmsgTruncLen0Minus1 (self ):
3857
3896
self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ),
3858
3897
socket .CMSG_LEN (0 ) - 1 ))
3859
3898
3899
+ @testCmsgTruncLen0Minus1 .client_skip
3860
3900
def _testCmsgTruncLen0Minus1 (self ):
3861
3901
self .createAndSendFDs (1 )
3862
3902
@@ -3887,29 +3927,38 @@ def checkTruncatedArray(self, ancbuf, maxdata, mindata=0):
3887
3927
len (cmsg_data ) - (len (cmsg_data ) % fds .itemsize )])
3888
3928
self .checkFDs (fds )
3889
3929
3930
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3890
3931
def testCmsgTruncLen0 (self ):
3891
3932
self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (0 ), maxdata = 0 )
3892
3933
3934
+ @testCmsgTruncLen0 .client_skip
3893
3935
def _testCmsgTruncLen0 (self ):
3894
3936
self .createAndSendFDs (1 )
3895
3937
3938
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3896
3939
def testCmsgTruncLen0Plus1 (self ):
3897
3940
self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (0 ) + 1 , maxdata = 1 )
3898
3941
3942
+ @testCmsgTruncLen0Plus1 .client_skip
3899
3943
def _testCmsgTruncLen0Plus1 (self ):
3900
3944
self .createAndSendFDs (2 )
3901
3945
3946
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3902
3947
def testCmsgTruncLen1 (self ):
3903
3948
self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (SIZEOF_INT ),
3904
3949
maxdata = SIZEOF_INT )
3905
3950
3951
+ @testCmsgTruncLen1 .client_skip
3906
3952
def _testCmsgTruncLen1 (self ):
3907
3953
self .createAndSendFDs (2 )
3908
3954
3955
+
3956
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3909
3957
def testCmsgTruncLen2Minus1 (self ):
3910
3958
self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (2 * SIZEOF_INT ) - 1 ,
3911
3959
maxdata = (2 * SIZEOF_INT ) - 1 )
3912
3960
3961
+ @testCmsgTruncLen2Minus1 .client_skip
3913
3962
def _testCmsgTruncLen2Minus1 (self ):
3914
3963
self .createAndSendFDs (2 )
3915
3964
0 commit comments