| 190 | } |
| 191 | |
| 192 | static void test_disable_enable(int fd_read, int fd_write) |
| 193 | { |
| 194 | int kqfd; |
| 195 | struct kevent changes[1]; |
| 196 | struct kevent events[2]; |
| 197 | int n; |
| 198 | char buf[8]; |
| 199 | |
| 200 | kqfd = kqueue(); |
| 201 | if (kqfd < 0) { |
| 202 | fail("kqueue() failed (disable/enable)"); |
| 203 | return; |
| 204 | } |
| 205 | |
| 206 | EV_SET(&changes[0], fd_read, EVFILT_READ, EV_ADD | EV_DISABLE, |
| 207 | 0, 0, NULL); |
| 208 | if (kevent(kqfd, changes, 1, NULL, 0, NULL) < 0) { |
| 209 | fail("kevent add disable failed"); |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | if (write(fd_write, "d", 1) != 1) { |
| 214 | fail("write failed (disable)"); |
| 215 | return; |
| 216 | } |
| 217 | |
| 218 | memset(events, 0, sizeof(events)); |
| 219 | n = kevent(kqfd, NULL, 0, events, 2, &(struct timespec){0, 0}); |
| 220 | if (n != 0) { |
| 221 | fail("disable: event should be disabled"); |
| 222 | return; |
| 223 | } |
| 224 | |
| 225 | EV_SET(&changes[0], fd_read, EVFILT_READ, EV_ENABLE, 0, 0, NULL); |
| 226 | if (kevent(kqfd, changes, 1, NULL, 0, NULL) < 0) { |
| 227 | fail("enable failed"); |
| 228 | return; |
| 229 | } |
| 230 | |
| 231 | memset(events, 0, sizeof(events)); |
| 232 | n = kevent(kqfd, NULL, 0, events, 2, &(struct timespec){1, 0}); |
| 233 | if (n != 1 || !expect_filter(events, n, EVFILT_READ)) { |
| 234 | fail("enable: read event missing"); |
| 235 | return; |
| 236 | } |
| 237 | |
| 238 | (void) read(fd_read, buf, sizeof(buf)); |
| 239 | close(kqfd); |
| 240 | } |
| 241 | |
| 242 | static void test_delete(int fd_read, int fd_write) |
| 243 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…