diff options
-rw-r--r-- | test/syscalls/linux/BUILD | 1 | ||||
-rw-r--r-- | test/syscalls/linux/poll.cc | 9 |
2 files changed, 7 insertions, 3 deletions
diff --git a/test/syscalls/linux/BUILD b/test/syscalls/linux/BUILD index 8cf83b311..e70742875 100644 --- a/test/syscalls/linux/BUILD +++ b/test/syscalls/linux/BUILD @@ -1246,6 +1246,7 @@ cc_binary( linkstatic = 1, deps = [ ":base_poll_test", + "//test/util:eventfd_util", "//test/util:file_descriptor", "//test/util:logging", "//test/util:test_main", diff --git a/test/syscalls/linux/poll.cc b/test/syscalls/linux/poll.cc index 897fd0bec..7a6a39444 100644 --- a/test/syscalls/linux/poll.cc +++ b/test/syscalls/linux/poll.cc @@ -23,6 +23,7 @@ #include "absl/time/clock.h" #include "absl/time/time.h" #include "test/syscalls/linux/base_poll_test.h" +#include "test/util/eventfd_util.h" #include "test/util/file_descriptor.h" #include "test/util/logging.h" #include "test/util/test_util.h" @@ -256,12 +257,14 @@ TEST_F(PollTest, Nfds) { TEST_PCHECK(getrlimit(RLIMIT_NOFILE, &rlim) == 0); rlim_t max_fds = rlim.rlim_cur; + // Create an eventfd. Since its value is initially zero, it is writable. + FileDescriptor efd = ASSERT_NO_ERRNO_AND_VALUE(NewEventFD()); + // Create the biggest possible pollfd array such that each element is valid. - // - // Each entry in the 'fds' array refers to stdout (fd=1) and polls for + // Each entry in the 'fds' array refers to the eventfd and polls for // "writable" events (events=POLLOUT). This essentially guarantees that the // poll() is a no-op and allows negative testing of the 'nfds' parameter. - std::vector<struct pollfd> fds(max_fds, {.fd = 1, .events = POLLOUT}); + std::vector<struct pollfd> fds(max_fds, {.fd = efd.get(), .events = POLLOUT}); // Verify that 'nfds' up to RLIMIT_NOFILE are allowed. EXPECT_THAT(RetryEINTR(poll)(fds.data(), 1, 1), SyscallSucceedsWithValue(1)); |