Back to index

python3.2  3.2.2
Public Member Functions | Private Member Functions
test.test_ioctl.IoctlTests Class Reference

List of all members.

Public Member Functions

def test_ioctl
def test_ioctl_mutate
def test_ioctl_mutate_1024
def test_ioctl_mutate_2048
def test_ioctl_signed_unsigned_code_param

Private Member Functions

def _check_ioctl_mutate_len

Detailed Description

Definition at line 28 of file test_ioctl.py.


Member Function Documentation

def test.test_ioctl.IoctlTests._check_ioctl_mutate_len (   self,
  nbytes = None 
) [private]

Definition at line 38 of file test_ioctl.py.

00038 
00039     def _check_ioctl_mutate_len(self, nbytes=None):
00040         buf = array.array('i')
00041         intsize = buf.itemsize
00042         ids = (os.getpgrp(), os.getsid(0))
00043         # A fill value unlikely to be in `ids`
00044         fill = -12345
00045         if nbytes is not None:
00046             # Extend the buffer so that it is exactly `nbytes` bytes long
00047             buf.extend([fill] * (nbytes // intsize))
00048             self.assertEqual(len(buf) * intsize, nbytes)   # sanity check
00049         else:
00050             buf.append(fill)
00051         with open("/dev/tty", "rb") as tty:
00052             r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1)
00053         rpgrp = buf[0]
00054         self.assertEqual(r, 0)
00055         self.assertIn(rpgrp, ids)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 29 of file test_ioctl.py.

00029 
00030     def test_ioctl(self):
00031         # If this process has been put into the background, TIOCGPGRP returns
00032         # the session ID instead of the process group id.
00033         ids = (os.getpgrp(), os.getsid(0))
00034         with open("/dev/tty", "rb") as tty:
00035             r = fcntl.ioctl(tty, termios.TIOCGPGRP, "    ")
00036             rpgrp = struct.unpack("i", r)[0]
00037             self.assertIn(rpgrp, ids)

Here is the call graph for this function:

Definition at line 56 of file test_ioctl.py.

00056 
00057     def test_ioctl_mutate(self):
00058         self._check_ioctl_mutate_len()

Here is the call graph for this function:

Definition at line 59 of file test_ioctl.py.

00059 
00060     def test_ioctl_mutate_1024(self):
00061         # Issue #9758: a mutable buffer of exactly 1024 bytes wouldn't be
00062         # copied back after the system call.
00063         self._check_ioctl_mutate_len(1024)

Here is the call graph for this function:

Definition at line 64 of file test_ioctl.py.

00064 
00065     def test_ioctl_mutate_2048(self):
00066         # Test with a larger buffer, just for the record.
00067         self._check_ioctl_mutate_len(2048)

Here is the call graph for this function:

Definition at line 68 of file test_ioctl.py.

00068 
00069     def test_ioctl_signed_unsigned_code_param(self):
00070         if not pty:
00071             raise unittest.SkipTest('pty module required')
00072         mfd, sfd = pty.openpty()
00073         try:
00074             if termios.TIOCSWINSZ < 0:
00075                 set_winsz_opcode_maybe_neg = termios.TIOCSWINSZ
00076                 set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xffffffff
00077             else:
00078                 set_winsz_opcode_pos = termios.TIOCSWINSZ
00079                 set_winsz_opcode_maybe_neg, = struct.unpack("i",
00080                         struct.pack("I", termios.TIOCSWINSZ))
00081 
00082             our_winsz = struct.pack("HHHH",80,25,0,0)
00083             # test both with a positive and potentially negative ioctl code
00084             new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_pos, our_winsz)
00085             new_winsz = fcntl.ioctl(mfd, set_winsz_opcode_maybe_neg, our_winsz)
00086         finally:
00087             os.close(mfd)
00088             os.close(sfd)

Here is the call graph for this function:


The documentation for this class was generated from the following file: