diff options
| author | Enji Cooper <ngie@FreeBSD.org> | 2017-01-15 09:35:49 +0000 |
|---|---|---|
| committer | Enji Cooper <ngie@FreeBSD.org> | 2017-01-15 09:35:49 +0000 |
| commit | 181439425f0bb490970e4e7022295f139d9988ad (patch) | |
| tree | f50851860df5c384bd23ea79e5af032c745fad3a /lib/libc/sys | |
| parent | a567518138e0e2fa7177c60e241e8b8e4bb468d5 (diff) | |
Notes
Diffstat (limited to 'lib/libc/sys')
| -rw-r--r-- | lib/libc/sys/t_mincore.c | 11 | ||||
| -rw-r--r-- | lib/libc/sys/t_msync.c | 29 | ||||
| -rw-r--r-- | lib/libc/sys/t_unlink.c | 9 |
3 files changed, 20 insertions, 29 deletions
diff --git a/lib/libc/sys/t_mincore.c b/lib/libc/sys/t_mincore.c index 431970953e19..e61c80e938ee 100644 --- a/lib/libc/sys/t_mincore.c +++ b/lib/libc/sys/t_mincore.c @@ -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_WITH_CLEANUP(mincore_resid); 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 @@ ATF_TC_BODY(mincore_resid, tc) 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 @@ ATF_TC_BODY(mincore_resid, tc) (void)munmap(addr2, npgs * page); (void)munmap(addr3, npgs * page); (void)unlink(path); + free(buf); } ATF_TC_CLEANUP(mincore_resid, tc) diff --git a/lib/libc/sys/t_msync.c b/lib/libc/sys/t_msync.c index 974330080604..5dfc2f0c56f1 100644 --- a/lib/libc/sys/t_msync.c +++ b/lib/libc/sys/t_msync.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_msync.c,v 1.2 2012/03/16 06:15:17 matt Exp $ */ +/* $NetBSD: t_msync.c,v 1.3 2017/01/14 20:52:42 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_msync.c,v 1.2 2012/03/16 06:15:17 matt Exp $"); +__RCSID("$NetBSD: t_msync.c,v 1.3 2017/01/14 20:52:42 christos Exp $"); #include <sys/mman.h> @@ -52,8 +52,7 @@ msync_sync(const char *garbage, int flags) { char *buf, *map = MAP_FAILED; const char *str = NULL; - size_t i, len; - ssize_t tot; + size_t len; int fd, rv; /* @@ -65,29 +64,17 @@ msync_sync(const char *garbage, int flags) if (buf == NULL) return NULL; - for (i = 0; i < (size_t)page; i++) - buf[i] = 'x'; + memset(buf, 'x', page); fd = open(path, O_RDWR | O_CREAT, 0700); if (fd < 0) { - str = "failed to open"; - goto out; + free(buf); + return "failed to open"; } - tot = 0; - - while (tot < page) { - - rv = write(fd, buf, sizeof(buf)); - - if (rv < 0) { - str = "failed to write"; - goto out; - } - - tot += rv; - } + ATF_REQUIRE_MSG(write(fd, buf, page) != -1, "write(2) failed: %s", + strerror(errno)); map = mmap(NULL, page, PROT_READ | PROT_WRITE, MAP_FILE|MAP_PRIVATE, fd, 0); diff --git a/lib/libc/sys/t_unlink.c b/lib/libc/sys/t_unlink.c index 6b05a0859b08..aee665c8a2e2 100644 --- a/lib/libc/sys/t_unlink.c +++ b/lib/libc/sys/t_unlink.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_unlink.c,v 1.3 2017/01/13 19:33:03 christos Exp $ */ +/* $NetBSD: t_unlink.c,v 1.4 2017/01/14 20:55:26 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_unlink.c,v 1.3 2017/01/13 19:33:03 christos Exp $"); +__RCSID("$NetBSD: t_unlink.c,v 1.4 2017/01/14 20:55:26 christos Exp $"); #include <sys/stat.h> @@ -107,11 +107,8 @@ ATF_TC_HEAD(unlink_fifo, tc) ATF_TC_BODY(unlink_fifo, tc) { - int fd; - ATF_REQUIRE_MSG((fd = mkfifo(path, 0666)) == 0, - "mkfifo failed: %s", strerror(errno)); - (void)close(fd); + ATF_REQUIRE(mkfifo(path, 0666) == 0); ATF_REQUIRE(unlink(path) == 0); errno = 0; |
