From owner-svn-src-all@freebsd.org Sat Dec 24 13:00:20 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93DDEC8E54C; Sat, 24 Dec 2016 13:00:20 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 4A9921DE0; Sat, 24 Dec 2016 13:00:20 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBOD0Jm1024475; Sat, 24 Dec 2016 13:00:19 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBOD0JLw024474; Sat, 24 Dec 2016 13:00:19 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201612241300.uBOD0JLw024474@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Sat, 24 Dec 2016 13:00:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r310507 - stable/10/contrib/netbsd-tests/lib/libc/sys X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Dec 2016 13:00:20 -0000 Author: ngie Date: Sat Dec 24 13:00:19 2016 New Revision: 310507 URL: https://svnweb.freebsd.org/changeset/base/310507 Log: MFstable/11 r310506: MFC r309837: Change the process limits for RLIMIT_MEMLOCK to RLIM_INFINITY when executing :mincore_resid The default process limits in FreeBSD is 64kB for unprivileged users, which empirically is too low to run the :mincore_resid testcase. Process limits are inherited, so even though the default limit for root users is RLIM_INFINITY, the inherited limit with "sudo" with the default login.conf will be 64kB. Use setrlimit to set rlim_max for RLIMIT_MEMLOCK to RLIM_INFINITY to avoid ENOMEM issues when calling mlock to wire the mmap'ed address space. setrlimit requires root access to increase rlim_max, so require root privileges when running the test Discovered when executing the tests with sudo, e.g. "sudo kyua test -k /usr/tests/lib/libc/sys/Kyuafile mincore_test" Modified: stable/10/contrib/netbsd-tests/lib/libc/sys/t_mincore.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/netbsd-tests/lib/libc/sys/t_mincore.c ============================================================================== --- stable/10/contrib/netbsd-tests/lib/libc/sys/t_mincore.c Sat Dec 24 12:58:33 2016 (r310506) +++ stable/10/contrib/netbsd-tests/lib/libc/sys/t_mincore.c Sat Dec 24 13:00:19 2016 (r310507) @@ -144,6 +144,9 @@ ATF_TC_WITH_CLEANUP(mincore_resid); ATF_TC_HEAD(mincore_resid, tc) { atf_tc_set_md_var(tc, "descr", "Test page residency with mincore(2)"); +#ifdef __FreeBSD__ + atf_tc_set_md_var(tc, "require.user", "root"); +#endif } ATF_TC_BODY(mincore_resid, tc) @@ -155,6 +158,13 @@ ATF_TC_BODY(mincore_resid, tc) struct rlimit rlim; ATF_REQUIRE(getrlimit(RLIMIT_MEMLOCK, &rlim) == 0); +#ifdef __FreeBSD__ + /* + * Bump the mlock limit to unlimited so the rest of the testcase + * passes instead of failing on the mlock call. + */ + rlim.rlim_max = RLIM_INFINITY; +#endif rlim.rlim_cur = rlim.rlim_max; ATF_REQUIRE(setrlimit(RLIMIT_MEMLOCK, &rlim) == 0); @@ -206,8 +216,9 @@ ATF_TC_BODY(mincore_resid, tc) "might be low on memory"); #ifdef __FreeBSD__ - ATF_REQUIRE_MSG(mlock(addr, npgs * page) == 0, "mlock failed: %s", - strerror(errno)); + if (mlock(addr, npgs * page) == -1 && errno != ENOMEM) + atf_tc_skip("could not wire anonymous test area, system might " + "be low on memory"); #endif ATF_REQUIRE(check_residency(addr, npgs) == npgs); ATF_REQUIRE(munmap(addr, npgs * page) == 0);