GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||
GeezerVison is showing github.com — gh-119273: Don't run test_ioctl in a process group by vstinner · Pull Request #119275 · python/cpython Conversation
|
|
Without this change, the test is skipped: With the change, the test is no longer skipped: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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.
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...
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
The following tests contains the word Skipped tests:
Tests not skipped (ok):
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
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: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I merged this PR as it is. I will prepare a following PR to handle test_builtin, test_fileio and test_shutil. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Follow-up: I created issue gh-119727: Add |
Sorry, something went wrong.
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.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.