From 140ffb60073c74953666be476fd0be13301a3b4d Mon Sep 17 00:00:00 2001 From: Zach Koopmans Date: Thu, 27 Aug 2020 09:50:53 -0700 Subject: Fix JobControl tests for open source. ioctl calls with TIOCSCTTY fail if the calling process already has a controlling terminal, which occurs on a 5.4 kernel like our Ubuntu 18 CI. Thus, run tests calling ioctl TTOCSCTTY in clean subprocess. Also, while we're here, switch out non-inclusive master/slave for main/replica. PiperOrigin-RevId: 328756598 --- test/util/pty_util.cc | 10 +++++----- test/util/pty_util.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'test/util') diff --git a/test/util/pty_util.cc b/test/util/pty_util.cc index c01f916aa..5fa622922 100644 --- a/test/util/pty_util.cc +++ b/test/util/pty_util.cc @@ -23,25 +23,25 @@ namespace gvisor { namespace testing { -PosixErrorOr OpenSlave(const FileDescriptor& master) { - PosixErrorOr n = SlaveID(master); +PosixErrorOr OpenReplica(const FileDescriptor& main) { + PosixErrorOr n = ReplicaID(main); if (!n.ok()) { return PosixErrorOr(n.error()); } return Open(absl::StrCat("/dev/pts/", n.ValueOrDie()), O_RDWR | O_NONBLOCK); } -PosixErrorOr SlaveID(const FileDescriptor& master) { +PosixErrorOr ReplicaID(const FileDescriptor& main) { // Get pty index. int n; - int ret = ioctl(master.get(), TIOCGPTN, &n); + int ret = ioctl(main.get(), TIOCGPTN, &n); if (ret < 0) { return PosixError(errno, "ioctl(TIOCGPTN) failed"); } // Unlock pts. int unlock = 0; - ret = ioctl(master.get(), TIOCSPTLCK, &unlock); + ret = ioctl(main.get(), TIOCSPTLCK, &unlock); if (ret < 0) { return PosixError(errno, "ioctl(TIOSPTLCK) failed"); } diff --git a/test/util/pty_util.h b/test/util/pty_util.h index 0722da379..dff6adab5 100644 --- a/test/util/pty_util.h +++ b/test/util/pty_util.h @@ -21,11 +21,11 @@ namespace gvisor { namespace testing { -// Opens the slave end of the passed master as R/W and nonblocking. -PosixErrorOr OpenSlave(const FileDescriptor& master); +// Opens the replica end of the passed main as R/W and nonblocking. +PosixErrorOr OpenReplica(const FileDescriptor& main); -// Get the number of the slave end of the master. -PosixErrorOr SlaveID(const FileDescriptor& master); +// Get the number of the replica end of the main. +PosixErrorOr ReplicaID(const FileDescriptor& main); } // namespace testing } // namespace gvisor -- cgit v1.2.3