Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
vstinner commented May 20, 2024 • edited by bedevere-app bot
Loading Uh oh!
There was an error while loading. Please reload this page.
edited by bedevere-app bot
Uh oh!
There was an error while loading. Please reload this page.
Python test runner no longer runs tests using TTY (ex: test_ioctl) in a process group (using setsid()). Previously, tests using TTY were skipped.
vstinner commented May 20, 2024
Without this change, the test is skipped: With the change, the test is no longer skipped: |
gpshead left a comment
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.
Uh oh!
There was an error while loading. Please reload this page.
| 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).
vstinner commented May 23, 2024
Test on fork+setsid: importioimportosdefcheck_tty(context): try: f=io.FileIO("/dev/tty", "a") tty=f.isatty() f.close() exceptOSErrorasexc: print(f"{context}: Is a TTY? {exc}") else: print(f"{context}: Is a TTY? {tty}") check_tty("parent") pid=os.fork() ifpid: os.waitpid(pid, 0) else: os.setsid() check_tty("child after fork+setsid")Result on Linux: The child process cannot open |
vstinner commented May 23, 2024 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
The following tests contains the word Skipped tests:
Tests not skipped (ok):
|
vstinner commented May 27, 2024
Using importioimportosdefcheck_tty(context): try: parent_fd, child_fd=os.openpty() tty=os.isatty(parent_fd) os.close(parent_fd) os.close(child_fd) exceptOSErrorasexc: print(f"{context}: Is a TTY? {exc}") else: print(f"{context}: Is a TTY? {tty}") check_tty("parent") pid=os.fork() ifpid: os.waitpid(pid, 0) else: os.setsid() check_tty("child after fork+setsid")Output: |
vstinner commented May 29, 2024
I merged this PR as it is. I will prepare a following PR to handle test_builtin, test_fileio and test_shutil. |
vstinner commented May 29, 2024
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. |
vstinner commented May 29, 2024
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.