MCPcopy Create free account
hub / github.com/twisted/twisted / test_sendSubProcessFD

Method test_sendSubProcessFD

src/twisted/python/test/test_sendmsg.py:277–299  ·  view source on GitHub ↗

Calling L{sendmsg} with SOL_SOCKET, SCM_RIGHTS, and a platform-endian packed file descriptor number should send that file descriptor to a different process, where it can be retrieved by using L{recv1msg}.

(self)

Source from the content-addressed store, hash-verified

275
276 @inlineCallbacks
277 def test_sendSubProcessFD(self):
278 """
279 Calling L{sendmsg} with SOL_SOCKET, SCM_RIGHTS, and a platform-endian
280 packed file descriptor number should send that file descriptor to a
281 different process, where it can be retrieved by using L{recv1msg}.
282 """
283 sspp = _spawn("pullpipe", self.output.fileno())
284 yield sspp.started
285 pipeOut, pipeIn = _makePipe()
286 self.addCleanup(pipeOut.close)
287 self.addCleanup(pipeIn.close)
288
289 with pipeIn:
290 sendmsg(
291 self.input,
292 b"blonk",
293 [(SOL_SOCKET, SCM_RIGHTS, pack("i", pipeIn.fileno()))],
294 )
295
296 yield sspp.stopped
297 self.assertEqual(read(pipeOut.fileno(), 1024), b"Test fixture data: blonk.\n")
298 # Make sure that the pipe is actually closed now.
299 self.assertEqual(read(pipeOut.fileno(), 1024), b"")
300
301
302@skipIf(nonUNIXSkip, "Platform does not support AF_UNIX sockets")

Callers

nothing calls this directly

Calls 7

sendmsgFunction · 0.90
_spawnFunction · 0.85
_makePipeFunction · 0.85
packFunction · 0.85
filenoMethod · 0.45
addCleanupMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected