|
52 | 52 | except ImportError:
|
53 | 53 | _socket = None
|
54 | 54 |
|
| 55 | +_hunting_for_refleaks = None |
| 56 | +def hunting_for_refleaks(): |
| 57 | + """ |
| 58 | + Return true iff running tests while hunting for refleaks |
| 59 | + """ |
| 60 | + from test.libregrtest.runtests import RunTests |
| 61 | + import gc |
| 62 | + |
| 63 | + global _hunting_for_refleaks |
| 64 | + |
| 65 | + if _hunting_for_refleaks is None: |
| 66 | + for value in gc.get_objects(): |
| 67 | + if isinstance(value, RunTests): |
| 68 | + _hunting_for_refleaks = (value.hunt_refleak is not None) |
| 69 | + break |
| 70 | + else: |
| 71 | + _hunting_for_refleaks = False |
| 72 | + |
| 73 | + return _hunting_for_refleaks |
| 74 | + |
| 75 | + |
| 76 | + |
55 | 77 | def get_cid():
|
56 | 78 | if fcntl is None:
|
57 | 79 | return None
|
@@ -3817,47 +3839,77 @@ def checkTruncatedHeader(self, result, ignoreflags=0):
|
3817 | 3839 | def testCmsgTruncNoBufSize(self):
|
3818 | 3840 | # Check that no ancillary data is received when no buffer size
|
3819 | 3841 | # is specified.
|
| 3842 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3843 | + return |
| 3844 | + |
3820 | 3845 | self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG)),
|
3821 | 3846 | # BSD seems to set MSG_CTRUNC only
|
3822 | 3847 | # if an item has been partially
|
3823 | 3848 | # received.
|
3824 | 3849 | ignoreflags=socket.MSG_CTRUNC)
|
3825 | 3850 |
|
3826 | 3851 | def _testCmsgTruncNoBufSize(self):
|
| 3852 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3853 | + return |
| 3854 | + |
3827 | 3855 | self.createAndSendFDs(1)
|
3828 | 3856 |
|
3829 | 3857 | def testCmsgTrunc0(self):
|
| 3858 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3859 | + return |
| 3860 | + |
3830 | 3861 | # Check that no ancillary data is received when buffer size is 0.
|
3831 | 3862 | self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), 0),
|
3832 | 3863 | ignoreflags=socket.MSG_CTRUNC)
|
3833 | 3864 |
|
3834 | 3865 | def _testCmsgTrunc0(self):
|
| 3866 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3867 | + return |
| 3868 | + |
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 |
|
3840 | 3874 | def testCmsgTrunc1(self):
|
| 3875 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3876 | + return |
| 3877 | + |
3841 | 3878 | self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), 1))
|
3842 | 3879 |
|
3843 | 3880 | def _testCmsgTrunc1(self):
|
| 3881 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3882 | + return |
| 3883 | + |
3844 | 3884 | self.createAndSendFDs(1)
|
3845 | 3885 |
|
3846 | 3886 | def testCmsgTrunc2Int(self):
|
| 3887 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3888 | + return |
| 3889 | + |
3847 | 3890 | # The cmsghdr structure has at least three members, two of
|
3848 | 3891 | # which are ints, so we still shouldn't see any ancillary
|
3849 | 3892 | # data.
|
3850 | 3893 | self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG),
|
3851 | 3894 | SIZEOF_INT * 2))
|
3852 | 3895 |
|
3853 | 3896 | def _testCmsgTrunc2Int(self):
|
| 3897 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3898 | + return |
| 3899 | + |
3854 | 3900 | self.createAndSendFDs(1)
|
3855 | 3901 |
|
3856 | 3902 | def testCmsgTruncLen0Minus1(self):
|
| 3903 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3904 | + return |
| 3905 | + |
3857 | 3906 | self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG),
|
3858 | 3907 | socket.CMSG_LEN(0) - 1))
|
3859 | 3908 |
|
3860 | 3909 | def _testCmsgTruncLen0Minus1(self):
|
| 3910 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3911 | + return |
| 3912 | + |
3861 | 3913 | self.createAndSendFDs(1)
|
3862 | 3914 |
|
3863 | 3915 | # The following tests try to truncate the control message in the
|
@@ -3888,29 +3940,53 @@ def checkTruncatedArray(self, ancbuf, maxdata, mindata=0):
|
3888 | 3940 | self.checkFDs(fds)
|
3889 | 3941 |
|
3890 | 3942 | def testCmsgTruncLen0(self):
|
| 3943 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3944 | + return |
| 3945 | + |
3891 | 3946 | self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0), maxdata=0)
|
3892 | 3947 |
|
3893 | 3948 | def _testCmsgTruncLen0(self):
|
| 3949 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3950 | + return |
| 3951 | + |
3894 | 3952 | self.createAndSendFDs(1)
|
3895 | 3953 |
|
3896 | 3954 | def testCmsgTruncLen0Plus1(self):
|
| 3955 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3956 | + return |
| 3957 | + |
3897 | 3958 | self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0) + 1, maxdata=1)
|
3898 | 3959 |
|
3899 | 3960 | def _testCmsgTruncLen0Plus1(self):
|
| 3961 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3962 | + return |
| 3963 | + |
3900 | 3964 | self.createAndSendFDs(2)
|
3901 | 3965 |
|
3902 | 3966 | def testCmsgTruncLen1(self):
|
| 3967 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3968 | + return |
| 3969 | + |
3903 | 3970 | self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(SIZEOF_INT),
|
3904 | 3971 | maxdata=SIZEOF_INT)
|
3905 | 3972 |
|
3906 | 3973 | def _testCmsgTruncLen1(self):
|
| 3974 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3975 | + return |
| 3976 | + |
3907 | 3977 | self.createAndSendFDs(2)
|
3908 | 3978 |
|
3909 | 3979 | def testCmsgTruncLen2Minus1(self):
|
| 3980 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3981 | + return |
| 3982 | + |
3910 | 3983 | self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(2 * SIZEOF_INT) - 1,
|
3911 | 3984 | maxdata=(2 * SIZEOF_INT) - 1)
|
3912 | 3985 |
|
3913 | 3986 | def _testCmsgTruncLen2Minus1(self):
|
| 3987 | + if sys.platform == "darwin" and hunting_for_refleaks(): |
| 3988 | + return |
| 3989 | + |
3914 | 3990 | self.createAndSendFDs(2)
|
3915 | 3991 |
|
3916 | 3992 |
|
|
0 commit comments