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 | |
| parent | a567518138e0e2fa7177c60e241e8b8e4bb468d5 (diff) | |
Notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/c063/t_mkfifoat.c | 17 | ||||
| -rw-r--r-- | lib/libc/gen/t_glob.c | 6 | ||||
| -rw-r--r-- | lib/libc/regex/t_regex_att.c | 13 | ||||
| -rw-r--r-- | lib/libc/setjmp/t_setjmp.c | 6 | ||||
| -rw-r--r-- | lib/libc/setjmp/t_threadjmp.c | 6 | ||||
| -rw-r--r-- | lib/libc/string/t_strlen.c | 7 | ||||
| -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 | ||||
| -rw-r--r-- | lib/librt/t_sem.c | 18 |
10 files changed, 60 insertions, 62 deletions
diff --git a/lib/libc/c063/t_mkfifoat.c b/lib/libc/c063/t_mkfifoat.c index 5c496c8d0987..4f91afd979a7 100644 --- a/lib/libc/c063/t_mkfifoat.c +++ b/lib/libc/c063/t_mkfifoat.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_mkfifoat.c,v 1.3 2017/01/10 15:15:09 christos Exp $ */ +/* $NetBSD: t_mkfifoat.c,v 1.4 2017/01/14 20:55:26 christos Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_mkfifoat.c,v 1.3 2017/01/10 15:15:09 christos Exp $"); +__RCSID("$NetBSD: t_mkfifoat.c,v 1.4 2017/01/14 20:55:26 christos Exp $"); #include <atf-c.h> #include <errno.h> @@ -55,13 +55,11 @@ ATF_TC_HEAD(mkfifoat_fd, tc) ATF_TC_BODY(mkfifoat_fd, tc) { int dfd; - int fd; mode_t mode = 0600; ATF_REQUIRE(mkdir(DIR, 0755) == 0); ATF_REQUIRE((dfd = open(DIR, O_RDONLY, 0)) != -1); - ATF_REQUIRE((fd = mkfifoat(dfd, BASEFIFO, mode)) != -1); - ATF_REQUIRE(close(fd) == 0); + ATF_REQUIRE(mkfifoat(dfd, BASEFIFO, mode) != -1); ATF_REQUIRE(access(FIFO, F_OK) == 0); (void)close(dfd); } @@ -74,12 +72,10 @@ ATF_TC_HEAD(mkfifoat_fdcwd, tc) } ATF_TC_BODY(mkfifoat_fdcwd, tc) { - int fd; mode_t mode = 0600; ATF_REQUIRE(mkdir(DIR, 0755) == 0); - ATF_REQUIRE((fd = mkfifoat(AT_FDCWD, FIFO, mode)) != -1); - ATF_REQUIRE(close(fd) == 0); + ATF_REQUIRE(mkfifoat(AT_FDCWD, FIFO, mode) != -1); ATF_REQUIRE(access(FIFO, F_OK) == 0); } @@ -91,10 +87,9 @@ ATF_TC_HEAD(mkfifoat_fdcwderr, tc) } ATF_TC_BODY(mkfifoat_fdcwderr, tc) { - int fd; mode_t mode = 0600; - ATF_REQUIRE((fd = mkfifoat(AT_FDCWD, FIFOERR, mode)) == -1); + ATF_REQUIRE(mkfifoat(AT_FDCWD, FIFOERR, mode) == -1); } ATF_TC(mkfifoat_fderr); @@ -110,7 +105,7 @@ ATF_TC_BODY(mkfifoat_fderr, tc) ATF_REQUIRE(mkdir(DIR, 0755) == 0); ATF_REQUIRE((fd = open(FIFO, O_CREAT|O_RDWR, 0644)) != -1); ATF_REQUIRE(close(fd) == 0); - ATF_REQUIRE((fd = mkfifoat(-1, FIFO, mode)) == -1); + ATF_REQUIRE(mkfifoat(-1, FIFO, mode) == -1); } ATF_TP_ADD_TCS(tp) diff --git a/lib/libc/gen/t_glob.c b/lib/libc/gen/t_glob.c index d741d939a43d..7eed624b4aef 100644 --- a/lib/libc/gen/t_glob.c +++ b/lib/libc/gen/t_glob.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_glob.c,v 1.4 2017/01/13 21:30:41 christos Exp $ */ +/* $NetBSD: t_glob.c,v 1.5 2017/01/14 20:47:41 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. * All rights reserved. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_glob.c,v 1.4 2017/01/13 21:30:41 christos Exp $"); +__RCSID("$NetBSD: t_glob.c,v 1.5 2017/01/14 20:47:41 christos Exp $"); #include <atf-c.h> @@ -146,7 +146,7 @@ gl_stat(const char *name , __gl_stat_t *st) memset(st, 0, sizeof(*st)); if (strcmp(buf, "a") == 0 || strcmp(buf, "a/b") == 0) { - st->st_mode |= _S_IFDIR; + st->st_mode |= S_IFDIR; return 0; } diff --git a/lib/libc/regex/t_regex_att.c b/lib/libc/regex/t_regex_att.c index 0425b6f2c58c..dd5b818a1ef3 100644 --- a/lib/libc/regex/t_regex_att.c +++ b/lib/libc/regex/t_regex_att.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_regex_att.c,v 1.2 2017/01/14 00:50:56 christos Exp $ */ +/* $NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -37,17 +37,18 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_regex_att.c,v 1.2 2017/01/14 00:50:56 christos Exp $"); +__RCSID("$NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $"); #include <sys/param.h> -#include <stdio.h> +#include <atf-c.h> +#include <ctype.h> #include <regex.h> -#include <string.h> +#include <stdio.h> #include <stdlib.h> +#include <string.h> +#include <util.h> #include <vis.h> -#include <ctype.h> -#include <atf-c.h> static const char sep[] = "\r\n\t"; static const char delim[3] = "\\\\\0"; diff --git a/lib/libc/setjmp/t_setjmp.c b/lib/libc/setjmp/t_setjmp.c index 4d2a93bab004..1f0f1ed5ea89 100644 --- a/lib/libc/setjmp/t_setjmp.c +++ b/lib/libc/setjmp/t_setjmp.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $ */ +/* $NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #include <sys/cdefs.h> __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $"); +__RCSID("$NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $"); #include <sys/types.h> @@ -87,7 +87,7 @@ __RCSID("$NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $"); static int expectsignal; static void -aborthandler(int signo) +aborthandler(int signo __unused) { ATF_REQUIRE_MSG(expectsignal, "kill(SIGABRT) succeeded"); atf_tc_pass(); diff --git a/lib/libc/setjmp/t_threadjmp.c b/lib/libc/setjmp/t_threadjmp.c index 4437c927214e..44d7555c0b16 100644 --- a/lib/libc/setjmp/t_threadjmp.c +++ b/lib/libc/setjmp/t_threadjmp.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_threadjmp.c,v 1.1 2011/04/21 18:58:20 martin Exp $ */ +/* $NetBSD: t_threadjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #include <sys/cdefs.h> __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_threadjmp.c,v 1.1 2011/04/21 18:58:20 martin Exp $"); +__RCSID("$NetBSD: t_threadjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $"); #include <sys/types.h> @@ -91,7 +91,7 @@ static pthread_t myself = NULL; static int expectsignal; static void -aborthandler(int signo) +aborthandler(int signo __unused) { ATF_REQUIRE(myself == pthread_self()); ATF_REQUIRE_MSG(expectsignal, "kill(SIGABRT) succeeded"); diff --git a/lib/libc/string/t_strlen.c b/lib/libc/string/t_strlen.c index 66158fd7113f..9899e6d5944c 100644 --- a/lib/libc/string/t_strlen.c +++ b/lib/libc/string/t_strlen.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_strlen.c,v 1.5 2011/07/14 07:33:20 jruoho Exp $ */ +/* $NetBSD: t_strlen.c,v 1.6 2017/01/14 20:49:24 christos Exp $ */ /* * Written by J.T. Conklin <jtc@acorntoolworks.com> @@ -40,6 +40,7 @@ ATF_TC_HEAD(strlen_basic, tc) ATF_TC_BODY(strlen_basic, tc) { + void *dl_handle; /* try to trick the compiler */ size_t (*strlen_fn)(const char *); @@ -107,7 +108,8 @@ ATF_TC_BODY(strlen_basic, tc) * During testing it is useful have the rest of the program * use a known good version! */ - strlen_fn = dlsym(dlopen(NULL, RTLD_LAZY), "test_strlen"); + dl_handle = dlopen(NULL, RTLD_LAZY); + strlen_fn = dlsym(dl_handle, "test_strlen"); if (!strlen_fn) strlen_fn = strlen; @@ -134,6 +136,7 @@ ATF_TC_BODY(strlen_basic, tc) } } } + (void)dlclose(dl_handle); } ATF_TC(strlen_huge); 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; diff --git a/lib/librt/t_sem.c b/lib/librt/t_sem.c index b6fc4dbf197b..0541ae57113a 100644 --- a/lib/librt/t_sem.c +++ b/lib/librt/t_sem.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_sem.c,v 1.2 2010/11/08 13:05:49 njoly Exp $ */ +/* $NetBSD: t_sem.c,v 1.3 2017/01/14 20:58:20 christos Exp $ */ /* * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ #include <sys/cdefs.h> __COPYRIGHT("@(#) Copyright (c) 2008, 2010\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_sem.c,v 1.2 2010/11/08 13:05:49 njoly Exp $"); +__RCSID("$NetBSD: t_sem.c,v 1.3 2017/01/14 20:58:20 christos Exp $"); #include <sys/wait.h> @@ -72,7 +72,7 @@ __RCSID("$NetBSD: t_sem.c,v 1.2 2010/11/08 13:05:49 njoly Exp $"); #define NCHILDREN 10 -ATF_TC(basic); +ATF_TC_WITH_CLEANUP(basic); ATF_TC_HEAD(basic, tc) { atf_tc_set_md_var(tc, "descr", "Checks basic functionality of POSIX " @@ -108,8 +108,12 @@ ATF_TC_BODY(basic, tc) ATF_REQUIRE_EQ(sem_close(sem_b), 0); ATF_REQUIRE_EQ(sem_unlink("/sem_b"), 0); } +ATF_TC_CLEANUP(basic, tc) +{ + (void)sem_unlink("/sem_b"); +} -ATF_TC(child); +ATF_TC_WITH_CLEANUP(child); ATF_TC_HEAD(child, tc) { atf_tc_set_md_var(tc, "descr", "Checks using semaphores to synchronize " @@ -124,7 +128,7 @@ ATF_TC_BODY(child, tc) pid_t pid; - if (sysconf(_SC_SEMAPHORES) == -1) + if (sysconf(_SC_SEMAPHORES) == -1) atf_tc_skip("POSIX semaphores not supported"); sem_a = sem_open("/sem_a", O_CREAT | O_EXCL, 0644, 0); @@ -164,6 +168,10 @@ ATF_TC_BODY(child, tc) ATF_REQUIRE_EQ(sem_close(sem_a), 0); ATF_REQUIRE_EQ(sem_unlink("/sem_a"), 0); } +ATF_TC_CLEANUP(child, tc) +{ + (void)sem_unlink("/sem_a"); +} ATF_TP_ADD_TCS(tp) { |
