Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
gh-80931: Skip some socket tests while hunting for refleaks on macOS#114057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
4 commits Select commit Hold shift + click to select a range
87330e7 gh-80931: Skip some socket tests while hunting for refleaks on macOS
ronaldoussoren 1fc2443 Cleaner way of annotating test functions using a decorator
ronaldoussoren 8907efc Integrate the refleak run check into regrtest and test.support
ronaldoussoren 86ff25a Merge branch 'main' into gh-80931
ronaldoussoren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| """ | ||
| Utilities for changing test behaviour while hunting | ||
| for refleaks | ||
| """ | ||
| _hunting_for_refleaks = False | ||
| def hunting_for_refleaks(): | ||
| return _hunting_for_refleaks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3,6 +3,7 @@ | ||
| from test.support import os_helper | ||
| from test.support import socket_helper | ||
| from test.support import threading_helper | ||
| from test.support import refleak_helper | ||
| import _thread as thread | ||
| import array | ||
| @@ -52,6 +53,35 @@ | ||
| except ImportError: | ||
| _socket = None | ||
| def skipForRefleakHuntinIf(condition, issueref): | ||
| if not condition: | ||
| def decorator(f): | ||
| f.client_skip = lambda f: f | ||
| return f | ||
| else: | ||
| def decorator(f): | ||
| @contextlib.wraps(f) | ||
| def wrapper(*args, **kwds): | ||
| if refleak_helper.hunting_for_refleaks(): | ||
| raise unittest.SkipTest(f"ignore while hunting for refleaks, see{issueref}") | ||
| return f(*args, **kwds) | ||
| def client_skip(f): | ||
| @contextlib.wraps(f) | ||
| def wrapper(*args, **kwds): | ||
| if refleak_helper.hunting_for_refleaks(): | ||
| return | ||
| return f(*args, **kwds) | ||
| return wrapper | ||
| wrapper.client_skip = client_skip | ||
| return wrapper | ||
| return decorator | ||
| def get_cid(): | ||
| if fcntl is None: | ||
| return None | ||
| @@ -3814,6 +3844,7 @@ def checkTruncatedHeader(self, result, ignoreflags=0): | ||
| self.checkFlags(flags, eor=True, checkset=socket.MSG_CTRUNC, | ||
| ignore=ignoreflags) | ||
| @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") | ||
| def testCmsgTruncNoBufSize(self): | ||
| # Check that no ancillary data is received when no buffer size | ||
| # is specified. | ||
| @@ -3823,40 +3854,49 @@ def testCmsgTruncNoBufSize(self): | ||
| # received. | ||
| ignoreflags=socket.MSG_CTRUNC) | ||
| @testCmsgTruncNoBufSize.client_skip | ||
| def _testCmsgTruncNoBufSize(self): | ||
| self.createAndSendFDs(1) | ||
| @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") | ||
| def testCmsgTrunc0(self): | ||
| # Check that no ancillary data is received when buffer size is 0. | ||
| self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), 0), | ||
| ignoreflags=socket.MSG_CTRUNC) | ||
| @testCmsgTrunc0.client_skip | ||
| def _testCmsgTrunc0(self): | ||
| self.createAndSendFDs(1) | ||
| # Check that no ancillary data is returned for various non-zero | ||
| # (but still too small) buffer sizes. | ||
| @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") | ||
| def testCmsgTrunc1(self): | ||
| self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), 1)) | ||
| @testCmsgTrunc1.client_skip | ||
| def _testCmsgTrunc1(self): | ||
| self.createAndSendFDs(1) | ||
| @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") | ||
| def testCmsgTrunc2Int(self): | ||
| # The cmsghdr structure has at least three members, two of | ||
| # which are ints, so we still shouldn't see any ancillary | ||
| # data. | ||
| self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), | ||
| SIZEOF_INT * 2)) | ||
| @testCmsgTrunc2Int.client_skip | ||
| def _testCmsgTrunc2Int(self): | ||
| self.createAndSendFDs(1) | ||
| @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") | ||
| def testCmsgTruncLen0Minus1(self): | ||
| self.checkTruncatedHeader(self.doRecvmsg(self.serv_sock, len(MSG), | ||
| socket.CMSG_LEN(0) - 1)) | ||
| @testCmsgTruncLen0Minus1.client_skip | ||
| def _testCmsgTruncLen0Minus1(self): | ||
| self.createAndSendFDs(1) | ||
| @@ -3887,29 +3927,38 @@ def checkTruncatedArray(self, ancbuf, maxdata, mindata=0): | ||
| len(cmsg_data) - (len(cmsg_data) % fds.itemsize)]) | ||
| self.checkFDs(fds) | ||
| @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") | ||
| def testCmsgTruncLen0(self): | ||
| self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0), maxdata=0) | ||
| @testCmsgTruncLen0.client_skip | ||
| def _testCmsgTruncLen0(self): | ||
| self.createAndSendFDs(1) | ||
| @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") | ||
| def testCmsgTruncLen0Plus1(self): | ||
| self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0) + 1, maxdata=1) | ||
| @testCmsgTruncLen0Plus1.client_skip | ||
| def _testCmsgTruncLen0Plus1(self): | ||
| self.createAndSendFDs(2) | ||
ronaldoussoren marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") | ||
| def testCmsgTruncLen1(self): | ||
| self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(SIZEOF_INT), | ||
| maxdata=SIZEOF_INT) | ||
| @testCmsgTruncLen1.client_skip | ||
| def _testCmsgTruncLen1(self): | ||
| self.createAndSendFDs(2) | ||
| @skipForRefleakHuntinIf(sys.platform == "darwin", "#80931") | ||
| def testCmsgTruncLen2Minus1(self): | ||
| self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(2 * SIZEOF_INT) - 1, | ||
| maxdata=(2 * SIZEOF_INT) - 1) | ||
| @testCmsgTruncLen2Minus1.client_skip | ||
| def _testCmsgTruncLen2Minus1(self): | ||
| self.createAndSendFDs(2) | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it's make sense to store it in
test.support.refleak_helper(as you said above)? It's can be useful in future in other situations like this