Add tests for eventfd/timerfd/inotify operations that should return ESPIPE.
PiperOrigin-RevId: 318585377
This commit is contained in:
parent
66d1665441
commit
85be13d9a3
|
@ -100,20 +100,21 @@ TEST(EventfdTest, SmallRead) {
|
||||||
ASSERT_THAT(read(efd.get(), &l, 4), SyscallFailsWithErrno(EINVAL));
|
ASSERT_THAT(read(efd.get(), &l, 4), SyscallFailsWithErrno(EINVAL));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(EventfdTest, PreadIllegalSeek) {
|
TEST(EventfdTest, IllegalSeek) {
|
||||||
FileDescriptor efd =
|
FileDescriptor efd = ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, 0));
|
||||||
ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, EFD_NONBLOCK | EFD_SEMAPHORE));
|
EXPECT_THAT(lseek(efd.get(), 0, SEEK_SET), SyscallFailsWithErrno(ESPIPE));
|
||||||
|
|
||||||
uint64_t l = 0;
|
|
||||||
ASSERT_THAT(pread(efd.get(), &l, 4, 0), SyscallFailsWithErrno(ESPIPE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(EventfdTest, PwriteIllegalSeek) {
|
TEST(EventfdTest, IllegalPread) {
|
||||||
FileDescriptor efd =
|
FileDescriptor efd = ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, 0));
|
||||||
ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, EFD_NONBLOCK | EFD_SEMAPHORE));
|
int l;
|
||||||
|
EXPECT_THAT(pread(efd.get(), &l, sizeof(l), 0),
|
||||||
|
SyscallFailsWithErrno(ESPIPE));
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t l = 0;
|
TEST(EventfdTest, IllegalPwrite) {
|
||||||
ASSERT_THAT(pwrite(efd.get(), &l, 4, 0), SyscallFailsWithErrno(ESPIPE));
|
FileDescriptor efd = ASSERT_NO_ERRNO_AND_VALUE(NewEventFD(0, 0));
|
||||||
|
EXPECT_THAT(pwrite(efd.get(), "x", 1, 0), SyscallFailsWithErrno(ESPIPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(EventfdTest, BigWrite) {
|
TEST(EventfdTest, BigWrite) {
|
||||||
|
|
|
@ -333,9 +333,27 @@ PosixErrorOr<int> InotifyAddWatch(int fd, const std::string& path,
|
||||||
return wd;
|
return wd;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Inotify, InotifyFdNotWritable) {
|
TEST(Inotify, IllegalSeek) {
|
||||||
const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(InotifyInit1(0));
|
const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(InotifyInit1(0));
|
||||||
EXPECT_THAT(write(fd.get(), "x", 1), SyscallFailsWithErrno(EBADF));
|
EXPECT_THAT(lseek(fd.get(), 0, SEEK_SET), SyscallFailsWithErrno(ESPIPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Inotify, IllegalPread) {
|
||||||
|
const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(InotifyInit1(0));
|
||||||
|
int val;
|
||||||
|
EXPECT_THAT(pread(fd.get(), &val, sizeof(val), 0),
|
||||||
|
SyscallFailsWithErrno(ESPIPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Inotify, IllegalPwrite) {
|
||||||
|
const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(InotifyInit1(0));
|
||||||
|
EXPECT_THAT(pwrite(fd.get(), "x", 1, 0), SyscallFailsWithErrno(ESPIPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Inotify, IllegalWrite) {
|
||||||
|
const FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(InotifyInit1(0));
|
||||||
|
int val = 0;
|
||||||
|
EXPECT_THAT(write(fd.get(), &val, sizeof(val)), SyscallFailsWithErrno(EBADF));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Inotify, InitFlags) {
|
TEST(Inotify, InitFlags) {
|
||||||
|
|
|
@ -204,16 +204,33 @@ TEST_P(TimerfdTest, SetAbsoluteTime) {
|
||||||
EXPECT_EQ(1, val);
|
EXPECT_EQ(1, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(TimerfdTest, IllegalReadWrite) {
|
TEST_P(TimerfdTest, IllegalSeek) {
|
||||||
|
auto const tfd = ASSERT_NO_ERRNO_AND_VALUE(TimerfdCreate(GetParam(), 0));
|
||||||
|
if (!IsRunningWithVFS1()) {
|
||||||
|
EXPECT_THAT(lseek(tfd.get(), 0, SEEK_SET), SyscallFailsWithErrno(ESPIPE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_P(TimerfdTest, IllegalPread) {
|
||||||
|
auto const tfd = ASSERT_NO_ERRNO_AND_VALUE(TimerfdCreate(GetParam(), 0));
|
||||||
|
int val;
|
||||||
|
EXPECT_THAT(pread(tfd.get(), &val, sizeof(val), 0),
|
||||||
|
SyscallFailsWithErrno(ESPIPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_P(TimerfdTest, IllegalPwrite) {
|
||||||
|
auto const tfd = ASSERT_NO_ERRNO_AND_VALUE(TimerfdCreate(GetParam(), 0));
|
||||||
|
EXPECT_THAT(pwrite(tfd.get(), "x", 1, 0), SyscallFailsWithErrno(ESPIPE));
|
||||||
|
if (!IsRunningWithVFS1()) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_P(TimerfdTest, IllegalWrite) {
|
||||||
auto const tfd =
|
auto const tfd =
|
||||||
ASSERT_NO_ERRNO_AND_VALUE(TimerfdCreate(GetParam(), TFD_NONBLOCK));
|
ASSERT_NO_ERRNO_AND_VALUE(TimerfdCreate(GetParam(), TFD_NONBLOCK));
|
||||||
uint64_t val = 0;
|
uint64_t val = 0;
|
||||||
EXPECT_THAT(PreadFd(tfd.get(), &val, sizeof(val), 0),
|
EXPECT_THAT(write(tfd.get(), &val, sizeof(val)),
|
||||||
SyscallFailsWithErrno(ESPIPE));
|
|
||||||
EXPECT_THAT(WriteFd(tfd.get(), &val, sizeof(val)),
|
|
||||||
SyscallFailsWithErrno(EINVAL));
|
SyscallFailsWithErrno(EINVAL));
|
||||||
EXPECT_THAT(PwriteFd(tfd.get(), &val, sizeof(val), 0),
|
|
||||||
SyscallFailsWithErrno(ESPIPE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string PrintClockId(::testing::TestParamInfo<int> info) {
|
std::string PrintClockId(::testing::TestParamInfo<int> info) {
|
||||||
|
|
Loading…
Reference in New Issue