| 41 | |
| 42 | |
| 43 | TEST_F(IOTest, PollRead) |
| 44 | { |
| 45 | Try<std::array<int_fd, 2>> pipes = os::pipe(); |
| 46 | ASSERT_SOME(pipes); |
| 47 | ASSERT_SOME(io::prepare_async((*pipes)[0])); |
| 48 | ASSERT_SOME(io::prepare_async((*pipes)[1])); |
| 49 | |
| 50 | // Test discard when polling. |
| 51 | Future<short> future = io::poll((*pipes)[0], io::READ); |
| 52 | EXPECT_TRUE(future.isPending()); |
| 53 | future.discard(); |
| 54 | AWAIT_DISCARDED(future); |
| 55 | |
| 56 | // Test successful polling. |
| 57 | future = io::poll((*pipes)[0], io::READ); |
| 58 | |
| 59 | // This is not sufficient for ensuring the event loop does |
| 60 | // not detect readiness, since it's happening asynchronously |
| 61 | // in the kernel. |
| 62 | Clock::pause(); |
| 63 | Clock::settle(); |
| 64 | Clock::resume(); |
| 65 | |
| 66 | EXPECT_TRUE(future.isPending()); |
| 67 | |
| 68 | ASSERT_EQ(2, write((*pipes)[1], "hi", 2)); |
| 69 | AWAIT_EXPECT_EQ(io::READ, future); |
| 70 | |
| 71 | ASSERT_SOME(os::close((*pipes)[0])); |
| 72 | ASSERT_SOME(os::close((*pipes)[1])); |
| 73 | } |
| 74 | |
| 75 | |
| 76 | // We do not support write readiness polling on Windows |
no test coverage detected