Skip to content

test_ioctl failing on MacOS #132843

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

Closed
smontanaro opened this issue Apr 23, 2025 · 1 comment · Fixed by #132848
Closed

test_ioctl failing on MacOS #132843

smontanaro opened this issue Apr 23, 2025 · 1 comment · Fixed by #132848
Labels
type-bug An unexpected behavior, bug, or error

Comments

@smontanaro
Copy link
Contributor

smontanaro commented Apr 23, 2025

Bug report

Bug description:

A new test, test_ioctl.test_ioctl_tcflush, fails for me on M1 MacBook Pro (Sequoia 15.4.1) because termios doesn't have a TCFLSH attribute.

% ./python.exe -m test test_ioctl
Using random seed: 2942680825
0:00:00 load avg: 1.77 Run 1 test sequentially in a single process
0:00:00 load avg: 1.77 [1/1] test_ioctl
test test_ioctl failed -- Traceback (most recent call last):
  File "/Users/skip/src/python/cpython/Lib/test/test_ioctl.py", line 137, in test_ioctl_tcflush
    r = fcntl.ioctl(tty, termios.TCFLSH, termios.TCIFLUSH)
                         ^^^^^^^^^^^^^^
AttributeError: module 'termios' has no attribute 'TCFLSH'. Did you mean: 'CFLUSH'?

0:00:00 load avg: 1.77 [1/1/1] test_ioctl failed (1 error)

== Tests result: FAILURE ==

1 test failed:
    test_ioctl

Total duration: 20 ms
Total tests: run=8
Total test files: run=1/1 failed=1
Result: FAILURE

Here's what termios does have which resembles "flush":

>>> [a for a in dir(termios) if "FLUSH" in a or "FLSH" in a]
['CFLUSH', 'FLUSHO', 'NOFLSH', 'TCIFLUSH', 'TCIOFLUSH', 'TCOFLUSH', 'TCSAFLUSH', 'TIOCPKT_FLUSHREAD', 'TIOCPKT_FLUSHWRITE']

I saw no check for TCFLSH in configure, so presume it's expected to be widely available, but I know nothing about this stuff. Pinging @serhiy-storchaka .

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

@smontanaro smontanaro added the type-bug An unexpected behavior, bug, or error label Apr 23, 2025
@serhiy-storchaka
Copy link
Member

serhiy-storchaka commented Apr 23, 2025

The test is passed on CI and builtbots because all these tests are skipped because "/dev/tty" is not available.

I discovered this when worked on #132791. There are some issues with handling tcflush() and tcflow() on BSD/macOS, but the part of that PR which fixes dependency on "/dev/tty" and TCFLSH can be safely merged.

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Apr 23, 2025
* Skip test_ioctl_tcflush if termios.TCFLSH is not available.
* Do not skip ALL ioctl() tests when /dev/tty is not available.
@serhiy-storchaka serhiy-storchaka linked a pull request Apr 23, 2025 that will close this issue
serhiy-storchaka added a commit that referenced this issue Apr 23, 2025
* Skip test_ioctl_tcflush if termios.TCFLSH is not available.
* Do not skip ALL ioctl() tests when /dev/tty is not available.
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Apr 23, 2025
…ythonGH-132848)

* Skip test_ioctl_tcflush if termios.TCFLSH is not available.
* Do not skip ALL ioctl() tests when /dev/tty is not available.
(cherry picked from commit 4b4b9fb)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this issue Apr 23, 2025
…H-132850)

* Skip test_ioctl_tcflush if termios.TCFLSH is not available.
* Do not skip ALL ioctl() tests when /dev/tty is not available.
(cherry picked from commit 4b4b9fb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants