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