Skip to content

Commit 3642a32

Browse files
Skip test_ioctl_suspend_and_resume_output on Android too.
1 parent 777da5b commit 3642a32

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

Lib/test/test_ioctl.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sys
55
import threading
66
import unittest
7-
from test.support import get_attribute
7+
from test import support
88
from test.support import threading_helper
99
from test.support.import_helper import import_module
1010
fcntl = import_module('fcntl')
@@ -13,7 +13,7 @@
1313
class IoctlTestsTty(unittest.TestCase):
1414
@classmethod
1515
def setUpClass(cls):
16-
TIOCGPGRP = get_attribute(termios, 'TIOCGPGRP')
16+
TIOCGPGRP = support.get_attribute(termios, 'TIOCGPGRP')
1717
try:
1818
tty = open("/dev/tty", "rb")
1919
except OSError:
@@ -143,8 +143,8 @@ def setUp(self):
143143
def test_ioctl_clear_input_or_output(self):
144144
wfd = self.slave_fd
145145
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.
148148
inbuf = sys.platform in ('linux', 'android')
149149

150150
os.write(wfd, b'abcdef')
@@ -165,6 +165,7 @@ def test_ioctl_clear_input_or_output(self):
165165
os.write(wfd, b'ABCDEF')
166166
self.assertEqual(os.read(rfd, 1024), b'ABCDEF')
167167

168+
@support.skip_android_selinux('tcflow')
168169
@unittest.skipUnless(sys.platform in ('linux', 'android'), 'only works on Linux')
169170
@unittest.skipUnless(hasattr(termios, 'TCXONC'), 'requires termios.TCXONC')
170171
def test_ioctl_suspend_and_resume_output(self):
@@ -175,20 +176,22 @@ def test_ioctl_suspend_and_resume_output(self):
175176

176177
def writer():
177178
os.write(wfd, b'abc')
178-
write_suspended.wait()
179+
self.assertTrue(write_suspended.wait(5))
179180
os.write(wfd, b'def')
180181
write_finished.set()
181182

182183
with threading_helper.start_threads([threading.Thread(target=writer)]):
183184
self.assertEqual(os.read(rfd, 3), b'abc')
184185
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()
187190
self.assertFalse(write_finished.wait(0.5),
188191
'output was not suspended')
189192
finally:
190193
fcntl.ioctl(wfd, termios.TCXONC, termios.TCOON)
191-
self.assertTrue(write_finished.wait(0.5),
194+
self.assertTrue(write_finished.wait(5),
192195
'output was not resumed')
193196
self.assertEqual(os.read(rfd, 1024), b'def')
194197

Lib/test/test_termios.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ def test_tcflush_errors(self):
152152
def test_tcflush_clear_input_or_output(self):
153153
wfd = self.fd
154154
rfd = self.master_fd
155-
# The data is buffered in input buffer on Linux, and in
156-
# output buffer on other platforms.
155+
# The data is buffered in the input buffer on Linux, and in
156+
# the output buffer on other platforms.
157157
inbuf = sys.platform in ('linux', 'android')
158158

159159
os.write(wfd, b'abcdef')
@@ -202,20 +202,22 @@ def test_tcflow_suspend_and_resume_output(self):
202202

203203
def writer():
204204
os.write(wfd, b'abc')
205-
write_suspended.wait()
205+
self.assertTrue(write_suspended.wait(5))
206206
os.write(wfd, b'def')
207207
write_finished.set()
208208

209209
with threading_helper.start_threads([threading.Thread(target=writer)]):
210210
self.assertEqual(os.read(rfd, 3), b'abc')
211211
try:
212-
termios.tcflow(wfd, termios.TCOOFF)
213-
write_suspended.set()
212+
try:
213+
termios.tcflow(wfd, termios.TCOOFF)
214+
finally:
215+
write_suspended.set()
214216
self.assertFalse(write_finished.wait(0.5),
215217
'output was not suspended')
216218
finally:
217219
termios.tcflow(wfd, termios.TCOON)
218-
self.assertTrue(write_finished.wait(0.5),
220+
self.assertTrue(write_finished.wait(5),
219221
'output was not resumed')
220222
self.assertEqual(os.read(rfd, 1024), b'def')
221223

0 commit comments

Comments
 (0)