diff options
author | ngie <ngie@FreeBSD.org> | 2017-02-10 02:57:37 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-02-10 02:57:37 +0000 |
commit | 9e0c92b812b404c1d5124f2e2d81cb448ec22b07 (patch) | |
tree | f9ad05c66447833aaf962ca03b436624b05cf501 /contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c | |
parent | 40a4c1db9870336906732ea813c6958f8f59a9f6 (diff) | |
download | FreeBSD-src-9e0c92b812b404c1d5124f2e2d81cb448ec22b07.zip FreeBSD-src-9e0c92b812b404c1d5124f2e2d81cb448ec22b07.tar.gz |
MFC r309373:
r309373 (by bdrewery):
Fix setrlimit_test:setrlimit_memlock when the system has exceeded vm.max_wired.
This uses the same fix as r294894 did for the mlock test. The code from
that commit is moved into a common object file which PROGS supports
building first.
Diffstat (limited to 'contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c')
-rw-r--r-- | contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c b/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c index f1100bf..31db878 100644 --- a/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c +++ b/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c @@ -50,6 +50,11 @@ __RCSID("$NetBSD: t_setrlimit.c,v 1.5 2016/07/13 09:53:16 njoly Exp $"); #include <ucontext.h> #include <unistd.h> +#ifdef __FreeBSD__ +void set_vm_max_wired(int); +void restore_vm_max_wired(void); +#endif + static void sighandler(int); static const char path[] = "setrlimit"; @@ -238,10 +243,18 @@ sighandler(int signo) _exit(EXIT_SUCCESS); } +#ifdef __FreeBSD__ +ATF_TC_WITH_CLEANUP(setrlimit_memlock); +#else ATF_TC(setrlimit_memlock); +#endif ATF_TC_HEAD(setrlimit_memlock, tc) { atf_tc_set_md_var(tc, "descr", "Test setrlimit(2), RLIMIT_MEMLOCK"); +#ifdef __FreeBSD__ + atf_tc_set_md_var(tc, "require.config", "allow_sysctl_side_effects"); + atf_tc_set_md_var(tc, "require.user", "root"); +#endif } ATF_TC_BODY(setrlimit_memlock, tc) @@ -252,6 +265,11 @@ ATF_TC_BODY(setrlimit_memlock, tc) pid_t pid; int sta; +#ifdef __FreeBSD__ + /* Set max_wired really really high to avoid EAGAIN */ + set_vm_max_wired(INT_MAX); +#endif + page = sysconf(_SC_PAGESIZE); ATF_REQUIRE(page >= 0); @@ -295,6 +313,14 @@ ATF_TC_BODY(setrlimit_memlock, tc) atf_tc_fail("RLIMIT_MEMLOCK not enforced"); } +#ifdef __FreeBSD__ +ATF_TC_CLEANUP(setrlimit_memlock, tc) +{ + + restore_vm_max_wired(); +} +#endif + ATF_TC(setrlimit_nofile_1); ATF_TC_HEAD(setrlimit_nofile_1, tc) { |