summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/pty_root.cc
diff options
context:
space:
mode:
authorZach Koopmans <zkoopmans@google.com>2020-08-27 09:50:53 -0700
committerAndrei Vagin <avagin@gmail.com>2020-09-09 17:53:10 -0700
commit5588def369a09b4525842b04a43fbf146e662311 (patch)
tree42ac061c1db2106e2cb0200a78399c732416f815 /test/syscalls/linux/pty_root.cc
parent4705782bf39e7202a5fd66a966fac94baf36492b (diff)
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
Diffstat (limited to 'test/syscalls/linux/pty_root.cc')
-rw-r--r--test/syscalls/linux/pty_root.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/test/syscalls/linux/pty_root.cc b/test/syscalls/linux/pty_root.cc
index 1d7dbefdb..a534cf0bb 100644
--- a/test/syscalls/linux/pty_root.cc
+++ b/test/syscalls/linux/pty_root.cc
@@ -48,12 +48,12 @@ TEST(JobControlRootTest, StealTTY) {
ASSERT_THAT(setsid(), SyscallSucceeds());
}
- FileDescriptor master =
+ FileDescriptor main =
ASSERT_NO_ERRNO_AND_VALUE(Open("/dev/ptmx", O_RDWR | O_NONBLOCK));
- FileDescriptor slave = ASSERT_NO_ERRNO_AND_VALUE(OpenSlave(master));
+ FileDescriptor replica = ASSERT_NO_ERRNO_AND_VALUE(OpenReplica(main));
- // Make slave the controlling terminal.
- ASSERT_THAT(ioctl(slave.get(), TIOCSCTTY, 0), SyscallSucceeds());
+ // Make replica the controlling terminal.
+ ASSERT_THAT(ioctl(replica.get(), TIOCSCTTY, 0), SyscallSucceeds());
// Fork, join a new session, and try to steal the parent's controlling
// terminal, which should succeed when we have CAP_SYS_ADMIN and pass an arg
@@ -62,9 +62,9 @@ TEST(JobControlRootTest, StealTTY) {
if (!child) {
ASSERT_THAT(setsid(), SyscallSucceeds());
// We shouldn't be able to steal the terminal with the wrong arg value.
- TEST_PCHECK(ioctl(slave.get(), TIOCSCTTY, 0));
+ TEST_PCHECK(ioctl(replica.get(), TIOCSCTTY, 0));
// We should be able to steal it if we are true root.
- TEST_PCHECK(true_root == !ioctl(slave.get(), TIOCSCTTY, 1));
+ TEST_PCHECK(true_root == !ioctl(replica.get(), TIOCSCTTY, 1));
_exit(0);
}