diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-01-28 12:22:00 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-01-28 12:24:37 -0800 |
commit | d8c330254a7df21cb5edac3440b62a512fcc8d2d (patch) | |
tree | 7c37b273cca0389da1375c7984cbd5fd21c01952 /test/syscalls/linux/preadv2.cc | |
parent | 449c155bc00aa36522f80f816b18e9a9521e1fe6 (diff) |
Add O_PATH support in vfs2
PiperOrigin-RevId: 354367665
Diffstat (limited to 'test/syscalls/linux/preadv2.cc')
-rw-r--r-- | test/syscalls/linux/preadv2.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/syscalls/linux/preadv2.cc b/test/syscalls/linux/preadv2.cc index 4a9acd7ae..cb58719c4 100644 --- a/test/syscalls/linux/preadv2.cc +++ b/test/syscalls/linux/preadv2.cc @@ -226,6 +226,24 @@ TEST(Preadv2Test, TestUnreadableFile) { SyscallFailsWithErrno(EBADF)); } +// This test calls preadv2 with a file opened with O_PATH. +TEST(Preadv2Test, Preadv2WithOpath) { + SKIP_IF(IsRunningWithVFS1()); + SKIP_IF(preadv2(-1, nullptr, 0, 0, 0) < 0 && errno == ENOSYS); + + const TempPath file = ASSERT_NO_ERRNO_AND_VALUE(TempPath::CreateFile()); + const FileDescriptor fd = + ASSERT_NO_ERRNO_AND_VALUE(Open(file.path(), O_PATH)); + + auto iov = absl::make_unique<struct iovec[]>(1); + iov[0].iov_base = nullptr; + iov[0].iov_len = 0; + + EXPECT_THAT(preadv2(fd.get(), iov.get(), /*iovcnt=*/1, /*offset=*/0, + /*flags=*/0), + SyscallFailsWithErrno(EBADF)); +} + // Calling preadv2 with a non-negative offset calls preadv. Calling preadv with // an unseekable file is not allowed. A pipe is used for an unseekable file. TEST(Preadv2Test, TestUnseekableFileInvalid) { |