Internal change.

PiperOrigin-RevId: 531546285
This commit is contained in:
gVisor bot
2023-05-12 10:42:51 -07:00
parent 82dd91778b
commit 4f665a8da5
+19 -12
View File
@@ -374,20 +374,27 @@ TEST(Inotify, NonBlockingReadReturnsEagain) {
TEST(Inotify, AddWatchOnInvalidFdFails) {
// Garbage fd.
EXPECT_THAT(inotify_add_watch(-1, "/tmp", IN_ALL_EVENTS),
SyscallFailsWithErrno(EBADF));
EXPECT_THAT(inotify_add_watch(1337, "/tmp", IN_ALL_EVENTS),
SyscallFailsWithErrno(EBADF));
EXPECT_THAT(
inotify_add_watch(-1, GetAbsoluteTestTmpdir().c_str(), IN_ALL_EVENTS),
SyscallFailsWithErrno(EBADF));
EXPECT_THAT(
inotify_add_watch(1337, GetAbsoluteTestTmpdir().c_str(), IN_ALL_EVENTS),
SyscallFailsWithErrno(EBADF));
// Non-inotify fds.
EXPECT_THAT(inotify_add_watch(0, "/tmp", IN_ALL_EVENTS),
SyscallFailsWithErrno(EINVAL));
EXPECT_THAT(inotify_add_watch(1, "/tmp", IN_ALL_EVENTS),
SyscallFailsWithErrno(EINVAL));
EXPECT_THAT(inotify_add_watch(2, "/tmp", IN_ALL_EVENTS),
SyscallFailsWithErrno(EINVAL));
const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(Open("/tmp", O_RDONLY));
EXPECT_THAT(inotify_add_watch(fd.get(), "/tmp", IN_ALL_EVENTS),
EXPECT_THAT(
inotify_add_watch(0, GetAbsoluteTestTmpdir().c_str(), IN_ALL_EVENTS),
SyscallFailsWithErrno(EINVAL));
EXPECT_THAT(
inotify_add_watch(1, GetAbsoluteTestTmpdir().c_str(), IN_ALL_EVENTS),
SyscallFailsWithErrno(EINVAL));
EXPECT_THAT(
inotify_add_watch(2, GetAbsoluteTestTmpdir().c_str(), IN_ALL_EVENTS),
SyscallFailsWithErrno(EINVAL));
const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(
Open(GetAbsoluteTestTmpdir().c_str(), O_RDONLY));
EXPECT_THAT(inotify_add_watch(fd.get(), GetAbsoluteTestTmpdir().c_str(),
IN_ALL_EVENTS),
SyscallFailsWithErrno(EINVAL));
}