summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/libc
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2016-12-03 02:47:16 +0000
committerngie <ngie@FreeBSD.org>2016-12-03 02:47:16 +0000
commit29db3b90328498474388e9cfb2c8ef6d816c05c2 (patch)
tree91ac81530a80d5ea64a24212d143cb2012f49a0a /contrib/netbsd-tests/lib/libc
parent8408238ce58163c0d88dea333c155b6806aae830 (diff)
downloadFreeBSD-src-29db3b90328498474388e9cfb2c8ef6d816c05c2.zip
FreeBSD-src-29db3b90328498474388e9cfb2c8ef6d816c05c2.tar.gz
MFC r305358:
Update contrib/netbsd-tests with new content from NetBSD This updates the snapshot from 09/30/2014 to 08/11/2016 This brings in a number of new testcases from upstream, most notably: - bin/cat - lib/libc - lib/msun - lib/libthr - usr.bin/sort lib/libc/tests/stdio/open_memstream_test.c was moved to lib/libc/tests/stdio/open_memstream2_test.c to accomodate the new open_memstream test from NetBSD. Tested on: amd64 (VMware fusion VM; various bare metal platforms); i386 (VMware fusion VM); make tinderbox
Diffstat (limited to 'contrib/netbsd-tests/lib/libc')
-rw-r--r--contrib/netbsd-tests/lib/libc/arch/ia64/return_one.S11
-rw-r--r--contrib/netbsd-tests/lib/libc/arch/powerpc/return_one.S5
-rw-r--r--contrib/netbsd-tests/lib/libc/arch/riscv/return_one.S4
-rw-r--r--contrib/netbsd-tests/lib/libc/db/h_lfsr.c179
-rwxr-xr-xcontrib/netbsd-tests/lib/libc/db/t_db.sh101
-rw-r--r--contrib/netbsd-tests/lib/libc/db/t_db_hash_seq.c343
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/execve/t_execve.c5
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/isqemu.h28
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c29
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c25
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_randomid.c22
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_siginfo.c25
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_sleep.c5
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_time.c13
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_vis.c33
-rw-r--r--contrib/netbsd-tests/lib/libc/inet/t_inet_addr.c109
-rw-r--r--contrib/netbsd-tests/lib/libc/inet/t_inet_network.c68
-rwxr-xr-xcontrib/netbsd-tests/lib/libc/net/t_servent.sh4
-rw-r--r--contrib/netbsd-tests/lib/libc/rpc/t_rpc.c254
-rw-r--r--contrib/netbsd-tests/lib/libc/stdio/t_open_memstream.c96
-rw-r--r--contrib/netbsd-tests/lib/libc/stdlib/t_getenv.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/stdlib/t_posix_memalign.c75
-rw-r--r--contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c10
-rw-r--r--contrib/netbsd-tests/lib/libc/stdlib/t_strtoi.c304
-rw-r--r--contrib/netbsd-tests/lib/libc/stdlib/t_strtol.c13
-rw-r--r--contrib/netbsd-tests/lib/libc/string/t_memset.c52
-rw-r--r--contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc119
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_bind.c78
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_connect.c31
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_getrusage.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_getsockname.c82
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_kevent.c14
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_mlock.c37
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_mmap.c71
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_mprotect.c17
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_posix_fallocate.c63
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c24
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c155
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_wait.c265
-rw-r--r--contrib/netbsd-tests/lib/libc/time/t_strptime.c257
41 files changed, 2809 insertions, 233 deletions
diff --git a/contrib/netbsd-tests/lib/libc/arch/ia64/return_one.S b/contrib/netbsd-tests/lib/libc/arch/ia64/return_one.S
index 5308876..5cb5f39 100644
--- a/contrib/netbsd-tests/lib/libc/arch/ia64/return_one.S
+++ b/contrib/netbsd-tests/lib/libc/arch/ia64/return_one.S
@@ -1,8 +1,11 @@
-/* $NetBSD: return_one.S,v 1.1 2011/07/18 23:16:09 jym Exp $ */
+/* $NetBSD: return_one.S,v 1.2 2016/08/05 15:02:29 scole Exp $ */
#include <machine/asm.h>
-.globl return_one, return_one_end;
+.globl return_one_end
-return_one: return_one_end:
- nop
+ENTRY(return_one,0)
+ mov ret0=1
+ br.ret.sptk.few rp
+return_one_end:
+END(return_one)
diff --git a/contrib/netbsd-tests/lib/libc/arch/powerpc/return_one.S b/contrib/netbsd-tests/lib/libc/arch/powerpc/return_one.S
index d40298e..10629c5 100644
--- a/contrib/netbsd-tests/lib/libc/arch/powerpc/return_one.S
+++ b/contrib/netbsd-tests/lib/libc/arch/powerpc/return_one.S
@@ -1,10 +1,11 @@
-/* $NetBSD: return_one.S,v 1.2 2012/03/16 08:51:47 matt Exp $ */
+/* $NetBSD: return_one.S,v 1.3 2015/03/29 00:38:36 matt Exp $ */
#include <machine/asm.h>
-.globl return_one, return_one_end
+.globl return_one_start, return_one_end
_ENTRY(return_one)
+return_one_start:
li %r3, 1
blr
return_one_end:
diff --git a/contrib/netbsd-tests/lib/libc/arch/riscv/return_one.S b/contrib/netbsd-tests/lib/libc/arch/riscv/return_one.S
index 43ddd2c..d393fd1 100644
--- a/contrib/netbsd-tests/lib/libc/arch/riscv/return_one.S
+++ b/contrib/netbsd-tests/lib/libc/arch/riscv/return_one.S
@@ -1,11 +1,11 @@
-/* $NetBSD: return_one.S,v 1.1 2014/09/19 17:36:26 matt Exp $ */
+/* $NetBSD: return_one.S,v 1.2 2015/03/28 07:07:54 matt Exp $ */
#include <machine/asm.h>
.globl return_one_end
ENTRY_NP(return_one)
- li v0, 1
+ li a0, 1
ret
return_one_end:
END(return_one)
diff --git a/contrib/netbsd-tests/lib/libc/db/h_lfsr.c b/contrib/netbsd-tests/lib/libc/db/h_lfsr.c
new file mode 100644
index 0000000..3f3d712
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/db/h_lfsr.c
@@ -0,0 +1,179 @@
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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: h_lfsr.c,v 1.1 2015/11/18 18:35:35 christos Exp $");
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <err.h>
+#include <string.h>
+#include <unistd.h>
+#include <db.h>
+
+#define MAXKEY 0xffff
+#ifdef DEBUG
+#define DPRINTF(...) printf(__VA_ARGS__)
+#else
+#define DPRINTF(...)
+#endif
+
+static uint16_t
+next(uint16_t *cur)
+{
+ uint16_t lsb = *cur & 1;
+ *cur >>= 1;
+ *cur ^= (-lsb) & 0xB400u;
+ return *cur;
+}
+
+int
+main(int argc, char *argv[])
+{
+ char buf[65536];
+ char kb[256];
+ DBT key, val;
+ DB *db;
+ HASHINFO hi;
+ uint8_t c;
+ uint16_t len;
+ uint32_t pagesize = atoi(argv[1]);
+
+ memset(&hi, 0, sizeof(hi));
+ memset(buf, 'a', sizeof(buf));
+ hi.bsize = pagesize;
+ hi.nelem = 65536;
+ hi.ffactor = 128;
+
+ key.data = kb;
+ val.data = buf;
+
+ db = dbopen(NULL, O_CREAT|O_TRUNC|O_RDWR, 0, DB_HASH, &hi);
+ if (db == NULL)
+ err(EXIT_FAILURE, "dbopen");
+
+ len = 0xaec1;
+ for (size_t i = 0; i < MAXKEY; i++) {
+ key.size = (len & 0xff) + 1;
+ c = len >> 8;
+ memset(kb, c, key.size);
+ val.size = (next(&len) & 0xff) + 1;
+ switch ((*db->put)(db, &key, &val, R_NOOVERWRITE)) {
+ case 0:
+ DPRINTF("put %zu %zu %#x\n",
+ key.size, val.size, c);
+ break;
+ case -1:
+ err(EXIT_FAILURE, "put error %zu %zu %#x",
+ key.size, val.size, c);
+ case 1:
+ errx(EXIT_FAILURE, "put overwrite %zu %zu %#x",
+ key.size, val.size, c);
+ default:
+ abort();
+ }
+ }
+
+ len = 0xaec1;
+ for (size_t i = 0; i < MAXKEY; i++) {
+ key.size = (len & 0xff) + 1;
+ c = len >> 8;
+ memset(kb, c, key.size);
+ next(&len);
+ switch ((*db->get)(db, &key, &val, 0)) {
+ case 0:
+ DPRINTF("get %zu %zu %#x\n",
+ key.size, val.size, c);
+ break;
+ case -1:
+ err(EXIT_FAILURE, "get %zu %zu %#x",
+ key.size, val.size, c);
+ case 1:
+ errx(EXIT_FAILURE, "get not found %zu %zu %#x",
+ key.size, val.size, c);
+ default:
+ abort();
+ }
+ if (memcmp(key.data, kb, key.size) != 0)
+ errx(EXIT_FAILURE, "get badkey %zu %zu %#x",
+ key.size, val.size, c);
+ if (val.size != (len & 0xff) + 1U)
+ errx(EXIT_FAILURE, "get badvallen %zu %zu %#x",
+ key.size, val.size, c);
+ if (memcmp(val.data, buf, val.size) != 0)
+ errx(EXIT_FAILURE, "get badval %zu %zu %#x",
+ key.size, val.size, c);
+ }
+
+ len = 0xaec1;
+ for (size_t i = 0; i < MAXKEY; i++) {
+ key.size = (len & 0xff) + 1;
+ c = len >> 8;
+ memset(kb, c, key.size);
+ next(&len);
+ switch ((*db->del)(db, &key, 0)) {
+ case 0:
+ DPRINTF("del %zu %zu %#x\n",
+ key.size, val.size, c);
+ break;
+ case -1:
+ err(EXIT_FAILURE, "del %zu %zu %#x", key.size,
+ val.size, c);
+ case 1:
+ errx(EXIT_FAILURE, "del not found %zu %zu %#x",
+ key.size, val.size, c);
+ default:
+ abort();
+ }
+ }
+
+ len = 0xaec1;
+ for (size_t i = 0; i < MAXKEY; i++) {
+ key.size = (len & 0xff) + 1;
+ c = len >> 8;
+ memset(kb, c, key.size);
+ next(&len);
+ switch ((*db->get)(db, &key, &val, 0)) {
+ case 0:
+ errx(EXIT_FAILURE, "get2 found %zu %zu %#x",
+ key.size, val.size, c);
+ break;
+ case -1:
+ err(EXIT_FAILURE, "get2 %zu %zu %#x",
+ key.size, val.size, c);
+ case 1:
+ DPRINTF("get2 %zu %zu %#x\n",
+ key.size, val.size, c);
+ break;
+ default:
+ abort();
+ }
+ }
+ return 0;
+}
diff --git a/contrib/netbsd-tests/lib/libc/db/t_db.sh b/contrib/netbsd-tests/lib/libc/db/t_db.sh
index 4f45ec1..eb6b8c9 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.4 2013/07/29 10:43:15 skrll Exp $
+# $NetBSD: t_db.sh,v 1.6 2015/11/18 18:35:35 christos Exp $
#
# Copyright (c) 2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -25,11 +25,16 @@
# POSSIBILITY OF SUCH DAMAGE.
#
-prog()
+prog_db()
{
echo $(atf_get_srcdir)/h_db
}
+prog_lfsr()
+{
+ echo $(atf_get_srcdir)/h_lfsr
+}
+
dict()
{
if [ -f /usr/share/dict/words ]; then
@@ -77,7 +82,7 @@ small_btree_body()
echo k$i
done >in
- atf_check -o file:exp "$(prog)" btree in
+ atf_check -o file:exp "$(prog_db)" btree in
}
atf_test_case small_hash
@@ -106,7 +111,7 @@ small_hash_body()
echo k$i
done >in
- atf_check -o file:exp "$(prog)" hash in
+ atf_check -o file:exp "$(prog_db)" hash in
}
atf_test_case small_recno
@@ -133,7 +138,7 @@ small_recno_body()
printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
}' >in
- atf_check -o file:exp "$(prog)" recno in
+ atf_check -o file:exp "$(prog_db)" recno in
}
atf_test_case medium_btree
@@ -164,7 +169,7 @@ medium_btree_body()
echo k$i
done >in
- atf_check -o file:exp "$(prog)" btree in
+ atf_check -o file:exp "$(prog_db)" btree in
}
atf_test_case medium_hash
@@ -195,7 +200,7 @@ medium_hash_body()
echo k$i
done >in
- atf_check -o file:exp "$(prog)" hash in
+ atf_check -o file:exp "$(prog_db)" hash in
}
atf_test_case medium_recno
@@ -220,7 +225,7 @@ medium_recno_body()
printf("p\nk%d\nd%s\ng\nk%d\n", i, $0, i);
}' >in
- atf_check -o file:exp "$(prog)" recno in
+ atf_check -o file:exp "$(prog_db)" recno in
}
atf_test_case big_btree
@@ -249,7 +254,7 @@ big_btree_body()
echo k$i
done >in
- atf_check "$(prog)" -o out btree in
+ atf_check "$(prog_db)" -o out btree in
cmp -s exp out || atf_fail "test failed for page size: $psize"
done
}
@@ -277,7 +282,7 @@ big_hash_body()
echo k$i
done >in
- atf_check "$(prog)" -o out hash in
+ atf_check "$(prog_db)" -o out hash in
cmp -s exp out || atf_fail "test failed"
}
@@ -305,7 +310,7 @@ big_recno_body()
for psize in 512 16384 65536; do
echo "checking page size: $psize"
- atf_check "$(prog)" -o out recno in
+ atf_check "$(prog_db)" -o out recno in
cmp -s exp out || atf_fail "test failed for page size: $psize"
done
}
@@ -373,7 +378,7 @@ random_recno_body()
printf("g\nk%d\n", i);
}' >in
- atf_check -o file:exp "$(prog)" recno in
+ atf_check -o file:exp "$(prog_db)" recno in
}
atf_test_case reverse_recno
@@ -411,7 +416,7 @@ reverse_recno_body()
printf("g\nk%d\n", i);
}' >in
- atf_check -o file:exp "$(prog)" recno in
+ atf_check -o file:exp "$(prog_db)" recno in
}
atf_test_case alternate_recno
@@ -463,7 +468,7 @@ alternate_recno_body()
printf("g\nk%d\n", i);
}' >in
- atf_check "$(prog)" -o out recno in
+ atf_check "$(prog_db)" -o out recno in
sort -o exp exp
sort -o out out
@@ -532,7 +537,7 @@ h_delete()
}' >> exp
fi
- atf_check "$(prog)" -o out $type in
+ atf_check "$(prog_db)" -o out $type in
atf_check -o file:exp cat out
}
@@ -576,7 +581,7 @@ h_repeated()
}
}' >in
- $(prog) btree in
+ $(prog_db) btree in
}
atf_test_case repeated_btree
@@ -631,7 +636,7 @@ duplicate_btree_body()
printf("o\n");
}' >in
- atf_check -o file:exp -x "$(prog) -iflags=1 btree in | sort"
+ atf_check -o file:exp -x "$(prog_db) -iflags=1 btree in | sort"
}
h_cursor_flags()
@@ -660,7 +665,7 @@ h_cursor_flags()
printf("eR_CURSOR SHOULD HAVE FAILED\n");
}' >in
- atf_check -o ignore -e ignore -s ne:0 "$(prog)" -o out $type in
+ atf_check -o ignore -e ignore -s ne:0 "$(prog_db)" -o out $type in
atf_check -s ne:0 test -s out
cat exp |
@@ -674,7 +679,7 @@ h_cursor_flags()
printf("eR_CURSOR SHOULD HAVE FAILED\n");
}' >in
- atf_check -o ignore -e ignore -s ne:0 "$(prog)" -o out $type in
+ atf_check -o ignore -e ignore -s ne:0 "$(prog_db)" -o out $type in
atf_check -s ne:0 test -s out
}
@@ -730,7 +735,7 @@ reverse_order_recno_body()
printf("or\n");
}' >in
- atf_check -o file:exp "$(prog)" recno in
+ atf_check -o file:exp "$(prog_db)" recno in
}
atf_test_case small_page_btree
@@ -763,7 +768,7 @@ small_page_btree_body()
echo k$i
done >in
- atf_check -o file:exp "$(prog)" -i psize=512 btree in
+ atf_check -o file:exp "$(prog_db)" -i psize=512 btree in
}
h_byte_orders()
@@ -783,14 +788,14 @@ h_byte_orders()
echo k$i
done >in
- atf_check -o file:exp "$(prog)" -ilorder=$order -f byte.file $type in
+ atf_check -o file:exp "$(prog_db)" -ilorder=$order -f byte.file $type in
for i in `sed 50q $(dict)`; do
echo g
echo k$i
done >in
- atf_check -o file:exp "$(prog)" -s -ilorder=$order -f byte.file $type in
+ atf_check -o file:exp "$(prog_db)" -s -ilorder=$order -f byte.file $type in
done
}
@@ -823,14 +828,14 @@ h_bsize_ffactor()
ffactor=$2
echo "bucketsize $bsize, fill factor $ffactor"
- atf_check -o file:exp "$(prog)" "-ibsize=$bsize,\
+ atf_check -o file:exp "$(prog_db)" "-ibsize=$bsize,\
ffactor=$ffactor,nelem=25000,cachesize=65536" hash in
}
atf_test_case bsize_ffactor
bsize_ffactor_head()
{
- atf_set "timeout" "480"
+ atf_set "timeout" "1800"
atf_set "descr" "Checks hash database with various" \
"bucketsizes and fill factors"
# Begin FreeBSD
@@ -896,9 +901,27 @@ bsize_ffactor_body()
h_bsize_ffactor 8192 341
h_bsize_ffactor 8192 455
h_bsize_ffactor 8192 683
+
+ h_bsize_ffactor 16384 341
+ h_bsize_ffactor 16384 455
+ h_bsize_ffactor 16384 683
+
+ h_bsize_ffactor 32768 341
+ h_bsize_ffactor 32768 455
+ h_bsize_ffactor 32768 683
+
+ # Begin FreeBSD
+ if false; then
+ # End FreeBSD
+ h_bsize_ffactor 65536 341
+ h_bsize_ffactor 65536 455
+ h_bsize_ffactor 65536 683
+ # Begin FreeBSD
+ fi
+ # End FreeBSD
}
-# FIXME: what does it test?
+# This tests 64K block size addition/removal
atf_test_case four_char_hash
four_char_hash_head()
{
@@ -921,15 +944,36 @@ EOF
# Begin FreeBSD
if true; then
- atf_check "$(prog)" -i bsize=32768 hash in
+ atf_check "$(prog_db)" -i bsize=32768 hash in
else
# End FreeBSD
- atf_check "$(prog)" -i bsize=65536 hash in
+ atf_check "$(prog_db)" -i bsize=65536 hash in
# Begin FreeBSD
fi
# End FreeBSD
}
+
+atf_test_case bsize_torture
+bsize_torture_head()
+{
+ atf_set "timeout" "36000"
+ atf_set "descr" "Checks hash database with various bucket sizes"
+}
+bsize_torture_body()
+{
+ TMPDIR="$(pwd)/db_dir"; export TMPDIR
+ mkdir ${TMPDIR}
+ # Begin FreeBSD
+ #
+ # db(3) doesn't support 64kB bucket sizes
+ for i in 2048 4096 8192 16384 32768 # 65536
+ # End FreeBSD
+ do
+ atf_check "$(prog_lfsr)" $i
+ done
+}
+
atf_init_test_cases()
{
atf_add_test_case small_btree
@@ -957,4 +1001,5 @@ atf_init_test_cases()
atf_add_test_case byte_orders_hash
atf_add_test_case bsize_ffactor
atf_add_test_case four_char_hash
+ atf_add_test_case bsize_torture
}
diff --git a/contrib/netbsd-tests/lib/libc/db/t_db_hash_seq.c b/contrib/netbsd-tests/lib/libc/db/t_db_hash_seq.c
new file mode 100644
index 0000000..6e19e22
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/db/t_db_hash_seq.c
@@ -0,0 +1,343 @@
+/* $NetBSD: t_db_hash_seq.c,v 1.2 2015/06/22 22:35:51 christos Exp $ */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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_db_hash_seq.c,v 1.2 2015/06/22 22:35:51 christos Exp $");
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <db.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <syslog.h>
+#include <netinet/in.h>
+
+#define ATF
+
+struct conf {
+ struct sockaddr_storage c_ss;
+ int c_lmask;
+ int c_port;
+ int c_proto;
+ int c_family;
+ int c_uid;
+ int c_nfail;
+ char c_name[128];
+ int c_rmask;
+ int c_duration;
+};
+
+struct dbinfo {
+ int count;
+ time_t last;
+ char id[64];
+};
+
+#ifdef ATF
+#include <atf-c.h>
+
+#define DO_ERR(msg, ...) ATF_REQUIRE_MSG(0, msg, __VA_ARGS__)
+#define DO_WARNX(msg, ...) ATF_REQUIRE_MSG(0, msg, __VA_ARGS__)
+#else
+#include <err.h>
+
+#define DO_ERR(fmt, ...) err(EXIT_FAILURE, fmt, __VA_ARGS__)
+#define DO_WARNX(fmt, ...) warnx(fmt, __VA_ARGS__)
+#endif
+
+#define DO_DEBUG(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
+
+static HASHINFO openinfo = {
+ 4096, /* bsize */
+ 32, /* ffactor */
+ 256, /* nelem */
+ 8 * 1024 * 1024,/* cachesize */
+ NULL, /* hash() */
+ 0 /* lorder */
+};
+
+static int debug = 0;
+
+static int
+state_close(DB *db)
+{
+ if (db == NULL)
+ return -1;
+ if ((*db->close)(db) == -1)
+ DO_ERR("%s: can't close db", __func__);
+ return 0;
+}
+
+static DB *
+state_open(const char *dbname, int flags, mode_t perm)
+{
+ DB *db;
+
+ db = dbopen(dbname, flags, perm, DB_HASH, &openinfo);
+ if (db == NULL) {
+ if (errno == ENOENT && (flags & O_CREAT) == 0)
+ return NULL;
+ DO_ERR("%s: can't open `%s'", __func__, dbname);
+ }
+ return db;
+}
+
+static int
+state_sizecheck(const DBT *t)
+{
+ if (sizeof(struct conf) == t->size)
+ return 0;
+ DO_WARNX("Key size mismatch %zu != %zu", sizeof(struct conf), t->size);
+ return 0;
+}
+
+static int
+state_del(DB *db, const struct conf *c)
+{
+ int rv;
+ DBT k;
+
+ if (db == NULL)
+ return -1;
+
+ k.data = __UNCONST(c);
+ k.size = sizeof(*c);
+
+ switch (rv = (*db->del)(db, &k, 1)) {
+ case 0:
+ case 1:
+ if (debug > 1) {
+ DO_DEBUG("%s: returns %d", __func__, rv);
+ (*db->sync)(db, 0);
+ }
+ return 0;
+ default:
+ DO_ERR("%s: failed", __func__);
+ return -1;
+ }
+}
+
+#if 0
+static int
+state_get(DB *db, const struct conf *c, struct dbinfo *dbi)
+{
+ int rv;
+ DBT k, v;
+
+ if (db == NULL)
+ return -1;
+
+ k.data = __UNCONST(c);
+ k.size = sizeof(*c);
+
+ switch (rv = (*db->get)(db, &k, &v, 0)) {
+ case 0:
+ case 1:
+ if (rv)
+ memset(dbi, 0, sizeof(*dbi));
+ else
+ memcpy(dbi, v.data, sizeof(*dbi));
+ if (debug > 1)
+ DO_DEBUG("%s: returns %d", __func__, rv);
+ return 0;
+ default:
+ DO_ERR("%s: failed", __func__);
+ return -1;
+ }
+}
+#endif
+
+static int
+state_put(DB *db, const struct conf *c, const struct dbinfo *dbi)
+{
+ int rv;
+ DBT k, v;
+
+ if (db == NULL)
+ return -1;
+
+ k.data = __UNCONST(c);
+ k.size = sizeof(*c);
+ v.data = __UNCONST(dbi);
+ v.size = sizeof(*dbi);
+
+ switch (rv = (*db->put)(db, &k, &v, 0)) {
+ case 0:
+ if (debug > 1) {
+ DO_DEBUG("%s: returns %d", __func__, rv);
+ (*db->sync)(db, 0);
+ }
+ return 0;
+ case 1:
+ errno = EEXIST;
+ /*FALLTHROUGH*/
+ default:
+ DO_ERR("%s: failed", __func__);
+ }
+}
+
+static int
+state_iterate(DB *db, struct conf *c, struct dbinfo *dbi, unsigned int first)
+{
+ int rv;
+ DBT k, v;
+
+ if (db == NULL)
+ return -1;
+
+ first = first ? R_FIRST : R_NEXT;
+
+ switch (rv = (*db->seq)(db, &k, &v, first)) {
+ case 0:
+ if (state_sizecheck(&k) == -1)
+ return -1;
+ memcpy(c, k.data, sizeof(*c));
+ memcpy(dbi, v.data, sizeof(*dbi));
+ if (debug > 1)
+ DO_DEBUG("%s: returns %d", __func__, rv);
+ return 1;
+ case 1:
+ if (debug > 1)
+ DO_DEBUG("%s: returns %d", __func__, rv);
+ return 0;
+ default:
+ DO_ERR("%s: failed", __func__);
+ return -1;
+ }
+}
+
+#define MAXB 100
+
+static int
+testdb(int skip)
+{
+ size_t i;
+ int f;
+ char flag[MAXB];
+ DB *db;
+ struct conf c;
+ struct dbinfo d;
+
+ db = state_open(NULL, O_RDWR|O_CREAT|O_TRUNC, 0600);
+ if (db == NULL)
+ DO_ERR("%s: cannot open `%s'", __func__, "foo");
+
+ memset(&c, 0, sizeof(c));
+ memset(&d, 0, sizeof(d));
+ memset(flag, 0, sizeof(flag));
+
+ for (i = 0; i < __arraycount(flag); i++) {
+ c.c_port = i;
+ state_put(db, &c, &d);
+ }
+
+ for (f = 1, i = 0; state_iterate(db, &c, &d, f) == 1; f = 0, i++) {
+ if (debug > 1)
+ DO_DEBUG("%zu %d\n", i, c.c_port);
+ if (flag[c.c_port])
+ DO_WARNX("Already visited %d", c.c_port);
+ flag[c.c_port] = 1;
+ if (skip == 0 || c.c_port % skip != 0)
+ continue;
+ state_del(db, &c);
+ }
+ state_close(db);
+ for (i = 0; i < __arraycount(flag); i++) {
+ if (flag[i] == 0)
+ DO_WARNX("Not visited %zu", i);
+ }
+ return 0;
+}
+
+#ifndef ATF
+int
+main(int argc, char *argv[])
+{
+ return testdb(6);
+}
+#else
+
+ATF_TC(test_hash_del_none);
+ATF_TC_HEAD(test_hash_del_none, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check sequential scan of hash tables deleting none");
+}
+
+ATF_TC_BODY(test_hash_del_none, tc)
+{
+ testdb(0);
+}
+
+ATF_TC(test_hash_del_all);
+ATF_TC_HEAD(test_hash_del_all, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check sequential scan of hash tables deleting all");
+}
+
+ATF_TC_BODY(test_hash_del_all, tc)
+{
+ testdb(1);
+}
+
+ATF_TC(test_hash_del_alt);
+ATF_TC_HEAD(test_hash_del_alt, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check sequential scan of hash tables alternating deletets");
+}
+
+ATF_TC_BODY(test_hash_del_alt, tc)
+{
+ testdb(2);
+}
+
+ATF_TC(test_hash_del_every_7);
+ATF_TC_HEAD(test_hash_del_every_7, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Check sequential scan of hash tables deleting every 7 elements");
+}
+
+ATF_TC_BODY(test_hash_del_every_7, tc)
+{
+ testdb(7);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, test_hash_del_none);
+ ATF_TP_ADD_TC(tp, test_hash_del_all);
+ ATF_TP_ADD_TC(tp, test_hash_del_alt);
+ ATF_TP_ADD_TC(tp, test_hash_del_every_7);
+
+ return 0;
+}
+#endif
diff --git a/contrib/netbsd-tests/lib/libc/gen/execve/t_execve.c b/contrib/netbsd-tests/lib/libc/gen/execve/t_execve.c
index 32de6e7..d3752cd 100644
--- a/contrib/netbsd-tests/lib/libc/gen/execve/t_execve.c
+++ b/contrib/netbsd-tests/lib/libc/gen/execve/t_execve.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_execve.c,v 1.1 2014/04/29 06:29:02 uebayasi Exp $ */
+/* $NetBSD: t_execve.c,v 1.2 2015/09/12 15:21:33 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -47,7 +47,8 @@ ATF_TC_BODY(t_execve_null, tc)
err = execve(NULL, NULL, NULL);
ATF_REQUIRE(err == -1);
- ATF_REQUIRE(errno == EFAULT);
+ ATF_REQUIRE_MSG(errno == EFAULT,
+ "wrong error returned %d instead of %d", errno, EFAULT);
}
ATF_TP_ADD_TCS(tp)
diff --git a/contrib/netbsd-tests/lib/libc/gen/isqemu.h b/contrib/netbsd-tests/lib/libc/gen/isqemu.h
index 7d73a22..c44ffda 100644
--- a/contrib/netbsd-tests/lib/libc/gen/isqemu.h
+++ b/contrib/netbsd-tests/lib/libc/gen/isqemu.h
@@ -1,4 +1,4 @@
-/* $NetBSD: isqemu.h,v 1.3 2013/04/14 12:46:29 martin Exp $ */
+/* $NetBSD: isqemu.h,v 1.4 2015/01/03 14:21:05 gson Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,12 +34,37 @@
#include <sys/param.h>
#include <sys/sysctl.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <err.h>
static __inline bool
isQEMU(void) {
+#ifdef __FreeBSD__
+ char *vm_guest_name_buf;
+ size_t len;
+ bool is_vm;
+
+ if (sysctlbyname("kern.vm_guest", NULL, &len, NULL, 0) == -1)
+ err(EXIT_FAILURE, "sysctl");
+
+ if ((vm_guest_name_buf = malloc(len)) == NULL)
+ err(EXIT_FAILURE, "malloc");
+
+ if (sysctlbyname("kern.vm_guest", vm_guest_name_buf, &len, NULL, 0)
+ == -1)
+ err(EXIT_FAILURE, "sysctl");
+
+ if (strcmp(vm_guest_name_buf, "none") == 0)
+ is_vm = false;
+ else
+ is_vm = true;
+
+ free(vm_guest_name_buf);
+
+ return is_vm;
+#else
#if defined(__i386__) || defined(__x86_64__)
char name[1024];
size_t len = sizeof(name);
@@ -53,6 +78,7 @@ isQEMU(void) {
#else
return false;
#endif
+#endif
}
#ifdef TEST
diff --git a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c
index 178374b..12f2760 100644
--- a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c
+++ b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_spawn.c,v 1.1 2012/02/13 21:03:08 martin Exp $ */
+/* $NetBSD: t_spawn.c,v 1.2 2014/10/18 08:33:30 snj Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -137,7 +137,7 @@ ATF_TC(t_spawn_child);
ATF_TC_HEAD(t_spawn_child, tc)
{
atf_tc_set_md_var(tc, "descr",
- "posix_spawn a child and get it's return code");
+ "posix_spawn a child and get its return code");
}
ATF_TC_BODY(t_spawn_child, tc)
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c b/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c
index f90d8cf..c0064c3 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.3 2012/04/08 09:58:59 jruoho Exp $ */
+/* $NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos 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.3 2012/04/08 09:58:59 jruoho Exp $");
+__RCSID("$NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos Exp $");
#include <atf-c.h>
#include <fnmatch.h>
@@ -153,6 +153,30 @@ ATF_TC_BODY(fnmatch_period, tc)
ATF_CHECK(fnmatch("x/*y", "x/.y", FNM_PATHNAME | FNM_PERIOD) != 0);
}
+ATF_TC(fnmatch_initialbracket);
+ATF_TC_HEAD(fnmatch_initialbracket, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test fnmatch with initial [");
+}
+
+ATF_TC_BODY(fnmatch_initialbracket, tc)
+{
+ ATF_CHECK(fnmatch("[[?*\\\\]", "\\", 0) == 0);
+ ATF_CHECK(fnmatch("[]?*\\\\]", "]", 0) == 0);
+ ATF_CHECK(fnmatch("[!]a-]", "b", 0) == 0);
+ ATF_CHECK(fnmatch("[]-_]", "^", 0) == 0); /* range: ']', '^', '_' */
+ ATF_CHECK(fnmatch("[!]-_]", "X", 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);
+ ATF_CHECK(fnmatch("[[a]/b", "a/b", 0) == 0);
+ ATF_CHECK(fnmatch("[[a]/b", "[/b", 0) == 0);
+ ATF_CHECK(fnmatch("[/b", "[/b", 0) == 0);
+
+ ATF_CHECK(fnmatch("[*]/b", "a/b", 0) != 0);
+ ATF_CHECK(fnmatch("[?]/b", "a/b", 0) != 0);
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -162,6 +186,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, fnmatch_noescape);
ATF_TP_ADD_TC(tp, fnmatch_pathname);
ATF_TP_ADD_TC(tp, fnmatch_period);
+ ATF_TP_ADD_TC(tp, fnmatch_initialbracket);
return atf_no_error();
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c b/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c
index 3366c1f..5edc583 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fpsetmask.c,v 1.14 2014/11/04 00:20:19 justin Exp $ */
+/* $NetBSD: t_fpsetmask.c,v 1.16 2016/03/12 11:55:14 martin Exp $ */
/*-
* Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -58,8 +58,20 @@ ATF_TC_BODY(no_test, tc)
#include <ieeefp.h>
-const char *skip_mesg;
-const char *skip_arch;
+#if __arm__ && !__SOFTFP__
+ /*
+ * Some NEON fpus do not implement IEEE exception handling,
+ * skip these tests if running on them and compiled for
+ * hard float.
+ */
+#define FPU_PREREQ() \
+ if (0 == fpsetmask(fpsetmask(FP_X_INV))) \
+ atf_tc_skip("FPU does not implement exception handling");
+#endif
+
+#ifndef FPU_PREREQ
+#define FPU_PREREQ() /* nothing */
+#endif
void sigfpe(int, siginfo_t *, void *);
@@ -296,6 +308,9 @@ sigfpe(int s, siginfo_t *si, void *c)
\
ATF_TC_BODY(m##_##t, tc) \
{ \
+ \
+ FPU_PREREQ(); \
+ \
if (strcmp(MACHINE, "macppc") == 0) \
atf_tc_expect_fail("PR port-macppc/46319"); \
\
@@ -323,11 +338,13 @@ ATF_TC_BODY(fpsetmask_basic, tc)
size_t i;
fp_except_t msk, lst[] = { FP_X_INV, FP_X_DZ, FP_X_OFL, FP_X_UFL };
+ FPU_PREREQ();
+
msk = fpgetmask();
for (i = 0; i < __arraycount(lst); i++) {
fpsetmask(msk | lst[i]);
ATF_CHECK((fpgetmask() & lst[i]) != 0);
- fpsetmask(msk & lst[i]);
+ fpsetmask(msk & ~lst[i]);
ATF_CHECK((fpgetmask() & lst[i]) == 0);
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_randomid.c b/contrib/netbsd-tests/lib/libc/gen/t_randomid.c
index 8377806..9ab2cca 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_randomid.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_randomid.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_randomid.c,v 1.3 2011/07/07 09:49:59 jruoho Exp $ */
+/* $NetBSD: t_randomid.c,v 1.5 2015/03/07 09:59:15 isaki Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#define PERIOD 30000
-uint64_t last[65536];
+uint32_t last[65536];
ATF_TC(randomid_basic);
ATF_TC_HEAD(randomid_basic, tc)
@@ -50,30 +50,30 @@ ATF_TC_HEAD(randomid_basic, tc)
ATF_TC_BODY(randomid_basic, tc)
{
static randomid_t ctx = NULL;
- uint64_t lowest, n, diff;
+ uint32_t lowest, n, diff;
uint16_t id;
memset(last, 0, sizeof(last));
ctx = randomid_new(16, (long)3600);
- lowest = UINT64_MAX;
+ lowest = UINT32_MAX;
- for (n = 0; n < 1000000; n++) {
+ for (n = 0; n < 100000; n++) {
id = randomid(ctx);
if (last[id] > 0) {
diff = n - last[id];
if (diff <= lowest) {
- if (lowest != UINT64_MAX)
- printf("id %5d: last call at %9"PRIu64
- ", current call %9"PRIu64
- " (diff %5"PRIu64"), "
- "lowest %"PRIu64"\n",
+ if (lowest != UINT32_MAX)
+ printf("id %5d: last call at %9"PRIu32
+ ", current call %9"PRIu32
+ " (diff %5"PRIu32"), "
+ "lowest %"PRIu32"\n",
id, last[id], n, diff, lowest);
ATF_REQUIRE_MSG(diff >= PERIOD,
- "diff (%"PRIu64") less than minimum "
+ "diff (%"PRIu32") less than minimum "
"period (%d)", diff, PERIOD);
lowest = diff;
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_siginfo.c b/contrib/netbsd-tests/lib/libc/gen/t_siginfo.c
index 9c9a3c7..64f72ac 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_siginfo.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_siginfo.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.24 2014/11/04 00:20:19 justin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.30 2015/12/22 14:25:58 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -46,8 +46,9 @@
#include <setjmp.h>
#include <float.h>
-#ifdef HAVE_FENV
#include <fenv.h>
+#ifdef __HAVE_FENV
+#include <ieeefp.h> /* only need for ARM Cortex/Neon hack */
#elif defined(_FLOAT_IEEE754)
#include <ieeefp.h>
#endif
@@ -316,13 +317,21 @@ ATF_TC_BODY(sigfpe_flt, tc)
atf_tc_skip("Test does not run correctly under QEMU");
#if defined(__powerpc__)
atf_tc_skip("Test not valid on powerpc");
+#elif defined(__arm__) && !__SOFTFP__
+ /*
+ * Some NEON fpus do not implement IEEE exception handling,
+ * skip these tests if running on them and compiled for
+ * hard float.
+ */
+ if (0 == fpsetmask(fpsetmask(FP_X_INV)))
+ atf_tc_skip("FPU does not implement exception handling");
#endif
if (sigsetjmp(sigfpe_flt_env, 0) == 0) {
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = sigfpe_flt_action;
sigemptyset(&sa.sa_mask);
sigaction(SIGFPE, &sa, NULL);
-#ifdef HAVE_FENV
+#ifdef __HAVE_FENV
feenableexcept(FE_ALL_EXCEPT);
#elif defined(_FLOAT_IEEE754)
fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
@@ -373,7 +382,7 @@ ATF_TC_BODY(sigfpe_int, tc)
sa.sa_sigaction = sigfpe_int_action;
sigemptyset(&sa.sa_mask);
sigaction(SIGFPE, &sa, NULL);
-#ifdef HAVE_FENV
+#ifdef __HAVE_FENV
feenableexcept(FE_ALL_EXCEPT);
#elif defined(_FLOAT_IEEE754)
fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
@@ -454,15 +463,19 @@ ATF_TC_BODY(sigbus_adraln, tc)
{
struct sigaction sa;
-#if defined(__alpha__)
+#if defined(__alpha__) || defined(__arm__)
int rv, val;
size_t len = sizeof(val);
rv = sysctlbyname("machdep.unaligned_sigbus", &val, &len, NULL, 0);
ATF_REQUIRE(rv == 0);
if (val == 0)
- atf_tc_skip("SIGBUS signal not enabled for unaligned accesses");
+ atf_tc_skip("No SIGBUS signal for unaligned accesses");
#endif
+ /* m68k (except sun2) never issue SIGBUS (PR lib/49653) */
+ if (strcmp(MACHINE_ARCH, "m68k") == 0)
+ atf_tc_skip("No SIGBUS signal for unaligned accesses");
+
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = sigbus_action;
sigemptyset(&sa.sa_mask);
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_sleep.c b/contrib/netbsd-tests/lib/libc/gen/t_sleep.c
index f722ec9..e89df69 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_sleep.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_sleep.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sleep.c,v 1.8 2014/07/15 14:56:34 gson Exp $ */
+/* $NetBSD: t_sleep.c,v 1.9 2016/08/11 21:34:11 kre Exp $ */
/*-
* Copyright (c) 2006 Frank Kardel
@@ -180,7 +180,8 @@ do_kevent(struct timespec *delay, struct timespec *remain)
(void)close(kq);
if (rtc == -1) {
- ATF_REQUIRE_MSG(kerrno == EINTR, "kevent: %s", strerror(errno));
+ ATF_REQUIRE_MSG(kerrno == EINTR, "kevent: %s",
+ strerror(kerrno));
return 0;
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_time.c b/contrib/netbsd-tests/lib/libc/gen/t_time.c
index 790f3ca..2905403 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_time.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_time.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_time.c,v 1.2 2011/11/11 05:03:38 jruoho Exp $ */
+/* $NetBSD: t_time.c,v 1.3 2014/10/31 12:22:38 justin Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_time.c,v 1.2 2011/11/11 05:03:38 jruoho Exp $");
+__RCSID("$NetBSD: t_time.c,v 1.3 2014/10/31 12:22:38 justin Exp $");
#ifdef __FreeBSD__
#include <sys/time.h>
@@ -94,15 +94,16 @@ ATF_TC_HEAD(time_timeofday, tc)
ATF_TC_BODY(time_timeofday, tc)
{
struct timeval tv = { 0, 0 };
- time_t t;
+ time_t t1, t2;
- t = time(NULL);
+ t1 = time(NULL);
ATF_REQUIRE(gettimeofday(&tv, NULL) == 0);
+ t2 = time(NULL);
(void)fprintf(stderr, "%"PRId64" vs. %"PRId64"\n",
- (int64_t)t, (int64_t)tv.tv_sec);
+ (int64_t)t1, (int64_t)tv.tv_sec);
- if (t != tv.tv_sec)
+ if (t1 > tv.tv_sec || t2 < tv.tv_sec)
atf_tc_fail("time(3) and gettimeofday(2) differ");
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_vis.c b/contrib/netbsd-tests/lib/libc/gen/t_vis.c
index 525bafa..38decb3 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_vis.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_vis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_vis.c,v 1.7 2014/09/08 19:01:03 christos Exp $ */
+/* $NetBSD: t_vis.c,v 1.8 2015/05/23 14:02:11 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -32,6 +32,7 @@
#include <string.h>
#include <stdlib.h>
+#include <locale.h>
#include <err.h>
#include <vis.h>
@@ -143,6 +144,35 @@ ATF_TC_BODY(strunvis_hex, tc)
}
}
+ATF_TC(strvis_locale);
+ATF_TC_HEAD(strvis_locale, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test strvis(3) with locale");
+}
+
+ATF_TC_BODY(strvis_locale, tc)
+{
+ char s[256], cd[sizeof(s) * 4 + 1], jd[sizeof(cd)], *ol;
+ int jr, cr;
+
+ for (size_t i = 0; i < sizeof(s) - 1; i++)
+ s[i] = i + 1;
+ s[sizeof(s) - 1] = '\0';
+
+ ol = setlocale(LC_CTYPE, "ja_JP.UTF-8");
+ ATF_REQUIRE(ol != NULL);
+ jr = strvisx(jd, s, sizeof(s), VIS_WHITE | VIS_NOLOCALE);
+ ATF_REQUIRE(jr != -1);
+ ol = strdup(ol);
+ ATF_REQUIRE(ol != NULL);
+ ATF_REQUIRE(setlocale(LC_CTYPE, "C") != NULL);
+ cr = strvisx(cd, s, sizeof(s), VIS_WHITE);
+ ATF_REQUIRE(jr == cr);
+ ATF_REQUIRE(memcmp(jd, cd, jr) == 0);
+ setlocale(LC_CTYPE, ol);
+ free(ol);
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -150,6 +180,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, strvis_null);
ATF_TP_ADD_TC(tp, strvis_empty);
ATF_TP_ADD_TC(tp, strunvis_hex);
+ ATF_TP_ADD_TC(tp, strvis_locale);
return atf_no_error();
}
diff --git a/contrib/netbsd-tests/lib/libc/inet/t_inet_addr.c b/contrib/netbsd-tests/lib/libc/inet/t_inet_addr.c
new file mode 100644
index 0000000..d7547fd
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/inet/t_inet_addr.c
@@ -0,0 +1,109 @@
+/* $NetBSD: t_inet_addr.c,v 1.1 2015/04/09 16:47:56 ginsbach Exp $ */
+
+/*
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ *
+ * 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>
+__COPYRIGHT("@(#) Copyright (c) 2011\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_inet_addr.c,v 1.1 2015/04/09 16:47:56 ginsbach Exp $");
+
+#include <arpa/inet.h>
+
+#include <atf-c.h>
+#include <stdio.h>
+#include <string.h>
+
+ATF_TC(inet_addr_basic);
+ATF_TC_HEAD(inet_addr_basic, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks inet_addr(3)");
+}
+
+ATF_TC_BODY(inet_addr_basic, tc)
+{
+ static const char *addrs[] = {
+ "127.0.0.1", "99.99.99.99", "0.0.0.0", "255.255.255.255" };
+
+ struct in_addr ia;
+ const char *ian;
+ in_addr_t addr;
+ size_t i;
+
+ for (i = 0; i < __arraycount(addrs); i++) {
+
+ (void)fprintf(stderr, "checking %s\n", addrs[i]);;
+
+ addr = inet_addr(addrs[i]);
+ ia.s_addr = addr;
+ ian = inet_ntoa(ia);
+
+ ATF_REQUIRE(ian != NULL);
+ ATF_CHECK(strcmp(ian, addrs[i]) == 0);
+ }
+}
+
+ATF_TC(inet_addr_err);
+ATF_TC_HEAD(inet_addr_err, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Invalid addresses with inet_addr(3)");
+}
+
+ATF_TC_BODY(inet_addr_err, tc)
+{
+ static const char *addrs[] = {
+ ". . . .", "1.2.3.", "0.0.0.256", "255.255.255.256",
+ "................................................",
+ "a.b.c.d", "0x0.0x1.0x2.0x3", "-1.-1.-1.-1", "", " "};
+
+ struct in_addr ia;
+ const char *ian;
+ in_addr_t addr;
+ size_t i;
+
+ for (i = 0; i < __arraycount(addrs); i++) {
+
+ (void)fprintf(stderr, "checking %s\n", addrs[i]);;
+
+ addr = inet_addr(addrs[i]);
+ ia.s_addr = addr;
+ ian = inet_ntoa(ia);
+
+ ATF_REQUIRE(ian != NULL);
+ ATF_CHECK(strcmp(ian, addrs[i]) != 0);
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, inet_addr_basic);
+ ATF_TP_ADD_TC(tp, inet_addr_err);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/inet/t_inet_network.c b/contrib/netbsd-tests/lib/libc/inet/t_inet_network.c
index a6a6c62..c44fe11 100644
--- a/contrib/netbsd-tests/lib/libc/inet/t_inet_network.c
+++ b/contrib/netbsd-tests/lib/libc/inet/t_inet_network.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_inet_network.c,v 1.3 2011/07/15 11:27:23 jruoho Exp $ */
+/* $NetBSD: t_inet_network.c,v 1.4 2015/04/09 16:47:56 ginsbach Exp $ */
/*
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -32,79 +32,17 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_inet_network.c,v 1.3 2011/07/15 11:27:23 jruoho Exp $");
+__RCSID("$NetBSD: t_inet_network.c,v 1.4 2015/04/09 16:47:56 ginsbach Exp $");
#include <arpa/inet.h>
#include <atf-c.h>
-#include <stdio.h>
-#include <string.h>
#define H_REQUIRE(input, expected) \
ATF_REQUIRE_EQ_MSG(inet_network(input), (in_addr_t) expected, \
"inet_network(%s) returned: 0x%08X, expected: %s", #input, \
inet_network(input), #expected)
-ATF_TC(inet_addr_basic);
-ATF_TC_HEAD(inet_addr_basic, tc)
-{
- atf_tc_set_md_var(tc, "descr", "Checks inet_addr(3)");
-}
-
-ATF_TC_BODY(inet_addr_basic, tc)
-{
- static const char *addrs[] = {
- "127.0.0.1", "99.99.99.99", "0.0.0.0", "255.255.255.255" };
-
- struct in_addr ia;
- const char *ian;
- in_addr_t addr;
- size_t i;
-
- for (i = 0; i < __arraycount(addrs); i++) {
-
- (void)fprintf(stderr, "checking %s\n", addrs[i]);;
-
- addr = inet_addr(addrs[i]);
- ia.s_addr = addr;
- ian = inet_ntoa(ia);
-
- ATF_REQUIRE(ian != NULL);
- ATF_CHECK(strcmp(ian, addrs[i]) == 0);
- }
-}
-
-ATF_TC(inet_addr_err);
-ATF_TC_HEAD(inet_addr_err, tc)
-{
- atf_tc_set_md_var(tc, "descr", "Invalid addresses with inet_addr(3)");
-}
-
-ATF_TC_BODY(inet_addr_err, tc)
-{
- static const char *addrs[] = {
- ". . . .", "1.2.3.", "0.0.0.256", "255.255.255.256",
- "................................................",
- "a.b.c.d", "0x0.0x1.0x2.0x3", "-1.-1.-1.-1", "", " "};
-
- struct in_addr ia;
- const char *ian;
- in_addr_t addr;
- size_t i;
-
- for (i = 0; i < __arraycount(addrs); i++) {
-
- (void)fprintf(stderr, "checking %s\n", addrs[i]);;
-
- addr = inet_addr(addrs[i]);
- ia.s_addr = addr;
- ian = inet_ntoa(ia);
-
- ATF_REQUIRE(ian != NULL);
- ATF_CHECK(strcmp(ian, addrs[i]) != 0);
- }
-}
-
ATF_TC(inet_network_basic);
ATF_TC_HEAD(inet_network_basic, tc)
{
@@ -165,8 +103,6 @@ ATF_TC_BODY(inet_network_err, tc)
ATF_TP_ADD_TCS(tp)
{
- ATF_TP_ADD_TC(tp, inet_addr_basic);
- ATF_TP_ADD_TC(tp, inet_addr_err);
ATF_TP_ADD_TC(tp, inet_network_basic);
ATF_TP_ADD_TC(tp, inet_network_err);
diff --git a/contrib/netbsd-tests/lib/libc/net/t_servent.sh b/contrib/netbsd-tests/lib/libc/net/t_servent.sh
index 0979eb3..4c23f00 100755
--- a/contrib/netbsd-tests/lib/libc/net/t_servent.sh
+++ b/contrib/netbsd-tests/lib/libc/net/t_servent.sh
@@ -1,4 +1,4 @@
-# $NetBSD: t_servent.sh,v 1.1 2011/01/12 17:32:27 pgoyette Exp $
+# $NetBSD: t_servent.sh,v 1.2 2016/03/08 08:34:17 joerg Exp $
#
# Copyright (c) 2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -29,6 +29,8 @@ atf_test_case servent
servent_head()
{
atf_set "descr" "Checks {get,set,end}servent(3)"
+ # libc doesn't include aliases
+ atf_set "require.files" "/var/db/services.cdb"
}
servent_body()
{
diff --git a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
index a9715cf..72bda8d 100644
--- a/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
+++ b/contrib/netbsd-tests/lib/libc/rpc/t_rpc.c
@@ -1,18 +1,19 @@
-/* $NetBSD: t_rpc.c,v 1.3 2013/02/28 15:56:53 christos Exp $ */
+/* $NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $ */
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_rpc.c,v 1.3 2013/02/28 15:56:53 christos Exp $");
+__RCSID("$NetBSD: t_rpc.c,v 1.9 2015/11/27 13:59:40 christos Exp $");
#include <sys/types.h>
#include <sys/socket.h>
#include <rpc/rpc.h>
#include <stdlib.h>
+#include <string.h>
#include <err.h>
#include <netdb.h>
#include <stdio.h>
+#include <errno.h>
#include <unistd.h>
-
#ifndef TEST
#include <atf-c.h>
@@ -28,6 +29,12 @@ __RCSID("$NetBSD: t_rpc.c,v 1.3 2013/02/28 15:56:53 christos Exp $");
#define SKIPX(ev, msg, ...) errx(ev, msg, __VA_ARGS__)
#endif
+#ifdef DEBUG
+#define DPRINTF(...) printf(__VA_ARGS__)
+#else
+#define DPRINTF(...)
+#endif
+
#define RPCBPROC_NULL 0
@@ -51,7 +58,7 @@ reply(caddr_t replyp, struct netbuf * raddrp, struct netconfig * nconf)
#define __rpc_control rpc_control
#endif
-extern bool __rpc_control(int, void *);
+extern bool_t __rpc_control(int, void *);
static void
onehost(const char *host, const char *transp)
@@ -86,9 +93,140 @@ onehost(const char *host, const char *transp)
reply(NULL, &addr, NULL);
}
+#define PROGNUM 0x81
+#define VERSNUM 0x01
+#define PLUSONE 1
+#define DESTROY 2
+
+static struct timeval tout = {1, 0};
+
+static void
+server(struct svc_req *rqstp, SVCXPRT *transp)
+{
+ int num;
+
+ DPRINTF("Starting server\n");
+
+ switch (rqstp->rq_proc) {
+ case NULLPROC:
+ if (!svc_sendreply(transp, (xdrproc_t)xdr_void, NULL))
+ ERRX(EXIT_FAILURE, "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);
+ svc_destroy(transp);
+ exit(0);
+ default:
+ svcerr_noproc(transp);
+ return;
+ }
+
+ if (!svc_getargs(transp, (xdrproc_t)xdr_int, (void *)&num)) {
+ svcerr_decode(transp);
+ return;
+ }
+ DPRINTF("About to increment\n");
+ num++;
+ if (!svc_sendreply(transp, (xdrproc_t)xdr_int, (void *)&num))
+ ERRX(EXIT_FAILURE, "svc_sendreply failed %d", 1);
+ DPRINTF("Leaving server procedure.\n");
+}
+
+static int
+rawtest(const char *arg)
+{
+ CLIENT *clnt;
+ SVCXPRT *svc;
+ int num, resp;
+ enum clnt_stat rv;
+
+ if (arg)
+ num = atoi(arg);
+ else
+ num = 0;
+
+ svc = svc_raw_create();
+ if (svc == NULL)
+ ERRX(EXIT_FAILURE, "Cannot create server %d", num);
+ if (!svc_reg(svc, PROGNUM, VERSNUM, server, NULL))
+ ERRX(EXIT_FAILURE, "Cannot register server %d", num);
+
+ clnt = clnt_raw_create(PROGNUM, VERSNUM);
+ if (clnt == NULL)
+ ERRX(EXIT_FAILURE, "%s",
+ clnt_spcreateerror("clnt_raw_create"));
+ rv = clnt_call(clnt, PLUSONE, (xdrproc_t)xdr_int, (void *)&num,
+ (xdrproc_t)xdr_int, (void *)&resp, tout);
+ if (rv != RPC_SUCCESS)
+ ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv));
+ DPRINTF("Got %d\n", resp);
+ clnt_destroy(clnt);
+ svc_destroy(svc);
+ if (++num != resp)
+ ERRX(EXIT_FAILURE, "expected %d got %d", num, resp);
+
+ return EXIT_SUCCESS;
+}
+
+static int
+regtest(const char *hostname, const char *transp, const char *arg, int p)
+{
+ CLIENT *clnt;
+ int num, resp;
+ enum clnt_stat rv;
+ pid_t pid;
+
+ if (arg)
+ num = atoi(arg);
+ else
+ num = 0;
+
+#ifdef __NetBSD__
+ svc_fdset_init(p ? SVC_FDSET_POLL : 0);
+#endif
+ if (!svc_create(server, PROGNUM, VERSNUM, transp))
+ ERRX(EXIT_FAILURE, "Cannot create server %d", num);
+
+ switch ((pid = fork())) {
+ case 0:
+ DPRINTF("Calling svc_run\n");
+ svc_run();
+ ERRX(EXIT_FAILURE, "svc_run returned %d!", num);
+ case -1:
+ ERRX(EXIT_FAILURE, "Fork failed (%s)", strerror(errno));
+ default:
+ sleep(1);
+ break;
+ }
+
+ DPRINTF("Initializing client\n");
+ clnt = clnt_create(hostname, PROGNUM, VERSNUM, transp);
+ if (clnt == NULL)
+ ERRX(EXIT_FAILURE, "%s",
+ clnt_spcreateerror("clnt_raw_create"));
+ rv = clnt_call(clnt, PLUSONE, (xdrproc_t)xdr_int, (void *)&num,
+ (xdrproc_t)xdr_int, (void *)&resp, tout);
+ if (rv != RPC_SUCCESS)
+ ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv));
+ DPRINTF("Got %d\n", resp);
+ if (++num != resp)
+ ERRX(EXIT_FAILURE, "expected %d got %d", num, resp);
+ rv = clnt_call(clnt, DESTROY, (xdrproc_t)xdr_void, NULL,
+ (xdrproc_t)xdr_void, NULL, tout);
+ if (rv != RPC_SUCCESS)
+ ERRX(EXIT_FAILURE, "clnt_call: %s", clnt_sperrno(rv));
+ clnt_destroy(clnt);
+
+ return EXIT_SUCCESS;
+}
+
+
#ifdef TEST
static void
-allhosts(void)
+allhosts(const char *transp)
{
enum clnt_stat clnt_stat;
@@ -103,28 +241,49 @@ int
main(int argc, char *argv[])
{
int ch;
+ int s, p;
const char *transp = "udp";
-
- while ((ch = getopt(argc, argv, "ut")) != -1)
+ p = s = 0;
+ while ((ch = getopt(argc, argv, "prstu")) != -1)
switch (ch) {
+ case 'p':
+ p = 1;
+ break;
+ case 's':
+ s = 1;
+ break;
case 't':
transp = "tcp";
break;
case 'u':
transp = "udp";
break;
+ case 'r':
+ transp = NULL;
+ break;
default:
- fprintf(stderr, "Usage: %s -[t|u] [<hostname>...]\n",
+ fprintf(stderr,
+ "Usage: %s -[r|s|t|u] [<hostname>...]\n",
getprogname());
return EXIT_FAILURE;
}
- if (argc == optind)
- allhosts();
- else
- for (; optind < argc; optind++)
- onehost(argv[optind], transp);
+ if (argc == optind) {
+ if (transp)
+ allhosts(transp);
+ else
+ rawtest(NULL);
+ } else {
+ for (; optind < argc; optind++) {
+ if (transp)
+ s == 0 ?
+ onehost(argv[optind], transp) :
+ regtest(argv[optind], transp, "1", p);
+ else
+ rawtest(argv[optind]);
+ }
+ }
return EXIT_SUCCESS;
}
@@ -156,10 +315,79 @@ ATF_TC_BODY(get_svc_addr_udp, tc)
}
+ATF_TC(raw);
+ATF_TC_HEAD(raw, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks svc raw");
+}
+
+ATF_TC_BODY(raw, tc)
+{
+#ifdef __FreeBSD__
+ atf_tc_expect_fail("fails with: clnt_call: "
+ "RPC: Can't decode result -- PR # 211804");
+#endif
+ rawtest(NULL);
+
+}
+
+ATF_TC(tcp);
+ATF_TC_HEAD(tcp, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks svc tcp (select)");
+}
+
+ATF_TC_BODY(tcp, tc)
+{
+ regtest("localhost", "tcp", "1", 0);
+
+}
+
+ATF_TC(udp);
+ATF_TC_HEAD(udp, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks svc udp (select)");
+}
+
+ATF_TC_BODY(udp, tc)
+{
+ regtest("localhost", "udp", "1", 0);
+
+}
+
+ATF_TC(tcp_poll);
+ATF_TC_HEAD(tcp_poll, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks svc tcp (poll)");
+}
+
+ATF_TC_BODY(tcp_poll, tc)
+{
+ regtest("localhost", "tcp", "1", 1);
+
+}
+
+ATF_TC(udp_poll);
+ATF_TC_HEAD(udp_poll, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks svc udp (poll)");
+}
+
+ATF_TC_BODY(udp_poll, tc)
+{
+ regtest("localhost", "udp", "1", 1);
+
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, get_svc_addr_udp);
ATF_TP_ADD_TC(tp, get_svc_addr_tcp);
+ ATF_TP_ADD_TC(tp, raw);
+ ATF_TP_ADD_TC(tp, tcp);
+ ATF_TP_ADD_TC(tp, udp);
+ ATF_TP_ADD_TC(tp, tcp_poll);
+ ATF_TP_ADD_TC(tp, udp_poll);
return atf_no_error();
}
diff --git a/contrib/netbsd-tests/lib/libc/stdio/t_open_memstream.c b/contrib/netbsd-tests/lib/libc/stdio/t_open_memstream.c
new file mode 100644
index 0000000..950a258
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/stdio/t_open_memstream.c
@@ -0,0 +1,96 @@
+/*
+ * Based on the OpenBSD test
+ * Copyright (c) 2011 Martin Pieuchot <mpi@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_open_memstream.c,v 1.2 2014/10/19 11:17:43 justin Exp $");
+
+#include <atf-c.h>
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+ATF_TC(test_open_memstream);
+ATF_TC_HEAD(test_open_memstream, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test open_memstream functionality");
+}
+
+#define OFFSET 16384
+
+const char start[] = "start";
+const char hello[] = "hello";
+
+ATF_TC_BODY(test_open_memstream, tc)
+{
+ FILE *fp;
+ char *buf = (char *)0xff;
+ size_t size = 0;
+ off_t off;
+ int i;
+
+ fp = open_memstream(&buf, &size);
+ ATF_REQUIRE(fp != NULL);
+
+ off = ftello(fp);
+ ATF_CHECK(off == 0);
+
+ ATF_CHECK(fflush(fp) == 0);
+ ATF_CHECK(size == 0);
+ ATF_CHECK(buf != (char *)0xff);
+ ATF_CHECK(fseek(fp, -6, SEEK_SET) == -1);
+ ATF_CHECK(fseek(fp, OFFSET, SEEK_SET) == 0);
+ ATF_CHECK(fprintf(fp, hello) != EOF);
+ ATF_CHECK(fflush(fp) != EOF);
+ ATF_CHECK(size == OFFSET + sizeof(hello)-1);
+ ATF_CHECK(fseek(fp, 0, SEEK_SET) == 0);
+ ATF_CHECK(fprintf(fp, start) != EOF);
+ ATF_CHECK(fflush(fp) != EOF);
+ ATF_CHECK(size == sizeof(start)-1);
+
+ /* Needed for sparse files */
+ ATF_CHECK(strncmp(buf, start, sizeof(start)-1) == 0);
+ for (i = sizeof(start)-1; i < OFFSET; i++)
+ ATF_CHECK(buf[i] == '\0');
+
+ ATF_CHECK(memcmp(buf + OFFSET, hello, sizeof(hello)-1) == 0);
+
+ /* verify that simply seeking past the end doesn't increase the size */
+ ATF_CHECK(fseek(fp, 100, SEEK_END) == 0);
+ ATF_CHECK(fflush(fp) != EOF);
+ ATF_CHECK(size == OFFSET + sizeof(hello)-1);
+ ATF_CHECK(fseek(fp, 8, SEEK_SET) == 0);
+ ATF_CHECK(ftell(fp) == 8);
+
+ /* Try to seek backward */
+ ATF_CHECK(fseek(fp, -1, SEEK_CUR) == 0);
+ ATF_CHECK(ftell(fp) == 7);
+ ATF_CHECK(fseek(fp, 5, SEEK_CUR) == 0);
+ ATF_CHECK(fclose(fp) != EOF);
+ ATF_CHECK(size == 12);
+
+ free(buf);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, test_open_memstream);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_getenv.c b/contrib/netbsd-tests/lib/libc/stdlib/t_getenv.c
index 5a8fa28..7e29778 100644
--- a/contrib/netbsd-tests/lib/libc/stdlib/t_getenv.c
+++ b/contrib/netbsd-tests/lib/libc/stdlib/t_getenv.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_getenv.c,v 1.2 2011/07/15 13:54:31 jruoho Exp $ */
+/* $NetBSD: t_getenv.c,v 1.3 2015/02/27 08:55:35 martin Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_getenv.c,v 1.2 2011/07/15 13:54:31 jruoho Exp $");
+__RCSID("$NetBSD: t_getenv.c,v 1.3 2015/02/27 08:55:35 martin Exp $");
#include <atf-c.h>
#include <errno.h>
@@ -123,7 +123,7 @@ ATF_TC_HEAD(setenv_basic, tc)
{
atf_tc_set_md_var(tc, "descr",
"Test setenv(3), getenv(3), unsetenv(3)");
- atf_tc_set_md_var(tc, "timeout", "300");
+ atf_tc_set_md_var(tc, "timeout", "600");
}
ATF_TC_BODY(setenv_basic, tc)
diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_posix_memalign.c b/contrib/netbsd-tests/lib/libc/stdlib/t_posix_memalign.c
index 47afb84..8db7880 100644
--- a/contrib/netbsd-tests/lib/libc/stdlib/t_posix_memalign.c
+++ b/contrib/netbsd-tests/lib/libc/stdlib/t_posix_memalign.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_posix_memalign.c,v 1.2 2011/07/07 11:12:18 jruoho Exp $ */
+/* $NetBSD: t_posix_memalign.c,v 1.4 2015/11/07 17:35:31 nros Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -32,11 +32,12 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_posix_memalign.c,v 1.2 2011/07/07 11:12:18 jruoho Exp $");
+__RCSID("$NetBSD: t_posix_memalign.c,v 1.4 2015/11/07 17:35:31 nros Exp $");
#include <atf-c.h>
#include <errno.h>
+#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@@ -49,10 +50,10 @@ ATF_TC_HEAD(posix_memalign_basic, tc)
}
ATF_TC_BODY(posix_memalign_basic, tc)
{
- size_t size[] = {
+ static const size_t size[] = {
1, 2, 3, 4, 10, 100, 16384, 32768, 65536
};
- size_t align[] = {
+ static const size_t align[] = {
512, 1024, 16, 32, 64, 4, 2048, 16, 2
};
@@ -63,7 +64,7 @@ ATF_TC_BODY(posix_memalign_basic, tc)
int ret;
p = (void*)0x1;
- (void)printf("Checking posix_memalign(&p, %zd, %zd)...\n",
+ (void)printf("Checking posix_memalign(&p, %zu, %zu)...\n",
align[i], size[i]);
ret = posix_memalign(&p, align[i], size[i]);
@@ -80,9 +81,71 @@ ATF_TC_BODY(posix_memalign_basic, tc)
}
}
+
+ATF_TC(aligned_alloc_basic);
+ATF_TC_HEAD(aligned_alloc_basic, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks aligned_alloc(3)");
+}
+ATF_TC_BODY(aligned_alloc_basic, tc)
+{
+ static const size_t size[] = {
+ 1, 2, 3, 4, 10, 100, 16384, 32768, 65536, 10000, 0
+ };
+ static const size_t align[] = {
+ 512, 1024, 16, 32, 64, 4, 2048, 16, 2, 2048, 0
+ };
+
+ size_t i;
+ void *p;
+
+ for (i = 0; i < __arraycount(size); i++) {
+ (void)printf("Checking aligned_alloc(%zu, %zu)...\n",
+ align[i], size[i]);
+ p = aligned_alloc(align[i], size[i]);
+ if (p == NULL) {
+ if (align[i] == 0 || ((align[i] - 1) & align[i]) != 0 ||
+ size[i] % align[i] != 0) {
+ ATF_REQUIRE_EQ_MSG(errno, EINVAL,
+ "aligned_alloc: %s", strerror(errno));
+ }
+ else {
+ ATF_REQUIRE_EQ_MSG(errno, ENOMEM,
+ "aligned_alloc: %s", strerror(errno));
+ }
+ }
+ else {
+ ATF_REQUIRE_EQ_MSG(align[i] == 0, false,
+ "aligned_alloc: success when alignment was not "
+ "a power of 2");
+ ATF_REQUIRE_EQ_MSG((align[i] - 1) & align[i], 0,
+ "aligned_alloc: success when alignment was not "
+ "a power of 2");
+#ifdef __NetBSD__
+ /*
+ * NetBSD-specific invariant
+ *
+ * From aligned_alloc(3) on FreeBSD:
+ *
+ * Behavior is undefined if size is not an integral
+ * multiple of alignment.
+ */
+ ATF_REQUIRE_EQ_MSG(size[i] % align[i], 0,
+ "aligned_alloc: success when size was not an "
+ "integer multiple of alignment");
+#endif
+ ATF_REQUIRE_EQ_MSG(((intptr_t)p) & (align[i] - 1), 0,
+ "p = %p", p);
+ free(p);
+ }
+ }
+}
+
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, posix_memalign_basic);
-
+ ATF_TP_ADD_TC(tp, aligned_alloc_basic);
+
return atf_no_error();
}
diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c b/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c
index 8f0f899..905306d 100644
--- a/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c
+++ b/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strtod.c,v 1.32 2014/11/04 00:20:19 justin Exp $ */
+/* $NetBSD: t_strtod.c,v 1.34 2015/12/22 14:19:25 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
/* Public domain, Otto Moerbeek <otto@drijf.net>, 2006. */
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_strtod.c,v 1.32 2014/11/04 00:20:19 justin Exp $");
+__RCSID("$NetBSD: t_strtod.c,v 1.34 2015/12/22 14:19:25 christos Exp $");
#include <errno.h>
#include <math.h>
@@ -42,9 +42,7 @@ __RCSID("$NetBSD: t_strtod.c,v 1.32 2014/11/04 00:20:19 justin Exp $");
#include <atf-c.h>
-#if defined(__i386__) || defined(__amd64__) || defined(__sparc__)
#include <fenv.h>
-#endif
#if !defined(__vax__)
static const char * const inf_strings[] =
@@ -246,7 +244,7 @@ ATF_TC_HEAD(strtod_round, tc)
ATF_TC_BODY(strtod_round, tc)
{
-#if defined(__i386__) || defined(__amd64__) || defined(__sparc__)
+#ifdef __HAVE_FENV
/*
* Test that strtod(3) honors the current rounding mode.
@@ -270,7 +268,7 @@ ATF_TC_BODY(strtod_round, tc)
atf_tc_fail("strtod(3) did not honor fesetround(3)");
}
#else
- atf_tc_skip("Requires one of i386, amd64 or sparc");
+ atf_tc_skip("Requires <fenv.h> support");
#endif
}
diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_strtoi.c b/contrib/netbsd-tests/lib/libc/stdlib/t_strtoi.c
new file mode 100644
index 0000000..bf958a1
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/stdlib/t_strtoi.c
@@ -0,0 +1,304 @@
+/* $NetBSD: t_strtoi.c,v 1.1 2015/05/01 14:17:56 christos Exp $ */
+
+/*-
+ * Copyright (c) 2015 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * 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.
+ */
+
+/*
+ * Created by Kamil Rytarowski, vesed on ID:
+ * NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_strtoi.c,v 1.1 2015/05/01 14:17:56 christos Exp $");
+
+#include <atf-c.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+struct test {
+ const char *str;
+ intmax_t res;
+ int base;
+ const char *end;
+ intmax_t lo;
+ intmax_t hi;
+ int rstatus;
+};
+
+static void check(struct test *, intmax_t, char *, int);
+
+static void
+check(struct test *t, intmax_t rv, char *end, int rstatus)
+{
+
+ if (rv != t->res)
+ atf_tc_fail_nonfatal("strtoi(%s, &end, %d, %jd, %jd, &rstatus)"
+ " failed (rv = %jd)", t->str, t->base, t->lo, t->hi, rv);
+
+ if (rstatus != t->rstatus)
+ atf_tc_fail_nonfatal("strtoi(%s, &end, %d, %jd, %jd, &rstatus)"
+ " failed (rstatus: %d ('%s'))",
+ t->str, t->base, t->lo, t->hi, rstatus, strerror(rstatus));
+
+ if ((t->end != NULL && strcmp(t->end, end) != 0) ||
+ (t->end == NULL && *end != '\0'))
+ atf_tc_fail_nonfatal("invalid end pointer ('%s') from "
+ "strtoi(%s, &end, %d, %jd, %jd, &rstatus)",
+ end, t->str, t->base, t->lo, t->hi);
+}
+
+ATF_TC(strtoi_base);
+ATF_TC_HEAD(strtoi_base, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test strtoi(3) with different bases");
+}
+
+ATF_TC_BODY(strtoi_base, tc)
+{
+ struct test t[] = {
+ { "123456789", 123456789, 0, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "111010110111100110100010101",123456789, 2, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "22121022020212200", 123456789, 3, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "13112330310111", 123456789, 4, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "223101104124", 123456789, 5, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "20130035113", 123456789, 6, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "3026236221", 123456789, 7, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "726746425", 123456789, 8, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "277266780", 123456789, 9, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "123456789", 123456789, 10, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "63762A05", 123456789, 11, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "35418A99", 123456789, 12, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "1C767471", 123456789, 13, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "12579781", 123456789, 14, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "AC89BC9", 123456789, 15, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "75BCD15", 123456789, 16, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "1234567", 342391, 8, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "01234567", 342391, 0, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "0123456789", 123456789, 10, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "0x75bcd15", 123456789, 0, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ };
+
+ intmax_t rv;
+ char *end;
+ int e;
+ size_t i;
+
+ for (i = 0; i < __arraycount(t); i++) {
+
+ errno = 0;
+ rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e);
+
+ if (errno != 0)
+ atf_tc_fail("strtoi(3) changed errno to %d ('%s')",
+ e, strerror(e));
+
+ check(&t[i], rv, end, e);
+ }
+}
+
+ATF_TC(strtoi_case);
+ATF_TC_HEAD(strtoi_case, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Case insensitivity with strtoi(3)");
+}
+
+ATF_TC_BODY(strtoi_case, tc)
+{
+ struct test t[] = {
+ { "abcd", 0xabcd, 16, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { " dcba", 0xdcba, 16, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "abcd dcba", 0xabcd, 16, " dcba",
+ INTMAX_MIN, INTMAX_MAX, ENOTSUP },
+ { "abc0x123", 0xabc0, 16, "x123",
+ INTMAX_MIN, INTMAX_MAX, ENOTSUP },
+ { "abcd\0x123", 0xabcd, 16, "\0x123",
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "ABCD", 0xabcd, 16, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "aBcD", 0xabcd, 16, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "0xABCD", 0xabcd, 16, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "0xABCDX", 0xabcd, 16, "X",
+ INTMAX_MIN, INTMAX_MAX, ENOTSUP},
+ };
+
+ intmax_t rv;
+ char *end;
+ int e;
+ size_t i;
+
+ for (i = 0; i < __arraycount(t); i++) {
+
+ errno = 0;
+ rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e);
+
+ if (errno != 0)
+ atf_tc_fail("strtoi(3) changed errno to %d ('%s')",
+ e, strerror(e));
+
+ check(&t[i], rv, end, e);
+ }
+}
+
+ATF_TC(strtoi_range);
+ATF_TC_HEAD(strtoi_range, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test ERANGE from strtoi(3)");
+}
+
+ATF_TC_BODY(strtoi_range, tc)
+{
+ struct test t[] = {
+#if INTMAX_MAX == 0x7fffffffffffffff
+ { "1000000000000000000000", INTMAX_MAX, 8, NULL,
+ INTMAX_MIN, INTMAX_MAX, ERANGE },
+ { "9223372036854775808", INTMAX_MAX, 10, NULL,
+ INTMAX_MIN, INTMAX_MAX, ERANGE },
+ { "8000000000000000", INTMAX_MAX, 16, NULL,
+ INTMAX_MIN, INTMAX_MAX, ERANGE },
+#else
+#error extend this test to your platform!
+#endif
+ { "10", 1, 10, NULL,
+ -1, 1, ERANGE },
+ { "10", 11, 10, NULL,
+ 11, 20, ERANGE },
+ };
+
+ intmax_t rv;
+ char *end;
+ int e;
+ size_t i;
+
+ for (i = 0; i < __arraycount(t); i++) {
+
+ errno = 0;
+ rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e);
+
+ if (errno != 0)
+ atf_tc_fail("strtoi(3) changed errno to %d ('%s')",
+ e, strerror(e));
+
+ check(&t[i], rv, end, e);
+ }
+}
+
+ATF_TC(strtoi_signed);
+ATF_TC_HEAD(strtoi_signed, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "A basic test of strtoi(3)");
+}
+
+ATF_TC_BODY(strtoi_signed, tc)
+{
+ struct test t[] = {
+ { "1", 1, 0, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { " 2", 2, 0, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { " 3", 3, 0, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { " -3", -3, 0, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "--1", 0, 0, "--1",
+ INTMAX_MIN, INTMAX_MAX, ECANCELED },
+ { "+-2", 0, 0, "+-2",
+ INTMAX_MIN, INTMAX_MAX, ECANCELED },
+ { "++3", 0, 0, "++3",
+ INTMAX_MIN, INTMAX_MAX, ECANCELED },
+ { "+9", 9, 0, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "+123", 123, 0, NULL,
+ INTMAX_MIN, INTMAX_MAX, 0 },
+ { "-1 3", -1, 0, " 3",
+ INTMAX_MIN, INTMAX_MAX, ENOTSUP },
+ { "-1.3", -1, 0, ".3",
+ INTMAX_MIN, INTMAX_MAX, ENOTSUP },
+ { "- 3", 0, 0, "- 3",
+ INTMAX_MIN, INTMAX_MAX, ECANCELED },
+ { "+33.", 33, 0, ".",
+ INTMAX_MIN, INTMAX_MAX, ENOTSUP },
+ { "30x0", 30, 0, "x0",
+ INTMAX_MIN, INTMAX_MAX, ENOTSUP },
+ };
+
+ intmax_t rv;
+ char *end;
+ int e;
+ size_t i;
+
+ for (i = 0; i < __arraycount(t); i++) {
+
+ errno = 0;
+ rv = strtoi(t[i].str, &end, t[i].base, t[i].lo, t[i].hi, &e);
+
+ if (errno != 0)
+ atf_tc_fail("strtoi(3) changed errno to %d ('%s')",
+ e, strerror(e));
+
+ check(&t[i], rv, end, e);
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, strtoi_base);
+ ATF_TP_ADD_TC(tp, strtoi_case);
+ ATF_TP_ADD_TC(tp, strtoi_range);
+ ATF_TP_ADD_TC(tp, strtoi_signed);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/stdlib/t_strtol.c b/contrib/netbsd-tests/lib/libc/stdlib/t_strtol.c
index 5a0c6d0..54e1907 100644
--- a/contrib/netbsd-tests/lib/libc/stdlib/t_strtol.c
+++ b/contrib/netbsd-tests/lib/libc/stdlib/t_strtol.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp $ */
+/* $NetBSD: t_strtol.c,v 1.6 2016/06/01 01:12:02 pgoyette Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_strtol.c,v 1.5 2011/06/14 02:45:58 jruoho Exp $");
+__RCSID("$NetBSD: t_strtol.c,v 1.6 2016/06/01 01:12:02 pgoyette Exp $");
#include <atf-c.h>
#include <errno.h>
@@ -59,7 +59,8 @@ check(struct test *t, long int li, long long int lli, char *end)
atf_tc_fail_nonfatal("strtoll(%s, NULL, %d) failed "
"(rv = %lld)", t->str, t->base, lli);
- if (t->end != NULL && strcmp(t->end, end) != 0)
+ if ((t->end != NULL && strcmp(t->end, end) != 0) ||
+ (t->end == NULL && *end != '\0'))
atf_tc_fail_nonfatal("invalid end pointer ('%s') from "
"strtol(%s, &end, %d)", end, t->str, t->base);
}
@@ -89,8 +90,8 @@ ATF_TC_BODY(strtol_base, tc)
{ "12579781", 123456789, 14, NULL },
{ "AC89BC9", 123456789, 15, NULL },
{ "75BCD15", 123456789, 16, NULL },
- { "123456789", 342391, 8, NULL },
- { "0123456789", 342391, 0, NULL },
+ { "1234567", 342391, 8, NULL },
+ { "01234567", 342391, 0, NULL },
{ "0123456789", 123456789, 10, NULL },
{ "0x75bcd15", 123456789, 0, NULL },
};
@@ -121,7 +122,7 @@ ATF_TC_BODY(strtol_case, tc)
{ "abcd", 0xabcd, 16, NULL },
{ " dcba", 0xdcba, 16, NULL },
{ "abcd dcba", 0xabcd, 16, " dcba" },
- { "abc0x123", 0xabc0, 16, NULL },
+ { "abc0x123", 0xabc0, 16, "x123" },
{ "abcd\0x123", 0xabcd, 16, "\0x123" },
{ "ABCD", 0xabcd, 16, NULL },
{ "aBcD", 0xabcd, 16, NULL },
diff --git a/contrib/netbsd-tests/lib/libc/string/t_memset.c b/contrib/netbsd-tests/lib/libc/string/t_memset.c
index c1fb385..5a2be28 100644
--- a/contrib/netbsd-tests/lib/libc/string/t_memset.c
+++ b/contrib/netbsd-tests/lib/libc/string/t_memset.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_memset.c,v 1.3 2013/03/17 02:23:31 christos Exp $ */
+/* $NetBSD: t_memset.c,v 1.4 2015/09/11 09:25:52 martin Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_memset.c,v 1.3 2013/03/17 02:23:31 christos Exp $");
+__RCSID("$NetBSD: t_memset.c,v 1.4 2015/09/11 09:25:52 martin Exp $");
#include <sys/stat.h>
@@ -42,6 +42,8 @@ static long page = 0;
static void fill(char *, size_t, char);
static bool check(char *, size_t, char);
+int zero; /* always zero, but the compiler does not know */
+
ATF_TC(memset_array);
ATF_TC_HEAD(memset_array, tc)
{
@@ -133,6 +135,50 @@ ATF_TC_BODY(memset_nonzero, tc)
free(buf);
}
+ATF_TC(memset_zero_size);
+
+ATF_TC_HEAD(memset_zero_size, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test memset(3) with zero size");
+}
+
+ATF_TC_BODY(memset_zero_size, tc)
+{
+ char buf[1024];
+
+ (void)memset(buf, 'x', sizeof(buf));
+
+ if (check(buf, sizeof(buf), 'x') != true)
+ atf_tc_fail("memset(3) did not fill a static buffer");
+
+ (void)memset(buf+sizeof(buf)/2, 0, zero);
+
+ if (check(buf, sizeof(buf), 'x') != true)
+ atf_tc_fail("memset(3) with 0 size did change the buffer");
+}
+
+ATF_TC(bzero_zero_size);
+
+ATF_TC_HEAD(bzero_zero_size, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test bzero(3) with zero size");
+}
+
+ATF_TC_BODY(bzero_zero_size, tc)
+{
+ char buf[1024];
+
+ (void)memset(buf, 'x', sizeof(buf));
+
+ if (check(buf, sizeof(buf), 'x') != true)
+ atf_tc_fail("memset(3) did not fill a static buffer");
+
+ (void)bzero(buf+sizeof(buf)/2, zero);
+
+ if (check(buf, sizeof(buf), 'x') != true)
+ atf_tc_fail("bzero(3) with 0 size did change the buffer");
+}
+
ATF_TC(memset_struct);
ATF_TC_HEAD(memset_struct, tc)
{
@@ -202,6 +248,8 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, memset_nonzero);
ATF_TP_ADD_TC(tp, memset_struct);
ATF_TP_ADD_TC(tp, memset_return);
+ ATF_TP_ADD_TC(tp, memset_zero_size);
+ ATF_TP_ADD_TC(tp, bzero_zero_size);
return atf_no_error();
}
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
new file mode 100644
index 0000000..7426851
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/sync/cpp_atomic_ops_linkable.cc
@@ -0,0 +1,119 @@
+/* $NetBSD: cpp_atomic_ops_linkable.cc,v 1.4 2016/02/27 18:50:39 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Martin Husemann <martin@NetBSD.org>.
+ *
+ * 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.
+ */
+
+/*
+ * This is a simple link-time test to verify all builtin atomic sync
+ * operations for C++ <atomic> are available.
+ */
+
+#include <atomic>
+#include <machine/types.h> // for __HAVE_ATOMIC64_OPS
+
+template <class T>
+class ATest {
+public:
+ ATest() : m_val(0)
+ {
+ m_val.exchange(std::atomic<T>(8));
+ m_val--;
+ m_val++;
+ m_val ^= 0x0f;
+ m_val &= 0x0f;
+ m_val |= 2;
+
+ T tval(1), other(42);
+ m_val.compare_exchange_weak(tval, other,
+ std::memory_order_release, std::memory_order_relaxed);
+ }
+
+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>();
+ ATest<unsigned long>();
+#ifdef __HAVE_ATOMIC64_OPS
+ 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
+ ATest<int_fast64_t>();
+ ATest<uint_fast64_t>();
+#endif
+ ATest<intptr_t>();
+ ATest<uintptr_t>();
+ ATest<std::size_t>();
+ ATest<std::ptrdiff_t>();
+#ifdef __HAVE_ATOMIC64_OPS
+ ATest<intmax_t>();
+ ATest<uintmax_t>();
+#endif /* NO_SHORT_ATOMICS */
+}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_bind.c b/contrib/netbsd-tests/lib/libc/sys/t_bind.c
new file mode 100644
index 0000000..0c6027c
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/sys/t_bind.c
@@ -0,0 +1,78 @@
+/* $NetBSD: t_bind.c,v 1.3 2015/04/05 23:28:10 rtr Exp $ */
+/*
+ * Copyright (c) 2015 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 <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <unistd.h>
+
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#include <atf-c.h>
+
+ATF_TC(bind_foreign_family);
+
+ATF_TC_HEAD(bind_foreign_family, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks that binding a socket "
+ "with a different address family fails");
+}
+
+ATF_TC_BODY(bind_foreign_family, tc)
+{
+ struct sockaddr_in addr;
+
+ /* addr.sin_family = AF_UNSPEC = 0 */
+ memset(&addr, 0, sizeof(addr));
+
+ /*
+ * it is not necessary to initialize sin_{addr,port} since
+ * those structure members shall not be accessed if bind
+ * fails correctly.
+ */
+
+ int sock = socket(AF_LOCAL, SOCK_STREAM, 0);
+ ATF_REQUIRE(sock != -1);
+
+ /* should fail but currently doesn't */
+ ATF_REQUIRE(-1 == bind(sock, (struct sockaddr *)&addr, sizeof(addr)));
+ ATF_REQUIRE(EAFNOSUPPORT == errno);
+
+ close(sock);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, bind_foreign_family);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_connect.c b/contrib/netbsd-tests/lib/libc/sys/t_connect.c
index 896b490..672a022 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_connect.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_connect.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_connect.c,v 1.1 2011/11/05 18:19:02 jruoho Exp $ */
+/* $NetBSD: t_connect.c,v 1.2 2015/04/05 23:17:41 rtr Exp $ */
/*
* Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -102,10 +102,39 @@ ATF_TC_BODY(connect_low_port, tc)
#endif
}
+ATF_TC(connect_foreign_family);
+ATF_TC_HEAD(connect_foreign_family, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks that connecting a socket "
+ "with a different address family fails");
+}
+ATF_TC_BODY(connect_foreign_family, tc)
+{
+ struct sockaddr_in addr;
+
+ /* addr.sin_family = AF_UNSPEC = 0 */
+ memset(&addr, 0, sizeof(addr));
+
+ /*
+ * it is not necessary to initialize sin_{addr,port} since
+ * those structure members shall not be accessed if connect
+ * fails correctly.
+ */
+
+ int sock = socket(AF_LOCAL, SOCK_STREAM, 0);
+ ATF_REQUIRE(sock != -1);
+
+ ATF_REQUIRE(-1 == connect(sock, (struct sockaddr *)&addr, sizeof(addr)));
+ ATF_REQUIRE(EAFNOSUPPORT == errno);
+
+ close(sock);
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, connect_low_port);
+ ATF_TP_ADD_TC(tp, connect_foreign_family);
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 85eeac6..aa5c4d5 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_getrusage.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_getrusage.c,v 1.3 2014/09/03 19:24:12 matt Exp $ */
+/* $NetBSD: t_getrusage.c,v 1.4 2016/08/05 15:01:39 scole Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_getrusage.c,v 1.3 2014/09/03 19:24:12 matt Exp $");
+__RCSID("$NetBSD: t_getrusage.c,v 1.4 2016/08/05 15:01:39 scole Exp $");
#include <sys/resource.h>
#include <sys/time.h>
@@ -64,6 +64,8 @@ work(void)
while (n > 0) {
#ifdef __or1k__
asm volatile("l.nop"); /* Do something. */
+#elif defined(__ia64__)
+ asm volatile("nop 0"); /* Do something. */
#else
asm volatile("nop"); /* Do something. */
#endif
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_getsockname.c b/contrib/netbsd-tests/lib/libc/sys/t_getsockname.c
new file mode 100644
index 0000000..01b1f8a
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/sys/t_getsockname.c
@@ -0,0 +1,82 @@
+/* $NetBSD: t_getsockname.c,v 1.1 2016/07/30 11:03:54 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/socket.h>
+#include <sys/un.h>
+
+#include <string.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+ATF_TC(getsockname_unix);
+
+ATF_TC_HEAD(getsockname_unix, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks getsockname with UNIX domain");
+}
+
+ATF_TC_BODY(getsockname_unix, tc)
+{
+ const char *path = "sock.unix";
+ int sd;
+ socklen_t len;
+ struct sockaddr_un sun;
+
+ sd = socket(AF_UNIX, SOCK_STREAM, 0);
+ ATF_REQUIRE(sd != -1);
+
+ len = sizeof(sun);
+ memset(&sun, 0, sizeof(sun));
+ ATF_REQUIRE(getsockname(sd, (struct sockaddr *)&sun, &len) != -1);
+ ATF_CHECK(sun.sun_family == AF_UNIX);
+ ATF_CHECK(strcmp(sun.sun_path, "") == 0);
+
+ len = sizeof(sun);
+ memset(&sun, 0, sizeof(sun));
+ sun.sun_family = AF_UNIX;
+ strcpy(sun.sun_path, path);
+ ATF_REQUIRE(bind(sd, (struct sockaddr *)&sun, len) != -1);
+
+ len = sizeof(sun);
+ memset(&sun, 0, sizeof(sun));
+ ATF_REQUIRE(getsockname(sd, (struct sockaddr *)&sun, &len) != -1);
+ ATF_CHECK(sun.sun_family == AF_UNIX);
+ ATF_CHECK(strcmp(sun.sun_path, path) == 0);
+
+ ATF_REQUIRE(close(sd) != -1);
+ ATF_REQUIRE(unlink(path) != -1);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, getsockname_unix);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_kevent.c b/contrib/netbsd-tests/lib/libc/sys/t_kevent.c
index fe298c5..3858554 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_kevent.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_kevent.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_kevent.c,v 1.6 2012/11/29 09:13:44 martin Exp $ */
+/* $NetBSD: t_kevent.c,v 1.7 2015/02/05 13:55:37 isaki Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_kevent.c,v 1.6 2012/11/29 09:13:44 martin Exp $");
+__RCSID("$NetBSD: t_kevent.c,v 1.7 2015/02/05 13:55:37 isaki Exp $");
#include <sys/types.h>
#include <sys/event.h>
@@ -179,8 +179,14 @@ ATF_TC_BODY(kqueue_unsupported_fd, tc)
struct kevent ev;
fd = open(DRVCTLDEV, O_RDONLY);
- if (fd == -1 && errno == ENOENT)
- atf_tc_skip("no " DRVCTLDEV " available for testing");
+ if (fd == -1) {
+ switch (errno) {
+ case ENOENT:
+ case ENXIO:
+ atf_tc_skip("no " DRVCTLDEV " available for testing");
+ break;
+ }
+ }
ATF_REQUIRE(fd != -1);
ATF_REQUIRE((kq = kqueue()) != -1);
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
index d4aef4a..75048b3 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mlock.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mlock.c,v 1.5 2014/02/26 20:49:26 martin Exp $ */
+/* $NetBSD: t_mlock.c,v 1.6 2016/08/09 12:02:44 kre Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mlock.c,v 1.5 2014/02/26 20:49:26 martin Exp $");
+__RCSID("$NetBSD: t_mlock.c,v 1.6 2016/08/09 12:02:44 kre Exp $");
#ifdef __FreeBSD__
#include <sys/types.h>
@@ -180,6 +180,7 @@ ATF_TC_BODY(mlock_err, tc)
void *invalid_ptr;
#endif
int null_errno = ENOMEM; /* error expected for NULL */
+ void *buf;
#ifdef __FreeBSD__
#ifdef VM_MIN_ADDRESS
@@ -191,32 +192,52 @@ ATF_TC_BODY(mlock_err, tc)
#else
if (sysctlbyname("vm.minaddress", &vmin, &len, NULL, 0) != 0)
atf_tc_fail("failed to read vm.minaddress");
+ /*
+ * Any bad address must return ENOMEM (for lock & unlock)
+ */
+ errno = 0;
+ ATF_REQUIRE_ERRNO(ENOMEM, mlock(NULL, page) == -1);
if (vmin > 0)
null_errno = EINVAL; /* NULL is not inside user VM */
#endif
errno = 0;
- ATF_REQUIRE_ERRNO(null_errno, mlock(NULL, page) == -1);
+ ATF_REQUIRE_ERRNO(ENOMEM, mlock((char *)0, page) == -1);
errno = 0;
- ATF_REQUIRE_ERRNO(null_errno, mlock((char *)0, page) == -1);
+ ATF_REQUIRE_ERRNO(ENOMEM, mlock((char *)-1, page) == -1);
errno = 0;
- ATF_REQUIRE_ERRNO(EINVAL, mlock((char *)-1, page) == -1);
+ ATF_REQUIRE_ERRNO(ENOMEM, munlock(NULL, page) == -1);
errno = 0;
- ATF_REQUIRE_ERRNO(null_errno, munlock(NULL, page) == -1);
+ ATF_REQUIRE_ERRNO(ENOMEM, munlock((char *)0, page) == -1);
errno = 0;
- ATF_REQUIRE_ERRNO(null_errno, munlock((char *)0, page) == -1);
+ ATF_REQUIRE_ERRNO(ENOMEM, munlock((char *)-1, page) == -1);
+
+ buf = malloc(page);
+ ATF_REQUIRE(buf != NULL);
+
+ /*
+ * unlocking memory that is not locked is an error...
+ */
errno = 0;
- ATF_REQUIRE_ERRNO(EINVAL, munlock((char *)-1, page) == -1);
+ ATF_REQUIRE_ERRNO(ENOMEM, munlock(buf, page) == -1);
/* There is no sbrk on AArch64 and RISC-V */
#if !defined(__aarch64__) && !defined(__riscv__)
/*
+ * These are permitted to fail (EINVAL) but do not on NetBSD
+ */
+ ATF_REQUIRE(mlock((void *)(((uintptr_t)buf) + page/3), page/5) == 0);
+ ATF_REQUIRE(munlock((void *)(((uintptr_t)buf) + page/3), page/5) == 0);
+
+ (void)free(buf);
+
+ /*
* Try to create a pointer to an unmapped page - first after current
* brk will likely do.
*/
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mmap.c b/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
index 5d821ec..9e74d41 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mmap.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mmap.c,v 1.7 2012/06/14 17:47:58 bouyer Exp $ */
+/* $NetBSD: t_mmap.c,v 1.9 2015/02/28 13:57:08 martin Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -55,7 +55,7 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mmap.c,v 1.7 2012/06/14 17:47:58 bouyer Exp $");
+__RCSID("$NetBSD: t_mmap.c,v 1.9 2015/02/28 13:57:08 martin Exp $");
#include <sys/param.h>
#include <sys/mman.h>
@@ -461,6 +461,72 @@ ATF_TC_CLEANUP(mmap_truncate, tc)
(void)unlink(path);
}
+ATF_TC_WITH_CLEANUP(mmap_truncate_signal);
+ATF_TC_HEAD(mmap_truncate_signal, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test mmap(2) ftruncate(2) causing signal");
+}
+
+ATF_TC_BODY(mmap_truncate_signal, tc)
+{
+ char *map;
+ long i;
+ int fd, sta;
+ pid_t pid;
+
+#ifdef __FreeBSD__
+ atf_tc_expect_fail("testcase fails with SIGSEGV on FreeBSD; bug # 211924");
+#endif
+
+ fd = open(path, O_RDWR | O_CREAT, 0700);
+
+ if (fd < 0)
+ return;
+
+ ATF_REQUIRE(write(fd, "foo\n", 5) == 5);
+
+ map = mmap(NULL, page, PROT_READ, MAP_FILE|MAP_PRIVATE, fd, 0);
+ ATF_REQUIRE(map != MAP_FAILED);
+
+ sta = 0;
+ for (i = 0; i < 5; i++)
+ sta += map[i];
+ ATF_REQUIRE(sta == 334);
+
+ ATF_REQUIRE(ftruncate(fd, 0) == 0);
+ pid = fork();
+ ATF_REQUIRE(pid >= 0);
+
+ if (pid == 0) {
+ ATF_REQUIRE(signal(SIGBUS, map_sighandler) != SIG_ERR);
+ ATF_REQUIRE(signal(SIGSEGV, map_sighandler) != SIG_ERR);
+ sta = 0;
+ for (i = 0; i < page; i++)
+ sta += map[i];
+ /* child never will get this far, but the compiler will
+ not know, so better use the values calculated to
+ prevent the access to be optimized out */
+ ATF_REQUIRE(i == 0);
+ ATF_REQUIRE(sta == 0);
+ return;
+ }
+
+ (void)wait(&sta);
+
+ ATF_REQUIRE(WIFEXITED(sta) != 0);
+ if (WEXITSTATUS(sta) == SIGSEGV)
+ atf_tc_fail("child process got SIGSEGV instead of SIGBUS");
+ ATF_REQUIRE(WEXITSTATUS(sta) == SIGBUS);
+ ATF_REQUIRE(munmap(map, page) == 0);
+ ATF_REQUIRE(close(fd) == 0);
+}
+
+ATF_TC_CLEANUP(mmap_truncate_signal, tc)
+{
+ (void)unlink(path);
+}
+
ATF_TC(mmap_va0);
ATF_TC_HEAD(mmap_va0, tc)
{
@@ -518,6 +584,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, mmap_prot_2);
ATF_TP_ADD_TC(tp, mmap_prot_3);
ATF_TP_ADD_TC(tp, mmap_truncate);
+ ATF_TP_ADD_TC(tp, mmap_truncate_signal);
ATF_TP_ADD_TC(tp, mmap_va0);
return atf_no_error();
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_mprotect.c b/contrib/netbsd-tests/lib/libc/sys/t_mprotect.c
index ee345aa..5dc3eae 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_mprotect.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_mprotect.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mprotect.c,v 1.3 2011/07/20 22:53:44 jym Exp $ */
+/* $NetBSD: t_mprotect.c,v 1.4 2016/05/28 14:34:49 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_mprotect.c,v 1.3 2011/07/20 22:53:44 jym Exp $");
+__RCSID("$NetBSD: t_mprotect.c,v 1.4 2016/05/28 14:34:49 christos Exp $");
#include <sys/param.h>
#include <sys/mman.h>
@@ -78,10 +78,7 @@ paxinit(void)
rv = sysctlbyname("security.pax.mprotect.enabled",
&pax_enabled, &len, NULL, 0);
- if (rv != 0)
- return false;
-
- return paxset(1, 1);
+ return rv == 0;
}
static bool
@@ -194,6 +191,12 @@ ATF_TC_BODY(mprotect_exec, tc)
break;
}
+ if (!paxinit())
+ return;
+ if (pax_enabled == 1 && pax_global == 1)
+ atf_tc_skip("PaX MPROTECT restrictions enabled");
+
+
/*
* Map a page read/write and copy a trivial assembly function inside.
* We will then change the mapping rights:
@@ -262,7 +265,7 @@ ATF_TC_BODY(mprotect_pax, tc)
size_t i;
int rv;
- if (paxinit() != true)
+ if (!paxinit() || !paxset(1, 1))
return;
/*
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_posix_fallocate.c b/contrib/netbsd-tests/lib/libc/sys/t_posix_fallocate.c
new file mode 100644
index 0000000..b931ebd
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/sys/t_posix_fallocate.c
@@ -0,0 +1,63 @@
+/* $NetBSD: t_posix_fallocate.c,v 1.1 2015/01/31 23:06:57 christos Exp $ */
+
+/*-
+ * Copyright 2015, Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google nor the names of its contributors may
+ * be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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_posix_fallocate.c,v 1.1 2015/01/31 23:06:57 christos Exp $");
+
+#include <atf-c.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+ATF_TC_WITHOUT_HEAD(ebadf);
+ATF_TC_BODY(ebadf, tc)
+{
+ int rc, saved;
+
+ errno = 1111;
+ rc = posix_fallocate(-1, 0, 4096);
+ saved = errno;
+ if (rc == -1 && saved != 1111)
+ atf_tc_fail("Should return error %s without setting errno.",
+ strerror(saved));
+ if (rc != EBADF)
+ atf_tc_fail("returned %s but expected %s.",
+ strerror(saved), strerror(EBADF));
+ if (saved != 1111)
+ atf_tc_fail("errno should be %d but got changed to %d.",
+ 1111, saved);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, ebadf);
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c b/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c
index 72175e4..84b0149 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_setrlimit.c,v 1.4 2012/06/12 23:56:19 christos Exp $ */
+/* $NetBSD: t_setrlimit.c,v 1.5 2016/07/13 09:53:16 njoly Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_setrlimit.c,v 1.4 2012/06/12 23:56:19 christos Exp $");
+__RCSID("$NetBSD: t_setrlimit.c,v 1.5 2016/07/13 09:53:16 njoly Exp $");
#include <sys/resource.h>
#include <sys/mman.h>
@@ -512,6 +512,25 @@ ATF_TC_BODY(setrlimit_perm, tc)
}
}
+ATF_TC(setrlimit_stack);
+ATF_TC_HEAD(setrlimit_stack, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test setrlimit(2), RLIMIT_STACK");
+ atf_tc_set_md_var(tc, "require.user", "unprivileged");
+}
+
+ATF_TC_BODY(setrlimit_stack, tc)
+{
+ struct rlimit res;
+
+ /* Ensure soft limit is not bigger than hard limit */
+ res.rlim_cur = res.rlim_max = 4192256;
+ ATF_REQUIRE(setrlimit(RLIMIT_STACK, &res) == 0);
+ ATF_REQUIRE(getrlimit(RLIMIT_STACK, &res) == 0);
+ ATF_CHECK(res.rlim_cur <= res.rlim_max);
+
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -527,6 +546,7 @@ ATF_TP_ADD_TCS(tp)
#ifdef __NetBSD__
ATF_TP_ADD_TC(tp, setrlimit_nthr);
#endif
+ ATF_TP_ADD_TC(tp, setrlimit_stack);
return atf_no_error();
}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c b/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c
index 6686f02..e911d42 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_sigqueue.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sigqueue.c,v 1.4 2011/07/07 16:31:11 jruoho Exp $ */
+/* $NetBSD: t_sigqueue.c,v 1.6 2016/08/04 06:43:43 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -30,8 +30,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_sigqueue.c,v 1.4 2011/07/07 16:31:11 jruoho Exp $");
-
+__RCSID("$NetBSD: t_sigqueue.c,v 1.6 2016/08/04 06:43:43 christos Exp $");
#include <atf-c.h>
#include <errno.h>
@@ -40,6 +39,11 @@ __RCSID("$NetBSD: t_sigqueue.c,v 1.4 2011/07/07 16:31:11 jruoho Exp $");
#include <sched.h>
#include <unistd.h>
+#ifdef __FreeBSD__
+#include <err.h>
+#include <stdio.h>
+#endif
+
static void handler(int, siginfo_t *, void *);
#define VALUE (int)0xc001dad1
@@ -77,7 +81,7 @@ ATF_TC_BODY(sigqueue_basic, tc)
sv.sival_int = VALUE;
#ifdef __FreeBSD__
- /*
+ /*
* From kern_sig.c:
* Specification says sigqueue can only send signal to single process.
*/
@@ -99,17 +103,158 @@ ATF_TC_HEAD(sigqueue_err, tc)
ATF_TC_BODY(sigqueue_err, tc)
{
- union sigval sv;
+ static union sigval sv;
errno = 0;
ATF_REQUIRE_ERRNO(EINVAL, sigqueue(getpid(), -1, sv) == -1);
}
+static int signals[] = {
+ SIGINT, SIGRTMIN + 1, SIGINT, SIGRTMIN + 0, SIGRTMIN + 2,
+ SIGQUIT, SIGRTMIN + 1
+};
+#ifdef __arraycount
+#define CNT __arraycount(signals)
+#else
+#define CNT (sizeof(signals) / sizeof(signals[0]))
+#endif
+
+static sig_atomic_t count = 0;
+static int delivered[CNT];
+
+static void
+myhandler(int signo, siginfo_t *info, void *context)
+{
+ delivered[count++] = signo;
+#ifdef __FreeBSD__
+ printf("Signal #%zu: signo: %d\n", (size_t)count, signo);
+#endif
+}
+
+static int
+asc(const void *a, const void *b)
+{
+ const int *ia = a, *ib = b;
+ return *ib - *ia;
+}
+
+/*
+ * given a array of signals to be delivered in tosend of size len
+ * place in ordered the signals to be delivered in delivery order
+ * and return the number of signals that should be delivered
+ */
+static size_t
+sigorder(int *ordered, const int *tosend, size_t len)
+{
+ memcpy(ordered, tosend, len * sizeof(*tosend));
+ qsort(ordered, len, sizeof(*ordered), asc);
+ if (len == 1)
+ return len;
+
+#ifdef __FreeBSD__
+ /*
+ * Don't dedupe signal numbers (bug 212173)
+ *
+ * Per kib's comment..
+ *
+ * "
+ * OTOH, FreeBSD behaviour is to treat all signals as realtime while
+ * there is no mem shortage and siginfo can be allocated. In
+ * particular, signals < SIGRTMIN are not collapsed when queued more
+ * than once.
+ * "
+ */
+
+ return len;
+#else
+
+ size_t i, j;
+ for (i = 0, j = 0; i < len - 1; i++) {
+ if (ordered[i] >= SIGRTMIN)
+ continue;
+ if (j == 0)
+ j = i + 1;
+ while (ordered[i] == ordered[j] && j < len)
+ j++;
+ if (j == len)
+ break;
+ ordered[i + 1] = ordered[j];
+ }
+ return i + 1;
+#endif
+}
+
+ATF_TC(sigqueue_rt);
+ATF_TC_HEAD(sigqueue_rt, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test queuing of real-time signals");
+}
+
+ATF_TC_BODY(sigqueue_rt, tc)
+{
+ pid_t pid;
+ union sigval val;
+ struct sigaction act;
+ int ordered[CNT];
+ struct sigaction oact[CNT];
+ size_t ndelivered;
+
+ ndelivered = sigorder(ordered, signals, CNT);
+
+ act.sa_flags = SA_SIGINFO;
+ act.sa_sigaction = myhandler;
+ sigemptyset(&act.sa_mask);
+ for (size_t i = 0; i < ndelivered; i++)
+ ATF_REQUIRE(sigaction(ordered[i], &act, &oact[i]) != -1);
+
+ val.sival_int = 0;
+ pid = getpid();
+
+ sigset_t mask, orig;
+ sigemptyset(&mask);
+ for (size_t i = 0; i < CNT; i++)
+#ifdef __FreeBSD__
+ if (sigaddset(&mask, signals[i]) == -1)
+ warn("sigaddset");
+#else
+ sigaddset(&mask, signals[i]);
+#endif
+
+ ATF_REQUIRE(sigprocmask(SIG_BLOCK, &mask, &orig) != -1);
+
+ for (size_t i = 0; i < CNT; i++)
+ ATF_REQUIRE(sigqueue(pid, signals[i], val) != -1);
+
+ ATF_REQUIRE(sigprocmask(SIG_UNBLOCK, &mask, &orig) != -1);
+ sleep(1);
+#ifdef __FreeBSD__
+ ATF_CHECK_MSG((size_t)count == ndelivered,
+ "count %zu != ndelivered %zu", (size_t)count, ndelivered);
+#else
+ ATF_REQUIRE_MSG((size_t)count == ndelivered,
+ "count %zu != ndelivered %zu", (size_t)count, ndelivered);
+#endif
+ for (size_t i = 0; i < ndelivered; i++)
+ ATF_REQUIRE_MSG(ordered[i] == delivered[i],
+ "%zu: ordered %d != delivered %d",
+ i, ordered[i], delivered[i]);
+
+#ifdef __FreeBSD__
+ if (count > ndelivered)
+ for (size_t i = ndelivered; i < count; i++)
+ printf("Undelivered signal #%zu: %d\n", i, ordered[i]);
+#endif
+
+ for (size_t i = 0; i < ndelivered; i++)
+ ATF_REQUIRE(sigaction(signals[i], &oact[i], NULL) != -1);
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, sigqueue_basic);
ATF_TP_ADD_TC(tp, sigqueue_err);
+ ATF_TP_ADD_TC(tp, sigqueue_rt);
return atf_no_error();
}
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_wait.c b/contrib/netbsd-tests/lib/libc/sys/t_wait.c
new file mode 100644
index 0000000..027c40d
--- /dev/null
+++ b/contrib/netbsd-tests/lib/libc/sys/t_wait.c
@@ -0,0 +1,265 @@
+/* $NetBSD: t_wait.c,v 1.4 2016/04/27 21:14:24 christos Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * 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.c,v 1.4 2016/04/27 21:14:24 christos Exp $");
+
+#include <sys/wait.h>
+#include <sys/resource.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <limits.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#ifdef __FreeBSD__
+#define wrusage __wrusage
+#endif
+
+ATF_TC(wait6_invalid);
+ATF_TC_HEAD(wait6_invalid, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait6(2) returns EINVAL with 0 options");
+}
+
+ATF_TC_BODY(wait6_invalid, tc)
+{
+ siginfo_t si;
+ struct wrusage wru;
+ int st;
+ ATF_REQUIRE(wait6(P_ALL, 0, &st, 0, &wru, &si) == -1
+ && errno == EINVAL);
+}
+
+ATF_TC(wait6_noproc);
+ATF_TC_HEAD(wait6_noproc, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait6(2) returns ECHILD with for no processes");
+}
+
+ATF_TC_BODY(wait6_noproc, tc)
+{
+ siginfo_t si;
+ struct wrusage wru;
+ int st;
+ ATF_REQUIRE(wait6(P_ALL, 0, &st, WEXITED, &wru, &si) == -1
+ && errno == ECHILD);
+}
+
+ATF_TC(wait6_exited);
+ATF_TC_HEAD(wait6_exited, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait6(2) handled exiting process and code");
+}
+
+ATF_TC_BODY(wait6_exited, tc)
+{
+ siginfo_t si;
+ struct wrusage wru;
+ int st;
+ pid_t pid;
+
+ switch (pid = fork()) {
+ case -1:
+ ATF_REQUIRE(pid > 0);
+ case 0:
+ exit(0x5a5a5a5a);
+ /*NOTREACHED*/
+ default:
+ ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid);
+ ATF_REQUIRE(WIFEXITED(st) && WEXITSTATUS(st) == 0x5a);
+ ATF_REQUIRE(si.si_status = 0x5a5a5a5a);
+ ATF_REQUIRE(si.si_pid == pid);
+ ATF_REQUIRE(si.si_uid == getuid());
+ ATF_REQUIRE(si.si_code == CLD_EXITED);
+#ifdef __NetBSD__
+ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime,
+ (uintmax_t)si.si_utime);
+#endif
+ break;
+ }
+}
+
+ATF_TC(wait6_terminated);
+ATF_TC_HEAD(wait6_terminated, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait6(2) handled terminated process and code");
+}
+
+ATF_TC_BODY(wait6_terminated, tc)
+{
+ siginfo_t si;
+ struct wrusage wru;
+ int st;
+ pid_t pid;
+
+ switch (pid = fork()) {
+ case 0:
+ sleep(100);
+ /*FALLTHROUGH*/
+ case -1:
+ ATF_REQUIRE(pid > 0);
+ default:
+ ATF_REQUIRE(kill(pid, SIGTERM) == 0);
+ ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid);
+ ATF_REQUIRE(WIFSIGNALED(st) && WTERMSIG(st) == SIGTERM);
+ ATF_REQUIRE(si.si_status == SIGTERM);
+ ATF_REQUIRE(si.si_pid == pid);
+ ATF_REQUIRE(si.si_uid == getuid());
+ ATF_REQUIRE(si.si_code == CLD_KILLED);
+#ifdef __NetBSD__
+ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime,
+ (uintmax_t)si.si_utime);
+#endif
+ break;
+ }
+}
+
+ATF_TC(wait6_coredumped);
+ATF_TC_HEAD(wait6_coredumped, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait6(2) handled coredumped process and code");
+}
+
+ATF_TC_BODY(wait6_coredumped, tc)
+{
+ siginfo_t si;
+ struct wrusage wru;
+ int st;
+ pid_t pid;
+ static const struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
+
+ switch (pid = fork()) {
+ case 0:
+ ATF_REQUIRE(setrlimit(RLIMIT_CORE, &rl) == 0);
+ *(char *)8 = 0;
+ /*FALLTHROUGH*/
+ case -1:
+ ATF_REQUIRE(pid > 0);
+ default:
+ ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid);
+ ATF_REQUIRE(WIFSIGNALED(st) && WTERMSIG(st) == SIGSEGV
+ && WCOREDUMP(st));
+ ATF_REQUIRE(si.si_status == SIGSEGV);
+ ATF_REQUIRE(si.si_pid == pid);
+ ATF_REQUIRE(si.si_uid == getuid());
+ ATF_REQUIRE(si.si_code == CLD_DUMPED);
+#ifdef __NetBSD__
+ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime,
+ (uintmax_t)si.si_utime);
+#endif
+ break;
+ }
+}
+
+ATF_TC(wait6_stop_and_go);
+ATF_TC_HEAD(wait6_stop_and_go, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test that wait6(2) handled stopped/continued process and code");
+}
+
+ATF_TC_BODY(wait6_stop_and_go, tc)
+{
+ siginfo_t si;
+ struct wrusage wru;
+ int st;
+ pid_t pid;
+ static const struct rlimit rl = { 0, 0 };
+
+ ATF_REQUIRE(setrlimit(RLIMIT_CORE, &rl) == 0);
+ switch (pid = fork()) {
+ case 0:
+ sleep(100);
+ /*FALLTHROUGH*/
+ case -1:
+ ATF_REQUIRE(pid > 0);
+ default:
+ ATF_REQUIRE(kill(pid, SIGSTOP) == 0);
+ ATF_REQUIRE(wait6(P_PID, pid, &st, WSTOPPED, &wru, &si) == pid);
+ ATF_REQUIRE(WIFSTOPPED(st) && WSTOPSIG(st) == SIGSTOP);
+ ATF_REQUIRE(si.si_status == SIGSTOP);
+ ATF_REQUIRE(si.si_pid == pid);
+ ATF_REQUIRE(si.si_uid == getuid());
+ ATF_REQUIRE(si.si_code == CLD_STOPPED);
+#ifdef __NetBSD__
+ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime,
+ (uintmax_t)si.si_utime);
+#endif
+
+ ATF_REQUIRE(kill(pid, SIGCONT) == 0);
+ ATF_REQUIRE(wait6(P_PID, pid, &st, WCONTINUED, &wru, &si) == pid);
+ ATF_REQUIRE(WIFCONTINUED(st));
+ ATF_REQUIRE(si.si_status == SIGCONT);
+ ATF_REQUIRE(si.si_pid == pid);
+ ATF_REQUIRE(si.si_uid == getuid());
+ ATF_REQUIRE(si.si_code == CLD_CONTINUED);
+#ifdef __NetBSD__
+ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime,
+ (uintmax_t)si.si_utime);
+#endif
+
+ ATF_REQUIRE(kill(pid, SIGQUIT) == 0);
+ ATF_REQUIRE(wait6(P_PID, pid, &st, WEXITED, &wru, &si) == pid);
+ ATF_REQUIRE(WIFSIGNALED(st) && WTERMSIG(st) == SIGQUIT);
+ ATF_REQUIRE(si.si_status == SIGQUIT);
+ ATF_REQUIRE(si.si_pid == pid);
+ ATF_REQUIRE(si.si_uid == getuid());
+ ATF_REQUIRE(si.si_code == CLD_KILLED);
+#ifdef __NetBSD__
+ printf("user: %ju system: %ju\n", (uintmax_t)si.si_utime,
+ (uintmax_t)si.si_utime);
+#endif
+ break;
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, wait6_invalid);
+ ATF_TP_ADD_TC(tp, wait6_noproc);
+ ATF_TP_ADD_TC(tp, wait6_exited);
+ ATF_TP_ADD_TC(tp, wait6_terminated);
+ ATF_TP_ADD_TC(tp, wait6_coredumped);
+ ATF_TP_ADD_TC(tp, wait6_stop_and_go);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/lib/libc/time/t_strptime.c b/contrib/netbsd-tests/lib/libc/time/t_strptime.c
index 99871ff..863df36e 100644
--- a/contrib/netbsd-tests/lib/libc/time/t_strptime.c
+++ b/contrib/netbsd-tests/lib/libc/time/t_strptime.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strptime.c,v 1.1 2011/01/13 00:14:10 pgoyette Exp $ */
+/* $NetBSD: t_strptime.c,v 1.12 2015/10/31 02:25:11 christos Exp $ */
/*-
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -32,9 +32,11 @@
#include <sys/cdefs.h>
__COPYRIGHT("@(#) Copyright (c) 2008\
The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_strptime.c,v 1.1 2011/01/13 00:14:10 pgoyette Exp $");
+__RCSID("$NetBSD: t_strptime.c,v 1.12 2015/10/31 02:25:11 christos Exp $");
#include <time.h>
+#include <stdlib.h>
+#include <stdio.h>
#include <atf-c.h>
@@ -97,6 +99,124 @@ h_fail(const char *buf, const char *fmt)
#endif
}
+static struct {
+ const char *name;
+ long offs;
+} zt[] = {
+ { "Z", 0 },
+ { "UT", 0 },
+ { "UTC", 0 },
+ { "GMT", 0 },
+ { "EST", -18000 },
+ { "EDT", -14400 },
+ { "CST", -21600 },
+ { "CDT", -18000 },
+ { "MST", -25200 },
+ { "MDT", -21600 },
+ { "PST", -28800 },
+ { "PDT", -25200 },
+
+ { "VST", -1 },
+ { "VDT", -1 },
+
+ { "+03", 10800 },
+ { "-03", -10800 },
+ { "+0403", 14580 },
+ { "-0403", -14580 },
+ { "+04:03", 14580 },
+ { "-04:03", -14580 },
+ { "+14:00", 50400 },
+ { "-14:00", -50400 },
+ { "+23:59", 86340 },
+ { "-23:59", -86340 },
+
+ { "1", -1 },
+ { "03", -1 },
+ { "0304", -1 },
+ { "+1", -1 },
+ { "-203", -1 },
+ { "+12345", -1 },
+ { "+12:345", -1 },
+ { "+123:45", -1 },
+ { "+2400", -1 },
+ { "-2400", -1 },
+ { "+1060", -1 },
+ { "-1060", -1 },
+
+ { "A", -3600 },
+ { "B", -7200 },
+ { "C", -10800 },
+ { "D", -14400 },
+ { "E", -18000 },
+ { "F", -21600 },
+ { "G", -25200 },
+ { "H", -28800 },
+ { "I", -32400 },
+ { "L", -39600 },
+ { "M", -43200 },
+ { "N", 3600 },
+ { "O", 7200 },
+ { "P", 10800 },
+ { "Q", 14400 },
+ { "R", 18000 },
+ { "T", 25200 },
+ { "U", 28800 },
+ { "V", 32400 },
+ { "W", 36000 },
+ { "X", 39600 },
+ { "Y", 43200 },
+
+ { "J", -2 },
+
+ { "America/Los_Angeles", -28800 },
+ { "America/New_York", -18000 },
+ { "EST4EDT", -14400 },
+
+ { "Bogus", -1 },
+};
+
+static void
+ztest1(const char *name, const char *fmt, long value)
+{
+ struct tm tm;
+ char *rv;
+
+ memset(&tm, 0, sizeof(tm));
+ if ((rv = strptime(name, fmt, &tm)) == NULL)
+ tm.tm_gmtoff = -1;
+ else if (rv == name && fmt[1] == 'Z')
+ value = 0;
+
+ switch (value) {
+ case -2:
+ value = -timezone;
+ break;
+ case -1:
+ if (fmt[1] == 'Z')
+ value = 0;
+ break;
+ default:
+ break;
+ }
+
+ ATF_REQUIRE_MSG(tm.tm_gmtoff == value,
+ "strptime(\"%s\", \"%s\", &tm): "
+ "expected: tm.tm_gmtoff=%ld, got: tm.tm_gmtoff=%ld",
+ name, fmt, value, tm.tm_gmtoff);
+ printf("%s %s %ld\n", name, fmt, tm.tm_gmtoff);
+}
+
+static void
+ztest(const char *fmt)
+{
+ setenv("TZ", "US/Eastern", 1);
+ ztest1("GMT", fmt, 0);
+ ztest1("UTC", fmt, 0);
+ ztest1("US/Eastern", fmt, -18000);
+ for (size_t i = 0; i < __arraycount(zt); i++)
+ ztest1(zt[i].name, fmt, zt[i].offs);
+}
+
ATF_TC(common);
ATF_TC_HEAD(common, tc)
@@ -113,33 +233,17 @@ ATF_TC_BODY(common, tc)
#endif
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %T %Y",
- 24, 46, 27, 23, 20, 0, 98, 2, -1);
+ 24, 46, 27, 23, 20, 0, 98, 2, 19);
h_pass("Tue Jan 20 23:27:46 1998", "%a %b %d %H:%M:%S %Y",
- 24, 46, 27, 23, 20, 0, 98, 2, -1);
+ 24, 46, 27, 23, 20, 0, 98, 2, 19);
h_pass("Tue Jan 20 23:27:46 1998", "%c",
- 24, 46, 27, 23, 20, 0, 98, 2, -1);
+ 24, 46, 27, 23, 20, 0, 98, 2, 19);
h_pass("Fri Mar 4 20:05:34 2005", "%a %b %e %H:%M:%S %Y",
- 24, 34, 5, 20, 4, 2, 105, 5, -1);
+ 24, 34, 5, 20, 4, 2, 105, 5, 62);
h_pass("5\t3 4 8pm:05:34 2005", "%w%n%m%t%d%n%k%p:%M:%S %Y",
- 21, 34, 5, 20, 4, 2, 105, 5, -1);
+ 21, 34, 5, 20, 4, 2, 105, 5, 62);
h_pass("Fri Mar 4 20:05:34 2005", "%c",
- 24, 34, 5, 20, 4, 2, 105, 5, -1);
-
- h_pass("x20y", "x%Cy", 4, -1, -1, -1, -1, -1, 100, -1, -1);
- h_pass("x84y", "x%yy", 4, -1, -1, -1, -1, -1, 84, -1, -1);
- h_pass("x2084y", "x%C%yy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
- h_pass("x8420y", "x%y%Cy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
- h_pass("%20845", "%%%C%y5", 6, -1, -1, -1, -1, -1, 184, -1, -1);
- h_fail("%", "%E%");
-
- h_pass("1980", "%Y", 4, -1, -1, -1, -1, -1, 80, -1, -1);
- h_pass("1980", "%EY", 4, -1, -1, -1, -1, -1, 80, -1, -1);
-
- h_pass("0", "%S", 1, 0, -1, -1, -1, -1, -1, -1, -1);
- h_pass("59", "%S", 2, 59, -1, -1, -1, -1, -1, -1, -1);
- h_pass("60", "%S", 2, 60, -1, -1, -1, -1, -1, -1, -1);
- h_pass("61", "%S", 2, 61, -1, -1, -1, -1, -1, -1, -1);
- h_fail("62", "%S");
+ 24, 34, 5, 20, 4, 2, 105, 5, 62);
}
ATF_TC(day);
@@ -147,7 +251,8 @@ ATF_TC(day);
ATF_TC_HEAD(day, tc)
{
- atf_tc_set_md_var(tc, "descr", "Checks strptime(3): day names");
+ atf_tc_set_md_var(tc, "descr",
+ "Checks strptime(3) day name conversions [aA]");
}
ATF_TC_BODY(day, tc)
@@ -202,12 +307,35 @@ ATF_TC_BODY(day, tc)
#endif
}
+ATF_TC(hour);
+
+ATF_TC_HEAD(hour, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Checks strptime(3) hour conversions [IH]");
+}
+
+ATF_TC_BODY(hour, tc)
+{
+
+ h_fail("00", "%I");
+ h_fail("13", "%I");
+
+ h_pass("00", "%H", 2, -1, -1, 0, -1, -1, -1, -1, -1);
+ h_pass("12", "%H", 2, -1, -1, 12, -1, -1, -1, -1, -1);
+ h_pass("23", "%H", 2, -1, -1, 23, -1, -1, -1, -1, -1);
+ h_fail("24", "%H");
+}
+
+
ATF_TC(month);
ATF_TC_HEAD(month, tc)
{
- atf_tc_set_md_var(tc, "descr", "Checks strptime(3): month names");
+ atf_tc_set_md_var(tc, "descr",
+ "Checks strptime(3) month name conversions [bB]");
}
ATF_TC_BODY(month, tc)
@@ -270,12 +398,89 @@ ATF_TC_BODY(month, tc)
h_pass("septembe", "%B", 3, -1, -1, -1, -1, 8, -1, -1, -1);
}
+ATF_TC(seconds);
+
+ATF_TC_HEAD(seconds, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Checks strptime(3) seconds conversions [S]");
+}
+
+ATF_TC_BODY(seconds, tc)
+{
+
+ h_pass("0", "%S", 1, 0, -1, -1, -1, -1, -1, -1, -1);
+ h_pass("59", "%S", 2, 59, -1, -1, -1, -1, -1, -1, -1);
+ h_pass("60", "%S", 2, 60, -1, -1, -1, -1, -1, -1, -1);
+ h_pass("61", "%S", 2, 61, -1, -1, -1, -1, -1, -1, -1);
+ h_fail("62", "%S");
+}
+
+ATF_TC(year);
+
+ATF_TC_HEAD(year, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Checks strptime(3) century/year conversions [CyY]");
+}
+
+ATF_TC_BODY(year, tc)
+{
+
+ h_pass("x20y", "x%Cy", 4, -1, -1, -1, -1, -1, 100, -1, -1);
+ h_pass("x84y", "x%yy", 4, -1, -1, -1, -1, -1, 84, -1, -1);
+ h_pass("x2084y", "x%C%yy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
+ h_pass("x8420y", "x%y%Cy", 6, -1, -1, -1, -1, -1, 184, -1, -1);
+ h_pass("%20845", "%%%C%y5", 6, -1, -1, -1, -1, -1, 184, -1, -1);
+ h_fail("%", "%E%");
+
+ h_pass("1980", "%Y", 4, -1, -1, -1, -1, -1, 80, -1, -1);
+ h_pass("1980", "%EY", 4, -1, -1, -1, -1, -1, 80, -1, -1);
+}
+
+ATF_TC(zone);
+
+ATF_TC_HEAD(zone, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Checks strptime(3) timezone conversion [z]");
+}
+
+
+ATF_TC_BODY(zone, tc)
+{
+ ztest("%z");
+}
+
+ATF_TC(Zone);
+
+ATF_TC_HEAD(Zone, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr",
+ "Checks strptime(3) timezone conversion [Z]");
+}
+
+
+ATF_TC_BODY(Zone, tc)
+{
+ ztest("%z");
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, common);
ATF_TP_ADD_TC(tp, day);
+ ATF_TP_ADD_TC(tp, hour);
ATF_TP_ADD_TC(tp, month);
+ ATF_TP_ADD_TC(tp, seconds);
+ ATF_TP_ADD_TC(tp, year);
+ ATF_TP_ADD_TC(tp, zone);
+ ATF_TP_ADD_TC(tp, Zone);
return atf_no_error();
}
OpenPOWER on IntegriCloud