Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
gh-132742: Fix newly added tcflush() tests on Android#133070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from2 commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -4,7 +4,7 @@ | ||
import sys | ||
import threading | ||
import unittest | ||
from test importsupport | ||
from test.support import threading_helper | ||
from test.support.import_helper import import_module | ||
fcntl = import_module('fcntl') | ||
@@ -13,7 +13,7 @@ | ||
class IoctlTestsTty(unittest.TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
TIOCGPGRP =support.get_attribute(termios, 'TIOCGPGRP') | ||
try: | ||
tty = open("/dev/tty", "rb") | ||
except OSError: | ||
@@ -143,7 +143,9 @@ def setUp(self): | ||
def test_ioctl_clear_input_or_output(self): | ||
wfd = self.slave_fd | ||
rfd = self.master_fd | ||
# The data is buffered in the input buffer on Linux, and in | ||
# the output buffer on other platforms. | ||
inbuf = sys.platform in ('linux', 'android') | ||
os.write(wfd, b'abcdef') | ||
self.assertEqual(os.read(rfd, 2), b'ab') | ||
@@ -163,7 +165,8 @@ def test_ioctl_clear_input_or_output(self): | ||
os.write(wfd, b'ABCDEF') | ||
self.assertEqual(os.read(rfd, 1024), b'ABCDEF') | ||
@support.skip_android_selinux('tcflow') | ||
@unittest.skipUnless(sys.platform in ('linux', 'android'), 'only works on Linux') | ||
@unittest.skipUnless(hasattr(termios, 'TCXONC'), 'requires termios.TCXONC') | ||
def test_ioctl_suspend_and_resume_output(self): | ||
wfd = self.slave_fd | ||
@@ -173,20 +176,22 @@ def test_ioctl_suspend_and_resume_output(self): | ||
def writer(): | ||
os.write(wfd, b'abc') | ||
self.assertTrue(write_suspended.wait(5)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I would prefer to use support.SHORT_TIMEOUT rather than hardcoded timeout. Same remark for other 5 seconds timeouts. | ||
os.write(wfd, b'def') | ||
write_finished.set() | ||
with threading_helper.start_threads([threading.Thread(target=writer)]): | ||
self.assertEqual(os.read(rfd, 3), b'abc') | ||
try: | ||
try: | ||
fcntl.ioctl(wfd, termios.TCXONC, termios.TCOOFF) | ||
finally: | ||
write_suspended.set() | ||
self.assertFalse(write_finished.wait(0.5), | ||
'output was not suspended') | ||
finally: | ||
fcntl.ioctl(wfd, termios.TCXONC, termios.TCOON) | ||
self.assertTrue(write_finished.wait(5), | ||
'output was not resumed') | ||
self.assertEqual(os.read(rfd, 1024), b'def') | ||
Uh oh!
There was an error while loading.Please reload this page.