summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2014-10-23 06:42:53 +0000
committerngie <ngie@FreeBSD.org>2014-10-23 06:42:53 +0000
commitafc0360866f8f6b208b8bd7d584b89d6a9c75f7a (patch)
treed6c8ddec573a975cd3f9fd2412889fadb00b19f3 /contrib/netbsd-tests
parent0637f547965251e7ff45666d26f94da8e6d2f1c3 (diff)
downloadFreeBSD-src-afc0360866f8f6b208b8bd7d584b89d6a9c75f7a.zip
FreeBSD-src-afc0360866f8f6b208b8bd7d584b89d6a9c75f7a.tar.gz
Port t_mmap.c to FreeBSD
- Add needed headers for the testcases - Omit mmap_block on non-NetBSD OSes - Use "security.bsd.map_at_zero" instead of "vm.user_va0_disable" Submitted by: pho Sponsored by: EMC / Isilon Storage Division
Diffstat (limited to 'contrib/netbsd-tests')
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_mmap.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mmap.c b/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
index c6b97b1..5d821ec 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
@@ -72,7 +72,15 @@ __RCSID("$NetBSD: t_mmap.c,v 1.7 2012/06/14 17:47:58 bouyer Exp $");
#include <string.h>
#include <unistd.h>
#include <paths.h>
+#ifdef __NetBSD__
#include <machine/disklabel.h>
+#endif
+
+#ifdef __FreeBSD__
+#include <sys/disklabel.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#endif
static long page = 0;
static char path[] = "mmap";
@@ -155,6 +163,7 @@ map_sighandler(int signo)
_exit(signo);
}
+#ifdef __NetBSD__
ATF_TC(mmap_block);
ATF_TC_HEAD(mmap_block, tc)
{
@@ -199,6 +208,7 @@ ATF_TC_BODY(mmap_block, tc)
ATF_REQUIRE(munmap(map, 4096) == 0);
}
+#endif
ATF_TC(mmap_err);
ATF_TC_HEAD(mmap_err, tc)
@@ -468,8 +478,15 @@ ATF_TC_BODY(mmap_va0, tc)
* Make an anonymous fixed mapping at zero address. If the address
* is restricted as noted in security(7), the syscall should fail.
*/
+#ifdef __FreeBSD__
+ if (sysctlbyname("security.bsd.map_at_zero", &val, &len, NULL, 0) != 0)
+ atf_tc_fail("failed to read security.bsd.map_at_zero");
+ val = !val; /* 1 == enable map at zero */
+#endif
+#ifdef __NetBSD__
if (sysctlbyname("vm.user_va0_disable", &val, &len, NULL, 0) != 0)
atf_tc_fail("failed to read vm.user_va0_disable");
+#endif
map = mmap(NULL, page, PROT_EXEC, flags, -1, 0);
map_check(map, val);
@@ -492,7 +509,9 @@ ATF_TP_ADD_TCS(tp)
page = sysconf(_SC_PAGESIZE);
ATF_REQUIRE(page >= 0);
+#ifdef __NetBSD__
ATF_TP_ADD_TC(tp, mmap_block);
+#endif
ATF_TP_ADD_TC(tp, mmap_err);
ATF_TP_ADD_TC(tp, mmap_loan);
ATF_TP_ADD_TC(tp, mmap_prot_1);
OpenPOWER on IntegriCloud