(self, nbytes=None)
| 37 | self.assertIn(rpgrp, ids) |
| 38 | |
| 39 | def _check_ioctl_mutate_len(self, nbytes=None): |
| 40 | buf = array.array('i') |
| 41 | intsize = buf.itemsize |
| 42 | ids = (os.getpgrp(), os.getsid(0)) |
| 43 | # A fill value unlikely to be in `ids` |
| 44 | fill = -12345 |
| 45 | if nbytes is not None: |
| 46 | # Extend the buffer so that it is exactly `nbytes` bytes long |
| 47 | buf.extend([fill] * (nbytes // intsize)) |
| 48 | self.assertEqual(len(buf) * intsize, nbytes) # sanity check |
| 49 | else: |
| 50 | buf.append(fill) |
| 51 | with open("/dev/tty", "rb") as tty: |
| 52 | r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, True) |
| 53 | rpgrp = buf[0] |
| 54 | self.assertEqual(r, 0) |
| 55 | self.assertIn(rpgrp, ids) |
| 56 | |
| 57 | def test_ioctl_mutate(self): |
| 58 | self._check_ioctl_mutate_len() |
no test coverage detected