|
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,7 +143,9 @@ 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 |
| - inbuf = sys.platform == 'linux' |
| 146 | + # The data is buffered in the input buffer on Linux, and in |
| 147 | + # the output buffer on other platforms. |
| 148 | + inbuf = sys.platform in ('linux', 'android') |
147 | 149 |
|
148 | 150 | os.write(wfd, b'abcdef')
|
149 | 151 | self.assertEqual(os.read(rfd, 2), b'ab')
|
@@ -173,20 +175,22 @@ def test_ioctl_suspend_and_resume_output(self):
|
173 | 175 |
|
174 | 176 | def writer():
|
175 | 177 | os.write(wfd, b'abc')
|
176 |
| - write_suspended.wait() |
| 178 | + self.assertTrue(write_suspended.wait(support.SHORT_TIMEOUT)) |
177 | 179 | os.write(wfd, b'def')
|
178 | 180 | write_finished.set()
|
179 | 181 |
|
180 | 182 | with threading_helper.start_threads([threading.Thread(target=writer)]):
|
181 | 183 | self.assertEqual(os.read(rfd, 3), b'abc')
|
182 | 184 | try:
|
183 |
| - fcntl.ioctl(wfd, termios.TCXONC, termios.TCOOFF) |
184 |
| - write_suspended.set() |
| 185 | + try: |
| 186 | + fcntl.ioctl(wfd, termios.TCXONC, termios.TCOOFF) |
| 187 | + finally: |
| 188 | + write_suspended.set() |
185 | 189 | self.assertFalse(write_finished.wait(0.5),
|
186 | 190 | 'output was not suspended')
|
187 | 191 | finally:
|
188 | 192 | fcntl.ioctl(wfd, termios.TCXONC, termios.TCOON)
|
189 |
| - self.assertTrue(write_finished.wait(0.5), |
| 193 | + self.assertTrue(write_finished.wait(support.SHORT_TIMEOUT), |
190 | 194 | 'output was not resumed')
|
191 | 195 | self.assertEqual(os.read(rfd, 1024), b'def')
|
192 | 196 |
|
|
0 commit comments