8000 gh-132742: Improve tests for fcntl.ioctl() by serhiy-storchaka · Pull Request #132791 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-132742: Improve tests for fcntl.ioctl() #132791

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000 Prev Previous commit
Next Next commit
Skip tcflow() tests on non-Linux.
  • Loading branch information
serhiy-storchaka committed Apr 24, 2025
commit 7efcbf9fb1e89137ba62648a36bc55eda7fe10b7
16 changes: 10 additions & 6 deletions Lib/test/test_ioctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,16 @@ def writer():
write_finished.set()

with threading_helper.start_threads([threading.Thread(target=writer)]):
self.assertEqual(os.read(rfd, 1024), b'abc')
fcntl.ioctl(wfd, termios.TCXONC, termios.TCOOFF)
write_suspended.set()
self.assertFalse(write_finished.wait(0.5))
fcntl.ioctl(wfd, termios.TCXONC, termios.TCOON)
self.assertTrue(write_finished.wait(0.5))
self.assertEqual(os.read(rfd, 3), b'abc')
try:
fcntl.ioctl(wfd, termios.TCXONC, termios.TCOOFF)
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(0.5),
'output was not resumed')
self.assertEqual(os.read(rfd, 1024), b'def')

def test_ioctl_set_window_size(self):
Expand Down
17 changes: 11 additions & 6 deletions Lib/test/test_termios.py
6712
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ def test_tcflow_errors(self):
self.assertRaises(TypeError, termios.tcflow, object(), termios.TCOON)
self.assertRaises(TypeError, termios.tcflow, self.fd)

@unittest.skipUnless(sys.platform == 'linux', 'only works on Linux')
def test_tcflow_suspend_and_resume_output(self):
wfd = self.fd
rfd = self.master_fd
Expand All @@ -203,12 +204,16 @@ def writer():
write_finished.set()

with threading_helper.start_threads([threading.Thread(target=writer)]):
self.assertEqual(os.read(rfd, 1024), b'abc')
termios.tcflow(wfd, termios.TCOOFF)
write_suspended.set()
self.assertFalse(write_finished.wait(0.5))
termios.tcflow(wfd, termios.TCOON)
self.assertTrue(write_finished.wait(0.5))
self.assertEqual(os.read(rfd, 3), b'abc')
try:
termios.tcflow(wfd, termios.TCOOFF)
write_suspended.set()
self.assertFalse(write_finished.wait(0.5),
'output was not suspended')
finally:
termios.tcflow(wfd, termios.TCOON)
self.assertTrue(write_finished.wait(0.5),
'output was not resumed')
self.assertEqual(os.read(rfd, 1024), b'def')

def test_tcgetwinsize(self):
Expand Down
Loading
0