summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/libc
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2017-02-23 06:37:07 -0300
committerRenato Botelho <renato@netgate.com>2017-02-23 06:37:07 -0300
commit4ef888db25896b2295f521c736ef04aa2e5e64ec (patch)
tree3fcc00dda536bd32ae85bc09f21be4081d32bad5 /contrib/netbsd-tests/lib/libc
parent272ffd7c3e4e5e27910eb918e2e36556f2a8ec3a (diff)
parentaf015c5bcac0e333adeec07eff0698bad3b91e95 (diff)
downloadFreeBSD-src-4ef888db25896b2295f521c736ef04aa2e5e64ec.zip
FreeBSD-src-4ef888db25896b2295f521c736ef04aa2e5e64ec.tar.gz
Merge remote-tracking branch 'origin/stable/11' into devel-11
Diffstat (limited to 'contrib/netbsd-tests/lib/libc')
-rw-r--r--contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c7
-rw-r--r--contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S11
-rw-r--r--contrib/netbsd-tests/lib/libc/db/h_db.c77
-rwxr-xr-xcontrib/netbsd-tests/lib/libc/db/t_db.sh313
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_dir.c36
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c5
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c5
-rw-r--r--contrib/netbsd-tests/lib/libc/rpc/t_rpc.c24
-rw-r--r--contrib/netbsd-tests/lib/libc/string/t_memcpy.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/string/t_memmem.c2
-rw-r--r--contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc16
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c63
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_getrusage.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c345
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c30
15 files changed, 875 insertions, 69 deletions
diff --git a/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c b/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c
index 474cfc7..8ca38b4 100644
--- a/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c
+++ b/contrib/netbsd-tests/lib/libc/arch/sparc64/exec_prot_support.c
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_prot_support.c,v 1.1 2011/07/18 23:16:10 jym Exp $ */
+/* $NetBSD: exec_prot_support.c,v 1.2 2016/12/31 11:51:20 martin Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,12 +30,13 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: exec_prot_support.c,v 1.1 2011/07/18 23:16:10 jym Exp $");
+__RCSID("$NetBSD: exec_prot_support.c,v 1.2 2016/12/31 11:51:20 martin Exp $");
#include "../../common/exec_prot.h"
int
exec_prot_support(void)
{
- return NOTIMPL;
+
+ return PERPAGE_XP;
}
diff --git a/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S b/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S
index 3495260..ec8bcdd 100644
--- a/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S
+++ b/contrib/netbsd-tests/lib/libc/arch/sparc64/return_one.S
@@ -1,8 +1,11 @@
-/* $NetBSD: return_one.S,v 1.1 2011/07/18 23:16:10 jym Exp $ */
+/* $NetBSD: return_one.S,v 1.2 2016/12/31 11:51:20 martin Exp $ */
#include <machine/asm.h>
-.globl return_one, return_one_end;
+.global return_one_end
-return_one: return_one_end:
- nop
+ENTRY(return_one)
+return_one:
+ retl
+ mov 1, %o0
+return_one_end:
diff --git a/contrib/netbsd-tests/lib/libc/db/h_db.c b/contrib/netbsd-tests/lib/libc/db/h_db.c
index dfb1385..dd19a03 100644
--- a/contrib/netbsd-tests/lib/libc/db/h_db.c
+++ b/contrib/netbsd-tests/lib/libc/db/h_db.c
@@ -1,4 +1,4 @@
-/* $NetBSD: h_db.c,v 1.1 2011/01/07 15:05:58 pgoyette Exp $ */
+/* $NetBSD: h_db.c,v 1.3 2016/09/24 21:18:22 christos Exp $ */
/*-
* Copyright (c) 1992, 1993, 1994
@@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\
#if 0
static char sccsid[] = "@(#)dbtest.c 8.17 (Berkeley) 9/1/94";
#else
-__RCSID("$NetBSD: h_db.c,v 1.1 2011/01/07 15:05:58 pgoyette Exp $");
+__RCSID("$NetBSD: h_db.c,v 1.3 2016/09/24 21:18:22 christos Exp $");
#endif
#endif /* not lint */
@@ -57,12 +57,13 @@ __RCSID("$NetBSD: h_db.c,v 1.1 2011/01/07 15:05:58 pgoyette Exp $");
#include <unistd.h>
#include <err.h>
#include <db.h>
+#include "btree.h"
enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA };
static void compare(DBT *, DBT *);
static DBTYPE dbtype(const char *);
-static void dump(DB *, int);
+static void dump(DB *, int, int);
static void get(DB *, DBT *);
static void getdata(DB *, DBT *, DBT *);
static void put(DB *, DBT *, DBT *);
@@ -73,6 +74,9 @@ static void *rfile(char *, size_t *);
static void seq(DB *, DBT *);
static u_int setflags(char *);
static void *setinfo(DBTYPE, char *);
+#ifdef __NetBSD__
+static void unlinkpg(DB *);
+#endif
static void usage(void) __attribute__((__noreturn__));
static void *xcopy(void *, size_t);
static void chkcmd(enum S);
@@ -82,6 +86,9 @@ static void chkkey(enum S);
#ifdef STATISTICS
extern void __bt_stat(DB *);
#endif
+#ifdef __NetBSD__
+extern int __bt_relink(BTREE *, PAGE *);
+#endif
static DBTYPE type; /* Database type. */
static void *infop; /* Iflags. */
@@ -315,8 +322,16 @@ lkey: switch (command) {
}
break;
case 'o':
- dump(dbp, p[1] == 'r');
+ dump(dbp, p[1] == 'r', 0);
+ break;
+#ifdef __NetBSD__
+ case 'O':
+ dump(dbp, p[1] == 'r', 1);
break;
+ case 'u':
+ unlinkpg(dbp);
+ break;
+#endif
default:
errx(1, "line %zu: %s: unknown command character",
lineno, p);
@@ -483,17 +498,25 @@ seq(DB *dbp, DBT *kp)
}
static void
-dump(DB *dbp, int rev)
+dump(DB *dbp, int rev, int recurse)
{
DBT key, data;
int xflags, nflags;
if (rev) {
xflags = R_LAST;
+#ifdef __NetBSD__
+ nflags = recurse ? R_RPREV : R_PREV;
+#else
nflags = R_PREV;
+#endif
} else {
xflags = R_FIRST;
+#ifdef __NetBSD__
+ nflags = recurse ? R_RNEXT : R_NEXT;
+#else
nflags = R_NEXT;
+#endif
}
for (;; xflags = nflags)
switch (dbp->seq(dbp, &key, &data, xflags)) {
@@ -511,6 +534,42 @@ dump(DB *dbp, int rev)
done: return;
}
+#ifdef __NetBSD__
+void
+unlinkpg(DB *dbp)
+{
+ BTREE *t = dbp->internal;
+ PAGE *h = NULL;
+ pgno_t pg;
+
+ for (pg = P_ROOT; pg < t->bt_mp->npages;
+ mpool_put(t->bt_mp, h, 0), pg++) {
+ if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
+ break;
+ /* Look for a nonempty leaf page that has both left
+ * and right siblings. */
+ if (h->prevpg == P_INVALID || h->nextpg == P_INVALID)
+ continue;
+ if (NEXTINDEX(h) == 0)
+ continue;
+ if ((h->flags & (P_BLEAF | P_RLEAF)))
+ break;
+ }
+ if (h == NULL || pg == t->bt_mp->npages) {
+ errx(1, "%s: no appropriate page found", __func__);
+ return;
+ }
+ if (__bt_relink(t, h) != 0) {
+ perror("unlinkpg");
+ goto cleanup;
+ }
+ h->prevpg = P_INVALID;
+ h->nextpg = P_INVALID;
+cleanup:
+ mpool_put(t->bt_mp, h, MPOOL_DIRTY);
+}
+#endif
+
static u_int
setflags(char *s)
{
@@ -725,7 +784,11 @@ static void
usage(void)
{
(void)fprintf(stderr,
- "Usage: %s [-l] [-f file] [-i info] [-o file] type script\n",
- getprogname());
+#ifdef __NetBSD__
+ "Usage: %s [-lu] [-f file] [-i info] [-o file] [-O file] "
+#else
+ "Usage: %s [-l] [-f file] [-i info] [-o file] "
+#endif
+ "type script\n", getprogname());
exit(1);
}
diff --git a/contrib/netbsd-tests/lib/libc/db/t_db.sh b/contrib/netbsd-tests/lib/libc/db/t_db.sh
index eb6b8c9..6858e36 100755
--- a/contrib/netbsd-tests/lib/libc/db/t_db.sh
+++ b/contrib/netbsd-tests/lib/libc/db/t_db.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_db.sh,v 1.6 2015/11/18 18:35:35 christos Exp $
+# $NetBSD: t_db.sh,v 1.7 2016/09/24 20:12:33 christos Exp $
#
# Copyright (c) 2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -563,6 +563,7 @@ delete_recno_body()
h_repeated()
{
+ local type="$1"
TMPDIR="$(pwd)/db_dir"; export TMPDIR
mkdir ${TMPDIR}
@@ -581,7 +582,7 @@ h_repeated()
}
}' >in
- $(prog_db) btree in
+ $(prog_db) $type in
}
atf_test_case repeated_btree
@@ -641,11 +642,10 @@ duplicate_btree_body()
h_cursor_flags()
{
+ local type=$1
TMPDIR="$(pwd)/db_dir"; export TMPDIR
mkdir ${TMPDIR}
- type=$1
-
echo $SEVEN_SEVEN |
awk '{
for (i = 1; i <= 20; ++i)
@@ -784,6 +784,7 @@ h_byte_orders()
echo p
echo k$i
echo d$i
+ echo S
echo g
echo k$i
done >in
@@ -974,6 +975,298 @@ bsize_torture_body()
done
}
+atf_test_case btree_weird_page_split
+btree_weird_page_split_head()
+{
+ atf_set "descr" \
+ "Test for a weird page split condition where an insertion " \
+ "into index 0 of a page that would cause the new item to " \
+ "be the only item on the left page results in index 0 of " \
+ "the right page being erroneously skipped; this only " \
+ "happens with one particular key+data length for each page size."
+}
+btree_weird_page_split_body()
+{
+ for psize in 512 1024 2048 4096 8192; do
+ echo " page size $psize"
+ kdsizes=`awk 'BEGIN {
+ psize = '$psize'; hsize = int(psize/2);
+ for (kdsize = hsize-40; kdsize <= hsize; kdsize++) {
+ print kdsize;
+ }
+ }' /dev/null`
+
+ # Use a series of keylen+datalen values in the right
+ # neighborhood to find the one that triggers the bug.
+ # We could compute the exact size that triggers the
+ # bug but this additional fuzz may be useful.
+
+ # Insert keys in reverse order to maximize the chances
+ # for a split on index 0.
+
+ for kdsize in $kdsizes; do
+ awk 'BEGIN {
+ kdsize = '$kdsize';
+ for (i = 8; i-- > 0; ) {
+ s = sprintf("a%03d:%09d", i, kdsize);
+ for (j = 0; j < kdsize-20; j++) {
+ s = s "x";
+ }
+ printf("p\nka%03d\nd%s\n", i, s);
+ }
+ print "o";
+ }' /dev/null > in
+ sed -n 's/^d//p' in | sort > exp
+ atf_check -o file:exp \
+ "$(prog_db)" -i psize=$psize btree in
+ done
+ done
+}
+
+# Extremely tricky test attempting to replicate some unusual database
+# corruption seen in the field: pieces of the database becoming
+# inaccessible to random access, sequential access, or both. The
+# hypothesis is that at least some of these are triggered by the bug
+# in page splits on index 0 with a particular exact keylen+datalen.
+# (See Test 40.) For psize=4096, this size is exactly 2024.
+
+# The order of operations here relies on very specific knowledge of
+# the internals of the btree access method in order to place records
+# at specific offsets in a page and to create certain keys on internal
+# pages. The to-be-split page immediately prior to the bug-triggering
+# split has the following properties:
+#
+# * is not the leftmost leaf page
+# * key on the parent page is compares less than the key of the item
+# on index 0
+# * triggering record's key also compares greater than the key on the
+# parent page
+
+# Additionally, we prime the mpool LRU chain so that the head page on
+# the chain has the following properties:
+#
+# * record at index 0 is located where it will not get overwritten by
+# items written to the right-hand page during the split
+# * key of the record at index 0 compares less than the key of the
+# bug-triggering record
+
+# If the page-split bug exists, this test appears to create a database
+# where some records are inaccessible to a search, but still remain in
+# the file and are accessible by sequential traversal. At least one
+# record gets duplicated out of sequence.
+
+atf_test_case btree_tricky_page_split
+btree_tricky_page_split_head()
+{
+ atf_set "descr" \
+ "btree: no unsearchables due to page split on index 0"
+}
+btree_tricky_page_split_body()
+{
+ list=`(for i in a b c d; do
+ for j in 990 998 999; do
+ echo g ${i}${j} 1024
+ done
+ done;
+ echo g y997 2014
+ for i in y z; do
+ for j in 998 999; do
+ echo g ${i}${j} 1024
+ done
+ done)`
+ # Exact number for trigger condition accounts for newlines
+ # retained by dbtest with -ofile but not without; we use
+ # -ofile, so count newlines. keylen=5,datalen=5+2014 for
+ # psize=4096 here.
+ (cat - <<EOF
+p z999 1024
+p z998 1024
+p y999 1024
+p y990 1024
+p d999 1024
+p d990 1024
+p c999 1024
+p c990 1024
+p b999 1024
+p b990 1024
+p a999 1024
+p a990 1024
+p y998 1024
+r y990
+p d998 1024
+p d990 1024
+p c998 1024
+p c990 1024
+p b998 1024
+p b990 1024
+p a998 1024
+p a990 1024
+p y997 2014
+S
+o
+EOF
+ echo "$list") |
+ # awk script input:
+ # {p|g|r} key [datasize]
+ awk '/^[pgr]/{
+ printf("%s\nk%s\n", $1, $2);
+ }
+ /^p/{
+ s = $2;
+ for (i = 0; i < $3; i++) {
+ s = s "x";
+ }
+ printf("d%s\n", s);
+ }
+ !/^[pgr]/{
+ print $0;
+ }' > in
+ (echo "$list"; echo "$list") | awk '{
+ s = $2;
+ for (i = 0; i < $3; i++) {
+ s = s "x";
+ }
+ print s;
+ }' > exp
+ atf_check -o file:exp \
+ "$(prog_db)" -i psize=4096 btree in
+}
+
+# Begin FreeBSD
+if false; then
+# End FreeBSD
+atf_test_case btree_recursive_traversal
+btree_recursive_traversal_head()
+{
+ atf_set "descr" \
+ "btree: Test for recursive traversal successfully " \
+ "retrieving records that are inaccessible to normal " \
+ "sequential 'sibling-link' traversal. This works by " \
+ "unlinking a few leaf pages but leaving their parent " \
+ "links intact. To verify that the unlink actually makes " \
+ "records inaccessible, the test first uses 'o' to do a " \
+ "normal sequential traversal, followed by 'O' to do a " \
+ "recursive traversal."
+}
+btree_recursive_traversal_body()
+{
+ fill="abcdefghijklmnopqrstuvwxyzy"
+ script='{
+ for (i = 0; i < 20000; i++) {
+ printf("p\nkAA%05d\nd%05d%s\n", i, i, $0);
+ }
+ print "u";
+ print "u";
+ print "u";
+ print "u";
+ }'
+ (echo $fill | awk "$script"; echo o) > in1
+ echo $fill |
+ awk '{
+ for (i = 0; i < 20000; i++) {
+ if (i >= 5 && i <= 40)
+ continue;
+ printf("%05d%s\n", i, $0);
+ }
+ }' > exp1
+ atf_check -o file:exp1 \
+ "$(prog_db)" -i psize=512 btree in1
+ echo $fill |
+ awk '{
+ for (i = 0; i < 20000; i++) {
+ printf("%05d%s\n", i, $0);
+ }
+ }' > exp2
+ (echo $fill | awk "$script"; echo O) > in2
+ atf_check -o file:exp2 \
+ "$(prog_db)" -i psize=512 btree in2
+}
+# Begin FreeBSD
+fi
+# End FreeBSD
+
+atf_test_case btree_byteswap_unaligned_access_bksd
+btree_byteswap_unaligned_access_bksd_head()
+{
+ atf_set "descr" \
+ "btree: big key, small data, byteswap unaligned access"
+}
+btree_byteswap_unaligned_access_bksd_body()
+{
+ (echo foo; echo bar) |
+ awk '{
+ s = $0
+ for (i = 0; i < 488; i++) {
+ s = s "x";
+ }
+ printf("p\nk%s\ndx\n", s);
+ }' > in
+ for order in 1234 4321; do
+ atf_check \
+ "$(prog_db)" -o out -i psize=512,lorder=$order btree in
+ done
+}
+
+atf_test_case btree_byteswap_unaligned_access_skbd
+btree_byteswap_unaligned_access_skbd_head()
+{
+ atf_set "descr" \
+ "btree: small key, big data, byteswap unaligned access"
+}
+btree_byteswap_unaligned_access_skbd_body()
+{
+ # 484 = 512 - 20 (header) - 7 ("foo1234") - 1 (newline)
+ (echo foo1234; echo bar1234) |
+ awk '{
+ s = $0
+ for (i = 0; i < 484; i++) {
+ s = s "x";
+ }
+ printf("p\nk%s\nd%s\n", $0, s);
+ }' > in
+ for order in 1234 4321; do
+ atf_check \
+ "$(prog_db)" -o out -i psize=512,lorder=$order btree in
+ done
+}
+
+atf_test_case btree_known_byte_order
+btree_known_byte_order_head()
+{
+ atf_set "descr" \
+ "btree: small key, big data, known byte order"
+}
+btree_known_byte_order_body()
+{
+ local a="-i psize=512,lorder="
+
+ (echo foo1234; echo bar1234) |
+ awk '{
+ s = $0
+ for (i = 0; i < 484; i++) {
+ s = s "x";
+ }
+ printf("%s\n", s);
+ }' > exp
+ (echo foo1234; echo bar1234) |
+ awk '{
+ s = $0
+ for (i = 0; i < 484; i++) {
+ s = s "x";
+ }
+ printf("p\nk%s\nd%s\n", $0, s);
+ }' > in1
+ for order in 1234 4321; do
+ atf_check \
+ "$(prog_db)" -f out.$order $a$order btree in1
+ done
+ (echo g; echo kfoo1234; echo g; echo kbar1234) > in2
+ for order in 1234 4321; do
+ atf_check -o file:exp \
+ "$(prog_db)" -s -f out.$order $a$order btree in2
+ done
+}
+
atf_init_test_cases()
{
atf_add_test_case small_btree
@@ -1002,4 +1295,16 @@ atf_init_test_cases()
atf_add_test_case bsize_ffactor
atf_add_test_case four_char_hash
atf_add_test_case bsize_torture
+ atf_add_test_case btree_weird_page_split
+ atf_add_test_case btree_tricky_page_split
+ # Begin FreeBSD
+ if false; then
+ # End FreeBSD
+ atf_add_test_case btree_recursive_traversal
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
+ atf_add_test_case btree_byteswap_unaligned_access_bksd
+ atf_add_test_case btree_byteswap_unaligned_access_skbd
+ atf_add_test_case btree_known_byte_order
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_dir.c b/contrib/netbsd-tests/lib/libc/gen/t_dir.c
index c058738..362692f 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_dir.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_dir.c,v 1.8 2017/01/11 07:26:17 christos Exp $ */
+/* $NetBSD: t_dir.c,v 1.10 2017/01/11 18:15:02 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -75,33 +75,40 @@ ATF_TC_BODY(seekdir_basic, tc)
/* skip two for . and .. */
entry = readdir(dp);
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ ".", strerror(errno));
+
entry = readdir(dp);
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "..", strerror(errno));
/* get first entry */
entry = readdir(dp);
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "first", strerror(errno));
+
here = telldir(dp);
- ATF_REQUIRE_MSG(here != -1,
- "telldir failed: %s", strerror(errno));
+ ATF_REQUIRE_MSG(here != -1, "telldir failed: %s", strerror(errno));
/* get second entry */
entry = readdir(dp);
-#ifdef __FreeBSD__
- ATF_REQUIRE_MSG(entry != NULL,
- "readdir failed: %s", strerror(errno));
-#endif
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "second", strerror(errno));
+
wasname = strdup(entry->d_name);
if (wasname == NULL)
atf_tc_fail("cannot allocate memory");
/* get third entry */
entry = readdir(dp);
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "third", strerror(errno));
/* try to return to the position after the first entry */
seekdir(dp, here);
entry = readdir(dp);
-
- if (entry == NULL)
- atf_tc_fail("entry 1 not found");
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "first[1]", strerror(errno));
if (strcmp(entry->d_name, wasname) != 0)
atf_tc_fail("1st seekdir found wrong name");
@@ -109,18 +116,17 @@ ATF_TC_BODY(seekdir_basic, tc)
seekdir(dp, here);
here = telldir(dp);
entry = readdir(dp);
-
- if (entry == NULL)
- atf_tc_fail("entry 2 not found");
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "second[1]", strerror(errno));
if (strcmp(entry->d_name, wasname) != 0)
atf_tc_fail("2nd seekdir found wrong name");
/* One more time, to make sure that telldir() doesn't affect result */
seekdir(dp, here);
entry = readdir(dp);
+ ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+ "third[1]", strerror(errno));
- if (entry == NULL)
- atf_tc_fail("entry 3 not found");
if (strcmp(entry->d_name, wasname) != 0)
atf_tc_fail("3rd seekdir found wrong name");
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c b/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c
index ef372f7..c3417bb 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c
@@ -119,6 +119,11 @@ ATF_TC_BODY(floatunditf, tc)
#else
size_t i;
+#if defined(__FreeBSD__) && defined(__i386__)
+ atf_tc_expect_fail("the floating point error on FreeBSD/i386 doesn't "
+ "match the expected floating point error on NetBSD");
+#endif
+
for (i = 0; i < __arraycount(testcases); ++i)
ATF_CHECK_MSG(
testcases[i].ld == (long double)testcases[i].u64,
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c b/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c
index c0064c3..69ee8d2 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos Exp $ */
+/* $NetBSD: t_fnmatch.c,v 1.7 2016/10/31 05:08:53 dholland Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos Exp $");
+__RCSID("$NetBSD: t_fnmatch.c,v 1.7 2016/10/31 05:08:53 dholland Exp $");
#include <atf-c.h>
#include <fnmatch.h>
@@ -166,6 +166,7 @@ ATF_TC_BODY(fnmatch_initialbracket, tc)
ATF_CHECK(fnmatch("[!]a-]", "b", 0) == 0);
ATF_CHECK(fnmatch("[]-_]", "^", 0) == 0); /* range: ']', '^', '_' */
ATF_CHECK(fnmatch("[!]-_]", "X", 0) == 0);
+ ATF_CHECK(fnmatch("[A-\\\\]", "[", 0) == 0);
ATF_CHECK(fnmatch("[a-z]/[a-z]", "a/b", 0) == 0);
ATF_CHECK(fnmatch("[*]/b", "*/b", 0) == 0);
ATF_CHECK(fnmatch("[?]/b", "?/b", 0) == 0);
diff --git a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
index 28a8763..bce3633 100644
--- a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
+++ b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
@@ -1,7 +1,7 @@
-/* $NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $ */
+/* $NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos Exp $ */
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $");
+__RCSID("$NetBSD: t_rpc.c,v 1.10 2016/08/27 14:36:22 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
@@ -21,7 +21,7 @@ __RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $");
#define SKIPX(ev, msg, ...) do { \
atf_tc_skip(msg, __VA_ARGS__); \
- return; \
+ return ev; \
} while(/*CONSTCOND*/0)
#ifdef __FreeBSD__
@@ -32,8 +32,8 @@ __RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $");
#endif
#else
-#define ERRX(ev, msg, ...) errx(ev, msg, __VA_ARGS__)
-#define SKIPX(ev, msg, ...) errx(ev, msg, __VA_ARGS__)
+#define ERRX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__)
+#define SKIPX(ev, msg, ...) errx(EXIT_FAILURE, msg, __VA_ARGS__)
#endif
#ifdef DEBUG
@@ -83,7 +83,7 @@ onehost(const char *host, const char *transp)
__rpc_control(CLCR_SET_RPCB_TIMEOUT, &tv);
if ((clnt = clnt_create(host, RPCBPROG, RPCBVERS, transp)) == NULL)
- SKIPX(EXIT_FAILURE, "clnt_create (%s)", clnt_spcreateerror(""));
+ SKIPX(, "clnt_create (%s)", clnt_spcreateerror(""));
tv.tv_sec = 1;
tv.tv_usec = 0;
@@ -95,7 +95,7 @@ onehost(const char *host, const char *transp)
if (clnt_call(clnt, RPCBPROC_NULL, xdr_void, NULL, xdr_void, NULL, tv)
!= RPC_SUCCESS)
#endif
- ERRX(EXIT_FAILURE, "clnt_call (%s)", clnt_sperror(clnt, ""));
+ ERRX(, "clnt_call (%s)", clnt_sperror(clnt, ""));
clnt_control(clnt, CLGET_SVC_ADDR, (char *) &addr);
reply(NULL, &addr, NULL);
}
@@ -117,13 +117,13 @@ server(struct svc_req *rqstp, SVCXPRT *transp)
switch (rqstp->rq_proc) {
case NULLPROC:
if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL))
- ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0);
+ ERRX(, "svc_sendreply failed %d", 0);
return;
case PLUSONE:
break;
case DESTROY:
if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL))
- ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 0);
+ ERRX(, "svc_sendreply failed %d", 0);
svc_destroy(transp);
exit(0);
default:
@@ -138,7 +138,7 @@ server(struct svc_req *rqstp, SVCXPRT *transp)
DPRINTF("About to increment\n");
num++;
if (!svc_sendreply(transp, (xdrproc_t)xdr_int, (void *)&num))
- ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 1);
+ ERRX(, "svc_sendreply failed %d", 1);
DPRINTF("Leaving server procedure.\n");
}
@@ -195,13 +195,9 @@ regtest(const char *hostname, const char *transp, const char *arg, int p)
svc_fdset_init(p ? SVC_FDSET_POLL : 0);
#endif
if (!svc_create(server, PROGNUM, VERSNUM, transp))
-#ifdef __NetBSD__
- ERRX(EXIT_FAILURE, "Cannot create server %d", num);
-#else
{
SKIPXI(EXIT_FAILURE, "Cannot create server %d", num);
}
-#endif
switch ((pid = fork())) {
case 0:
diff --git a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
index 5bbd924..64cdb29 100644
--- a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
+++ b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_memcpy.c,v 1.5 2013/03/17 02:23:31 christos Exp $ */
+/* $NetBSD: t_memcpy.c,v 1.6 2017/01/11 18:05:54 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -108,12 +108,8 @@ ATF_TC_BODY(memcpy_basic, tc)
if (i != j)
runTest(start[i], start[j]);
MD5End(mc, result);
-#ifdef __NetBSD__
- ATF_REQUIRE_EQ(strcmp(result, goodResult), 0);
-#else
ATF_REQUIRE_EQ_MSG(strcmp(result, goodResult), 0, "%s != %s",
result, goodResult);
-#endif
}
ATF_TC(memccpy_simple);
diff --git a/contrib/netbsd-tests/lib/libc/string/t_memmem.c b/contrib/netbsd-tests/lib/libc/string/t_memmem.c
index 5807662..2f37788 100644
--- a/contrib/netbsd-tests/lib/libc/string/t_memmem.c
+++ b/contrib/netbsd-tests/lib/libc/string/t_memmem.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_memmem.c,v 1.2 2011/07/07 08:27:36 jruoho Exp $ */
+/* $NetBSD: t_memmem.c,v 1.3 2017/01/11 18:07:37 christos Exp $ */
/*-
* Copyright (c) 2005 The NetBSD Foundation, Inc.
diff --git a/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc b/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc
index 7426851..e7822b7 100644
--- a/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc
+++ b/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc
@@ -1,4 +1,4 @@
-/* $NetBSD: cpp_atomic_ops_linkable.cc,v 1.4 2016/02/27 18:50:39 joerg Exp $ */
+/* $NetBSD: cpp_atomic_ops_linkable.cc,v 1.5 2017/01/11 12:10:26 joerg Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -58,19 +58,13 @@ private:
volatile std::atomic<T> m_val;
};
-#if defined(__clang__) && defined(__sparc64__)
-#define NO_SHORT_ATOMICS
-#endif
-
int main(int argc, char **argv)
{
-#ifndef NO_SHORT_ATOMICS
ATest<char>();
ATest<signed char>();
ATest<unsigned char>();
ATest<short>();
ATest<unsigned short>();
-#endif
ATest<int>();
ATest<unsigned int>();
ATest<long>();
@@ -79,29 +73,23 @@ int main(int argc, char **argv)
ATest<long long>();
ATest<unsigned long long>();
#endif
-#ifndef NO_SHORT_ATOMICS
ATest<char16_t>();
-#endif
ATest<char32_t>();
ATest<wchar_t>();
-#ifndef NO_SHORT_ATOMICS
ATest<int_least8_t>();
ATest<uint_least8_t>();
ATest<int_least16_t>();
ATest<uint_least16_t>();
-#endif
ATest<int_least32_t>();
ATest<uint_least32_t>();
#ifdef __HAVE_ATOMIC64_OPS
ATest<int_least64_t>();
ATest<uint_least64_t>();
#endif
-#ifndef NO_SHORT_ATOMICS
ATest<int_fast8_t>();
ATest<uint_fast8_t>();
ATest<int_fast16_t>();
ATest<uint_fast16_t>();
-#endif
ATest<int_fast32_t>();
ATest<uint_fast32_t>();
#ifdef __HAVE_ATOMIC64_OPS
@@ -115,5 +103,5 @@ int main(int argc, char **argv)
#ifdef __HAVE_ATOMIC64_OPS
ATest<intmax_t>();
ATest<uintmax_t>();
-#endif /* NO_SHORT_ATOMICS */
+#endif
}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c b/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c
new file mode 100644
index 0000000..8c1fd03
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c
@@ -0,0 +1,63 @@
+/* $NetBSD: t_clock_nanosleep.c,v 1.1 2016/11/11 15:30:44 njoly Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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>
+__RCSID("$NetBSD: t_clock_nanosleep.c,v 1.1 2016/11/11 15:30:44 njoly Exp $");
+
+#include <atf-c.h>
+#include <time.h>
+
+ATF_TC(clock_nanosleep_remain);
+ATF_TC_HEAD(clock_nanosleep_remain, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Check clock_nanosleep(2) remaining time");
+}
+
+ATF_TC_BODY(clock_nanosleep_remain, tc)
+{
+ struct timespec rqtp, rmtp;
+
+ rqtp.tv_sec = 0; rqtp.tv_nsec = 0;
+ rmtp.tv_sec = -1; rmtp.tv_nsec = -1;
+ ATF_REQUIRE(clock_nanosleep(CLOCK_REALTIME, 0, &rqtp, &rmtp) == 0);
+ ATF_CHECK(rmtp.tv_sec == 0 && rmtp.tv_nsec == 0);
+
+ ATF_REQUIRE(clock_gettime(CLOCK_REALTIME, &rqtp) == 0);
+ rmtp.tv_sec = -1; rmtp.tv_nsec = -1;
+ ATF_REQUIRE(clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &rqtp, &rmtp) == 0);
+ ATF_CHECK(rmtp.tv_sec == -1 && rmtp.tv_nsec == -1);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, clock_nanosleep_remain);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c b/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c
index aa5c4d5..f4ee96b 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c
@@ -56,6 +56,10 @@ sighandler(int signo)
/* Nothing. */
}
+#ifdef __FreeBSD__
+#define asm __asm
+#endif
+
static void
work(void)
{
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c
new file mode 100644
index 0000000..e5ddcbd
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c
@@ -0,0 +1,345 @@
+/* $NetBSD: t_wait_noproc.c,v 1.5 2016/11/09 17:50:19 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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>
+__RCSID("$NetBSD: t_wait_noproc.c,v 1.5 2016/11/09 17:50:19 kamil Exp $");
+
+#ifdef __FreeBSD__
+#include <sys/param.h> /* For NBBY -- it's in sys/types.h on NetBSD */
+#endif
+#include <sys/wait.h>
+#include <sys/resource.h>
+
+#include <errno.h>
+#include <stdio.h>
+
+#include <atf-c.h>
+
+#ifndef TWAIT_OPTION
+#define TWAIT_OPTION 0
+#endif
+
+#if TWAIT_OPTION == 0
+ATF_TC(wait);
+ATF_TC_HEAD(wait, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait(2) returns ECHILD for no child");
+}
+
+ATF_TC_BODY(wait, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD, wait(NULL) == -1);
+}
+#endif
+
+ATF_TC(waitpid);
+ATF_TC_HEAD(waitpid, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that waitpid(2) returns ECHILD for WAIT_ANY and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(waitpid, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD, waitpid(WAIT_ANY, NULL, TWAIT_OPTION) == -1);
+}
+
+ATF_TC(waitid);
+ATF_TC_HEAD(waitid, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that waitid(2) returns ECHILD for P_ALL and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(waitid, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD,
+ waitid(P_ALL, 0, NULL,
+ WTRAPPED | WEXITED | TWAIT_OPTION) == -1);
+}
+
+ATF_TC(wait3);
+ATF_TC_HEAD(wait3, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait3(2) returns ECHILD for no child");
+}
+
+ATF_TC_BODY(wait3, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD, wait3(NULL, TWAIT_OPTION, NULL) == -1);
+}
+
+ATF_TC(wait4);
+ATF_TC_HEAD(wait4, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait4(2) returns ECHILD for WAIT_ANY and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(wait4, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD,
+ wait4(WAIT_ANY, NULL, TWAIT_OPTION, NULL) == -1);
+}
+
+ATF_TC(wait6);
+ATF_TC_HEAD(wait6, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait6(2) returns ECHILD for P_ALL and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(wait6, tc)
+{
+ ATF_REQUIRE_ERRNO(ECHILD,
+ wait6(P_ALL, 0, NULL,
+ WTRAPPED | WEXITED | TWAIT_OPTION, NULL, NULL) == -1);
+}
+
+/*
+ * Generator of valid combinations of options
+ * Usage: i = 0; while ((o = get_options_wait6(i++)) != -1) {}
+ */
+static int
+get_options6(size_t pos)
+{
+ int rv = 0;
+ size_t n;
+
+ /*
+ * waitid(2) must specify at least one of WEXITED, WUNTRACED,
+ * WSTOPPED, WTRAPPED or WCONTINUED. Single option WNOWAIT
+ * isn't valid.
+ */
+
+ const int matrix[] = {
+ WNOWAIT, /* First in order to blacklist it easily */
+ WEXITED,
+ WUNTRACED,
+ WSTOPPED, /* SUS compatibility, equal to WUNTRACED */
+ WTRAPPED,
+ WCONTINUED
+ };
+
+ const size_t M = (1 << __arraycount(matrix)) - 1;
+
+ /* Skip empty and sole WNOWAIT option */
+ pos+=2;
+
+ if (pos > M)
+ return -1;
+
+ for (n = 0; n < __arraycount(matrix); n++) {
+ if (pos & __BIT(n))
+ rv |= matrix[n];
+ }
+
+ return rv;
+}
+
+/*
+ * Generator of valid combinations of options
+ * Usage: i = 0; while ((o = get_options_wait4(i++)) != -1) {}
+ */
+static int
+get_options4(size_t pos)
+{
+ int rv = 0;
+ size_t n;
+
+ const int special[] = {
+ 0,
+#ifdef __NetBSD__
+ WALLSIG,
+ WALTSIG,
+ __WALL, /* Linux compatibility, equal to WALLSIG */
+ __WCLONE /* Linux compatibility, equal to WALTSIG */
+#endif
+ };
+
+ const int matrix[] = {
+ WNOWAIT,
+ WEXITED,
+ WUNTRACED,
+ WSTOPPED, /* SUS compatibility, equal to WUNTRACED */
+ WTRAPPED,
+ WCONTINUED
+ };
+
+ const size_t M = (1 << __arraycount(special)) - 1;
+
+ if (pos < __arraycount(special))
+ return special[pos];
+
+ pos -= __arraycount(special);
+
+ ++pos; /* Don't start with empty mask */
+
+ if (pos > M)
+ return -1;
+
+ for (n = 0; n < __arraycount(special); n++) {
+ if (pos & __BIT(n))
+ rv |= matrix[n];
+ }
+
+ return rv;
+}
+
+ATF_TC(waitpid_options);
+ATF_TC_HEAD(waitpid_options, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that waitpid(2) returns ECHILD for WAIT_ANY and valid "
+ "combination of options with%s WNOHANG",
+ TWAIT_OPTION == 0 ? "out" : "");
+}
+
+ATF_TC_BODY(waitpid_options, tc)
+{
+ size_t i = 0;
+ int o;
+
+ while((o = get_options4(i++)) != -1) {
+ printf("Testing waitpid(2) with options %x\n", o);
+
+ ATF_REQUIRE_ERRNO(ECHILD,
+ waitpid(WAIT_ANY, NULL, o | TWAIT_OPTION) == -1);
+ }
+}
+
+ATF_TC(waitid_options);
+ATF_TC_HEAD(waitid_options, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that waitid(2) returns ECHILD for P_ALL and valid "
+ "combination of options with%s WNOHANG",
+ TWAIT_OPTION == 0 ? "out" : "");
+}
+
+ATF_TC_BODY(waitid_options, tc)
+{
+ size_t i = 0;
+ int o;
+
+ while((o = get_options6(i++)) != -1) {
+ printf("Testing waitid(2) with options %x\n", o);
+
+ ATF_REQUIRE_ERRNO(ECHILD,
+ waitid(P_ALL, 0, NULL, o | TWAIT_OPTION) == -1);
+ }
+}
+
+ATF_TC(wait3_options);
+ATF_TC_HEAD(wait3_options, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait3(2) returns ECHILD for no child");
+}
+
+ATF_TC_BODY(wait3_options, tc)
+{
+ size_t i = 0;
+ int o;
+
+ while((o = get_options4(i++)) != -1) {
+ printf("Testing wait3(2) with options %x\n", o);
+
+ ATF_REQUIRE_ERRNO(ECHILD,
+ wait3(NULL, o | TWAIT_OPTION, NULL) == -1);
+ }
+}
+
+ATF_TC(wait4_options);
+ATF_TC_HEAD(wait4_options, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait4(2) returns ECHILD for WAIT_ANY and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(wait4_options, tc)
+{
+ size_t i = 0;
+ int o;
+
+ while((o = get_options4(i++)) != -1) {
+ printf("Testing wait4(2) with options %x\n", o);
+
+ ATF_REQUIRE_ERRNO(ECHILD,
+ wait4(WAIT_ANY, NULL, o | TWAIT_OPTION, NULL) == -1);
+ }
+}
+
+ATF_TC(wait6_options);
+ATF_TC_HEAD(wait6_options, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait6(2) returns ECHILD for P_ALL and option %s",
+ ___STRING(TWAIT_OPTION));
+}
+
+ATF_TC_BODY(wait6_options, tc)
+{
+ size_t i = 0;
+ int o;
+
+ while((o = get_options6(i++)) != -1) {
+ printf("Testing wait6(2) with options %x\n", o);
+
+ ATF_REQUIRE_ERRNO(ECHILD,
+ wait6(P_ALL, 0, NULL, o | TWAIT_OPTION, NULL, NULL) == -1);
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+#if TWAIT_OPTION == 0
+ ATF_TP_ADD_TC(tp, wait);
+#endif
+ ATF_TP_ADD_TC(tp, waitpid);
+ ATF_TP_ADD_TC(tp, waitid);
+ ATF_TP_ADD_TC(tp, wait3);
+ ATF_TP_ADD_TC(tp, wait4);
+ ATF_TP_ADD_TC(tp, wait6);
+
+ ATF_TP_ADD_TC(tp, waitpid_options);
+ ATF_TP_ADD_TC(tp, waitid_options);
+ ATF_TP_ADD_TC(tp, wait3_options);
+ ATF_TP_ADD_TC(tp, wait4_options);
+ ATF_TP_ADD_TC(tp, wait6_options);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c
new file mode 100644
index 0000000..45a9998
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c
@@ -0,0 +1,30 @@
+/* $NetBSD: t_wait_noproc_wnohang.c,v 1.1 2016/11/06 15:03:30 kamil Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+ */
+
+#define TWAIT_OPTION WNOHANG
+#include "t_wait_noproc.c"
OpenPOWER on IntegriCloud