summaryrefslogtreecommitdiffhomepage
path: root/tests/test_transport.py
diff options
context:
space:
mode:
authorRobey Pointer <robey@lag.net>2007-10-28 20:03:44 -0700
committerRobey Pointer <robey@lag.net>2007-10-28 20:03:44 -0700
commite3d9b90ea1f25792e652a0809b37b52635243932 (patch)
treec6b99f4940f2ceec7941500839d860119d0609fb /tests/test_transport.py
parent80b9e289cef4fc0939141ccf15751017a58a1637 (diff)
[project @ robey@lag.net-20071029030344-9adfzb9ulfodtepu]
bug 157205: select() doesn't notify incoming stderr data, because stderr's pipe isn't hooked up to the fileno() BufferedPipe. to fix, i added an "or" pipe-event that can be triggered by either stdout or stderr, and hooked them both up to fileno(). added a unit test for the bug and one for the "or" pipe.
Diffstat (limited to 'tests/test_transport.py')
-rw-r--r--tests/test_transport.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test_transport.py b/tests/test_transport.py
index 53e69690..6aaf7386 100644
--- a/tests/test_transport.py
+++ b/tests/test_transport.py
@@ -639,3 +639,41 @@ class TransportTest (unittest.TestCase):
self.tc.cancel_port_forward('', port)
self.assertTrue(self.server._listen is None)
+ def test_K_stderr_select(self):
+ """
+ verify that select() on a channel works even if only stderr is
+ receiving data.
+ """
+ self.setup_test_server()
+ chan = self.tc.open_session()
+ chan.invoke_shell()
+ schan = self.ts.accept(1.0)
+
+ # nothing should be ready
+ r, w, e = select.select([chan], [], [], 0.1)
+ self.assertEquals([], r)
+ self.assertEquals([], w)
+ self.assertEquals([], e)
+
+ schan.send_stderr('hello\n')
+
+ # something should be ready now (give it 1 second to appear)
+ for i in range(10):
+ r, w, e = select.select([chan], [], [], 0.1)
+ if chan in r:
+ break
+ time.sleep(0.1)
+ self.assertEquals([chan], r)
+ self.assertEquals([], w)
+ self.assertEquals([], e)
+
+ self.assertEquals('hello\n', chan.recv_stderr(6))
+
+ # and, should be dead again now
+ r, w, e = select.select([chan], [], [], 0.1)
+ self.assertEquals([], r)
+ self.assertEquals([], w)
+ self.assertEquals([], e)
+
+ schan.close()
+ chan.close()