<s> import unittest <EOL> from test . test_support import TestSkipped , run_unittest <EOL> import os , struct <EOL> try : <EOL> import fcntl , termios <EOL> except ImportError : <EOL> raise TestSkipped ( "<STR_LIT>" ) <EOL> if not hasattr ( termios , '<STR_LIT>' ) : <EOL> raise TestSkipped ( "<STR_LIT>" ) <EOL> try : <EOL> tty = open ( "<STR_LIT>" , "<STR_LIT:r>" ) <EOL> tty . close ( ) <EOL> except IOError : <EOL> raise TestSkipped ( "<STR_LIT>" ) <EOL> class IoctlTests ( unittest . TestCase ) : <EOL> def test_ioctl ( self ) : <EOL> ids = ( os . getpgrp ( ) , os . getsid ( <NUM_LIT:0> ) ) <EOL> tty = open ( "<STR_LIT>" , "<STR_LIT:r>" ) <EOL> r = fcntl . ioctl ( tty , termios . TIOCGPGRP , "<STR_LIT:U+0020>" ) <EOL> rpgrp = struct . unpack ( "<STR_LIT:i>" , r ) [ <NUM_LIT:0> ] <EOL> self . assert_ ( rpgrp in ids , "<STR_LIT>" % ( rpgrp , ids ) ) <EOL> def test_ioctl_mutate ( self ) : <EOL> import array <EOL> buf = array . array ( '<STR_LIT:i>' , [ <NUM_LIT:0> ] ) <EOL> ids = ( os . getpgrp ( ) , os . getsid ( <NUM_LIT:0> ) ) <EOL> tty = open ( "<STR_LIT>" , "<STR_LIT:r>" ) <EOL> r = fcntl . ioctl ( tty , termios . TIOCGPGRP , buf , <NUM_LIT:1> ) <EOL> rpgrp = buf [ <NUM_LIT:0> ] <EOL> self . assertEquals ( r , <NUM_LIT:0> ) <EOL> self . assert_ ( rpgrp in ids , "<STR_LIT>" % ( rpgrp , ids ) ) <EOL> def test_main ( ) : <EOL> run_unittest ( IoctlTests ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> test_main ( ) </s>
