From 78e3a559e196fc51e69e57f5434cd3ca9bd767c7 Mon Sep 17 00:00:00 2001 From: ngie Date: Sun, 12 Feb 2017 09:24:18 +0000 Subject: MFC r312008: Upgrade NetBSD tests to 01.11.2017_23.20 snapshot This contains some new testcases in /usr/tests/...: - .../lib/libc - .../lib/libthr - .../lib/msun - .../sys/kern Tested on: amd64, i386 --- .../lib/libc/arch/sparc64/exec_prot_support.c | 7 +- .../lib/libc/arch/sparc64/return_one.S | 11 +- contrib/netbsd-tests/lib/libc/db/h_db.c | 77 ++++- contrib/netbsd-tests/lib/libc/db/t_db.sh | 313 ++++++++++++++++++- contrib/netbsd-tests/lib/libc/gen/t_dir.c | 36 ++- contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c | 5 +- contrib/netbsd-tests/lib/libc/rpc/t_rpc.c | 24 +- contrib/netbsd-tests/lib/libc/string/t_memcpy.c | 6 +- contrib/netbsd-tests/lib/libc/string/t_memmem.c | 2 +- .../lib/libc/sync/cpp_atomic_ops_linkable.cc | 16 +- .../netbsd-tests/lib/libc/sys/t_clock_nanosleep.c | 63 ++++ contrib/netbsd-tests/lib/libc/sys/t_getrusage.c | 4 + contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c | 345 +++++++++++++++++++++ .../lib/libc/sys/t_wait_noproc_wnohang.c | 30 ++ contrib/netbsd-tests/lib/libm/t_casinh.c | 81 +++++ contrib/netbsd-tests/lib/libm/t_fe_round.c | 124 ++++++++ contrib/netbsd-tests/lib/libm/t_ilogb.c | 130 ++++++++ contrib/netbsd-tests/lib/libm/t_ldexp.c | 12 +- contrib/netbsd-tests/lib/libm/t_precision.c | 8 +- contrib/netbsd-tests/lib/libpthread/h_common.h | 6 + contrib/netbsd-tests/lib/libpthread/t_mutex.c | 198 ++++++++++-- contrib/netbsd-tests/lib/libpthread/t_timedmutex.c | 30 ++ contrib/netbsd-tests/lib/librumpclient/h_execthr.c | 68 +++- contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh | 7 +- contrib/netbsd-tests/lib/libusbhid/t_usbhid.c | 7 +- 25 files changed, 1488 insertions(+), 122 deletions(-) create mode 100644 contrib/netbsd-tests/lib/libc/sys/t_clock_nanosleep.c create mode 100644 contrib/netbsd-tests/lib/libc/sys/t_wait_noproc.c create mode 100644 contrib/netbsd-tests/lib/libc/sys/t_wait_noproc_wnohang.c create mode 100644 contrib/netbsd-tests/lib/libm/t_casinh.c create mode 100644 contrib/netbsd-tests/lib/libm/t_fe_round.c create mode 100644 contrib/netbsd-tests/lib/libm/t_ilogb.c create mode 100644 contrib/netbsd-tests/lib/libpthread/t_timedmutex.c (limited to 'contrib/netbsd-tests/lib') 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 -__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 -.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 #include #include +#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 - < 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_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 -__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 #include @@ -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 -__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 #include @@ -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 m_val; }; -#if defined(__clang__) && defined(__sparc64__) -#define NO_SHORT_ATOMICS -#endif - int main(int argc, char **argv) { -#ifndef NO_SHORT_ATOMICS ATest(); ATest(); ATest(); ATest(); ATest(); -#endif ATest(); ATest(); ATest(); @@ -79,29 +73,23 @@ int main(int argc, char **argv) ATest(); ATest(); #endif -#ifndef NO_SHORT_ATOMICS ATest(); -#endif ATest(); ATest(); -#ifndef NO_SHORT_ATOMICS ATest(); ATest(); ATest(); ATest(); -#endif ATest(); ATest(); #ifdef __HAVE_ATOMIC64_OPS ATest(); ATest(); #endif -#ifndef NO_SHORT_ATOMICS ATest(); ATest(); ATest(); ATest(); -#endif ATest(); ATest(); #ifdef __HAVE_ATOMIC64_OPS @@ -115,5 +103,5 @@ int main(int argc, char **argv) #ifdef __HAVE_ATOMIC64_OPS ATest(); ATest(); -#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 +__RCSID("$NetBSD: t_clock_nanosleep.c,v 1.1 2016/11/11 15:30:44 njoly Exp $"); + +#include +#include + +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 +__RCSID("$NetBSD: t_wait_noproc.c,v 1.5 2016/11/09 17:50:19 kamil Exp $"); + +#ifdef __FreeBSD__ +#include /* For NBBY -- it's in sys/types.h on NetBSD */ +#endif +#include +#include + +#include +#include + +#include + +#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" diff --git a/contrib/netbsd-tests/lib/libm/t_casinh.c b/contrib/netbsd-tests/lib/libm/t_casinh.c new file mode 100644 index 0000000..f9f93c3 --- /dev/null +++ b/contrib/netbsd-tests/lib/libm/t_casinh.c @@ -0,0 +1,81 @@ +/* $NetBSD: t_casinh.c,v 1.2 2016/09/20 17:19:28 christos Exp $ */ + +/* + * Written by Maya Rashish + * Public domain. + * + * Testing special values of casinh + * Values from ISO/IEC 9899:201x G.6.2.2 + */ + +#include +#include +#include + +#define RE(z) (((double *)(&z))[0]) +#define IM(z) (((double *)(&z))[1]) + +static const struct { + double input_re; + double input_im; + double result_re; + double result_im; +} values[] = { + { +0, +0, +0, +0}, + { +5.032E3, +INFINITY, +INFINITY, +M_PI/2}, + { +INFINITY, +5.023E3, +INFINITY, +0}, + { +INFINITY, +INFINITY, +INFINITY, +M_PI/4}, +#ifdef __HAVE_NANF + { +INFINITY, +NAN, +INFINITY, +NAN}, + { +5.032E3, +NAN, +NAN, +NAN}, /* + FE_INVALID optionally raised */ + { +NAN, +0, +NAN, +0}, + { +NAN, -5.023E3, +NAN, +NAN}, /* + FE_INVALID optionally raised */ + { +NAN, +INFINITY, +INFINITY, +NAN}, /* sign of real part of result unspecified */ + { +NAN, +NAN, +NAN, +NAN}, +#endif +}; + +#ifdef __HAVE_NANF +#define both_nan(a,b) (isnan(a) && isnan(b)) +#else +#define both_nan(a,b) 0 +#endif + +#define crude_equality(a,b) ((a == b) || both_nan(a,b)) + +#define ATF_COMPLEX_EQUAL(a,b) do { \ + complex double ci = casinh(a); \ + ATF_CHECK_MSG(crude_equality(creal(ci),creal(b)) && \ + crude_equality(cimag(ci), cimag(b)), \ + "for casinh([%g,%g]) = [%g,%g] != [%g,%g]", \ + creal(a), cimag(a), creal(ci), cimag(ci), creal(b), cimag(b)); \ +} while (0/*CONSTCOND*/) + + +ATF_TC(casinh); +ATF_TC_HEAD(casinh, tc) +{ + atf_tc_set_md_var(tc, "descr","Check casinh family - special values"); +} + +ATF_TC_BODY(casinh, tc) +{ + complex double input; + complex double result; + unsigned int i; + for (i = 0; i < __arraycount(values); i++) { + RE(input) = values[i].input_re; + IM(input) = values[i].input_im; + RE(result) = values[i].result_re; + IM(result) = values[i].result_im; + ATF_COMPLEX_EQUAL(input, result); + } +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, casinh); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/lib/libm/t_fe_round.c b/contrib/netbsd-tests/lib/libm/t_fe_round.c new file mode 100644 index 0000000..fe805b4 --- /dev/null +++ b/contrib/netbsd-tests/lib/libm/t_fe_round.c @@ -0,0 +1,124 @@ +/* + * Written by Maya Rashish + * Public domain. + * + * Testing IEEE-754 rounding modes (and lrint) + */ + +#include +#include +#ifdef __HAVE_FENV +#include +#include +#include + +/*#pragma STDC FENV_ACCESS ON gcc?? */ + +#define INT 9223L + +#define EPSILON 0.001 + +static const struct { + int round_mode; + double input; + long int expected; +} values[] = { + { FE_DOWNWARD, 3.7, 3}, + { FE_DOWNWARD, -3.7, -4}, + { FE_DOWNWARD, +0, 0}, + { FE_DOWNWARD, -INT-0.01, -INT-1}, + { FE_DOWNWARD, +INT-0.01, INT-1}, + { FE_DOWNWARD, -INT+0.01, -INT}, + { FE_DOWNWARD, +INT+0.01, INT}, +#if 0 /* cpu bugs? */ + { FE_DOWNWARD, -0, -1}, + + { FE_UPWARD, +0, 1}, +#endif + { FE_UPWARD, -0, 0}, + { FE_UPWARD, -123.7, -123}, + { FE_UPWARD, 123.999, 124}, + { FE_UPWARD, -INT-0.01, -INT}, + { FE_UPWARD, +INT-0.01, INT}, + { FE_UPWARD, -INT+0.01, -INT+1}, + { FE_UPWARD, +INT+0.01, INT+1}, + + { FE_TOWARDZERO, 1.99, 1}, + { FE_TOWARDZERO, -1.99, -1}, + { FE_TOWARDZERO, 0.2, 0}, + { FE_TOWARDZERO, INT+0.01, INT}, + { FE_TOWARDZERO, INT-0.01, INT - 1}, + { FE_TOWARDZERO, -INT+0.01, -INT + 1}, + { FE_TOWARDZERO, +0, 0}, + { FE_TOWARDZERO, -0, 0}, + + { FE_TONEAREST, -INT-0.01, -INT}, + { FE_TONEAREST, +INT-0.01, INT}, + { FE_TONEAREST, -INT+0.01, -INT}, + { FE_TONEAREST, +INT+0.01, INT}, + { FE_TONEAREST, -INT-0.501, -INT-1}, + { FE_TONEAREST, +INT-0.501, INT-1}, + { FE_TONEAREST, -INT+0.501, -INT+1}, + { FE_TONEAREST, +INT+0.501, INT+1}, + { FE_TONEAREST, +0, 0}, + { FE_TONEAREST, -0, 0}, +}; + +ATF_TC(fe_round); +ATF_TC_HEAD(fe_round, tc) +{ + atf_tc_set_md_var(tc, "descr","Checking IEEE 754 rounding modes using lrint"); +} + +ATF_TC_BODY(fe_round, tc) +{ + long int received; + + for (unsigned int i = 0; i < __arraycount(values); i++) { + fesetround(values[i].round_mode); + + received = lrint(values[i].input); + ATF_CHECK_MSG( + (labs(received - values[i].expected) < EPSILON), + "lrint rounding wrong, difference too large\n" + "input: %f (index %d): got %ld, expected %ld\n", + values[i].input, i, received, values[i].expected); + + /* Do we get the same rounding mode out? */ + ATF_CHECK_MSG( + (fegetround() == values[i].round_mode), + "Didn't get the same rounding mode out!\n" + "(index %d) fed in %d rounding mode, got %d out\n", + i, fegetround(), values[i].round_mode); + } +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, fe_round); + + return atf_no_error(); +} +#else +ATF_TC(t_nofe_round); + +ATF_TC_HEAD(t_nofe_round, tc) +{ + atf_tc_set_md_var(tc, "descr", + "dummy test case - no fenv.h support"); +} + + +ATF_TC_BODY(t_nofe_round, tc) +{ + atf_tc_skip("no fenv.h support on this architecture"); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, t_nofe_round); + return atf_no_error(); +} + +#endif diff --git a/contrib/netbsd-tests/lib/libm/t_ilogb.c b/contrib/netbsd-tests/lib/libm/t_ilogb.c new file mode 100644 index 0000000..b3c2126 --- /dev/null +++ b/contrib/netbsd-tests/lib/libm/t_ilogb.c @@ -0,0 +1,130 @@ +/* $NetBSD: t_ilogb.c,v 1.6 2016/08/26 08:01:55 christos Exp $ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Maya Rashish. + * + * 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. + */ + +#ifdef __FreeBSD__ +#include +#endif +#include +#include +#include + +#ifndef __HAVE_FENV + +# define ATF_CHECK_RAISED_INVALID +# define ATF_CHECK_RAISED_NOTHING + +#else +# define ATF_CHECK_RAISED_INVALID do { \ + int r = fetestexcept(FE_ALL_EXCEPT); \ + ATF_CHECK_MSG(r == FE_INVALID, "r=%#x != %#x\n", r, FE_INVALID); \ + (void)feclearexcept(FE_ALL_EXCEPT); \ +} while (/*CONSTCOND*/0) + +# define ATF_CHECK_RAISED_NOTHING do { \ + int r = fetestexcept(FE_ALL_EXCEPT); \ + ATF_CHECK_MSG(r == 0, "r=%#x != 0\n", r); \ + (void)feclearexcept(FE_ALL_EXCEPT); \ +} while (/*CONSTCOND*/0) +#endif + +ATF_TC(ilogb); +ATF_TC_HEAD(ilogb, tc) +{ + atf_tc_set_md_var(tc, "descr","Check ilogb family"); +} + +ATF_TC_BODY(ilogb, tc) +{ + + ATF_CHECK(ilogbf(0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; +#endif + + ATF_CHECK(ilogbf(-0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(-0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(-0) == FP_ILOGB0); + ATF_CHECK_RAISED_INVALID; +#endif + + ATF_CHECK(ilogbf(INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; +#endif + + ATF_CHECK(ilogbf(-INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(-INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(-INFINITY) == INT_MAX); + ATF_CHECK_RAISED_INVALID; +#endif + + ATF_CHECK(ilogbf(1024) == 10); + ATF_CHECK_RAISED_NOTHING; + ATF_CHECK(ilogb(1024) == 10); + ATF_CHECK_RAISED_NOTHING; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(1024) == 10); + ATF_CHECK_RAISED_NOTHING; +#endif + +#ifndef __vax__ + ATF_CHECK(ilogbf(NAN) == FP_ILOGBNAN); + ATF_CHECK_RAISED_INVALID; + ATF_CHECK(ilogb(NAN) == FP_ILOGBNAN); + ATF_CHECK_RAISED_INVALID; +#ifdef __HAVE_LONG_DOUBLE + ATF_CHECK(ilogbl(NAN) == FP_ILOGBNAN); + ATF_CHECK_RAISED_INVALID; +#endif +#endif +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, ilogb); + + return atf_no_error(); +} diff --git a/contrib/netbsd-tests/lib/libm/t_ldexp.c b/contrib/netbsd-tests/lib/libm/t_ldexp.c index eaf8a4b..251f2ae 100644 --- a/contrib/netbsd-tests/lib/libm/t_ldexp.c +++ b/contrib/netbsd-tests/lib/libm/t_ldexp.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_ldexp.c,v 1.14 2014/11/04 00:20:19 justin Exp $ */ +/* $NetBSD: t_ldexp.c,v 1.16 2016/08/25 00:32:31 maya Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_ldexp.c,v 1.14 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_ldexp.c,v 1.16 2016/08/25 00:32:31 maya Exp $"); #include @@ -96,10 +96,12 @@ struct ldexp_test ldexp_overflow[] = { { 1.0, 1023, 1, " inf" }, { 1.0, -1022, 2046, " inf" }, { 1.0, 1025, SKIP, " inf" }, + { 2.0, INT_MAX,SKIP, " inf" }, { -1.0, 1024, SKIP, " -inf" }, { -1.0, 1023, 1, " -inf" }, { -1.0, -1022, 2046, " -inf" }, { -1.0, 1025, SKIP, " -inf" }, + { -2.0, INT_MAX,SKIP, " -inf" }, { 0, 0, 0, NULL } }; @@ -170,10 +172,8 @@ run_test(struct ldexp_test *table) v = ldexp(table->x, table->exp1); - if (table->exp2 == SKIP) - continue; - - v = ldexp(v, table->exp2); + if (table->exp2 != SKIP) + v = ldexp(v, table->exp2); (void)snprintf(outbuf, sizeof(outbuf), FORMAT, v); diff --git a/contrib/netbsd-tests/lib/libm/t_precision.c b/contrib/netbsd-tests/lib/libm/t_precision.c index c01deba..df2d8a3 100644 --- a/contrib/netbsd-tests/lib/libm/t_precision.c +++ b/contrib/netbsd-tests/lib/libm/t_precision.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_precision.c,v 1.2 2014/11/04 00:20:19 justin Exp $ */ +/* $NetBSD: t_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include -__RCSID("$NetBSD: t_precision.c,v 1.2 2014/11/04 00:20:19 justin Exp $"); +__RCSID("$NetBSD: t_precision.c,v 1.3 2016/08/27 10:07:05 christos Exp $"); #include @@ -45,7 +45,9 @@ ATF_TC_HEAD(t_precision, tc) } volatile double x = 1; +#if __HAVE_LONG_DOUBLE volatile long double y = 1; +#endif ATF_TC_BODY(t_precision, tc) { @@ -58,7 +60,7 @@ ATF_TC_BODY(t_precision, tc) x += DBL_EPSILON; ATF_CHECK(x == 2.0); -#if !defined(__FreeBSD__) || !defined(__i386__) +#if __HAVE_LONG_DOUBLE y += LDBL_EPSILON; ATF_CHECK(y != 1.0L); y -= 1; diff --git a/contrib/netbsd-tests/lib/libpthread/h_common.h b/contrib/netbsd-tests/lib/libpthread/h_common.h index f4d03bc..2e8b0a1 100644 --- a/contrib/netbsd-tests/lib/libpthread/h_common.h +++ b/contrib/netbsd-tests/lib/libpthread/h_common.h @@ -9,4 +9,10 @@ ATF_REQUIRE_MSG(ret == 0, "%s: %s", #x, strerror(ret)); \ } while (0) +#define PTHREAD_REQUIRE_STATUS(x, v) \ + do { \ + int ret = (x); \ + ATF_REQUIRE_MSG(ret == (v), "%s: %s", #x, strerror(ret)); \ + } while (0) + #endif // H_COMMON_H diff --git a/contrib/netbsd-tests/lib/libpthread/t_mutex.c b/contrib/netbsd-tests/lib/libpthread/t_mutex.c index 1fcd69e..b8d60e6 100644 --- a/contrib/netbsd-tests/lib/libpthread/t_mutex.c +++ b/contrib/netbsd-tests/lib/libpthread/t_mutex.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_mutex.c,v 1.10 2016/07/31 13:01:29 christos Exp $ */ +/* $NetBSD: t_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,12 +29,17 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_mutex.c,v 1.10 2016/07/31 13:01:29 christos Exp $"); +__RCSID("$NetBSD: t_mutex.c,v 1.14 2016/10/31 23:51:20 christos Exp $"); +#ifdef __FreeBSD__ +#include /* For timespecadd */ +#include /* For UINT16_MAX */ +#endif #include #include #include #include +#include #include #include #include @@ -47,6 +52,31 @@ static pthread_mutex_t mutex; static pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER; static int global_x; +#ifdef TIMEDMUTEX +/* This code is used for verifying non-timed specific code */ +static struct timespec ts_lengthy = { + .tv_sec = UINT16_MAX, + .tv_nsec = 0 +}; +/* This code is used for verifying timed-only specific code */ +static struct timespec ts_shortlived = { + .tv_sec = 0, + .tv_nsec = 120 +}; + +static int +mutex_lock(pthread_mutex_t *m, const struct timespec *ts) +{ + struct timespec ts_wait; + ATF_REQUIRE(clock_gettime(CLOCK_REALTIME, &ts_wait) != -1); + timespecadd(&ts_wait, ts, &ts_wait); + + return pthread_mutex_timedlock(m, &ts_wait); +} +#else +#define mutex_lock(a, b) pthread_mutex_lock(a) +#endif + static void * mutex1_threadfunc(void *arg) { @@ -56,7 +86,7 @@ mutex1_threadfunc(void *arg) param = arg; printf("2: Locking mutex\n"); - pthread_mutex_lock(&mutex); + mutex_lock(&mutex, &ts_lengthy); printf("2: Got mutex. *param = %d\n", *param); ATF_REQUIRE_EQ(*param, 20); (*param)++; @@ -81,7 +111,7 @@ ATF_TC_BODY(mutex1, tc) PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); x = 1; - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex1_threadfunc, &x)); printf("1: Before changing the value.\n"); sleep(2); @@ -92,7 +122,7 @@ ATF_TC_BODY(mutex1, tc) printf("1: After releasing the mutex.\n"); PTHREAD_REQUIRE(pthread_join(new, &joinval)); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (int) was %d\n", x, *(int *)joinval); ATF_REQUIRE_EQ(x, 21); @@ -108,7 +138,7 @@ mutex2_threadfunc(void *arg) printf("2: Second thread (%p). Count is %ld\n", pthread_self(), count); while (count--) { - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } @@ -145,7 +175,7 @@ ATF_TC_BODY(mutex2, tc) global_x = 0; count = count2 = 10000000; - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex2_threadfunc, &count2)); printf("1: Thread %p\n", pthread_self()); @@ -153,14 +183,14 @@ ATF_TC_BODY(mutex2, tc) PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); while (count--) { - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } PTHREAD_REQUIRE(pthread_join(new, &joinval)); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (long) was %ld\n", global_x, (long)joinval); ATF_REQUIRE_EQ(global_x, 20000000); @@ -184,7 +214,7 @@ mutex3_threadfunc(void *arg) printf("2: Second thread (%p). Count is %ld\n", pthread_self(), count); while (count--) { - PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); + PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); } @@ -220,7 +250,7 @@ ATF_TC_BODY(mutex3, tc) global_x = 0; count = count2 = 10000000; - PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); + PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex3_threadfunc, &count2)); printf("1: Thread %p\n", pthread_self()); @@ -228,14 +258,14 @@ ATF_TC_BODY(mutex3, tc) PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); while (count--) { - PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); + PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); } PTHREAD_REQUIRE(pthread_join(new, &joinval)); - PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); + PTHREAD_REQUIRE(mutex_lock(&static_mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (long) was %ld\n", global_x, (long)joinval); ATF_REQUIRE_EQ(global_x, 20000000); @@ -260,7 +290,7 @@ mutex4_threadfunc(void *arg) param = arg; printf("2: Locking mutex\n"); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("2: Got mutex. *param = %d\n", *param); (*param)++; @@ -291,11 +321,11 @@ ATF_TC_BODY(mutex4, tc) PTHREAD_REQUIRE(pthread_mutexattr_destroy(&mattr)); x = 1; - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex4_threadfunc, &x)); printf("1: Before recursively acquiring the mutex.\n"); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Before releasing the mutex once.\n"); sleep(2); @@ -311,7 +341,7 @@ ATF_TC_BODY(mutex4, tc) PTHREAD_REQUIRE(pthread_join(new, &joinval)); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); printf("1: Thread joined. X was %d. Return value (int) was %d\n", x, *(int *)joinval); ATF_REQUIRE_EQ(x, 21); @@ -333,7 +363,7 @@ child_func(void* arg) res = _sched_protect(-2); ATF_REQUIRE_EQ_MSG(res, -1, "sched_protect returned %d", res); ATF_REQUIRE_EQ(errno, ENOENT); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex5)); + PTHREAD_REQUIRE(mutex_lock(&mutex5, &ts_lengthy)); printf("child is owning resource\n"); res = _sched_protect(-2); ATF_REQUIRE_EQ(res, max_fifo_prio); @@ -376,7 +406,7 @@ ATF_TC_BODY(mutex5, tc) max_fifo_prio)); PTHREAD_REQUIRE(pthread_mutex_init(&mutex5, &attr5)); - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex5)); + PTHREAD_REQUIRE(mutex_lock(&mutex5, &ts_lengthy)); printf("enter critical section for main\n"); PTHREAD_REQUIRE(pthread_create(&child, NULL, child_func, NULL)); printf("main starts to sleep\n"); @@ -414,7 +444,7 @@ high_prio(void* arg) high_cnt = 0; sleep(1); } - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex6)); + PTHREAD_REQUIRE(mutex_lock(&mutex6, &ts_lengthy)); if (start == 0) start = 2; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex6)); @@ -446,7 +476,7 @@ low_prio(void* arg) low_cnt = 0; sleep(1); } - PTHREAD_REQUIRE(pthread_mutex_lock(&mutex6)); + PTHREAD_REQUIRE(mutex_lock(&mutex6, &ts_lengthy)); if (start == 0) start = 1; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex6)); @@ -582,6 +612,123 @@ ATF_TC_BODY(mutexattr2, tc) } } +#ifdef TIMEDMUTEX +ATF_TC(timedmutex1); +ATF_TC_HEAD(timedmutex1, tc) +{ + atf_tc_set_md_var(tc, "descr", "Checks timeout on selflock"); +} + +ATF_TC_BODY(timedmutex1, tc) +{ + + printf("Timed mutex-test 1\n"); + + PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); + + printf("Before acquiring mutex\n"); + PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + + printf("Before endeavor to reacquire timed-mutex (timeout expected)\n"); + PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived), + ETIMEDOUT); + + printf("Unlocking mutex\n"); + PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); +} + +ATF_TC(timedmutex2); +ATF_TC_HEAD(timedmutex2, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Checks timeout on selflock with timedlock"); +} + +ATF_TC_BODY(timedmutex2, tc) +{ + + printf("Timed mutex-test 2\n"); + + PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); + + printf("Before acquiring mutex with timedlock\n"); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); + + printf("Before endeavor to reacquire timed-mutex (timeout expected)\n"); + PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived), + ETIMEDOUT); + + printf("Unlocking mutex\n"); + PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); +} + +ATF_TC(timedmutex3); +ATF_TC_HEAD(timedmutex3, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Checks timeout on selflock in a new thread"); +} + +static void * +timedmtx_thrdfunc(void *arg) +{ + printf("Before endeavor to reacquire timed-mutex (timeout expected)\n"); + PTHREAD_REQUIRE_STATUS(mutex_lock(&mutex, &ts_shortlived), + ETIMEDOUT); + + return NULL; +} + +ATF_TC_BODY(timedmutex3, tc) +{ + pthread_t new; + + printf("Timed mutex-test 3\n"); + + PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); + + printf("Before acquiring mutex with timedlock\n"); + PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); + + printf("Before creating new thread\n"); + PTHREAD_REQUIRE(pthread_create(&new, NULL, timedmtx_thrdfunc, NULL)); + + printf("Before joining the mutex\n"); + PTHREAD_REQUIRE(pthread_join(new, NULL)); + + printf("Unlocking mutex\n"); + PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); +} + +ATF_TC(timedmutex4); +ATF_TC_HEAD(timedmutex4, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Checks timeout on selflock with timedlock in a new thread"); +} + +ATF_TC_BODY(timedmutex4, tc) +{ + pthread_t new; + + printf("Timed mutex-test 4\n"); + + PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); + + printf("Before acquiring mutex with timedlock\n"); + PTHREAD_REQUIRE(mutex_lock(&mutex, &ts_lengthy)); + + printf("Before creating new thread\n"); + PTHREAD_REQUIRE(pthread_create(&new, NULL, timedmtx_thrdfunc, NULL)); + + printf("Before joining the mutex\n"); + PTHREAD_REQUIRE(pthread_join(new, NULL)); + + printf("Unlocking mutex\n"); + PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); +} +#endif + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, mutex1); @@ -594,6 +741,13 @@ ATF_TP_ADD_TCS(tp) #endif ATF_TP_ADD_TC(tp, mutexattr1); ATF_TP_ADD_TC(tp, mutexattr2); - + +#ifdef TIMEDMUTEX + ATF_TP_ADD_TC(tp, timedmutex1); + ATF_TP_ADD_TC(tp, timedmutex2); + ATF_TP_ADD_TC(tp, timedmutex3); + ATF_TP_ADD_TC(tp, timedmutex4); +#endif + return atf_no_error(); } diff --git a/contrib/netbsd-tests/lib/libpthread/t_timedmutex.c b/contrib/netbsd-tests/lib/libpthread/t_timedmutex.c new file mode 100644 index 0000000..4f71acd --- /dev/null +++ b/contrib/netbsd-tests/lib/libpthread/t_timedmutex.c @@ -0,0 +1,30 @@ +/* $NetBSD: t_timedmutex.c,v 1.2 2016/10/31 16:21:23 christos Exp $ */ + +/* + * Copyright (c) 2008 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 TIMEDMUTEX +#include "t_mutex.c" diff --git a/contrib/netbsd-tests/lib/librumpclient/h_execthr.c b/contrib/netbsd-tests/lib/librumpclient/h_execthr.c index f653fe6..c209375 100644 --- a/contrib/netbsd-tests/lib/librumpclient/h_execthr.c +++ b/contrib/netbsd-tests/lib/librumpclient/h_execthr.c @@ -1,4 +1,4 @@ -/* $NetBSD: h_execthr.c,v 1.3 2014/08/13 00:03:00 pooka Exp $ */ +/* $NetBSD: h_execthr.c,v 1.7 2016/11/24 00:37:29 dholland Exp $ */ /* * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -42,6 +42,14 @@ #include #include +//#define VERBOSE + +#ifdef VERBOSE +#define SAY(...) printf(__VA_ARGS__) +#else +#define SAY(...) +#endif + static int canreturn = 0; /* @@ -103,6 +111,7 @@ main(int argc, char *argv[], char *envp[]) else execd = 0; sprintf(nexec, "%d", execd+1); + SAY("execd: %d\n", execd); if (rumpclient_init() == -1) { if (execd) @@ -111,33 +120,43 @@ main(int argc, char *argv[], char *envp[]) err(1, "init"); } mypid = rump_sys_getpid(); + SAY("rumpclient_init finished.\n"); if (execd) { canreturn = 1; - if (pthread_create(&pt, NULL, - wrk, (void *)(uintptr_t)P2_0) != 0) - errx(1, "exec pthread_create"); + errno = pthread_create(&pt, NULL, + wrk, (void *)(uintptr_t)P2_0); + if (errno != 0) + err(1, "exec pthread_create"); + SAY("startup pthread_create finished.\n"); i = 37; rump_sys_write(P2_1, &i, sizeof(i)); pthread_join(pt, NULL); + SAY("startup pthread_join finished.\n"); n = rump_sys_read(P1_0, &i, sizeof(i)); if (n != -1 || errno != EBADF) errx(1, "post-exec cloexec works"); + SAY("startup rump_sys_read finished.\n"); getproc(mypid, &p); + SAY("startup getproc finished.\n"); if (p.p_nlwps != 2) errx(1, "invalid nlwps: %lld", (long long)p.p_nlwps); /* we passed? */ - if (execd > 10) + if (execd > 10) { + SAY("done.\n"); exit(0); + } rump_sys_close(P2_0); rump_sys_close(P2_1); } + SAY("making pipes...\n"); + if (rump_sys_pipe(p1) == -1) err(1, "pipe1"); if (p1[0] != P1_0 || p1[1] != P1_1) @@ -151,32 +170,47 @@ main(int argc, char *argv[], char *envp[]) if (rump_sys_fcntl(p1[1], F_SETFD, FD_CLOEXEC) == -1) err(1, "cloexec"); - for (i = 0; i < NTHR; i++) - if (pthread_create(&pt, NULL, - wrk, (void *)(uintptr_t)p1[0]) != 0) - errx(1, "pthread_create 1 %d", i); + SAY("making threads...\n"); + + for (i = 0; i < NTHR; i++) { + errno = pthread_create(&pt, NULL, + wrk, (void *)(uintptr_t)p1[0]); + if (errno != 0) + err(1, "pthread_create 1 %d", i); + } + + for (i = 0; i < NTHR; i++) { + errno = pthread_create(&pt, NULL, + wrk, (void *)(uintptr_t)p2[0]); + if (errno != 0) + err(1, "pthread_create 2 %d", i); + } - for (i = 0; i < NTHR; i++) - if (pthread_create(&pt, NULL, - wrk, (void *)(uintptr_t)p2[0]) != 0) - errx(1, "pthread_create 2 %d", i); + SAY("waiting for threads to start...\n"); /* wait for all the threads to be enjoying themselves */ for (;;) { getproc(mypid, &p); + SAY("getproc finished.\n"); if (p.p_nlwps == 2*NTHR + 2) break; usleep(10000); } + SAY("making some more threads start...\n"); + /* * load up one more (big) set. these won't start executing, though, * but we're interested in if they create blockage */ - for (i = 0; i < 3*NTHR; i++) - if (pthread_create(&pt, NULL, - wrk, (void *)(uintptr_t)p1[0]) != 0) - errx(1, "pthread_create 1 %d", i); + for (i = 0; i < 3*NTHR; i++) { + errno = pthread_create(&pt, NULL, + wrk, (void *)(uintptr_t)p1[0]); + if (errno != 0) + err(1, "pthread_create 3 %d", i); + } + + SAY("calling exec...\n"); /* then, we exec! */ execarg[0] = argv[0]; diff --git a/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh b/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh index 718dfdc..411be33 100755 --- a/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh +++ b/contrib/netbsd-tests/lib/librumphijack/t_tcpip.sh @@ -1,4 +1,4 @@ -# $NetBSD: t_tcpip.sh,v 1.17 2016/08/11 21:29:44 kre Exp $ +# $NetBSD: t_tcpip.sh,v 1.18 2016/08/13 11:22:11 christos Exp $ # # Copyright (c) 2011 The NetBSD Foundation, Inc. # All rights reserved. @@ -25,7 +25,8 @@ # POSSIBILITY OF SUCH DAMAGE. # -rumpnetsrv='rump_server -lrumpnet -lrumpnet_net -lrumpnet_netinet -lrumpdev' +rumpnetlibs="-lrumpnet -lrumpnet_net -lrumpnet_netinet6 -lrumpnet_netinet" +rumpnetsrv="rump_server $rumpnetlibs -lrumpdev" export RUMP_SERVER=unix://csock atf_test_case http cleanup @@ -37,7 +38,7 @@ http_head() http_body() { - atf_check -s exit:0 ${rumpnetsrv} -lrumpnet_netinet6 ${RUMP_SERVER} + atf_check -s exit:0 ${rumpnetsrv} ${RUMP_SERVER} # start bozo in daemon mode atf_check -s exit:0 env LD_PRELOAD=/usr/lib/librumphijack.so \ diff --git a/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c b/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c index f20652a..2766da2 100644 --- a/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c +++ b/contrib/netbsd-tests/lib/libusbhid/t_usbhid.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_usbhid.c,v 1.11 2016/01/07 16:10:49 jakllsch Exp $ */ +/* $NetBSD: t_usbhid.c,v 1.12 2016/08/17 12:10:42 jakllsch Exp $ */ /* * Copyright (c) 2016 Jonathan A. Kollasch @@ -27,7 +27,7 @@ */ #include -__RCSID("$NetBSD: t_usbhid.c,v 1.11 2016/01/07 16:10:49 jakllsch Exp $"); +__RCSID("$NetBSD: t_usbhid.c,v 1.12 2016/08/17 12:10:42 jakllsch Exp $"); #include @@ -244,6 +244,9 @@ ATF_TC_BODY(check_hid_get_data, tc) int32_t data; uint32_t udat; + atf_tc_expect_fail("only the 32-bit opcode works, " + "8 and 16-bit is broken"); + ATF_REQUIRE((hrd = hid_use_report_desc( range_test_report_descriptor, __arraycount(range_test_report_descriptor))) != NULL); -- cgit v1.1 From 2db56beee1ae7ba1d122f40eaa47a7bbd8f14aa5 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 14 Feb 2017 04:43:03 +0000 Subject: MFC r313377: Expect :floatunditf to fail on FreeBSD/i386 The precision error on FreeBSD/i386 doesn't match the expected output in long double form. --- contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'contrib/netbsd-tests/lib') 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, -- cgit v1.1