diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2007-04-27 06:45:32 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2007-04-27 06:45:32 (GMT) |
commit | 1b59d10ce2a8eeb50878bc5a292bcc2257c40c47 (patch) | |
tree | afa48dfcc25e48ad57ec9ca3fb835986e1540ae1 /Lib/test/test_pty.py | |
parent | bd77c037ed6826683458f15cad481abf8dff0525 (diff) | |
download | cpython-1b59d10ce2a8eeb50878bc5a292bcc2257c40c47.zip cpython-1b59d10ce2a8eeb50878bc5a292bcc2257c40c47.tar.gz cpython-1b59d10ce2a8eeb50878bc5a292bcc2257c40c47.tar.bz2 |
This gets the test working on Solaris. It seems a little hokey to me,
but the test passed on Linux and Solaris, hopefully other platforms too.
Diffstat (limited to 'Lib/test/test_pty.py')
-rw-r--r-- | Lib/test/test_pty.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py index 11fff34..c00244f 100644 --- a/Lib/test/test_pty.py +++ b/Lib/test/test_pty.py @@ -1,3 +1,5 @@ +import errno +import fcntl import pty import os import sys @@ -40,6 +42,7 @@ def normalize_output(data): # Marginal testing of pty suite. Cannot do extensive 'do or fail' testing # because pty code is not too portable. +# XXX(nnorwitz): these tests leak fds when there is an error. class PtyTest(unittest.TestCase): def setUp(self): # isatty() and close() can hang on some platforms. Set an alarm @@ -70,6 +73,22 @@ class PtyTest(unittest.TestCase): self.assertTrue(os.isatty(slave_fd), 'slave_fd is not a tty') + # Solaris requires reading the fd before anything is returned. + # My guess is that since we open and close the slave fd + # in master_open(), we need to read the EOF. + + # Ensure the fd is non-blocking in case there's nothing to read. + orig_flags = fcntl.fcntl(master_fd, fcntl.F_GETFL) + fcntl.fcntl(master_fd, fcntl.F_SETFL, orig_flags | os.O_NONBLOCK) + try: + s1 = os.read(master_fd, 1024) + self.assertEquals('', s1) + except OSError, e: + if e.errno != errno.EAGAIN: + raise + # Restore the original flags. + fcntl.fcntl(master_fd, fcntl.F_SETFL, orig_flags) + debug("Writing to slave_fd") os.write(slave_fd, TEST_STRING_1) s1 = os.read(master_fd, 1024) |