@@ -73,6 +73,34 @@ def hunting_for_refleaks():
73
73
return _hunting_for_refleaks
74
74
75
75
76
+ def skipForRefleakHuntinIf (condition , issueref ):
77
+ if not condition :
78
+ def decorator (f ):
79
+ f .client_skip = lambda f : f
80
+ return f
81
+
82
+ else :
83
+ def decorator (f ):
84
+ @contextlib .wraps (f )
85
+ def wrapper (* args , ** kwds ):
86
+ if hunting_for_refleaks ():
87
+ raise unittest .SkipTest (f"ignore while hunting for refleaks, see { issueref } " )
88
+
89
+ return f (* args , ** kwds )
90
+
91
+ def client_skip (f ):
92
+ @contextlib .wraps (f )
93
+ def wrapper (* args , ** kwds ):
94
+ if hunting_for_refleaks ():
95
+ return
96
+
97
+ return f (* args , ** kwds )
98
+
99
+ return wrapper
100
+ wrapper .client_skip = client_skip
101
+ return wrapper
102
+
103
+ return decorator
76
104
77
105
def get_cid ():
78
106
if fcntl is None :
@@ -3836,32 +3864,27 @@ def checkTruncatedHeader(self, result, ignoreflags=0):
3836
3864
self .checkFlags (flags , eor = True , checkset = socket .MSG_CTRUNC ,
3837
3865
ignore = ignoreflags )
3838
3866
3867
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3839
3868
def testCmsgTruncNoBufSize (self ):
3840
3869
# Check that no ancillary data is received when no buffer size
3841
3870
# is specified.
3842
- if sys .platform == "darwin" and hunting_for_refleaks ():
3843
- return
3844
-
3845
3871
self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG )),
3846
3872
# BSD seems to set MSG_CTRUNC only
3847
3873
# if an item has been partially
3848
3874
# received.
3849
3875
ignoreflags = socket .MSG_CTRUNC )
3850
3876
3877
+ @testCmsgTruncNoBufSize .client_skip
3851
3878
def _testCmsgTruncNoBufSize (self ):
3852
- if sys .platform == "darwin" and hunting_for_refleaks ():
3853
- return
3854
-
3855
3879
self .createAndSendFDs (1 )
3856
3880
3881
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3857
3882
def testCmsgTrunc0 (self ):
3858
- if sys .platform == "darwin" and hunting_for_refleaks ():
3859
- return
3860
-
3861
3883
# Check that no ancillary data is received when buffer size is 0.
3862
3884
self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ), 0 ),
3863
3885
ignoreflags = socket .MSG_CTRUNC )
3864
3886
3887
+ @testCmsgTrunc0 .client_skip
3865
3888
def _testCmsgTrunc0 (self ):
3866
3889
if sys .platform == "darwin" and hunting_for_refleaks ():
3867
3890
return
@@ -3871,45 +3894,33 @@ def _testCmsgTrunc0(self):
3871
3894
# Check that no ancillary data is returned for various non-zero
3872
3895
# (but still too small) buffer sizes.
3873
3896
3897
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3874
3898
def testCmsgTrunc1 (self ):
3875
- if sys .platform == "darwin" and hunting_for_refleaks ():
3876
- return
3877
-
3878
3899
self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ), 1 ))
3879
3900
3901
+ @testCmsgTrunc1 .client_skip
3880
3902
def _testCmsgTrunc1 (self ):
3881
- if sys .platform == "darwin" and hunting_for_refleaks ():
3882
- return
3883
-
3884
3903
self .createAndSendFDs (1 )
3885
3904
3905
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3886
3906
def testCmsgTrunc2Int (self ):
3887
- if sys .platform == "darwin" and hunting_for_refleaks ():
3888
- return
3889
-
3890
3907
# The cmsghdr structure has at least three members, two of
3891
3908
# which are ints, so we still shouldn't see any ancillary
3892
3909
# data.
3893
3910
self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ),
3894
3911
SIZEOF_INT * 2 ))
3895
3912
3913
+ @testCmsgTrunc2Int .client_skip
3896
3914
def _testCmsgTrunc2Int (self ):
3897
- if sys .platform == "darwin" and hunting_for_refleaks ():
3898
- return
3899
-
3900
3915
self .createAndSendFDs (1 )
3901
3916
3917
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3902
3918
def testCmsgTruncLen0Minus1 (self ):
3903
- if sys .platform == "darwin" and hunting_for_refleaks ():
3904
- return
3905
-
3906
3919
self .checkTruncatedHeader (self .doRecvmsg (self .serv_sock , len (MSG ),
3907
3920
socket .CMSG_LEN (0 ) - 1 ))
3908
3921
3922
+ @testCmsgTruncLen0Minus1 .client_skip
3909
3923
def _testCmsgTruncLen0Minus1 (self ):
3910
- if sys .platform == "darwin" and hunting_for_refleaks ():
3911
- return
3912
-
3913
3924
self .createAndSendFDs (1 )
3914
3925
3915
3926
# The following tests try to truncate the control message in the
@@ -3939,54 +3950,39 @@ def checkTruncatedArray(self, ancbuf, maxdata, mindata=0):
3939
3950
len (cmsg_data ) - (len (cmsg_data ) % fds .itemsize )])
3940
3951
self .checkFDs (fds )
3941
3952
3953
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3942
3954
def testCmsgTruncLen0 (self ):
3943
- if sys .platform == "darwin" and hunting_for_refleaks ():
3944
- return
3945
-
3946
3955
self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (0 ), maxdata = 0 )
3947
3956
3957
+ @testCmsgTruncLen0 .client_skip
3948
3958
def _testCmsgTruncLen0 (self ):
3949
- if sys .platform == "darwin" and hunting_for_refleaks ():
3950
- return
3951
-
3952
3959
self .createAndSendFDs (1 )
3953
3960
3961
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3954
3962
def testCmsgTruncLen0Plus1 (self ):
3955
- if sys .platform == "darwin" and hunting_for_refleaks ():
3956
- return
3957
-
3958
3963
self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (0 ) + 1 , maxdata = 1 )
3959
3964
3965
+ @testCmsgTruncLen0Plus1 .client_skip
3960
3966
def _testCmsgTruncLen0Plus1 (self ):
3961
- if sys .platform == "darwin" and hunting_for_refleaks ():
3962
- return
3963
-
3964
3967
self .createAndSendFDs (2 )
3965
3968
3969
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3966
3970
def testCmsgTruncLen1 (self ):
3967
- if sys .platform == "darwin" and hunting_for_refleaks ():
3968
- return
3969
-
3970
3971
self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (SIZEOF_INT ),
3971
3972
maxdata = SIZEOF_INT )
3972
3973
3974
+ @testCmsgTruncLen1 .client_skip
3973
3975
def _testCmsgTruncLen1 (self ):
3974
- if sys .platform == "darwin" and hunting_for_refleaks ():
3975
- return
3976
-
3977
3976
self .createAndSendFDs (2 )
3978
3977
3979
- def testCmsgTruncLen2Minus1 (self ):
3980
- if sys .platform == "darwin" and hunting_for_refleaks ():
3981
- return
3982
3978
3979
+ @skipForRefleakHuntinIf (sys .platform == "darwin" , "#80931" )
3980
+ def testCmsgTruncLen2Minus1 (self ):
3983
3981
self .checkTruncatedArray (ancbuf = socket .CMSG_LEN (2 * SIZEOF_INT ) - 1 ,
3984
3982
maxdata = (2 * SIZEOF_INT ) - 1 )
3985
3983
3984
+ @testCmsgTruncLen2Minus1 .client_skip
3986
3985
def _testCmsgTruncLen2Minus1 (self ):
3987
- if sys .platform == "darwin" and hunting_for_refleaks ():
3988
- return
3989
-
3990
3986
self .createAndSendFDs (2 )
3991
3987
3992
3988
0 commit comments