2 * Copyright (c) 2009 Mark Heily <mark@heily.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26 const char *test_id = "kevent(EVFILT_USER, EV_ADD and EV_DELETE)";
31 kevent_add(kqfd, &kev, 1, EVFILT_USER, EV_ADD, 0, 0, NULL);
34 kevent_add(kqfd, &kev, 1, EVFILT_USER, EV_DELETE, 0, 0, NULL);
43 const char *test_id = "kevent(EVFILT_USER, wait)";
50 /* Add the event, and then trigger it */
51 kevent_add(kqfd, &kev, 1, EVFILT_USER, EV_ADD | EV_CLEAR, 0, 0, NULL);
52 kevent_add(kqfd, &kev, 1, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL);
54 kev.fflags &= ~NOTE_FFCTRLMASK;
55 kev.fflags &= ~NOTE_TRIGGER;
57 kevent_cmp(&kev, kevent_get(kqfd));
65 disable_and_enable(void)
67 const char *test_id = "kevent(EVFILT_USER, EV_DISABLE and EV_ENABLE)";
74 kevent_add(kqfd, &kev, 1, EVFILT_USER, EV_ADD, 0, 0, NULL);
75 kevent_add(kqfd, &kev, 1, EVFILT_USER, EV_DISABLE, 0, 0, NULL);
77 /* Trigger the event, but since it is disabled, nothing will happen. */
78 kevent_add(kqfd, &kev, 1, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL);
81 kevent_add(kqfd, &kev, 1, EVFILT_USER, EV_ENABLE, 0, 0, NULL);
82 kevent_add(kqfd, &kev, 1, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL);
85 kev.fflags &= ~NOTE_FFCTRLMASK;
86 kev.fflags &= ~NOTE_TRIGGER;
87 kevent_cmp(&kev, kevent_get(kqfd));
95 const char *test_id = "kevent(EVFILT_USER, EV_ONESHOT)";
102 kevent_add(kqfd, &kev, 2, EVFILT_USER, EV_ADD | EV_ONESHOT, 0, 0, NULL);
105 kevent_add(kqfd, &kev, 2, EVFILT_USER, 0, NOTE_TRIGGER, 0, NULL);
107 kev.flags = EV_ONESHOT;
108 kev.fflags &= ~NOTE_FFCTRLMASK;
109 kev.fflags &= ~NOTE_TRIGGER;
110 kevent_cmp(&kev, kevent_get(kqfd));
124 disable_and_enable();
126 /* TODO: try different fflags operations */