from test
.test_support
import TestSkipped
, run_unittest
raise TestSkipped("No fcntl or termios module")
if not hasattr(termios
,'TIOCGPGRP'):
raise TestSkipped("termios module doesn't have TIOCGPGRP")
tty
= open("/dev/tty", "r")
raise TestSkipped("Unable to open /dev/tty")
class IoctlTests(unittest
.TestCase
):
# If this process has been put into the background, TIOCGPGRP returns
# the session ID instead of the process group id.
ids
= (os
.getpgrp(), os
.getsid(0))
tty
= open("/dev/tty", "r")
r
= fcntl
.ioctl(tty
, termios
.TIOCGPGRP
, " ")
rpgrp
= struct
.unpack("i", r
)[0]
self
.assert_(rpgrp
in ids
, "%s not in %s" % (rpgrp
, ids
))
def test_ioctl_mutate(self
):
buf
= array
.array('i', [0])
ids
= (os
.getpgrp(), os
.getsid(0))
tty
= open("/dev/tty", "r")
r
= fcntl
.ioctl(tty
, termios
.TIOCGPGRP
, buf
, 1)
self
.assert_(rpgrp
in ids
, "%s not in %s" % (rpgrp
, ids
))
if __name__
== "__main__":