]> git.saurik.com Git - apple/xnu.git/blob - tests/kqueue_add_and_trigger.c
xnu-7195.101.1.tar.gz
[apple/xnu.git] / tests / kqueue_add_and_trigger.c
1 #include <unistd.h>
2 #include <errno.h>
3 #include <sys/event.h>
4 #include <darwintest.h>
5
6 T_GLOBAL_META(T_META_RUN_CONCURRENTLY(true));
7
8 /* <rdar://problem/28139044> EVFILT_USER doesn't properly support add&fire atomic combination
9 *
10 * Chek that using EV_ADD and EV_TRIGGER on a EV_USER actually trigger the event just added.
11 *
12 */
13
14 T_DECL(kqueue_add_and_trigger_evfilt_user, "Add and trigger EVFILT_USER events with kevent ")
15 {
16 int kq_fd, ret;
17 struct kevent ret_kev;
18 const struct kevent kev = {
19 .ident = 1,
20 .filter = EVFILT_USER,
21 .flags = EV_ADD | EV_CLEAR,
22 .fflags = NOTE_TRIGGER,
23 };
24 const struct timespec timeout = {
25 .tv_sec = 1,
26 .tv_nsec = 0,
27 };
28
29 T_ASSERT_POSIX_SUCCESS((kq_fd = kqueue()), NULL);
30 ret = kevent(kq_fd, &kev, 1, &ret_kev, 1, &timeout);
31
32 T_ASSERT_POSIX_SUCCESS(ret, "kevent");
33
34 T_ASSERT_EQ(ret, 1, "kevent with add and trigger, ret");
35 T_ASSERT_EQ(ret_kev.ident, 1, "kevent with add and trigger, ident");
36 T_ASSERT_EQ(ret_kev.filter, EVFILT_USER, "kevent with add and trigger, filter");
37 }