Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Nov 2014 20:41:40 +0000 (UTC)
From:      Garrett Cooper <ngie@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r273943 - head/contrib/netbsd-tests/lib/libc/sys
Message-ID:  <201411012041.sA1Kfeiw034450@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sat Nov  1 20:41:40 2014
New Revision: 273943
URL: https://svnweb.freebsd.org/changeset/base/273943

Log:
  Port t_kevent to FreeBSD
  
  Submitted by: pho

Modified:
  head/contrib/netbsd-tests/lib/libc/sys/t_kevent.c

Modified: head/contrib/netbsd-tests/lib/libc/sys/t_kevent.c
==============================================================================
--- head/contrib/netbsd-tests/lib/libc/sys/t_kevent.c	Sat Nov  1 20:33:42 2014	(r273942)
+++ head/contrib/netbsd-tests/lib/libc/sys/t_kevent.c	Sat Nov  1 20:41:40 2014	(r273943)
@@ -43,12 +43,18 @@ __RCSID("$NetBSD: t_kevent.c,v 1.6 2012/
 #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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411012041.sA1Kfeiw034450>