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

Function test_delete

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

Source from the content-addressed store, hash-verified

240}
241
242static void test_delete(int fd_read, int fd_write)
243{
244 int kqfd;
245 struct kevent changes[1];
246 struct kevent events[2];
247 int n;
248
249 kqfd = kqueue();
250 if (kqfd < 0) {
251 fail("kqueue() failed (delete)");
252 return;
253 }
254
255 EV_SET(&changes[0], fd_read, EVFILT_READ, EV_ADD | EV_ENABLE, 0, 0, NULL);
256 if (kevent(kqfd, changes, 1, NULL, 0, NULL) < 0) {
257 fail("kevent add delete failed");
258 return;
259 }
260
261 EV_SET(&changes[0], fd_read, EVFILT_READ, EV_DELETE, 0, 0, NULL);
262 if (kevent(kqfd, changes, 1, NULL, 0, NULL) < 0) {
263 fail("kevent delete failed");
264 return;
265 }
266
267 if (write(fd_write, "x", 1) != 1) {
268 fail("write failed (delete)");
269 return;
270 }
271
272 memset(events, 0, sizeof(events));
273 n = kevent(kqfd, NULL, 0, events, 2, &(struct timespec){0, 0});
274 if (n != 0) {
275 fail("delete: event should be removed");
276 return;
277 }
278
279 if (kevent(kqfd, changes, 1, NULL, 0, NULL) >= 0) {
280 fail("delete: expected error on deleting non-existent filter");
281 return;
282 }
283 if (acl_fiber_last_error() != ENOENT) {
284 fail("delete: expected ENOENT");
285 }
286
287 close(kqfd);
288}
289
290static void test_timeout(int fd_read, int fd_write)
291{

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…