-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-119273: Don't run test_ioctl in a process group #119275
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
Conversation
Python test runner no longer runs tests using TTY (ex: test_ioctl) in a process group (using setsid()). Previously, tests using TTY were skipped.
Without this change, the test is skipped:
With the change, the test is no longer skipped:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. While I wish there were a better way to avoid maintaining a special case list within libregrtest itself, the implementation of how not to use a process group is the same even if we gain that more direct ability instead of a far removed list in the future.
@@ -14,6 +14,9 @@ | |||
|
|||
|
|||
USE_PROCESS_GROUP = (hasattr(os, "setsid") and hasattr(os, "killpg")) | |||
NEED_TTY = set(''' | |||
test_ioctl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a couple of other tests that skip some of the test methods/classes when stdout is not a tty: test_builtin, test_curses, test_os, test_shutil at least, from a quick grep. I'm not sure it's going to be maintainable to keep a list like this up to date...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One option would be to move "tty" tests in separated test files and disable setsid() if the test name contains _tty
. For example, we already do that with GUI tests (ex: test_ttk and test_ttk_textonly).
Test on fork+setsid: import io
import os
def check_tty(context):
try:
f = io.FileIO("/dev/tty", "a")
tty = f.isatty()
f.close()
except OSError as exc:
print(f"{context}: Is a TTY? {exc}")
else:
print(f"{context}: Is a TTY? {tty}")
check_tty("parent")
pid = os.fork()
if pid:
os.waitpid(pid, 0)
else:
os.setsid()
check_tty("child after fork+setsid") Result on Linux:
The child process cannot open |
The following tests contains the word Skipped tests:
Tests not skipped (ok):
|
Using import io
import os
def check_tty(context):
try:
parent_fd, child_fd = os.openpty()
tty = os.isatty(parent_fd)
os.close(parent_fd)
os.close(child_fd)
except OSError as exc:
print(f"{context}: Is a TTY? {exc}")
else:
print(f"{context}: Is a TTY? {tty}")
check_tty("parent")
pid = os.fork()
if pid:
os.waitpid(pid, 0)
else:
os.setsid()
check_tty("child after fork+setsid") Output:
|
I merged this PR as it is. I will prepare a following PR to handle test_builtin, test_fileio and test_shutil. |
Sadly, these two tests need stdout to be a TTY. It's only doable if tests are run sequentially.
Well, it's just a subset of a minor test. I don't think that it's worth it to create a whole test file just for a few lines. |
Follow-up: I created issue gh-119727: Add |
Python test runner no longer runs tests using TTY (ex: test_ioctl) in a process group (using setsid()). Previously, tests using TTY were skipped.
Python test runner no longer runs tests using TTY (ex: test_ioctl) in a process group (using setsid()). Previously, tests using TTY were skipped.
Python test runner no longer runs tests using TTY (ex: test_ioctl) in a process group (using setsid()). Previously, tests using TTY were skipped.