MCPcopy Create free account
hub / github.com/acl-dev/acl / test_timeout

Function test_timeout

lib_fiber/samples-c/test/kqueue_hook/main.c:290–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290static 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
337static void test_error_eof(void)
338{

Callers

nothing calls this directly

Calls 5

kqueueFunction · 0.85
failFunction · 0.85
acl_fiber_last_errorFunction · 0.85
keventClass · 0.70
closeFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…