| 288 | } |
| 289 | |
| 290 | static void test_timeout(int fd_read, int fd_write) |
| 291 | { |
| 292 | int kqfd; |
| 293 | struct kevent changes[1]; |
| 294 | struct kevent events[2]; |
| 295 | int n; |
| 296 | struct timespec ts; |
| 297 | |
| 298 | (void) fd_write; |
| 299 | |
| 300 | kqfd = kqueue(); |
| 301 | if (kqfd < 0) { |
| 302 | fail("kqueue() failed (timeout)"); |
| 303 | return; |
| 304 | } |
| 305 | |
| 306 | EV_SET(&changes[0], fd_read, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, NULL); |
| 307 | if (kevent(kqfd, changes, 1, NULL, 0, NULL) < 0) { |
| 308 | fail("kevent add timeout failed"); |
| 309 | return; |
| 310 | } |
| 311 | |
| 312 | /* timeout = 0 (return immediately) */ |
| 313 | ts.tv_sec = 0; |
| 314 | ts.tv_nsec = 0; |
| 315 | n = kevent(kqfd, NULL, 0, events, 2, &ts); |
| 316 | if (n != 0) { |
| 317 | fail("timeout: zero should return 0"); |
| 318 | return; |
| 319 | } |
| 320 | |
| 321 | /* invalid tv_nsec */ |
| 322 | ts.tv_sec = 0; |
| 323 | ts.tv_nsec = 2000000000; |
| 324 | n = kevent(kqfd, NULL, 0, events, 2, &ts); |
| 325 | if (n >= 0) { |
| 326 | fail("timeout: invalid tv_nsec should fail"); |
| 327 | return; |
| 328 | } |
| 329 | if (acl_fiber_last_error() != FIBER_EINVAL) { |
| 330 | fail("timeout: expected EINVAL"); |
| 331 | return; |
| 332 | } |
| 333 | |
| 334 | close(kqfd); |
| 335 | } |
| 336 | |
| 337 | static void test_error_eof(void) |
| 338 | { |
nothing calls this directly
no test coverage detected
searching dependent graphs…