| 103 | |
| 104 | |
| 105 | TEST_P(EventDriverTest, PipeTest) { |
| 106 | int fds[2]; |
| 107 | vector<FiredFileEvent> fired_events; |
| 108 | int r; |
| 109 | struct timeval tv; |
| 110 | tv.tv_sec = 0; |
| 111 | tv.tv_usec = 1; |
| 112 | |
| 113 | r = pipe(fds); |
| 114 | ASSERT_EQ(r, 0); |
| 115 | r = driver->add_event(fds[0], EVENT_NONE, EVENT_READABLE); |
| 116 | ASSERT_EQ(r, 0); |
| 117 | r = driver->event_wait(fired_events, &tv); |
| 118 | ASSERT_EQ(r, 0); |
| 119 | |
| 120 | char c = 'A'; |
| 121 | r = write(fds[1], &c, sizeof(c)); |
| 122 | ASSERT_EQ(r, 1); |
| 123 | r = driver->event_wait(fired_events, &tv); |
| 124 | ASSERT_EQ(r, 1); |
| 125 | ASSERT_EQ(fired_events[0].fd, fds[0]); |
| 126 | |
| 127 | |
| 128 | fired_events.clear(); |
| 129 | r = write(fds[1], &c, sizeof(c)); |
| 130 | ASSERT_EQ(r, 1); |
| 131 | r = driver->event_wait(fired_events, &tv); |
| 132 | ASSERT_EQ(r, 1); |
| 133 | ASSERT_EQ(fired_events[0].fd, fds[0]); |
| 134 | |
| 135 | fired_events.clear(); |
| 136 | driver->del_event(fds[0], EVENT_READABLE, EVENT_READABLE); |
| 137 | r = write(fds[1], &c, sizeof(c)); |
| 138 | ASSERT_EQ(r, 1); |
| 139 | r = driver->event_wait(fired_events, &tv); |
| 140 | ASSERT_EQ(r, 0); |
| 141 | } |
| 142 | |
| 143 | void* echoclient(void *arg) |
| 144 | { |
nothing calls this directly
no test coverage detected