From owner-svn-src-head@FreeBSD.ORG Thu Oct 23 06:42:54 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id E95E950F; Thu, 23 Oct 2014 06:42:54 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BC32D207; Thu, 23 Oct 2014 06:42:54 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9N6gseY048918; Thu, 23 Oct 2014 06:42:54 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9N6gsN6048917; Thu, 23 Oct 2014 06:42:54 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201410230642.s9N6gsN6048917@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Thu, 23 Oct 2014 06:42:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273525 - head/contrib/netbsd-tests/lib/libc/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Oct 2014 06:42:55 -0000 Author: ngie Date: Thu Oct 23 06:42:53 2014 New Revision: 273525 URL: https://svnweb.freebsd.org/changeset/base/273525 Log: 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 Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Modified: head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c ============================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Thu Oct 23 06:35:19 2014 (r273524) +++ head/contrib/netbsd-tests/lib/libc/sys/t_mmap.c Thu Oct 23 06:42:53 2014 (r273525) @@ -72,7 +72,15 @@ __RCSID("$NetBSD: t_mmap.c,v 1.7 2012/06 #include #include #include +#ifdef __NetBSD__ #include +#endif + +#ifdef __FreeBSD__ +#include +#include +#include +#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);