summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2017-01-15 09:35:49 +0000
committerEnji Cooper <ngie@FreeBSD.org>2017-01-15 09:35:49 +0000
commit181439425f0bb490970e4e7022295f139d9988ad (patch)
treef50851860df5c384bd23ea79e5af032c745fad3a
parenta567518138e0e2fa7177c60e241e8b8e4bb468d5 (diff)
downloadsrc-test2-181439425f0bb490970e4e7022295f139d9988ad.tar.gz
src-test2-181439425f0bb490970e4e7022295f139d9988ad.zip
Notes
-rw-r--r--kernel/t_mqueue.c10
-rw-r--r--kernel/t_ptrace_wait.c322
-rw-r--r--lib/libc/c063/t_mkfifoat.c17
-rw-r--r--lib/libc/gen/t_glob.c6
-rw-r--r--lib/libc/regex/t_regex_att.c13
-rw-r--r--lib/libc/setjmp/t_setjmp.c6
-rw-r--r--lib/libc/setjmp/t_threadjmp.c6
-rw-r--r--lib/libc/string/t_strlen.c7
-rw-r--r--lib/libc/sys/t_mincore.c11
-rw-r--r--lib/libc/sys/t_msync.c29
-rw-r--r--lib/libc/sys/t_unlink.c9
-rw-r--r--lib/librt/t_sem.c18
-rw-r--r--usr.bin/grep/d_binary.out2
-rwxr-xr-xusr.bin/grep/t_grep.sh8
-rwxr-xr-xusr.sbin/mtree/t_mtree.sh16
15 files changed, 406 insertions, 74 deletions
diff --git a/kernel/t_mqueue.c b/kernel/t_mqueue.c
index 7206bc6ef917..c5c7ce3be0f2 100644
--- a/kernel/t_mqueue.c
+++ b/kernel/t_mqueue.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mqueue.c,v 1.5 2017/01/10 22:10:22 christos Exp $ */
+/* $NetBSD: t_mqueue.c,v 1.6 2017/01/14 20:57:24 christos Exp $ */
/*
* Test for POSIX message queue priority handling.
@@ -6,17 +6,17 @@
* This file is in the Public Domain.
*/
-#include <atf-c.h>
#include <sys/stat.h>
+#include <atf-c.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <mqueue.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <errno.h>
#include <unistd.h>
-#include <mqueue.h>
-
#define MQ_PRIO_BASE 24
static void
diff --git a/kernel/t_ptrace_wait.c b/kernel/t_ptrace_wait.c
index b1b4d1bef2c2..9d2edff4c3ec 100644
--- a/kernel/t_ptrace_wait.c
+++ b/kernel/t_ptrace_wait.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.58 2017/01/14 04:37:55 kamil Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.60 2017/01/14 19:17:10 kamil Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.58 2017/01/14 04:37:55 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.60 2017/01/14 19:17:10 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -39,6 +39,7 @@ __RCSID("$NetBSD: t_ptrace_wait.c,v 1.58 2017/01/14 04:37:55 kamil Exp $");
#include <machine/reg.h>
#include <err.h>
#include <errno.h>
+#include <lwp.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
@@ -1184,6 +1185,116 @@ ATF_TC_BODY(eventmask4, tc)
TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
}
+ATF_TC(eventmask5);
+ATF_TC_HEAD(eventmask5, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that PTRACE_LWP_CREATE in EVENT_MASK is preserved");
+}
+
+ATF_TC_BODY(eventmask5, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ ptrace_event_t set_event, get_event;
+ const int len = sizeof(ptrace_event_t);
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ set_event.pe_set_event = PTRACE_LWP_CREATE;
+ ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1);
+ ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1);
+ ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(eventmask6);
+ATF_TC_HEAD(eventmask6, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that PTRACE_LWP_EXIT in EVENT_MASK is preserved");
+}
+
+ATF_TC_BODY(eventmask6, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ ptrace_event_t set_event, get_event;
+ const int len = sizeof(ptrace_event_t);
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ set_event.pe_set_event = PTRACE_LWP_EXIT;
+ ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1);
+ ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1);
+ ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
#if defined(TWAIT_HAVE_PID)
ATF_TC(fork1);
ATF_TC_HEAD(fork1, tc)
@@ -5286,6 +5397,207 @@ ATF_TC_BODY(siginfo6, tc)
}
#endif
+volatile lwpid_t the_lwp_id = 0;
+
+static void
+lwp_main_func(void *arg)
+{
+ the_lwp_id = _lwp_self();
+ _lwp_exit();
+}
+
+ATF_TC(lwp_create1);
+ATF_TC_HEAD(lwp_create1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that 1 LWP creation is intercepted by ptrace(2) with "
+ "EVENT_MASK set to PTRACE_LWP_CREATE");
+}
+
+ATF_TC_BODY(lwp_create1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ ptrace_state_t state;
+ const int slen = sizeof(state);
+ ptrace_event_t event;
+ const int elen = sizeof(event);
+ ucontext_t uc;
+ lwpid_t lid;
+ static const size_t ssize = 16*1024;
+ void *stack;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before allocating memory for stack in child\n");
+ FORKEE_ASSERT((stack = malloc(ssize)) != NULL);
+
+ printf("Before making context for new lwp in child\n");
+ _lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize);
+
+ printf("Before creating new in child\n");
+ FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0);
+
+ printf("Before waiting for lwp %d to exit\n", lid);
+ FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0);
+
+ printf("Before verifying that reported %d and running lid %d "
+ "are the same\n", lid, the_lwp_id);
+ FORKEE_ASSERT_EQ(lid, the_lwp_id);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Set empty EVENT_MASK for the child %d\n", child);
+ event.pe_set_event = PTRACE_LWP_CREATE;
+ ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child - expected stopped "
+ "SIGTRAP\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGTRAP);
+
+ ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
+
+ ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_LWP_CREATE);
+
+ lid = state.pe_lwp;
+ printf("Reported PTRACE_LWP_CREATE event with lid %d\n", lid);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child - expected exited\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child - expected no process\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(lwp_exit1);
+ATF_TC_HEAD(lwp_exit1, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that 1 LWP creation is intercepted by ptrace(2) with "
+ "EVENT_MASK set to PTRACE_LWP_EXIT");
+}
+
+ATF_TC_BODY(lwp_exit1, tc)
+{
+ const int exitval = 5;
+ const int sigval = SIGSTOP;
+ pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+ int status;
+#endif
+ ptrace_state_t state;
+ const int slen = sizeof(state);
+ ptrace_event_t event;
+ const int elen = sizeof(event);
+ ucontext_t uc;
+ lwpid_t lid;
+ static const size_t ssize = 16*1024;
+ void *stack;
+
+ printf("Before forking process PID=%d\n", getpid());
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+ FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ printf("Before raising %s from child\n", strsignal(sigval));
+ FORKEE_ASSERT(raise(sigval) == 0);
+
+ printf("Before allocating memory for stack in child\n");
+ FORKEE_ASSERT((stack = malloc(ssize)) != NULL);
+
+ printf("Before making context for new lwp in child\n");
+ _lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize);
+
+ printf("Before creating new in child\n");
+ FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0);
+
+ printf("Before waiting for lwp %d to exit\n", lid);
+ FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0);
+
+ printf("Before verifying that reported %d and running lid %d "
+ "are the same\n", lid, the_lwp_id);
+ FORKEE_ASSERT_EQ(lid, the_lwp_id);
+
+ printf("Before exiting of the child process\n");
+ _exit(exitval);
+ }
+ printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+ printf("Before calling %s() for the child\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, sigval);
+
+ printf("Set empty EVENT_MASK for the child %d\n", child);
+ event.pe_set_event = PTRACE_LWP_EXIT;
+ ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child - expected stopped "
+ "SIGTRAP\n", TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_stopped(status, SIGTRAP);
+
+ ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
+
+ ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_LWP_EXIT);
+
+ lid = state.pe_lwp;
+ printf("Reported PTRACE_LWP_EXIT event with lid %d\n", lid);
+
+ printf("Before resuming the child process where it left off and "
+ "without signal to be sent\n");
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+ printf("Before calling %s() for the child - expected exited\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+ validate_status_exited(status, exitval);
+
+ printf("Before calling %s() for the child - expected no process\n",
+ TWAIT_FNAME);
+ TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
ATF_TP_ADD_TCS(tp)
{
setvbuf(stdout, NULL, _IONBF, 0);
@@ -5307,6 +5619,8 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, eventmask2);
ATF_TP_ADD_TC(tp, eventmask3);
ATF_TP_ADD_TC(tp, eventmask4);
+ ATF_TP_ADD_TC(tp, eventmask5);
+ ATF_TP_ADD_TC(tp, eventmask6);
ATF_TP_ADD_TC_HAVE_PID(tp, fork1);
ATF_TP_ADD_TC(tp, fork2);
@@ -5380,5 +5694,9 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC_HAVE_PID(tp, siginfo5);
ATF_TP_ADD_TC_PT_STEP(tp, siginfo6);
+ ATF_TP_ADD_TC(tp, lwp_create1);
+
+ ATF_TP_ADD_TC(tp, lwp_exit1);
+
return atf_no_error();
}
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)
{
diff --git a/usr.bin/grep/d_binary.out b/usr.bin/grep/d_binary.out
index ce030561340d..f0ef9880d6d5 100644
--- a/usr.bin/grep/d_binary.out
+++ b/usr.bin/grep/d_binary.out
@@ -1 +1 @@
-Binary file /bin/sh matches
+Binary file test.file matches
diff --git a/usr.bin/grep/t_grep.sh b/usr.bin/grep/t_grep.sh
index f2d70f08bded..558b074ad4b3 100755
--- a/usr.bin/grep/t_grep.sh
+++ b/usr.bin/grep/t_grep.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_grep.sh,v 1.2 2013/05/17 15:39:17 christos Exp $
+# $NetBSD: t_grep.sh,v 1.3 2017/01/14 20:43:52 christos Exp $
#
# Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -43,7 +43,9 @@ binary_head()
}
binary_body()
{
- atf_check -o file:"$(atf_get_srcdir)/d_binary.out" grep $(uname) /bin/sh
+ dd if=/dev/zero count=1 of=test.file
+ echo -n "foobar" >> test.file
+ atf_check -o file:"$(atf_get_srcdir)/d_binary.out" grep foobar test.file
}
atf_test_case recurse
@@ -57,7 +59,7 @@ recurse_body()
echo -e "cod\ndover sole\nhaddock\nhalibut\npilchard" > recurse/d/fish
echo -e "cod\nhaddock\nplaice" > recurse/a/f/favourite-fish
- atf_check -o file:"$(atf_get_srcdir)/d_recurse.out" grep -r haddock recurse
+ atf_check -o file:"$(atf_get_srcdir)/d_recurse.out" -x "grep -r haddock recurse | sort"
}
atf_test_case recurse_symlink
diff --git a/usr.sbin/mtree/t_mtree.sh b/usr.sbin/mtree/t_mtree.sh
index 20fda75e02ea..58fc7db6155b 100755
--- a/usr.sbin/mtree/t_mtree.sh
+++ b/usr.sbin/mtree/t_mtree.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_mtree.sh,v 1.6 2013/02/05 16:49:42 christos Exp $
+# $NetBSD: t_mtree.sh,v 1.7 2017/01/14 20:45:16 christos Exp $
#
# Copyright (c) 2009, 2012 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -284,6 +284,13 @@ ignore_head()
ignore_body()
{
+ # Kyua 0.11 and above point TMPDIR to our work directory and atf-check
+ # generates a temporary file, which confuses mtree. Put the mtree files
+ # into a subdirectory.
+ #
+ # See https://github.com/jmmv/kyua/issues/133 for details.
+ mkdir root && cd root
+
mkdir newdir
mtree -F ${FLAVOR} -c | mtree -F ${FLAVOR} -Ck uid,gid,mode > mtree.spec
ln -s newdir otherdir
@@ -313,6 +320,13 @@ mtree_ignore_body()
}
netbsd6_ignore_body()
{
+ # Kyua 0.11 and above point TMPDIR to our work directory and atf-check
+ # generates a temporary file, which confuses mtree. Put the mtree files
+ # into a subdirectory.
+ #
+ # See https://github.com/jmmv/kyua/issues/133 for details.
+ mkdir root && cd root
+
FLAVOR=netbsd6 ignore_body
}