Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/sys Pr/51866: Ngie Cooper: fix leak and relea...



details:   https://anonhg.NetBSD.org/src/rev/59245730faa8
branches:  trunk
changeset: 820766:59245730faa8
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Jan 14 20:51:13 2017 +0000

description:
Pr/51866: Ngie Cooper: fix leak and release limit on memory to prevent
false positives with mlock/mmap

diffstat:

 tests/lib/libc/sys/t_mincore.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (46 lines):

diff -r 99e2e5700296 -r 59245730faa8 tests/lib/libc/sys/t_mincore.c
--- a/tests/lib/libc/sys/t_mincore.c    Sat Jan 14 20:50:15 2017 +0000
+++ b/tests/lib/libc/sys/t_mincore.c    Sat Jan 14 20:51:13 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mincore.c,v 1.9 2017/01/10 22:36:29 christos Exp $ */
+/* $NetBSD: t_mincore.c,v 1.10 2017/01/14 20:51:13 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mincore.c,v 1.9 2017/01/10 22:36:29 christos Exp $");
+__RCSID("$NetBSD: t_mincore.c,v 1.10 2017/01/14 20:51:13 christos Exp $");
 
 #include <sys/mman.h>
 #include <sys/stat.h>
@@ -139,6 +139,7 @@
 ATF_TC_HEAD(mincore_resid, tc)
 {
        atf_tc_set_md_var(tc, "descr", "Test page residency with mincore(2)");
+       atf_tc_set_md_var(tc, "require.user", "root");
 }
 
 ATF_TC_BODY(mincore_resid, tc)
@@ -150,6 +151,11 @@
        struct rlimit rlim;
 
        ATF_REQUIRE(getrlimit(RLIMIT_MEMLOCK, &rlim) == 0);
+       /*
+        * 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;
        rlim.rlim_cur = rlim.rlim_max;
        ATF_REQUIRE(setrlimit(RLIMIT_MEMLOCK, &rlim) == 0);
 
@@ -250,6 +256,7 @@
        (void)munmap(addr2, npgs * page);
        (void)munmap(addr3, npgs * page);
        (void)unlink(path);
+       free(buf);
 }
 
 ATF_TC_CLEANUP(mincore_resid, tc)



Home | Main Index | Thread Index | Old Index