From 6ec9d60403fdf7a33072eaa023e62bfd56ed9f5c Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Fri, 12 Jun 2020 11:56:43 -0700 Subject: vfs2: implement fcntl(fd, F_SETFL, flags) PiperOrigin-RevId: 316148074 --- test/syscalls/linux/fcntl.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/syscalls') diff --git a/test/syscalls/linux/fcntl.cc b/test/syscalls/linux/fcntl.cc index c7cc5816e..35e8a4ff3 100644 --- a/test/syscalls/linux/fcntl.cc +++ b/test/syscalls/linux/fcntl.cc @@ -115,6 +115,15 @@ PosixErrorOr SubprocessLock(std::string const& path, bool for_write, return std::move(cleanup); } +TEST(FcntlTest, SetCloExecBadFD) { + // Open an eventfd file descriptor with FD_CLOEXEC descriptor flag not set. + FileDescriptor f = ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, 0)); + auto fd = f.get(); + f.reset(); + ASSERT_THAT(fcntl(fd, F_GETFD), SyscallFailsWithErrno(EBADF)); + ASSERT_THAT(fcntl(fd, F_SETFD, FD_CLOEXEC), SyscallFailsWithErrno(EBADF)); +} + TEST(FcntlTest, SetCloExec) { // Open an eventfd file descriptor with FD_CLOEXEC descriptor flag not set. FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, 0)); -- cgit v1.2.3