Pull in additional test changes accepted upstream as well as some

additional testcases added in .../kernel/t_ptrace_wait.c
This commit is contained in:
Enji Cooper 2017-01-15 09:35:49 +00:00
parent a567518138
commit 181439425f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/vendor/NetBSD/tests/dist/; revision=312219
15 changed files with 408 additions and 76 deletions

View File

@ -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

View File

@ -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();
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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 <regex.h>
#include <string.h>
#include <stdlib.h>
#include <vis.h>
#include <ctype.h>
#include <atf-c.h>
#include <ctype.h>
#include <regex.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <util.h>
#include <vis.h>
static const char sep[] = "\r\n\t";
static const char delim[3] = "\\\\\0";

View File

@ -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();

View File

@ -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");

View File

@ -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);

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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)
{

View File

@ -1 +1 @@
Binary file /bin/sh matches
Binary file test.file matches

View File

@ -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

View File

@ -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
}