Skip to content

Commit 777da5b

Browse files
gh-132742: Fix tcflush() tests on Android
1 parent 6677c2c commit 777da5b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

Lib/test/test_ioctl.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ def setUp(self):
143143
def test_ioctl_clear_input_or_output(self):
144144
wfd = self.slave_fd
145145
rfd = self.master_fd
146-
inbuf = sys.platform == 'linux'
146+
# The data is buffered in input buffer on Linux, and in
147+
# output buffer on other platforms.
148+
inbuf = sys.platform in ('linux', 'android')
147149

148150
os.write(wfd, b'abcdef')
149151
self.assertEqual(os.read(rfd, 2), b'ab')
@@ -163,7 +165,7 @@ def test_ioctl_clear_input_or_output(self):
163165
os.write(wfd, b'ABCDEF')
164166
self.assertEqual(os.read(rfd, 1024), b'ABCDEF')
165167

166-
@unittest.skipUnless(sys.platform == 'linux', 'only works on Linux')
168+
@unittest.skipUnless(sys.platform in ('linux', 'android'), 'only works on Linux')
167169
@unittest.skipUnless(hasattr(termios, 'TCXONC'), 'requires termios.TCXONC')
168170
def test_ioctl_suspend_and_resume_output(self):
169171
wfd = self.slave_fd

Lib/test/test_termios.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ def test_tcflush_errors(self):
152152
def test_tcflush_clear_input_or_output(self):
153153
wfd = self.fd
154154
rfd = self.master_fd
155-
inbuf = sys.platform == 'linux'
155+
# The data is buffered in input buffer on Linux, and in
156+
# output buffer on other platforms.
157+
inbuf = sys.platform in ('linux', 'android')
156158

157159
os.write(wfd, b'abcdef')
158160
self.assertEqual(os.read(rfd, 2), b'ab')
@@ -190,7 +192,8 @@ def test_tcflow_errors(self):
190192
self.assertRaises(TypeError, termios.tcflow, object(), termios.TCOON)
191193
self.assertRaises(TypeError, termios.tcflow, self.fd)
192194

193-
@unittest.skipUnless(sys.platform == 'linux', 'only works on Linux')
195+
@support.skip_android_selinux('tcflow')
196+
@unittest.skipUnless(sys.platform in ('linux', 'android'), 'only works on Linux')
194197
def test_tcflow_suspend_and_resume_output(self):
195198
wfd = self.fd
196199
rfd = self.master_fd

0 commit comments

Comments
 (0)