blob: a6a59c5a4e10f53420f9b9081f0345bfc98d3785 [file] [log] [blame]
Michael W. Hudsonf0089982003-03-03 12:29:42 +00001import unittest
2from test_support import TestSkipped, run_unittest
3import os, struct
4try:
5 import fcntl, termios
6except ImportError:
7 raise TestSkipped("No fcntl or termios module")
8if not hasattr(termios,'TIOCGPGRP'):
9 raise TestSkipped("termios module doesn't have TIOCGPGRP")
10
11class IoctlTests(unittest.TestCase):
12 def test_ioctl(self):
13 pgrp = os.getpgrp()
14 tty = open("/dev/tty", "r")
15 r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
16 self.assertEquals(pgrp, struct.unpack("i", r)[0])
17
18 def test_ioctl_mutate(self):
19 import array
20 buf = array.array('i', [0])
21 pgrp = os.getpgrp()
22 tty = open("/dev/tty", "r")
23 r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1)
24 self.assertEquals(r, 0)
25 self.assertEquals(pgrp, buf[0])
26
27def test_main():
28 run_unittest(IoctlTests)
29
30if __name__ == "__main__":
31 test_main()