OLD | NEW |
1 import array | 1 import array |
2 import unittest | 2 import unittest |
3 from test.support import run_unittest, import_module, get_attribute | 3 from test.support import run_unittest, import_module, get_attribute |
4 import os, struct | 4 import os, struct |
5 fcntl = import_module('fcntl') | 5 fcntl = import_module('fcntl') |
6 termios = import_module('termios') | 6 termios = import_module('termios') |
7 get_attribute(termios, 'TIOCGPGRP') #Can't run tests without this feature | 7 get_attribute(termios, 'TIOCGPGRP') #Can't run tests without this feature |
8 | 8 |
9 try: | 9 try: |
10 tty = open("/dev/tty", "r") | 10 tty = open("/dev/tty", "r") |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 fill = -12345 | 43 fill = -12345 |
44 if nbytes is not None: | 44 if nbytes is not None: |
45 # Extend the buffer so that it is exactly `nbytes` bytes long | 45 # Extend the buffer so that it is exactly `nbytes` bytes long |
46 buf.extend([fill] * (nbytes // intsize)) | 46 buf.extend([fill] * (nbytes // intsize)) |
47 self.assertEqual(len(buf) * intsize, nbytes) # sanity check | 47 self.assertEqual(len(buf) * intsize, nbytes) # sanity check |
48 else: | 48 else: |
49 buf.append(fill) | 49 buf.append(fill) |
50 with open("/dev/tty", "r") as tty: | 50 with open("/dev/tty", "r") as tty: |
51 r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1) | 51 r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1) |
52 rpgrp = buf[0] | 52 rpgrp = buf[0] |
53 self.assertEquals(r, 0) | 53 self.assertEqual(r, 0) |
54 self.assertIn(rpgrp, ids) | 54 self.assertIn(rpgrp, ids) |
55 | 55 |
56 def test_ioctl_mutate(self): | 56 def test_ioctl_mutate(self): |
57 self._check_ioctl_mutate_len() | 57 self._check_ioctl_mutate_len() |
58 | 58 |
59 def test_ioctl_mutate_1024(self): | 59 def test_ioctl_mutate_1024(self): |
60 # Issue #9758: a mutable buffer of exactly 1024 bytes wouldn't be | 60 # Issue #9758: a mutable buffer of exactly 1024 bytes wouldn't be |
61 # copied back after the system call. | 61 # copied back after the system call. |
62 self._check_ioctl_mutate_len(1024) | 62 self._check_ioctl_mutate_len(1024) |
63 | 63 |
(...skipping 20 matching lines...) Expand all Loading... |
84 new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_maybe_neg, our_winsz) | 84 new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_maybe_neg, our_winsz) |
85 finally: | 85 finally: |
86 os.close(mfd) | 86 os.close(mfd) |
87 os.close(sfd) | 87 os.close(sfd) |
88 | 88 |
89 def test_main(): | 89 def test_main(): |
90 run_unittest(IoctlTests) | 90 run_unittest(IoctlTests) |
91 | 91 |
92 if __name__ == "__main__": | 92 if __name__ == "__main__": |
93 test_main() | 93 test_main() |
OLD | NEW |