Internal change.

PiperOrigin-RevId: 518617649
This commit is contained in:
gVisor bot
2023-03-22 11:04:58 -07:00
parent 1063b2a08e
commit ca7e83b679
+10
View File
@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include <fcntl.h>
#include <poll.h>
#include <sys/resource.h>
#include <sys/socket.h>
@@ -350,6 +351,15 @@ TEST_F(PollTest, Nfds) {
EXPECT_THAT(poll(fds.data(), max_fds + 1, 1), SyscallFailsWithErrno(EINVAL));
}
// Polling on a file that doesn't support blocking, like a directory, should
// immediately return.
TEST_F(PollTest, UnpollableFile) {
FileDescriptor fd = ASSERT_NO_ERRNO_AND_VALUE(Open("/", O_RDONLY));
struct pollfd poll_fd = {fd.get(), POLLIN | POLLOUT, 0};
EXPECT_THAT(RetryEINTR(poll)(&poll_fd, 1, -1), SyscallSucceedsWithValue(1));
EXPECT_EQ(poll_fd.revents, POLLIN | POLLOUT);
}
} // namespace
} // namespace testing
} // namespace gvisor