(self)
| 4004 | |
| 4005 | @requireAttrs(socket, "CMSG_SPACE") |
| 4006 | def testCMSG_SPACE(self): |
| 4007 | # Test CMSG_SPACE() with various valid and invalid values, |
| 4008 | # checking the assumptions used by sendmsg(). |
| 4009 | toobig = self.socklen_t_limit - socket.CMSG_SPACE(1) + 1 |
| 4010 | if SOLARIS and platform.processor() == "sparc": |
| 4011 | # On Solaris SPARC, number of bytes returned by socket.CMSG_SPACE |
| 4012 | # increases at different lengths; see gh-91214. |
| 4013 | toobig -= 3 |
| 4014 | values = list(range(257)) + list(range(toobig - 257, toobig)) |
| 4015 | |
| 4016 | last = socket.CMSG_SPACE(0) |
| 4017 | # struct cmsghdr has at least three members, two of which are ints |
| 4018 | self.assertGreater(last, array.array("i").itemsize * 2) |
| 4019 | for n in values: |
| 4020 | ret = socket.CMSG_SPACE(n) |
| 4021 | self.assertGreaterEqual(ret, last) |
| 4022 | self.assertGreaterEqual(ret, socket.CMSG_LEN(n)) |
| 4023 | self.assertGreaterEqual(ret, n + socket.CMSG_LEN(0)) |
| 4024 | self.assertLessEqual(ret, self.socklen_t_limit) |
| 4025 | last = ret |
| 4026 | |
| 4027 | self.assertRaises(OverflowError, socket.CMSG_SPACE, -1) |
| 4028 | # sendmsg() shares code with these functions, and requires |
| 4029 | # that it reject values over the limit. |
| 4030 | self.assertRaises(OverflowError, socket.CMSG_SPACE, toobig) |
| 4031 | self.assertRaises(OverflowError, socket.CMSG_SPACE, sys.maxsize) |
| 4032 | |
| 4033 | |
| 4034 | class SCMRightsTest(SendrecvmsgServerTimeoutBase): |
nothing calls this directly
no test coverage detected