summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2015-05-24 07:11:03 +0000
committerngie <ngie@FreeBSD.org>2015-05-24 07:11:03 +0000
commit1a0cbcd01aba9ae90897d49b5987c635a695c974 (patch)
tree007bbfb4eef88985f91be20dbbd9080c695a4fdb /tests
parentb0e50d6cad74822a727e0d04d3c960115275e21e (diff)
parente6b664c390af88d4a87208bc042ce503da664c3b (diff)
downloadFreeBSD-src-1a0cbcd01aba9ae90897d49b5987c635a695c974.zip
FreeBSD-src-1a0cbcd01aba9ae90897d49b5987c635a695c974.tar.gz
MFhead @ r283351
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile1
-rw-r--r--tests/etc/Makefile12
-rw-r--r--tests/etc/rc.d/Makefile7
-rwxr-xr-xtests/etc/rc.d/routing_test.sh138
-rw-r--r--tests/freebsd_test_suite/macros.h56
-rw-r--r--tests/sys/Makefile1
-rw-r--r--tests/sys/aio/Makefile2
-rw-r--r--tests/sys/aio/aio_kqueue_test.c36
-rw-r--r--tests/sys/aio/aio_test.c27
-rw-r--r--tests/sys/aio/lio_kqueue_test.c22
-rw-r--r--tests/sys/kern/Makefile2
-rw-r--r--tests/sys/kern/ptrace_test.c143
-rw-r--r--tests/sys/mqueue/Makefile2
-rw-r--r--tests/sys/mqueue/mqtest1.c4
-rw-r--r--tests/sys/mqueue/mqtest2.c4
-rw-r--r--tests/sys/mqueue/mqtest3.c4
-rw-r--r--tests/sys/mqueue/mqtest4.c4
-rw-r--r--tests/sys/mqueue/mqtest5.c4
-rwxr-xr-xtests/sys/mqueue/mqueue_test.sh27
-rw-r--r--tests/sys/vm/Makefile7
-rw-r--r--tests/sys/vm/mmap_test.c (renamed from tests/sys/kern/mmap_test.c)0
21 files changed, 460 insertions, 43 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 89da82d..12c1509 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -2,6 +2,7 @@
.include <bsd.own.mk>
+SUBDIR= etc
SUBDIR= sys
TESTSDIR= ${TESTSBASE}
diff --git a/tests/etc/Makefile b/tests/etc/Makefile
new file mode 100644
index 0000000..9aad25c
--- /dev/null
+++ b/tests/etc/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/etc
+
+.PATH: ${.CURDIR:H}
+KYUAFILE= yes
+
+SUBDIR+= rc.d
+
+.include <bsd.test.mk>
diff --git a/tests/etc/rc.d/Makefile b/tests/etc/rc.d/Makefile
new file mode 100644
index 0000000..368e8f4
--- /dev/null
+++ b/tests/etc/rc.d/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+TESTSDIR= ${TESTSBASE}/etc/rc.d
+
+ATF_TESTS_SH+= routing_test
+
+.include <bsd.test.mk>
diff --git a/tests/etc/rc.d/routing_test.sh b/tests/etc/rc.d/routing_test.sh
new file mode 100755
index 0000000..693af23
--- /dev/null
+++ b/tests/etc/rc.d/routing_test.sh
@@ -0,0 +1,138 @@
+#
+# Copyright (c) 2014 Spectra Logic Corporation
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions, and the following disclaimer,
+# without modification.
+# 2. Redistributions in binary form must reproduce at minimum a disclaimer
+# substantially similar to the "NO WARRANTY" disclaimer below
+# ("Disclaimer") and any redistribution must be conditioned upon
+# including a substantially similar Disclaimer requirement for further
+# binary redistribution.
+#
+# NO WARRANTY
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGES.
+#
+# Authors: Alan Somers (Spectra Logic Corporation)
+#
+# $FreeBSD$
+
+atf_test_case static_ipv6_loopback_route_for_each_fib cleanup
+static_ipv6_loopback_route_for_each_fib_head()
+{
+ atf_set "descr" "Every FIB should have a static IPv6 loopback route"
+ atf_set "require.user" "root"
+ atf_set "require.config" "fibs"
+ atf_set "require.progs" "sysrc"
+}
+static_ipv6_loopback_route_for_each_fib_body()
+{
+ # Configure the TAP interface to use an RFC5737 nonrouteable address
+ # and a non-default fib
+ ADDR="192.0.2.2"
+ SUBNET="192.0.2.0"
+ MASK="24"
+
+ # Check system configuration
+ if [ 0 != `sysctl -n net.add_addr_allfibs` ]; then
+ atf_skip "This test requires net.add_addr_allfibs=0"
+ fi
+
+ get_fibs 1
+ get_tap
+
+ # Configure a TAP interface in /etc/rc.conf. Register the sysrc
+ # variable for cleanup.
+ echo "ifconfig_${TAP}" >> "sysrc_vars_to_cleanup"
+ sysrc ifconfig_${TAP}="${ADDR}/${MASK} fib ${FIB0}"
+
+ # Start the interface
+ service netif start ${TAP}
+ # Check for an IPv6 loopback route
+ setfib ${FIB0} netstat -rn -f inet6 | grep -q "^::1.*lo0$"
+ if [ 0 -eq $? ]; then
+ atf_pass
+ else
+ setfib ${FIB0} netstat -rn -f inet6
+ atf_fail "Did not find an IPv6 loopback route"
+ fi
+}
+static_ipv6_loopback_route_for_each_fib_cleanup()
+{
+ cleanup_sysrc
+ cleanup_tap
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case static_ipv6_loopback_route_for_each_fib
+}
+
+# Looks up one or more fibs from the configuration data and validates them.
+# Returns the results in the env varilables FIB0, FIB1, etc.
+# parameter numfibs The number of fibs to lookup
+get_fibs()
+{
+ NUMFIBS=$1
+ net_fibs=`sysctl -n net.fibs`
+ i=0
+ while [ $i -lt "$NUMFIBS" ]; do
+ fib=`atf_config_get "fibs" | \
+ awk -v i=$(( i + 1 )) '{print $i}'`
+ echo "fib is ${fib}"
+ eval FIB${i}=${fib}
+ if [ "$fib" -ge "$net_fibs" ]; then
+ msg="The ${i}th configured fib is ${fub}, which is "
+ msg="$msg not less than net.fibs (${net_fibs})"
+ atf_skip "$msg"
+ fi
+ i=$(( $i + 1 ))
+ done
+}
+
+
+# Creates a new tap(4) interface, registers it for cleanup, and returns the
+# name via the environment variable TAP
+get_tap()
+{
+ local TAPN=0
+ while ! ifconfig tap${TAPN} create > /dev/null 2>&1; do
+ if [ "$TAPN" -ge 8 ]; then
+ atf_skip "Could not create a tap(4) interface"
+ else
+ TAPN=$(($TAPN + 1))
+ fi
+ done
+ local TAPD=tap${TAPN}
+ # Record the TAP device so we can clean it up later
+ echo ${TAPD} >> "tap_devices_to_cleanup"
+ TAP=${TAPD}
+}
+
+cleanup_sysrc()
+{
+ for var in `cat "sysrc_vars_to_cleanup"`; do
+ sysrc -x $var
+ done
+}
+
+cleanup_tap()
+{
+ for TAPD in `cat "tap_devices_to_cleanup"`; do
+ ifconfig ${TAPD} destroy
+ done
+}
diff --git a/tests/freebsd_test_suite/macros.h b/tests/freebsd_test_suite/macros.h
new file mode 100644
index 0000000..8d95f05
--- /dev/null
+++ b/tests/freebsd_test_suite/macros.h
@@ -0,0 +1,56 @@
+/*-
+ * Copyright (c) 2015 EMC / Isilon Storage Division
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _FREEBSD_TEST_MACROS_H_
+#define _FREEBSD_TEST_MACROS_H_
+
+#include <sys/param.h>
+#include <sys/module.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#define ATF_REQUIRE_KERNEL_MODULE(_mod_name) do { \
+ if (modfind(_mod_name) == -1) { \
+ atf_tc_skip("module %s could not be resolved: %s", \
+ _mod_name, strerror(errno)); \
+ } \
+} while(0)
+
+#define PLAIN_REQUIRE_KERNEL_MODULE(_mod_name, _exit_code) do { \
+ if (modfind(_mod_name) == -1) { \
+ printf("module %s could not be resolved: %s\n", \
+ _mod_name, strerror(errno)); \
+ _exit(_exit_code); \
+ } \
+} while(0)
+
+#endif
diff --git a/tests/sys/Makefile b/tests/sys/Makefile
index b54feca..8f37490 100644
--- a/tests/sys/Makefile
+++ b/tests/sys/Makefile
@@ -15,6 +15,7 @@ TESTS_SUBDIRS+= opencrypto
TESTS_SUBDIRS+= posixshm
TESTS_SUBDIRS+= socket
TESTS_SUBDIRS+= vfs
+TESTS_SUBDIRS+= vm
# Items not integrated into kyua runs by default
SUBDIR+= pjdfstest
diff --git a/tests/sys/aio/Makefile b/tests/sys/aio/Makefile
index c6e3f4a..3117462 100644
--- a/tests/sys/aio/Makefile
+++ b/tests/sys/aio/Makefile
@@ -9,6 +9,8 @@ ATF_TESTS_C+= aio_test
DPADD.aio_test+= ${LIBUTIL}
LDADD.aio_test+= -lutil
+CFLAGS+= -I${.CURDIR:H:H}
+
WARNS?= 6
.include <bsd.test.mk>
diff --git a/tests/sys/aio/aio_kqueue_test.c b/tests/sys/aio/aio_kqueue_test.c
index 87b4125..14e4729 100644
--- a/tests/sys/aio/aio_kqueue_test.c
+++ b/tests/sys/aio/aio_kqueue_test.c
@@ -46,25 +46,29 @@
#include <string.h>
#include <unistd.h>
-#define PATH_TEMPLATE "/tmp/aio.XXXXXXXXXX"
+#include "freebsd_test_suite/macros.h"
-#define MAX 128
+#define PATH_TEMPLATE "aio.XXXXXXXXXX"
+
+#define MAX_IOCBS 128
#define MAX_RUNS 300
/* #define DEBUG */
int
main (int argc, char *argv[])
{
- int fd;
- struct aiocb *iocb[MAX], *kq_iocb;
- int i, result, run, error, j;
- char buffer[32768];
- int kq = kqueue();
+ struct aiocb *iocb[MAX_IOCBS], *kq_iocb;
+ char *file, pathname[sizeof(PATH_TEMPLATE)+1];
struct kevent ke, kq_returned;
struct timespec ts;
- int cancel, pending, tmp_file = 0, failed = 0;
- char *file, pathname[sizeof(PATH_TEMPLATE)+1];
+ char buffer[32768];
+ int cancel, error, failed = 0, fd, kq, pending, result, run;
+ int tmp_file = 0;
+ unsigned i, j;
+
+ PLAIN_REQUIRE_KERNEL_MODULE("aio", 0);
+ kq = kqueue();
if (kq < 0) {
perror("No kqeueue\n");
exit(1);
@@ -86,7 +90,7 @@ main (int argc, char *argv[])
#ifdef DEBUG
printf("Run %d\n", run);
#endif
- for (i = 0; i < MAX; i++) {
+ for (i = 0; i < nitems(iocb); i++) {
iocb[i] = (struct aiocb *)calloc(1,
sizeof(struct aiocb));
if (iocb[i] == NULL)
@@ -94,7 +98,7 @@ main (int argc, char *argv[])
}
pending = 0;
- for (i = 0; i < MAX; i++) {
+ for (i = 0; i < nitems(iocb); i++) {
pending++;
iocb[i]->aio_nbytes = sizeof(buffer);
iocb[i]->aio_buf = buffer;
@@ -129,8 +133,8 @@ main (int argc, char *argv[])
}
}
}
- cancel = MAX - pending;
-
+ cancel = nitems(iocb) - pending;
+
i = 0;
while (pending) {
@@ -159,11 +163,11 @@ main (int argc, char *argv[])
break;
#ifdef DEBUG
printf("Try again left %d out of %d %d\n",
- pending, MAX, cancel);
+ pending, nitems(iocb), cancel);
#endif
}
- for (j = 0; j < MAX && iocb[j] != kq_iocb;
+ for (j = 0; j < nitems(iocb) && iocb[j] != kq_iocb;
j++) ;
#ifdef DEBUG
printf("kq_iocb %p\n", kq_iocb);
@@ -190,7 +194,7 @@ main (int argc, char *argv[])
i++;
}
- for (i = 0; i < MAX; i++)
+ for (i = 0; i < nitems(iocb); i++)
free(iocb[i]);
}
diff --git a/tests/sys/aio/aio_test.c b/tests/sys/aio/aio_test.c
index 6975bcb..4134e78 100644
--- a/tests/sys/aio/aio_test.c
+++ b/tests/sys/aio/aio_test.c
@@ -59,6 +59,8 @@
#include <atf-c.h>
+#include "freebsd_test_suite/macros.h"
+
#define PATH_TEMPLATE "aio.XXXXXXXXXX"
/*
@@ -82,15 +84,6 @@ struct aio_context {
static int aio_timedout;
-static void
-aio_available(void)
-{
-
- if (modfind("aio") == -1)
- atf_tc_skip("aio support not available in the kernel; "
- "skipping testcases");
-}
-
/*
* Each test run specifies a timeout in seconds. Use the somewhat obsoleted
* signal(3) and alarm(3) APIs to set this up.
@@ -211,7 +204,7 @@ aio_write_test(struct aio_context *ac)
struct aiocb aio, *aiop;
ssize_t len;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
bzero(&aio, sizeof(aio));
aio.aio_buf = ac->ac_buffer;
@@ -263,7 +256,7 @@ aio_read_test(struct aio_context *ac)
struct aiocb aio, *aiop;
ssize_t len;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
bzero(ac->ac_buffer, ac->ac_buflen);
bzero(&aio, sizeof(aio));
@@ -346,7 +339,7 @@ ATF_TC_BODY(aio_file_test, tc)
struct aio_context ac;
int fd;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
strcpy(pathname, PATH_TEMPLATE);
fd = mkstemp(pathname);
@@ -392,7 +385,7 @@ ATF_TC_BODY(aio_fifo_test, tc)
char pathname[PATH_MAX];
struct aio_context ac;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
/*
* In theory, mkstemp() can return a name that is then collided with.
@@ -461,7 +454,7 @@ ATF_TC_BODY(aio_unix_socketpair_test, tc)
struct aio_context ac;
int sockets[2];
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
ATF_REQUIRE_MSG(socketpair(PF_UNIX, SOCK_STREAM, 0, sockets) != -1,
"socketpair failed: %s", strerror(errno));
@@ -503,7 +496,7 @@ ATF_TC_BODY(aio_pty_test, tc)
struct termios ts;
int error;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
ATF_REQUIRE_MSG(openpty(&read_fd, &write_fd, NULL, NULL, NULL) == 0,
"openpty failed: %s", strerror(errno));
@@ -550,7 +543,7 @@ ATF_TC_BODY(aio_pipe_test, tc)
struct aio_context ac;
int pipes[2];
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
ATF_REQUIRE_MSG(pipe(pipes) != -1,
"pipe failed: %s", strerror(errno));
@@ -613,7 +606,7 @@ ATF_TC_BODY(aio_md_test, tc)
struct aio_context ac;
struct md_ioctl mdio;
- aio_available();
+ ATF_REQUIRE_KERNEL_MODULE("aio");
mdctl_fd = open("/dev/" MDCTL_NAME, O_RDWR, 0);
ATF_REQUIRE_MSG(mdctl_fd != -1,
diff --git a/tests/sys/aio/lio_kqueue_test.c b/tests/sys/aio/lio_kqueue_test.c
index ad7fc68..5cc87b3 100644
--- a/tests/sys/aio/lio_kqueue_test.c
+++ b/tests/sys/aio/lio_kqueue_test.c
@@ -48,16 +48,18 @@
#include <string.h>
#include <unistd.h>
-#define PATH_TEMPLATE "/tmp/aio.XXXXXXXXXX"
+#include "freebsd_test_suite/macros.h"
+
+#define PATH_TEMPLATE "aio.XXXXXXXXXX"
#define LIO_MAX 5
-#define MAX LIO_MAX * 16
+#define MAX_IOCBS LIO_MAX * 16
#define MAX_RUNS 300
int
main(int argc, char *argv[]){
int fd;
- struct aiocb *iocb[MAX];
+ struct aiocb *iocb[MAX_IOCBS];
struct aiocb **lio[LIO_MAX], **lio_element, **kq_lio;
int i, result, run, error, j, k;
char buffer[32768];
@@ -69,6 +71,8 @@ main(int argc, char *argv[]){
char *file, pathname[sizeof(PATH_TEMPLATE)-1];
int tmp_file = 0, failed = 0;
+ PLAIN_REQUIRE_KERNEL_MODULE("aio", 0);
+
if (kq < 0) {
perror("No kqeueue\n");
exit(1);
@@ -99,9 +103,9 @@ main(int argc, char *argv[]){
#endif
for (j = 0; j < LIO_MAX; j++) {
lio[j] = (struct aiocb **)
- malloc(sizeof(struct aiocb *) * MAX/LIO_MAX);
- for(i = 0; i < MAX / LIO_MAX; i++) {
- k = (MAX / LIO_MAX * j) + i;
+ malloc(sizeof(struct aiocb *) * MAX_IOCBS/LIO_MAX);
+ for(i = 0; i < MAX_IOCBS / LIO_MAX; i++) {
+ k = (MAX_IOCBS / LIO_MAX * j) + i;
lio_element = lio[j];
lio[j][i] = iocb[k] = (struct aiocb *)
malloc(sizeof(struct aiocb));
@@ -123,7 +127,7 @@ main(int argc, char *argv[]){
sig.sigev_notify = SIGEV_KEVENT;
time(&time1);
result = lio_listio(LIO_NOWAIT, lio[j],
- MAX / LIO_MAX, &sig);
+ MAX_IOCBS / LIO_MAX, &sig);
error = errno;
time(&time2);
#ifdef DEBUG
@@ -203,7 +207,7 @@ main(int argc, char *argv[]){
} else {
printf("PASS: run %d, operation %d result %d \n", run, LIO_MAX - i -1, result);
}
- for(k = 0; k < MAX / LIO_MAX; k++){
+ for(k = 0; k < MAX_IOCBS / LIO_MAX; k++){
result = aio_return(kq_lio[k]);
#ifdef DEBUG
printf("Return Resulto for %d %d is %d\n", j, k, result);
@@ -220,7 +224,7 @@ main(int argc, char *argv[]){
printf("\n");
#endif
- for(k = 0; k < MAX / LIO_MAX; k++) {
+ for(k = 0; k < MAX_IOCBS / LIO_MAX; k++) {
free(lio[j][k]);
}
free(lio[j]);
diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile
index 3d2127f..bf6aa0d 100644
--- a/tests/sys/kern/Makefile
+++ b/tests/sys/kern/Makefile
@@ -3,7 +3,7 @@
TESTSDIR= ${TESTSBASE}/sys/kern
ATF_TESTS_C+= kern_descrip_test
-TAP_TESTS_C+= mmap_test
+ATF_TESTS_C+= ptrace_test
ATF_TESTS_C+= unix_seqpacket_test
TEST_METADATA.unix_seqpacket_test+= timeout="15"
diff --git a/tests/sys/kern/ptrace_test.c b/tests/sys/kern/ptrace_test.c
new file mode 100644
index 0000000..28b0592
--- /dev/null
+++ b/tests/sys/kern/ptrace_test.c
@@ -0,0 +1,143 @@
+/*-
+ * Copyright (c) 2015 John Baldwin <jhb@FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/ptrace.h>
+#include <sys/wait.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <atf-c.h>
+
+/*
+ * Verify that a parent debugger process "sees" the exit of a debugged
+ * process exactly once when attached via PT_TRACE_ME.
+ */
+ATF_TC_WITHOUT_HEAD(ptrace__parent_wait_after_trace_me);
+ATF_TC_BODY(ptrace__parent_wait_after_trace_me, tc)
+{
+ pid_t child, wpid;
+ int status;
+
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ /* Child process. */
+ ATF_REQUIRE(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+ /* Trigger a stop. */
+ raise(SIGSTOP);
+
+ exit(1);
+ }
+
+ /* Parent process. */
+
+ /* The first wait() should report the stop from SIGSTOP. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == child);
+ ATF_REQUIRE(WIFSTOPPED(status));
+ ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+
+ /* Continue the child ignoring the SIGSTOP. */
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (caddr_t)1, 0) != -1);
+
+ /* The second wait() should report the exit status. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == child);
+ ATF_REQUIRE(WIFEXITED(status));
+ ATF_REQUIRE(WEXITSTATUS(status) == 1);
+
+ /* The child should no longer exist. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == -1);
+ ATF_REQUIRE(errno == ECHILD);
+}
+
+/*
+ * Verify that a parent debugger process "sees" the exit of a debugged
+ * process exactly once when attached via PT_ATTACH.
+ */
+ATF_TC_WITHOUT_HEAD(ptrace__parent_wait_after_attach);
+ATF_TC_BODY(ptrace__parent_wait_after_attach, tc)
+{
+ pid_t child, wpid;
+ int cpipe[2], status;
+ char c;
+
+ ATF_REQUIRE(pipe(cpipe) == 0);
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ /* Child process. */
+ close(cpipe[0]);
+
+ /* Wait for the parent to attach. */
+ ATF_REQUIRE(read(cpipe[1], &c, sizeof(c)) == 0);
+
+ exit(1);
+ }
+ close(cpipe[1]);
+
+ /* Parent process. */
+
+ /* Attach to the child process. */
+ ATF_REQUIRE(ptrace(PT_ATTACH, child, NULL, 0) == 0);
+
+ /* The first wait() should report the SIGSTOP from PT_ATTACH. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == child);
+ ATF_REQUIRE(WIFSTOPPED(status));
+ ATF_REQUIRE(WSTOPSIG(status) == SIGSTOP);
+
+ /* Continue the child ignoring the SIGSTOP. */
+ ATF_REQUIRE(ptrace(PT_CONTINUE, child, (caddr_t)1, 0) != -1);
+
+ /* Signal the child to exit. */
+ close(cpipe[0]);
+
+ /* The second wait() should report the exit status. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == child);
+ ATF_REQUIRE(WIFEXITED(status));
+ ATF_REQUIRE(WEXITSTATUS(status) == 1);
+
+ /* The child should no longer exist. */
+ wpid = waitpid(child, &status, 0);
+ ATF_REQUIRE(wpid == -1);
+ ATF_REQUIRE(errno == ECHILD);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, ptrace__parent_wait_after_trace_me);
+ ATF_TP_ADD_TC(tp, ptrace__parent_wait_after_attach);
+
+ return (atf_no_error());
+}
diff --git a/tests/sys/mqueue/Makefile b/tests/sys/mqueue/Makefile
index 230fcb7..5af8b25 100644
--- a/tests/sys/mqueue/Makefile
+++ b/tests/sys/mqueue/Makefile
@@ -6,6 +6,8 @@ ATF_TESTS_SH= mqueue_test
BINDIR= ${TESTSDIR}
+CFLAGS+= -I${.CURDIR:H:H}
+
PROGS+= mqtest1
PROGS+= mqtest2
PROGS+= mqtest3
diff --git a/tests/sys/mqueue/mqtest1.c b/tests/sys/mqueue/mqtest1.c
index 5590b87..3accb28 100644
--- a/tests/sys/mqueue/mqtest1.c
+++ b/tests/sys/mqueue/mqtest1.c
@@ -7,6 +7,8 @@
#include <signal.h>
#include <stdio.h>
+#include "freebsd_test_suite/macros.h"
+
#define MQNAME "/mytstqueue1"
int
@@ -17,6 +19,8 @@ main(void)
mqd_t mq;
int status;
+ PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0);
+
attr.mq_maxmsg = 2;
attr.mq_msgsize = 100;
mq = mq_open(MQNAME, O_CREAT | O_RDWR | O_EXCL, 0666, &attr);
diff --git a/tests/sys/mqueue/mqtest2.c b/tests/sys/mqueue/mqtest2.c
index aaef43b..067e619 100644
--- a/tests/sys/mqueue/mqtest2.c
+++ b/tests/sys/mqueue/mqtest2.c
@@ -10,6 +10,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include "freebsd_test_suite/macros.h"
+
#define MQNAME "/mytstqueue2"
#define LOOPS 1000
#define PRIO 10
@@ -29,6 +31,8 @@ main(void)
int status;
pid_t pid;
+ PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0);
+
mq_unlink(MQNAME);
attr.mq_maxmsg = 5;
diff --git a/tests/sys/mqueue/mqtest3.c b/tests/sys/mqueue/mqtest3.c
index 4ee812c..c4b849e 100644
--- a/tests/sys/mqueue/mqtest3.c
+++ b/tests/sys/mqueue/mqtest3.c
@@ -11,6 +11,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include "freebsd_test_suite/macros.h"
+
#define MQNAME "/mytstqueue3"
#define LOOPS 1000
#define PRIO 10
@@ -31,6 +33,8 @@ main(void)
mqd_t mq;
pid_t pid;
+ PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0);
+
mq_unlink(MQNAME);
attr.mq_maxmsg = 5;
diff --git a/tests/sys/mqueue/mqtest4.c b/tests/sys/mqueue/mqtest4.c
index d249cf6..474d212 100644
--- a/tests/sys/mqueue/mqtest4.c
+++ b/tests/sys/mqueue/mqtest4.c
@@ -12,6 +12,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include "freebsd_test_suite/macros.h"
+
#define MQNAME "/mytstqueue4"
#define LOOPS 1000
#define PRIO 10
@@ -32,6 +34,8 @@ main(void)
int kq, status;
pid_t pid;
+ PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0);
+
mq_unlink(MQNAME);
attr.mq_maxmsg = 5;
diff --git a/tests/sys/mqueue/mqtest5.c b/tests/sys/mqueue/mqtest5.c
index 7f4d554..0c8aa89 100644
--- a/tests/sys/mqueue/mqtest5.c
+++ b/tests/sys/mqueue/mqtest5.c
@@ -12,6 +12,8 @@
#include <stdlib.h>
#include <unistd.h>
+#include "freebsd_test_suite/macros.h"
+
#define MQNAME "/mytstqueue5"
#define LOOPS 1000
#define PRIO 10
@@ -34,6 +36,8 @@ main(void)
mqd_t mq;
pid_t pid;
+ PLAIN_REQUIRE_KERNEL_MODULE("mqueuefs", 0);
+
mq_unlink(MQNAME);
sigemptyset(&set);
diff --git a/tests/sys/mqueue/mqueue_test.sh b/tests/sys/mqueue/mqueue_test.sh
index dd2469e..4841418 100755
--- a/tests/sys/mqueue/mqueue_test.sh
+++ b/tests/sys/mqueue/mqueue_test.sh
@@ -1,3 +1,30 @@
+#
+# Copyright (c) 2015 EMC / Isilon Storage Division
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
mqtest1_head()
{
diff --git a/tests/sys/vm/Makefile b/tests/sys/vm/Makefile
new file mode 100644
index 0000000..1795eef
--- /dev/null
+++ b/tests/sys/vm/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+TESTSDIR= ${TESTSBASE}/sys/vm
+
+TAP_TESTS_C+= mmap_test
+
+.include <bsd.test.mk>
diff --git a/tests/sys/kern/mmap_test.c b/tests/sys/vm/mmap_test.c
index 7591a09..7591a09 100644
--- a/tests/sys/kern/mmap_test.c
+++ b/tests/sys/vm/mmap_test.c
OpenPOWER on IntegriCloud