summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/libc
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2016-12-24 12:58:33 +0000
committerngie <ngie@FreeBSD.org>2016-12-24 12:58:33 +0000
commit29cf69d0fdeacdd9809208786e6ed1ab3c4f0ecb (patch)
tree4473bb42be74a080ac4664af82a9a2fe302e6b71 /contrib/netbsd-tests/lib/libc
parent7b08136c1699729ff75fc4b6ae32bede6588dc12 (diff)
downloadFreeBSD-src-29cf69d0fdeacdd9809208786e6ed1ab3c4f0ecb.zip
FreeBSD-src-29cf69d0fdeacdd9809208786e6ed1ab3c4f0ecb.tar.gz
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"
Diffstat (limited to 'contrib/netbsd-tests/lib/libc')
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_mincore.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mincore.c b/contrib/netbsd-tests/lib/libc/sys/t_mincore.c
index 872856e..72355e2 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_mincore.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mincore.c
@@ -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);
OpenPOWER on IntegriCloud