gh-119273: Don't run test_ioctl in a process group#119275
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: |
Sorry, something went wrong.
gpshead
left a comment
There was a problem hiding this comment.
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.
|
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.
|
The following tests contains the word Skipped tests:
Tests not skipped (ok):
|
Sorry, something went wrong.
|
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.
|
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.
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.
|
Follow-up: I created issue gh-119727: Add |
Sorry, something went wrong.
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.