4
4
import sys
5
5
import threading
6
6
import unittest
7
- from test . support import get_attribute
7
+ from test import support
8
8
from test .support import threading_helper
9
9
from test .support .import_helper import import_module
10
10
fcntl = import_module ('fcntl' )
13
13
class IoctlTestsTty (unittest .TestCase ):
14
14
@classmethod
15
15
def setUpClass (cls ):
16
- TIOCGPGRP = get_attribute (termios , 'TIOCGPGRP' )
16
+ TIOCGPGRP = support . get_attribute (termios , 'TIOCGPGRP' )
17
17
try :
18
18
tty = open ("/dev/tty" , "rb" )
19
19
except OSError :
@@ -143,8 +143,8 @@ def setUp(self):
143
143
def test_ioctl_clear_input_or_output (self ):
144
144
wfd = self .slave_fd
145
145
rfd = self .master_fd
146
- # The data is buffered in input buffer on Linux, and in
147
- # output buffer on other platforms.
146
+ # The data is buffered in the input buffer on Linux, and in
147
+ # the output buffer on other platforms.
148
148
inbuf = sys .platform in ('linux' , 'android' )
149
149
150
150
os .write (wfd , b'abcdef' )
@@ -165,6 +165,7 @@ def test_ioctl_clear_input_or_output(self):
165
165
os .write (wfd , b'ABCDEF' )
166
166
self .assertEqual (os .read (rfd , 1024 ), b'ABCDEF' )
167
167
168
+ @support .skip_android_selinux ('tcflow' )
168
169
@unittest .skipUnless (sys .platform in ('linux' , 'android' ), 'only works on Linux' )
169
170
@unittest .skipUnless (hasattr (termios , 'TCXONC' ), 'requires termios.TCXONC' )
170
171
def test_ioctl_suspend_and_resume_output (self ):
@@ -175,20 +176,22 @@ def test_ioctl_suspend_and_resume_output(self):
175
176
176
177
def writer ():
177
178
os .write (wfd , b'abc' )
178
- write_suspended .wait ()
179
+ self . assertTrue ( write_suspended .wait (5 ) )
179
180
os .write (wfd , b'def' )
180
181
write_finished .set ()
181
182
182
183
with threading_helper .start_threads ([threading .Thread (target = writer )]):
183
184
self .assertEqual (os .read (rfd , 3 ), b'abc' )
184
185
try :
185
- fcntl .ioctl (wfd , termios .TCXONC , termios .TCOOFF )
186
- write_suspended .set ()
186
+ try :
187
+ fcntl .ioctl (wfd , termios .TCXONC , termios .TCOOFF )
188
+ finally :
189
+ write_suspended .set ()
187
190
self .assertFalse (write_finished .wait (0.5 ),
188
191
'output was not suspended' )
189
192
finally :
190
193
fcntl .ioctl (wfd , termios .TCXONC , termios .TCOON )
191
- self .assertTrue (write_finished .wait (0. 5 ),
194
+ self .assertTrue (write_finished .wait (5 ),
192
195
'output was not resumed' )
193
196
self .assertEqual (os .read (rfd , 1024 ), b'def' )
194
197
0 commit comments