Skip to content
Snippets Groups Projects
Commit e5293c75 authored by Simon McVittie's avatar Simon McVittie
Browse files

tests: Test adverb --pass-fd

parent 1c1c410b
No related branches found
No related tags found
No related merge requests found
...@@ -83,6 +83,30 @@ class TestAdverb(BaseTest): ...@@ -83,6 +83,30 @@ class TestAdverb(BaseTest):
(128 + signal.SIGTERM, -signal.SIGTERM), (128 + signal.SIGTERM, -signal.SIGTERM),
) )
def test_fd_passthrough(self) -> None:
read_end, write_end = os.pipe2(os.O_CLOEXEC)
proc = subprocess.Popen(
self.adverb + [
'--pass-fd=%d' % write_end,
'--',
'sh', '-euc', 'echo hello >&%d' % write_end,
],
pass_fds=[write_end],
stdout=2,
stderr=2,
universal_newlines=True,
)
try:
os.close(write_end)
with os.fdopen(read_end, 'rb') as reader:
self.assertEqual(reader.read(), b'hello\n')
finally:
proc.wait()
self.assertEqual(proc.returncode, 0)
def tearDown(self) -> None: def tearDown(self) -> None:
super().tearDown() super().tearDown()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment