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