diff options
author | ngie <ngie@FreeBSD.org> | 2014-11-01 20:41:40 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2014-11-01 20:41:40 +0000 |
commit | d38d28efa1770a9bd82fced1a26dc8b84616b209 (patch) | |
tree | a20ee9b1fea8192ce419b822c1fb8f3b41d29a89 /contrib/netbsd-tests | |
parent | 872d5cc719423a7fa0ede6e52339a7d0f5544d44 (diff) | |
download | FreeBSD-src-d38d28efa1770a9bd82fced1a26dc8b84616b209.zip FreeBSD-src-d38d28efa1770a9bd82fced1a26dc8b84616b209.tar.gz |
Port t_kevent to FreeBSD
Submitted by: pho
Diffstat (limited to 'contrib/netbsd-tests')
-rw-r--r-- | contrib/netbsd-tests/lib/libc/sys/t_kevent.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_kevent.c b/contrib/netbsd-tests/lib/libc/sys/t_kevent.c index 73ffbf8..5578adc 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_kevent.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_kevent.c @@ -43,12 +43,18 @@ __RCSID("$NetBSD: t_kevent.c,v 1.6 2012/11/29 09:13:44 martin Exp $"); #include <unistd.h> #include <fcntl.h> #include <err.h> +#ifdef __NetBSD__ #include <sys/drvctlio.h> +#endif #include <sys/event.h> #include <sys/time.h> #include <sys/socket.h> #include <sys/wait.h> +#ifdef __FreeBSD__ +#define DRVCTLDEV "/nonexistent" +#endif + ATF_TC(kevent_zerotimer); ATF_TC_HEAD(kevent_zerotimer, tc) { @@ -108,9 +114,15 @@ ATF_TC_BODY(kqueue_desc_passing, tc) if (recvmsg(s[1], &m, 0) == -1) err(1, "child: could not recvmsg"); +#ifdef __FreeBSD__ + bcopy(CMSG_DATA(msg), &kq, sizeof(kq)); + printf("child (pid %d): received kq fd %d\n", getpid(), kq); + _exit(0); +#else kq = *(int *)CMSG_DATA(msg); printf("child (pid %d): received kq fd %d\n", getpid(), kq); exit(0); +#endif } close(s[1]); @@ -122,15 +134,29 @@ ATF_TC_BODY(kqueue_desc_passing, tc) msg->cmsg_type = SCM_RIGHTS; msg->cmsg_len = CMSG_LEN(sizeof(int)); +#ifdef __FreeBSD__ + /* + * What is should have been + * bcopy(&s[0], CMSG_DATA(msg), sizeof(kq)); + */ + bcopy(&kq, CMSG_DATA(msg), sizeof(kq)); +#else *(int *)CMSG_DATA(msg) = kq; +#endif EV_SET(&ev, 1, EVFILT_TIMER, EV_ADD|EV_ENABLE, 0, 1, 0); ATF_CHECK(kevent(kq, &ev, 1, NULL, 0, NULL) != -1); printf("parent (pid %d): sending kq fd %d\n", getpid(), kq); if (sendmsg(s[0], &m, 0) == -1) { +#if defined(__NetBSD__) ATF_REQUIRE_EQ_MSG(errno, EBADF, "errno is %d", errno); atf_tc_skip("PR kern/46523"); +#endif +#if defined(__FreeBSD__) + ATF_REQUIRE_EQ_MSG(errno, EOPNOTSUPP, "errno is %d", errno); + close(s[0]); +#endif } close(kq); |