aboutsummaryrefslogtreecommitdiff
path: root/contrib/netbsd-tests/include
diff options
context:
space:
mode:
authorEnji Cooper <ngie@FreeBSD.org>2014-10-02 23:26:49 +0000
committerEnji Cooper <ngie@FreeBSD.org>2014-10-02 23:26:49 +0000
commit57718be8fa0bd5edc11ab9a72e68cc71982939a6 (patch)
tree544932e2a2c5a5a202b752beefba0b3e327b3858 /contrib/netbsd-tests/include
parent3fbe079a343c4122c09478f9679d9ca224f4b9c0 (diff)
parent478290db20b28ab28ce7e08cf33f1b44d82e4cb3 (diff)
downloadsrc-57718be8fa0bd5edc11ab9a72e68cc71982939a6.tar.gz
src-57718be8fa0bd5edc11ab9a72e68cc71982939a6.zip
Import the NetBSD test suite from ^/vendor/NetBSD/tests/09.30.2014_20.45 ,
minus the vendor Makefiles Provide directions for how to bootstrap the vendor sources in FREEBSD-upgrade MFC after 2 weeks Discussed with: rpaulo Sponsored by: EMC / Isilon Storage Division
Notes
Notes: svn path=/head/; revision=272458
Diffstat (limited to 'contrib/netbsd-tests/include')
-rw-r--r--contrib/netbsd-tests/include/d_bitstring_27.out263
-rw-r--r--contrib/netbsd-tests/include/d_bitstring_32.out303
-rw-r--r--contrib/netbsd-tests/include/d_bitstring_49.out439
-rw-r--r--contrib/netbsd-tests/include/d_bitstring_64.out559
-rw-r--r--contrib/netbsd-tests/include/d_bitstring_67.out583
-rw-r--r--contrib/netbsd-tests/include/d_bitstring_8.out111
-rw-r--r--contrib/netbsd-tests/include/machine/t_bswap.c178
-rw-r--r--contrib/netbsd-tests/include/sys/t_bitops.c238
-rw-r--r--contrib/netbsd-tests/include/sys/t_bootblock.c73
-rw-r--r--contrib/netbsd-tests/include/sys/t_cdefs.c267
-rw-r--r--contrib/netbsd-tests/include/sys/t_socket.c205
-rw-r--r--contrib/netbsd-tests/include/sys/t_tree.c124
-rw-r--r--contrib/netbsd-tests/include/sys/t_types.c144
-rw-r--r--contrib/netbsd-tests/include/t_bitstring.c298
-rw-r--r--contrib/netbsd-tests/include/t_errno.c765
-rw-r--r--contrib/netbsd-tests/include/t_glob.c75
-rw-r--r--contrib/netbsd-tests/include/t_inttypes.c250
-rw-r--r--contrib/netbsd-tests/include/t_limits.c287
-rw-r--r--contrib/netbsd-tests/include/t_netdb.c244
-rw-r--r--contrib/netbsd-tests/include/t_paths.c205
-rw-r--r--contrib/netbsd-tests/include/t_stdint.c57
21 files changed, 5668 insertions, 0 deletions
diff --git a/contrib/netbsd-tests/include/d_bitstring_27.out b/contrib/netbsd-tests/include/d_bitstring_27.out
new file mode 100644
index 000000000000..55ba39e774d9
--- /dev/null
+++ b/contrib/netbsd-tests/include/d_bitstring_27.out
@@ -0,0 +1,263 @@
+Testing with TEST_LENGTH = 27
+
+test _bit_byte, _bit_mask, and bitstr_size
+ i _bit_byte(i) _bit_mask(i) bitstr_size(i)
+ 0 0 1 0
+ 1 0 2 1
+ 2 0 4 1
+ 3 0 8 1
+ 4 0 16 1
+ 5 0 32 1
+ 6 0 64 1
+ 7 0 128 1
+ 8 1 1 1
+ 9 1 2 2
+ 10 1 4 2
+ 11 1 8 2
+ 12 1 16 2
+ 13 1 32 2
+ 14 1 64 2
+ 15 1 128 2
+ 16 2 1 2
+ 17 2 2 3
+ 18 2 4 3
+ 19 2 8 3
+ 20 2 16 3
+ 21 2 32 3
+ 22 2 64 3
+ 23 2 128 3
+ 24 3 1 3
+ 25 3 2 4
+ 26 3 4 4
+
+test bit_alloc, clearbits, bit_ffc, bit_ffs
+be: 0 -1 000000000000000000000000000
+is: 0 -1 000000000000000000000000000
+
+test bit_set
+be: 1 0 100100100100100100100100100
+is: 1 0 100100100100100100100100100
+
+test bit_clear
+be: 0 3 000100000100000100000100000
+is: 0 3 000100000100000100000100000
+
+test bit_test using previous bitstring
+ i bit_test(i)
+ 0 0
+ 1 0
+ 2 0
+ 3 8
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 2
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 128
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 32
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+
+test clearbits
+be: 0 -1 000000000000000000000000000
+is: 0 -1 000000000000000000000000000
+
+test bit_nset and bit_nclear
+be: 0 1 011111111111111111111111110
+is: 0 1 011111111111111111111111110
+be: 0 1 010000000000000000000000010
+is: 0 1 010000000000000000000000010
+be: 0 -1 000000000000000000000000000
+is: 0 -1 000000000000000000000000000
+be: 26 0 111111111111111111111111110
+is: 26 0 111111111111111111111111110
+be: 0 -1 000000000000000000000000000
+is: 0 -1 000000000000000000000000000
+
+first 1 bit should move right 1 position each line
+ 0 -1 0 111111111111111111111111111
+ 1 0 1 011111111111111111111111111
+ 2 0 2 001111111111111111111111111
+ 3 0 3 000111111111111111111111111
+ 4 0 4 000011111111111111111111111
+ 5 0 5 000001111111111111111111111
+ 6 0 6 000000111111111111111111111
+ 7 0 7 000000011111111111111111111
+ 8 0 8 000000001111111111111111111
+ 9 0 9 000000000111111111111111111
+ 10 0 10 000000000011111111111111111
+ 11 0 11 000000000001111111111111111
+ 12 0 12 000000000000111111111111111
+ 13 0 13 000000000000011111111111111
+ 14 0 14 000000000000001111111111111
+ 15 0 15 000000000000000111111111111
+ 16 0 16 000000000000000011111111111
+ 17 0 17 000000000000000001111111111
+ 18 0 18 000000000000000000111111111
+ 19 0 19 000000000000000000011111111
+ 20 0 20 000000000000000000001111111
+ 21 0 21 000000000000000000000111111
+ 22 0 22 000000000000000000000011111
+ 23 0 23 000000000000000000000001111
+ 24 0 24 000000000000000000000000111
+ 25 0 25 000000000000000000000000011
+ 26 0 26 000000000000000000000000001
+
+first 0 bit should move right 1 position each line
+ 0 0 -1 000000000000000000000000000
+ 1 1 0 100000000000000000000000000
+ 2 2 0 110000000000000000000000000
+ 3 3 0 111000000000000000000000000
+ 4 4 0 111100000000000000000000000
+ 5 5 0 111110000000000000000000000
+ 6 6 0 111111000000000000000000000
+ 7 7 0 111111100000000000000000000
+ 8 8 0 111111110000000000000000000
+ 9 9 0 111111111000000000000000000
+ 10 10 0 111111111100000000000000000
+ 11 11 0 111111111110000000000000000
+ 12 12 0 111111111111000000000000000
+ 13 13 0 111111111111100000000000000
+ 14 14 0 111111111111110000000000000
+ 15 15 0 111111111111111000000000000
+ 16 16 0 111111111111111100000000000
+ 17 17 0 111111111111111110000000000
+ 18 18 0 111111111111111111000000000
+ 19 19 0 111111111111111111100000000
+ 20 20 0 111111111111111111110000000
+ 21 21 0 111111111111111111111000000
+ 22 22 0 111111111111111111111100000
+ 23 23 0 111111111111111111111110000
+ 24 24 0 111111111111111111111111000
+ 25 25 0 111111111111111111111111100
+ 26 26 0 111111111111111111111111110
+
+first 0 bit should move left 1 position each line
+ 0 -1 0 111111111111111111111111111
+ 1 26 0 111111111111111111111111110
+ 2 25 0 111111111111111111111111100
+ 3 24 0 111111111111111111111111000
+ 4 23 0 111111111111111111111110000
+ 5 22 0 111111111111111111111100000
+ 6 21 0 111111111111111111111000000
+ 7 20 0 111111111111111111110000000
+ 8 19 0 111111111111111111100000000
+ 9 18 0 111111111111111111000000000
+ 10 17 0 111111111111111110000000000
+ 11 16 0 111111111111111100000000000
+ 12 15 0 111111111111111000000000000
+ 13 14 0 111111111111110000000000000
+ 14 13 0 111111111111100000000000000
+ 15 12 0 111111111111000000000000000
+ 16 11 0 111111111110000000000000000
+ 17 10 0 111111111100000000000000000
+ 18 9 0 111111111000000000000000000
+ 19 8 0 111111110000000000000000000
+ 20 7 0 111111100000000000000000000
+ 21 6 0 111111000000000000000000000
+ 22 5 0 111110000000000000000000000
+ 23 4 0 111100000000000000000000000
+ 24 3 0 111000000000000000000000000
+ 25 2 0 110000000000000000000000000
+ 26 1 0 100000000000000000000000000
+
+first 1 bit should move left 1 position each line
+ 0 0 -1 000000000000000000000000000
+ 1 0 26 000000000000000000000000001
+ 2 0 25 000000000000000000000000011
+ 3 0 24 000000000000000000000000111
+ 4 0 23 000000000000000000000001111
+ 5 0 22 000000000000000000000011111
+ 6 0 21 000000000000000000000111111
+ 7 0 20 000000000000000000001111111
+ 8 0 19 000000000000000000011111111
+ 9 0 18 000000000000000000111111111
+ 10 0 17 000000000000000001111111111
+ 11 0 16 000000000000000011111111111
+ 12 0 15 000000000000000111111111111
+ 13 0 14 000000000000001111111111111
+ 14 0 13 000000000000011111111111111
+ 15 0 12 000000000000111111111111111
+ 16 0 11 000000000001111111111111111
+ 17 0 10 000000000011111111111111111
+ 18 0 9 000000000111111111111111111
+ 19 0 8 000000001111111111111111111
+ 20 0 7 000000011111111111111111111
+ 21 0 6 000000111111111111111111111
+ 22 0 5 000001111111111111111111111
+ 23 0 4 000011111111111111111111111
+ 24 0 3 000111111111111111111111111
+ 25 0 2 001111111111111111111111111
+ 26 0 1 011111111111111111111111111
+
+0 bit should move right 1 position each line
+ 0 0 1 011111111111111111111111111
+ 1 1 0 101111111111111111111111111
+ 2 2 0 110111111111111111111111111
+ 3 3 0 111011111111111111111111111
+ 4 4 0 111101111111111111111111111
+ 5 5 0 111110111111111111111111111
+ 6 6 0 111111011111111111111111111
+ 7 7 0 111111101111111111111111111
+ 8 8 0 111111110111111111111111111
+ 9 9 0 111111111011111111111111111
+ 10 10 0 111111111101111111111111111
+ 11 11 0 111111111110111111111111111
+ 12 12 0 111111111111011111111111111
+ 13 13 0 111111111111101111111111111
+ 14 14 0 111111111111110111111111111
+ 15 15 0 111111111111111011111111111
+ 16 16 0 111111111111111101111111111
+ 17 17 0 111111111111111110111111111
+ 18 18 0 111111111111111111011111111
+ 19 19 0 111111111111111111101111111
+ 20 20 0 111111111111111111110111111
+ 21 21 0 111111111111111111111011111
+ 22 22 0 111111111111111111111101111
+ 23 23 0 111111111111111111111110111
+ 24 24 0 111111111111111111111111011
+ 25 25 0 111111111111111111111111101
+ 26 26 0 111111111111111111111111110
+
+1 bit should move right 1 position each line
+ 0 1 0 100000000000000000000000000
+ 1 0 1 010000000000000000000000000
+ 2 0 2 001000000000000000000000000
+ 3 0 3 000100000000000000000000000
+ 4 0 4 000010000000000000000000000
+ 5 0 5 000001000000000000000000000
+ 6 0 6 000000100000000000000000000
+ 7 0 7 000000010000000000000000000
+ 8 0 8 000000001000000000000000000
+ 9 0 9 000000000100000000000000000
+ 10 0 10 000000000010000000000000000
+ 11 0 11 000000000001000000000000000
+ 12 0 12 000000000000100000000000000
+ 13 0 13 000000000000010000000000000
+ 14 0 14 000000000000001000000000000
+ 15 0 15 000000000000000100000000000
+ 16 0 16 000000000000000010000000000
+ 17 0 17 000000000000000001000000000
+ 18 0 18 000000000000000000100000000
+ 19 0 19 000000000000000000010000000
+ 20 0 20 000000000000000000001000000
+ 21 0 21 000000000000000000000100000
+ 22 0 22 000000000000000000000010000
+ 23 0 23 000000000000000000000001000
+ 24 0 24 000000000000000000000000100
+ 25 0 25 000000000000000000000000010
+ 26 0 26 000000000000000000000000001
diff --git a/contrib/netbsd-tests/include/d_bitstring_32.out b/contrib/netbsd-tests/include/d_bitstring_32.out
new file mode 100644
index 000000000000..2e1ca55d6e32
--- /dev/null
+++ b/contrib/netbsd-tests/include/d_bitstring_32.out
@@ -0,0 +1,303 @@
+Testing with TEST_LENGTH = 32
+
+test _bit_byte, _bit_mask, and bitstr_size
+ i _bit_byte(i) _bit_mask(i) bitstr_size(i)
+ 0 0 1 0
+ 1 0 2 1
+ 2 0 4 1
+ 3 0 8 1
+ 4 0 16 1
+ 5 0 32 1
+ 6 0 64 1
+ 7 0 128 1
+ 8 1 1 1
+ 9 1 2 2
+ 10 1 4 2
+ 11 1 8 2
+ 12 1 16 2
+ 13 1 32 2
+ 14 1 64 2
+ 15 1 128 2
+ 16 2 1 2
+ 17 2 2 3
+ 18 2 4 3
+ 19 2 8 3
+ 20 2 16 3
+ 21 2 32 3
+ 22 2 64 3
+ 23 2 128 3
+ 24 3 1 3
+ 25 3 2 4
+ 26 3 4 4
+ 27 3 8 4
+ 28 3 16 4
+ 29 3 32 4
+ 30 3 64 4
+ 31 3 128 4
+
+test bit_alloc, clearbits, bit_ffc, bit_ffs
+be: 0 -1 00000000000000000000000000000000
+is: 0 -1 00000000000000000000000000000000
+
+test bit_set
+be: 1 0 10010010010010010010010010010010
+is: 1 0 10010010010010010010010010010010
+
+test bit_clear
+be: 0 3 00010000010000010000010000010000
+is: 0 3 00010000010000010000010000010000
+
+test bit_test using previous bitstring
+ i bit_test(i)
+ 0 0
+ 1 0
+ 2 0
+ 3 8
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 2
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 128
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 32
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 8
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+
+test clearbits
+be: 0 -1 00000000000000000000000000000000
+is: 0 -1 00000000000000000000000000000000
+
+test bit_nset and bit_nclear
+be: 0 1 01111111111111111111111111111110
+is: 0 1 01111111111111111111111111111110
+be: 0 1 01000000000000000000000000000010
+is: 0 1 01000000000000000000000000000010
+be: 0 -1 00000000000000000000000000000000
+is: 0 -1 00000000000000000000000000000000
+be: 31 0 11111111111111111111111111111110
+is: 31 0 11111111111111111111111111111110
+be: 0 -1 00000000000000000000000000000000
+is: 0 -1 00000000000000000000000000000000
+
+first 1 bit should move right 1 position each line
+ 0 -1 0 11111111111111111111111111111111
+ 1 0 1 01111111111111111111111111111111
+ 2 0 2 00111111111111111111111111111111
+ 3 0 3 00011111111111111111111111111111
+ 4 0 4 00001111111111111111111111111111
+ 5 0 5 00000111111111111111111111111111
+ 6 0 6 00000011111111111111111111111111
+ 7 0 7 00000001111111111111111111111111
+ 8 0 8 00000000111111111111111111111111
+ 9 0 9 00000000011111111111111111111111
+ 10 0 10 00000000001111111111111111111111
+ 11 0 11 00000000000111111111111111111111
+ 12 0 12 00000000000011111111111111111111
+ 13 0 13 00000000000001111111111111111111
+ 14 0 14 00000000000000111111111111111111
+ 15 0 15 00000000000000011111111111111111
+ 16 0 16 00000000000000001111111111111111
+ 17 0 17 00000000000000000111111111111111
+ 18 0 18 00000000000000000011111111111111
+ 19 0 19 00000000000000000001111111111111
+ 20 0 20 00000000000000000000111111111111
+ 21 0 21 00000000000000000000011111111111
+ 22 0 22 00000000000000000000001111111111
+ 23 0 23 00000000000000000000000111111111
+ 24 0 24 00000000000000000000000011111111
+ 25 0 25 00000000000000000000000001111111
+ 26 0 26 00000000000000000000000000111111
+ 27 0 27 00000000000000000000000000011111
+ 28 0 28 00000000000000000000000000001111
+ 29 0 29 00000000000000000000000000000111
+ 30 0 30 00000000000000000000000000000011
+ 31 0 31 00000000000000000000000000000001
+
+first 0 bit should move right 1 position each line
+ 0 0 -1 00000000000000000000000000000000
+ 1 1 0 10000000000000000000000000000000
+ 2 2 0 11000000000000000000000000000000
+ 3 3 0 11100000000000000000000000000000
+ 4 4 0 11110000000000000000000000000000
+ 5 5 0 11111000000000000000000000000000
+ 6 6 0 11111100000000000000000000000000
+ 7 7 0 11111110000000000000000000000000
+ 8 8 0 11111111000000000000000000000000
+ 9 9 0 11111111100000000000000000000000
+ 10 10 0 11111111110000000000000000000000
+ 11 11 0 11111111111000000000000000000000
+ 12 12 0 11111111111100000000000000000000
+ 13 13 0 11111111111110000000000000000000
+ 14 14 0 11111111111111000000000000000000
+ 15 15 0 11111111111111100000000000000000
+ 16 16 0 11111111111111110000000000000000
+ 17 17 0 11111111111111111000000000000000
+ 18 18 0 11111111111111111100000000000000
+ 19 19 0 11111111111111111110000000000000
+ 20 20 0 11111111111111111111000000000000
+ 21 21 0 11111111111111111111100000000000
+ 22 22 0 11111111111111111111110000000000
+ 23 23 0 11111111111111111111111000000000
+ 24 24 0 11111111111111111111111100000000
+ 25 25 0 11111111111111111111111110000000
+ 26 26 0 11111111111111111111111111000000
+ 27 27 0 11111111111111111111111111100000
+ 28 28 0 11111111111111111111111111110000
+ 29 29 0 11111111111111111111111111111000
+ 30 30 0 11111111111111111111111111111100
+ 31 31 0 11111111111111111111111111111110
+
+first 0 bit should move left 1 position each line
+ 0 -1 0 11111111111111111111111111111111
+ 1 31 0 11111111111111111111111111111110
+ 2 30 0 11111111111111111111111111111100
+ 3 29 0 11111111111111111111111111111000
+ 4 28 0 11111111111111111111111111110000
+ 5 27 0 11111111111111111111111111100000
+ 6 26 0 11111111111111111111111111000000
+ 7 25 0 11111111111111111111111110000000
+ 8 24 0 11111111111111111111111100000000
+ 9 23 0 11111111111111111111111000000000
+ 10 22 0 11111111111111111111110000000000
+ 11 21 0 11111111111111111111100000000000
+ 12 20 0 11111111111111111111000000000000
+ 13 19 0 11111111111111111110000000000000
+ 14 18 0 11111111111111111100000000000000
+ 15 17 0 11111111111111111000000000000000
+ 16 16 0 11111111111111110000000000000000
+ 17 15 0 11111111111111100000000000000000
+ 18 14 0 11111111111111000000000000000000
+ 19 13 0 11111111111110000000000000000000
+ 20 12 0 11111111111100000000000000000000
+ 21 11 0 11111111111000000000000000000000
+ 22 10 0 11111111110000000000000000000000
+ 23 9 0 11111111100000000000000000000000
+ 24 8 0 11111111000000000000000000000000
+ 25 7 0 11111110000000000000000000000000
+ 26 6 0 11111100000000000000000000000000
+ 27 5 0 11111000000000000000000000000000
+ 28 4 0 11110000000000000000000000000000
+ 29 3 0 11100000000000000000000000000000
+ 30 2 0 11000000000000000000000000000000
+ 31 1 0 10000000000000000000000000000000
+
+first 1 bit should move left 1 position each line
+ 0 0 -1 00000000000000000000000000000000
+ 1 0 31 00000000000000000000000000000001
+ 2 0 30 00000000000000000000000000000011
+ 3 0 29 00000000000000000000000000000111
+ 4 0 28 00000000000000000000000000001111
+ 5 0 27 00000000000000000000000000011111
+ 6 0 26 00000000000000000000000000111111
+ 7 0 25 00000000000000000000000001111111
+ 8 0 24 00000000000000000000000011111111
+ 9 0 23 00000000000000000000000111111111
+ 10 0 22 00000000000000000000001111111111
+ 11 0 21 00000000000000000000011111111111
+ 12 0 20 00000000000000000000111111111111
+ 13 0 19 00000000000000000001111111111111
+ 14 0 18 00000000000000000011111111111111
+ 15 0 17 00000000000000000111111111111111
+ 16 0 16 00000000000000001111111111111111
+ 17 0 15 00000000000000011111111111111111
+ 18 0 14 00000000000000111111111111111111
+ 19 0 13 00000000000001111111111111111111
+ 20 0 12 00000000000011111111111111111111
+ 21 0 11 00000000000111111111111111111111
+ 22 0 10 00000000001111111111111111111111
+ 23 0 9 00000000011111111111111111111111
+ 24 0 8 00000000111111111111111111111111
+ 25 0 7 00000001111111111111111111111111
+ 26 0 6 00000011111111111111111111111111
+ 27 0 5 00000111111111111111111111111111
+ 28 0 4 00001111111111111111111111111111
+ 29 0 3 00011111111111111111111111111111
+ 30 0 2 00111111111111111111111111111111
+ 31 0 1 01111111111111111111111111111111
+
+0 bit should move right 1 position each line
+ 0 0 1 01111111111111111111111111111111
+ 1 1 0 10111111111111111111111111111111
+ 2 2 0 11011111111111111111111111111111
+ 3 3 0 11101111111111111111111111111111
+ 4 4 0 11110111111111111111111111111111
+ 5 5 0 11111011111111111111111111111111
+ 6 6 0 11111101111111111111111111111111
+ 7 7 0 11111110111111111111111111111111
+ 8 8 0 11111111011111111111111111111111
+ 9 9 0 11111111101111111111111111111111
+ 10 10 0 11111111110111111111111111111111
+ 11 11 0 11111111111011111111111111111111
+ 12 12 0 11111111111101111111111111111111
+ 13 13 0 11111111111110111111111111111111
+ 14 14 0 11111111111111011111111111111111
+ 15 15 0 11111111111111101111111111111111
+ 16 16 0 11111111111111110111111111111111
+ 17 17 0 11111111111111111011111111111111
+ 18 18 0 11111111111111111101111111111111
+ 19 19 0 11111111111111111110111111111111
+ 20 20 0 11111111111111111111011111111111
+ 21 21 0 11111111111111111111101111111111
+ 22 22 0 11111111111111111111110111111111
+ 23 23 0 11111111111111111111111011111111
+ 24 24 0 11111111111111111111111101111111
+ 25 25 0 11111111111111111111111110111111
+ 26 26 0 11111111111111111111111111011111
+ 27 27 0 11111111111111111111111111101111
+ 28 28 0 11111111111111111111111111110111
+ 29 29 0 11111111111111111111111111111011
+ 30 30 0 11111111111111111111111111111101
+ 31 31 0 11111111111111111111111111111110
+
+1 bit should move right 1 position each line
+ 0 1 0 10000000000000000000000000000000
+ 1 0 1 01000000000000000000000000000000
+ 2 0 2 00100000000000000000000000000000
+ 3 0 3 00010000000000000000000000000000
+ 4 0 4 00001000000000000000000000000000
+ 5 0 5 00000100000000000000000000000000
+ 6 0 6 00000010000000000000000000000000
+ 7 0 7 00000001000000000000000000000000
+ 8 0 8 00000000100000000000000000000000
+ 9 0 9 00000000010000000000000000000000
+ 10 0 10 00000000001000000000000000000000
+ 11 0 11 00000000000100000000000000000000
+ 12 0 12 00000000000010000000000000000000
+ 13 0 13 00000000000001000000000000000000
+ 14 0 14 00000000000000100000000000000000
+ 15 0 15 00000000000000010000000000000000
+ 16 0 16 00000000000000001000000000000000
+ 17 0 17 00000000000000000100000000000000
+ 18 0 18 00000000000000000010000000000000
+ 19 0 19 00000000000000000001000000000000
+ 20 0 20 00000000000000000000100000000000
+ 21 0 21 00000000000000000000010000000000
+ 22 0 22 00000000000000000000001000000000
+ 23 0 23 00000000000000000000000100000000
+ 24 0 24 00000000000000000000000010000000
+ 25 0 25 00000000000000000000000001000000
+ 26 0 26 00000000000000000000000000100000
+ 27 0 27 00000000000000000000000000010000
+ 28 0 28 00000000000000000000000000001000
+ 29 0 29 00000000000000000000000000000100
+ 30 0 30 00000000000000000000000000000010
+ 31 0 31 00000000000000000000000000000001
diff --git a/contrib/netbsd-tests/include/d_bitstring_49.out b/contrib/netbsd-tests/include/d_bitstring_49.out
new file mode 100644
index 000000000000..d63c0692deed
--- /dev/null
+++ b/contrib/netbsd-tests/include/d_bitstring_49.out
@@ -0,0 +1,439 @@
+Testing with TEST_LENGTH = 49
+
+test _bit_byte, _bit_mask, and bitstr_size
+ i _bit_byte(i) _bit_mask(i) bitstr_size(i)
+ 0 0 1 0
+ 1 0 2 1
+ 2 0 4 1
+ 3 0 8 1
+ 4 0 16 1
+ 5 0 32 1
+ 6 0 64 1
+ 7 0 128 1
+ 8 1 1 1
+ 9 1 2 2
+ 10 1 4 2
+ 11 1 8 2
+ 12 1 16 2
+ 13 1 32 2
+ 14 1 64 2
+ 15 1 128 2
+ 16 2 1 2
+ 17 2 2 3
+ 18 2 4 3
+ 19 2 8 3
+ 20 2 16 3
+ 21 2 32 3
+ 22 2 64 3
+ 23 2 128 3
+ 24 3 1 3
+ 25 3 2 4
+ 26 3 4 4
+ 27 3 8 4
+ 28 3 16 4
+ 29 3 32 4
+ 30 3 64 4
+ 31 3 128 4
+ 32 4 1 4
+ 33 4 2 5
+ 34 4 4 5
+ 35 4 8 5
+ 36 4 16 5
+ 37 4 32 5
+ 38 4 64 5
+ 39 4 128 5
+ 40 5 1 5
+ 41 5 2 6
+ 42 5 4 6
+ 43 5 8 6
+ 44 5 16 6
+ 45 5 32 6
+ 46 5 64 6
+ 47 5 128 6
+ 48 6 1 6
+
+test bit_alloc, clearbits, bit_ffc, bit_ffs
+be: 0 -1 0000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000
+
+test bit_set
+be: 1 0 1001001001001001001001001001001001001001001001001
+is: 1 0 1001001001001001001001001001001001001001001001001
+
+test bit_clear
+be: 0 3 0001000001000001000001000001000001000001000001000
+is: 0 3 0001000001000001000001000001000001000001000001000
+
+test bit_test using previous bitstring
+ i bit_test(i)
+ 0 0
+ 1 0
+ 2 0
+ 3 8
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 2
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 128
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 32
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 8
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+ 32 0
+ 33 2
+ 34 0
+ 35 0
+ 36 0
+ 37 0
+ 38 0
+ 39 128
+ 40 0
+ 41 0
+ 42 0
+ 43 0
+ 44 0
+ 45 32
+ 46 0
+ 47 0
+ 48 0
+
+test clearbits
+be: 0 -1 0000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000
+
+test bit_nset and bit_nclear
+be: 0 1 0111111111111111111111111111111111111111111111110
+is: 0 1 0111111111111111111111111111111111111111111111110
+be: 0 1 0100000000000000000000000000000000000000000000010
+is: 0 1 0100000000000000000000000000000000000000000000010
+be: 0 -1 0000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000
+be: 48 0 1111111111111111111111111111111111111111111111110
+is: 48 0 1111111111111111111111111111111111111111111111110
+be: 0 -1 0000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000
+
+first 1 bit should move right 1 position each line
+ 0 -1 0 1111111111111111111111111111111111111111111111111
+ 1 0 1 0111111111111111111111111111111111111111111111111
+ 2 0 2 0011111111111111111111111111111111111111111111111
+ 3 0 3 0001111111111111111111111111111111111111111111111
+ 4 0 4 0000111111111111111111111111111111111111111111111
+ 5 0 5 0000011111111111111111111111111111111111111111111
+ 6 0 6 0000001111111111111111111111111111111111111111111
+ 7 0 7 0000000111111111111111111111111111111111111111111
+ 8 0 8 0000000011111111111111111111111111111111111111111
+ 9 0 9 0000000001111111111111111111111111111111111111111
+ 10 0 10 0000000000111111111111111111111111111111111111111
+ 11 0 11 0000000000011111111111111111111111111111111111111
+ 12 0 12 0000000000001111111111111111111111111111111111111
+ 13 0 13 0000000000000111111111111111111111111111111111111
+ 14 0 14 0000000000000011111111111111111111111111111111111
+ 15 0 15 0000000000000001111111111111111111111111111111111
+ 16 0 16 0000000000000000111111111111111111111111111111111
+ 17 0 17 0000000000000000011111111111111111111111111111111
+ 18 0 18 0000000000000000001111111111111111111111111111111
+ 19 0 19 0000000000000000000111111111111111111111111111111
+ 20 0 20 0000000000000000000011111111111111111111111111111
+ 21 0 21 0000000000000000000001111111111111111111111111111
+ 22 0 22 0000000000000000000000111111111111111111111111111
+ 23 0 23 0000000000000000000000011111111111111111111111111
+ 24 0 24 0000000000000000000000001111111111111111111111111
+ 25 0 25 0000000000000000000000000111111111111111111111111
+ 26 0 26 0000000000000000000000000011111111111111111111111
+ 27 0 27 0000000000000000000000000001111111111111111111111
+ 28 0 28 0000000000000000000000000000111111111111111111111
+ 29 0 29 0000000000000000000000000000011111111111111111111
+ 30 0 30 0000000000000000000000000000001111111111111111111
+ 31 0 31 0000000000000000000000000000000111111111111111111
+ 32 0 32 0000000000000000000000000000000011111111111111111
+ 33 0 33 0000000000000000000000000000000001111111111111111
+ 34 0 34 0000000000000000000000000000000000111111111111111
+ 35 0 35 0000000000000000000000000000000000011111111111111
+ 36 0 36 0000000000000000000000000000000000001111111111111
+ 37 0 37 0000000000000000000000000000000000000111111111111
+ 38 0 38 0000000000000000000000000000000000000011111111111
+ 39 0 39 0000000000000000000000000000000000000001111111111
+ 40 0 40 0000000000000000000000000000000000000000111111111
+ 41 0 41 0000000000000000000000000000000000000000011111111
+ 42 0 42 0000000000000000000000000000000000000000001111111
+ 43 0 43 0000000000000000000000000000000000000000000111111
+ 44 0 44 0000000000000000000000000000000000000000000011111
+ 45 0 45 0000000000000000000000000000000000000000000001111
+ 46 0 46 0000000000000000000000000000000000000000000000111
+ 47 0 47 0000000000000000000000000000000000000000000000011
+ 48 0 48 0000000000000000000000000000000000000000000000001
+
+first 0 bit should move right 1 position each line
+ 0 0 -1 0000000000000000000000000000000000000000000000000
+ 1 1 0 1000000000000000000000000000000000000000000000000
+ 2 2 0 1100000000000000000000000000000000000000000000000
+ 3 3 0 1110000000000000000000000000000000000000000000000
+ 4 4 0 1111000000000000000000000000000000000000000000000
+ 5 5 0 1111100000000000000000000000000000000000000000000
+ 6 6 0 1111110000000000000000000000000000000000000000000
+ 7 7 0 1111111000000000000000000000000000000000000000000
+ 8 8 0 1111111100000000000000000000000000000000000000000
+ 9 9 0 1111111110000000000000000000000000000000000000000
+ 10 10 0 1111111111000000000000000000000000000000000000000
+ 11 11 0 1111111111100000000000000000000000000000000000000
+ 12 12 0 1111111111110000000000000000000000000000000000000
+ 13 13 0 1111111111111000000000000000000000000000000000000
+ 14 14 0 1111111111111100000000000000000000000000000000000
+ 15 15 0 1111111111111110000000000000000000000000000000000
+ 16 16 0 1111111111111111000000000000000000000000000000000
+ 17 17 0 1111111111111111100000000000000000000000000000000
+ 18 18 0 1111111111111111110000000000000000000000000000000
+ 19 19 0 1111111111111111111000000000000000000000000000000
+ 20 20 0 1111111111111111111100000000000000000000000000000
+ 21 21 0 1111111111111111111110000000000000000000000000000
+ 22 22 0 1111111111111111111111000000000000000000000000000
+ 23 23 0 1111111111111111111111100000000000000000000000000
+ 24 24 0 1111111111111111111111110000000000000000000000000
+ 25 25 0 1111111111111111111111111000000000000000000000000
+ 26 26 0 1111111111111111111111111100000000000000000000000
+ 27 27 0 1111111111111111111111111110000000000000000000000
+ 28 28 0 1111111111111111111111111111000000000000000000000
+ 29 29 0 1111111111111111111111111111100000000000000000000
+ 30 30 0 1111111111111111111111111111110000000000000000000
+ 31 31 0 1111111111111111111111111111111000000000000000000
+ 32 32 0 1111111111111111111111111111111100000000000000000
+ 33 33 0 1111111111111111111111111111111110000000000000000
+ 34 34 0 1111111111111111111111111111111111000000000000000
+ 35 35 0 1111111111111111111111111111111111100000000000000
+ 36 36 0 1111111111111111111111111111111111110000000000000
+ 37 37 0 1111111111111111111111111111111111111000000000000
+ 38 38 0 1111111111111111111111111111111111111100000000000
+ 39 39 0 1111111111111111111111111111111111111110000000000
+ 40 40 0 1111111111111111111111111111111111111111000000000
+ 41 41 0 1111111111111111111111111111111111111111100000000
+ 42 42 0 1111111111111111111111111111111111111111110000000
+ 43 43 0 1111111111111111111111111111111111111111111000000
+ 44 44 0 1111111111111111111111111111111111111111111100000
+ 45 45 0 1111111111111111111111111111111111111111111110000
+ 46 46 0 1111111111111111111111111111111111111111111111000
+ 47 47 0 1111111111111111111111111111111111111111111111100
+ 48 48 0 1111111111111111111111111111111111111111111111110
+
+first 0 bit should move left 1 position each line
+ 0 -1 0 1111111111111111111111111111111111111111111111111
+ 1 48 0 1111111111111111111111111111111111111111111111110
+ 2 47 0 1111111111111111111111111111111111111111111111100
+ 3 46 0 1111111111111111111111111111111111111111111111000
+ 4 45 0 1111111111111111111111111111111111111111111110000
+ 5 44 0 1111111111111111111111111111111111111111111100000
+ 6 43 0 1111111111111111111111111111111111111111111000000
+ 7 42 0 1111111111111111111111111111111111111111110000000
+ 8 41 0 1111111111111111111111111111111111111111100000000
+ 9 40 0 1111111111111111111111111111111111111111000000000
+ 10 39 0 1111111111111111111111111111111111111110000000000
+ 11 38 0 1111111111111111111111111111111111111100000000000
+ 12 37 0 1111111111111111111111111111111111111000000000000
+ 13 36 0 1111111111111111111111111111111111110000000000000
+ 14 35 0 1111111111111111111111111111111111100000000000000
+ 15 34 0 1111111111111111111111111111111111000000000000000
+ 16 33 0 1111111111111111111111111111111110000000000000000
+ 17 32 0 1111111111111111111111111111111100000000000000000
+ 18 31 0 1111111111111111111111111111111000000000000000000
+ 19 30 0 1111111111111111111111111111110000000000000000000
+ 20 29 0 1111111111111111111111111111100000000000000000000
+ 21 28 0 1111111111111111111111111111000000000000000000000
+ 22 27 0 1111111111111111111111111110000000000000000000000
+ 23 26 0 1111111111111111111111111100000000000000000000000
+ 24 25 0 1111111111111111111111111000000000000000000000000
+ 25 24 0 1111111111111111111111110000000000000000000000000
+ 26 23 0 1111111111111111111111100000000000000000000000000
+ 27 22 0 1111111111111111111111000000000000000000000000000
+ 28 21 0 1111111111111111111110000000000000000000000000000
+ 29 20 0 1111111111111111111100000000000000000000000000000
+ 30 19 0 1111111111111111111000000000000000000000000000000
+ 31 18 0 1111111111111111110000000000000000000000000000000
+ 32 17 0 1111111111111111100000000000000000000000000000000
+ 33 16 0 1111111111111111000000000000000000000000000000000
+ 34 15 0 1111111111111110000000000000000000000000000000000
+ 35 14 0 1111111111111100000000000000000000000000000000000
+ 36 13 0 1111111111111000000000000000000000000000000000000
+ 37 12 0 1111111111110000000000000000000000000000000000000
+ 38 11 0 1111111111100000000000000000000000000000000000000
+ 39 10 0 1111111111000000000000000000000000000000000000000
+ 40 9 0 1111111110000000000000000000000000000000000000000
+ 41 8 0 1111111100000000000000000000000000000000000000000
+ 42 7 0 1111111000000000000000000000000000000000000000000
+ 43 6 0 1111110000000000000000000000000000000000000000000
+ 44 5 0 1111100000000000000000000000000000000000000000000
+ 45 4 0 1111000000000000000000000000000000000000000000000
+ 46 3 0 1110000000000000000000000000000000000000000000000
+ 47 2 0 1100000000000000000000000000000000000000000000000
+ 48 1 0 1000000000000000000000000000000000000000000000000
+
+first 1 bit should move left 1 position each line
+ 0 0 -1 0000000000000000000000000000000000000000000000000
+ 1 0 48 0000000000000000000000000000000000000000000000001
+ 2 0 47 0000000000000000000000000000000000000000000000011
+ 3 0 46 0000000000000000000000000000000000000000000000111
+ 4 0 45 0000000000000000000000000000000000000000000001111
+ 5 0 44 0000000000000000000000000000000000000000000011111
+ 6 0 43 0000000000000000000000000000000000000000000111111
+ 7 0 42 0000000000000000000000000000000000000000001111111
+ 8 0 41 0000000000000000000000000000000000000000011111111
+ 9 0 40 0000000000000000000000000000000000000000111111111
+ 10 0 39 0000000000000000000000000000000000000001111111111
+ 11 0 38 0000000000000000000000000000000000000011111111111
+ 12 0 37 0000000000000000000000000000000000000111111111111
+ 13 0 36 0000000000000000000000000000000000001111111111111
+ 14 0 35 0000000000000000000000000000000000011111111111111
+ 15 0 34 0000000000000000000000000000000000111111111111111
+ 16 0 33 0000000000000000000000000000000001111111111111111
+ 17 0 32 0000000000000000000000000000000011111111111111111
+ 18 0 31 0000000000000000000000000000000111111111111111111
+ 19 0 30 0000000000000000000000000000001111111111111111111
+ 20 0 29 0000000000000000000000000000011111111111111111111
+ 21 0 28 0000000000000000000000000000111111111111111111111
+ 22 0 27 0000000000000000000000000001111111111111111111111
+ 23 0 26 0000000000000000000000000011111111111111111111111
+ 24 0 25 0000000000000000000000000111111111111111111111111
+ 25 0 24 0000000000000000000000001111111111111111111111111
+ 26 0 23 0000000000000000000000011111111111111111111111111
+ 27 0 22 0000000000000000000000111111111111111111111111111
+ 28 0 21 0000000000000000000001111111111111111111111111111
+ 29 0 20 0000000000000000000011111111111111111111111111111
+ 30 0 19 0000000000000000000111111111111111111111111111111
+ 31 0 18 0000000000000000001111111111111111111111111111111
+ 32 0 17 0000000000000000011111111111111111111111111111111
+ 33 0 16 0000000000000000111111111111111111111111111111111
+ 34 0 15 0000000000000001111111111111111111111111111111111
+ 35 0 14 0000000000000011111111111111111111111111111111111
+ 36 0 13 0000000000000111111111111111111111111111111111111
+ 37 0 12 0000000000001111111111111111111111111111111111111
+ 38 0 11 0000000000011111111111111111111111111111111111111
+ 39 0 10 0000000000111111111111111111111111111111111111111
+ 40 0 9 0000000001111111111111111111111111111111111111111
+ 41 0 8 0000000011111111111111111111111111111111111111111
+ 42 0 7 0000000111111111111111111111111111111111111111111
+ 43 0 6 0000001111111111111111111111111111111111111111111
+ 44 0 5 0000011111111111111111111111111111111111111111111
+ 45 0 4 0000111111111111111111111111111111111111111111111
+ 46 0 3 0001111111111111111111111111111111111111111111111
+ 47 0 2 0011111111111111111111111111111111111111111111111
+ 48 0 1 0111111111111111111111111111111111111111111111111
+
+0 bit should move right 1 position each line
+ 0 0 1 0111111111111111111111111111111111111111111111111
+ 1 1 0 1011111111111111111111111111111111111111111111111
+ 2 2 0 1101111111111111111111111111111111111111111111111
+ 3 3 0 1110111111111111111111111111111111111111111111111
+ 4 4 0 1111011111111111111111111111111111111111111111111
+ 5 5 0 1111101111111111111111111111111111111111111111111
+ 6 6 0 1111110111111111111111111111111111111111111111111
+ 7 7 0 1111111011111111111111111111111111111111111111111
+ 8 8 0 1111111101111111111111111111111111111111111111111
+ 9 9 0 1111111110111111111111111111111111111111111111111
+ 10 10 0 1111111111011111111111111111111111111111111111111
+ 11 11 0 1111111111101111111111111111111111111111111111111
+ 12 12 0 1111111111110111111111111111111111111111111111111
+ 13 13 0 1111111111111011111111111111111111111111111111111
+ 14 14 0 1111111111111101111111111111111111111111111111111
+ 15 15 0 1111111111111110111111111111111111111111111111111
+ 16 16 0 1111111111111111011111111111111111111111111111111
+ 17 17 0 1111111111111111101111111111111111111111111111111
+ 18 18 0 1111111111111111110111111111111111111111111111111
+ 19 19 0 1111111111111111111011111111111111111111111111111
+ 20 20 0 1111111111111111111101111111111111111111111111111
+ 21 21 0 1111111111111111111110111111111111111111111111111
+ 22 22 0 1111111111111111111111011111111111111111111111111
+ 23 23 0 1111111111111111111111101111111111111111111111111
+ 24 24 0 1111111111111111111111110111111111111111111111111
+ 25 25 0 1111111111111111111111111011111111111111111111111
+ 26 26 0 1111111111111111111111111101111111111111111111111
+ 27 27 0 1111111111111111111111111110111111111111111111111
+ 28 28 0 1111111111111111111111111111011111111111111111111
+ 29 29 0 1111111111111111111111111111101111111111111111111
+ 30 30 0 1111111111111111111111111111110111111111111111111
+ 31 31 0 1111111111111111111111111111111011111111111111111
+ 32 32 0 1111111111111111111111111111111101111111111111111
+ 33 33 0 1111111111111111111111111111111110111111111111111
+ 34 34 0 1111111111111111111111111111111111011111111111111
+ 35 35 0 1111111111111111111111111111111111101111111111111
+ 36 36 0 1111111111111111111111111111111111110111111111111
+ 37 37 0 1111111111111111111111111111111111111011111111111
+ 38 38 0 1111111111111111111111111111111111111101111111111
+ 39 39 0 1111111111111111111111111111111111111110111111111
+ 40 40 0 1111111111111111111111111111111111111111011111111
+ 41 41 0 1111111111111111111111111111111111111111101111111
+ 42 42 0 1111111111111111111111111111111111111111110111111
+ 43 43 0 1111111111111111111111111111111111111111111011111
+ 44 44 0 1111111111111111111111111111111111111111111101111
+ 45 45 0 1111111111111111111111111111111111111111111110111
+ 46 46 0 1111111111111111111111111111111111111111111111011
+ 47 47 0 1111111111111111111111111111111111111111111111101
+ 48 48 0 1111111111111111111111111111111111111111111111110
+
+1 bit should move right 1 position each line
+ 0 1 0 1000000000000000000000000000000000000000000000000
+ 1 0 1 0100000000000000000000000000000000000000000000000
+ 2 0 2 0010000000000000000000000000000000000000000000000
+ 3 0 3 0001000000000000000000000000000000000000000000000
+ 4 0 4 0000100000000000000000000000000000000000000000000
+ 5 0 5 0000010000000000000000000000000000000000000000000
+ 6 0 6 0000001000000000000000000000000000000000000000000
+ 7 0 7 0000000100000000000000000000000000000000000000000
+ 8 0 8 0000000010000000000000000000000000000000000000000
+ 9 0 9 0000000001000000000000000000000000000000000000000
+ 10 0 10 0000000000100000000000000000000000000000000000000
+ 11 0 11 0000000000010000000000000000000000000000000000000
+ 12 0 12 0000000000001000000000000000000000000000000000000
+ 13 0 13 0000000000000100000000000000000000000000000000000
+ 14 0 14 0000000000000010000000000000000000000000000000000
+ 15 0 15 0000000000000001000000000000000000000000000000000
+ 16 0 16 0000000000000000100000000000000000000000000000000
+ 17 0 17 0000000000000000010000000000000000000000000000000
+ 18 0 18 0000000000000000001000000000000000000000000000000
+ 19 0 19 0000000000000000000100000000000000000000000000000
+ 20 0 20 0000000000000000000010000000000000000000000000000
+ 21 0 21 0000000000000000000001000000000000000000000000000
+ 22 0 22 0000000000000000000000100000000000000000000000000
+ 23 0 23 0000000000000000000000010000000000000000000000000
+ 24 0 24 0000000000000000000000001000000000000000000000000
+ 25 0 25 0000000000000000000000000100000000000000000000000
+ 26 0 26 0000000000000000000000000010000000000000000000000
+ 27 0 27 0000000000000000000000000001000000000000000000000
+ 28 0 28 0000000000000000000000000000100000000000000000000
+ 29 0 29 0000000000000000000000000000010000000000000000000
+ 30 0 30 0000000000000000000000000000001000000000000000000
+ 31 0 31 0000000000000000000000000000000100000000000000000
+ 32 0 32 0000000000000000000000000000000010000000000000000
+ 33 0 33 0000000000000000000000000000000001000000000000000
+ 34 0 34 0000000000000000000000000000000000100000000000000
+ 35 0 35 0000000000000000000000000000000000010000000000000
+ 36 0 36 0000000000000000000000000000000000001000000000000
+ 37 0 37 0000000000000000000000000000000000000100000000000
+ 38 0 38 0000000000000000000000000000000000000010000000000
+ 39 0 39 0000000000000000000000000000000000000001000000000
+ 40 0 40 0000000000000000000000000000000000000000100000000
+ 41 0 41 0000000000000000000000000000000000000000010000000
+ 42 0 42 0000000000000000000000000000000000000000001000000
+ 43 0 43 0000000000000000000000000000000000000000000100000
+ 44 0 44 0000000000000000000000000000000000000000000010000
+ 45 0 45 0000000000000000000000000000000000000000000001000
+ 46 0 46 0000000000000000000000000000000000000000000000100
+ 47 0 47 0000000000000000000000000000000000000000000000010
+ 48 0 48 0000000000000000000000000000000000000000000000001
diff --git a/contrib/netbsd-tests/include/d_bitstring_64.out b/contrib/netbsd-tests/include/d_bitstring_64.out
new file mode 100644
index 000000000000..7e9308eabc73
--- /dev/null
+++ b/contrib/netbsd-tests/include/d_bitstring_64.out
@@ -0,0 +1,559 @@
+Testing with TEST_LENGTH = 64
+
+test _bit_byte, _bit_mask, and bitstr_size
+ i _bit_byte(i) _bit_mask(i) bitstr_size(i)
+ 0 0 1 0
+ 1 0 2 1
+ 2 0 4 1
+ 3 0 8 1
+ 4 0 16 1
+ 5 0 32 1
+ 6 0 64 1
+ 7 0 128 1
+ 8 1 1 1
+ 9 1 2 2
+ 10 1 4 2
+ 11 1 8 2
+ 12 1 16 2
+ 13 1 32 2
+ 14 1 64 2
+ 15 1 128 2
+ 16 2 1 2
+ 17 2 2 3
+ 18 2 4 3
+ 19 2 8 3
+ 20 2 16 3
+ 21 2 32 3
+ 22 2 64 3
+ 23 2 128 3
+ 24 3 1 3
+ 25 3 2 4
+ 26 3 4 4
+ 27 3 8 4
+ 28 3 16 4
+ 29 3 32 4
+ 30 3 64 4
+ 31 3 128 4
+ 32 4 1 4
+ 33 4 2 5
+ 34 4 4 5
+ 35 4 8 5
+ 36 4 16 5
+ 37 4 32 5
+ 38 4 64 5
+ 39 4 128 5
+ 40 5 1 5
+ 41 5 2 6
+ 42 5 4 6
+ 43 5 8 6
+ 44 5 16 6
+ 45 5 32 6
+ 46 5 64 6
+ 47 5 128 6
+ 48 6 1 6
+ 49 6 2 7
+ 50 6 4 7
+ 51 6 8 7
+ 52 6 16 7
+ 53 6 32 7
+ 54 6 64 7
+ 55 6 128 7
+ 56 7 1 7
+ 57 7 2 8
+ 58 7 4 8
+ 59 7 8 8
+ 60 7 16 8
+ 61 7 32 8
+ 62 7 64 8
+ 63 7 128 8
+
+test bit_alloc, clearbits, bit_ffc, bit_ffs
+be: 0 -1 0000000000000000000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000000000000000000
+
+test bit_set
+be: 1 0 1001001001001001001001001001001001001001001001001001001001001001
+is: 1 0 1001001001001001001001001001001001001001001001001001001001001001
+
+test bit_clear
+be: 0 3 0001000001000001000001000001000001000001000001000001000001000001
+is: 0 3 0001000001000001000001000001000001000001000001000001000001000001
+
+test bit_test using previous bitstring
+ i bit_test(i)
+ 0 0
+ 1 0
+ 2 0
+ 3 8
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 2
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 128
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 32
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 8
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+ 32 0
+ 33 2
+ 34 0
+ 35 0
+ 36 0
+ 37 0
+ 38 0
+ 39 128
+ 40 0
+ 41 0
+ 42 0
+ 43 0
+ 44 0
+ 45 32
+ 46 0
+ 47 0
+ 48 0
+ 49 0
+ 50 0
+ 51 8
+ 52 0
+ 53 0
+ 54 0
+ 55 0
+ 56 0
+ 57 2
+ 58 0
+ 59 0
+ 60 0
+ 61 0
+ 62 0
+ 63 128
+
+test clearbits
+be: 0 -1 0000000000000000000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000000000000000000
+
+test bit_nset and bit_nclear
+be: 0 1 0111111111111111111111111111111111111111111111111111111111111110
+is: 0 1 0111111111111111111111111111111111111111111111111111111111111110
+be: 0 1 0100000000000000000000000000000000000000000000000000000000000010
+is: 0 1 0100000000000000000000000000000000000000000000000000000000000010
+be: 0 -1 0000000000000000000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000000000000000000
+be: 63 0 1111111111111111111111111111111111111111111111111111111111111110
+is: 63 0 1111111111111111111111111111111111111111111111111111111111111110
+be: 0 -1 0000000000000000000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000000000000000000
+
+first 1 bit should move right 1 position each line
+ 0 -1 0 1111111111111111111111111111111111111111111111111111111111111111
+ 1 0 1 0111111111111111111111111111111111111111111111111111111111111111
+ 2 0 2 0011111111111111111111111111111111111111111111111111111111111111
+ 3 0 3 0001111111111111111111111111111111111111111111111111111111111111
+ 4 0 4 0000111111111111111111111111111111111111111111111111111111111111
+ 5 0 5 0000011111111111111111111111111111111111111111111111111111111111
+ 6 0 6 0000001111111111111111111111111111111111111111111111111111111111
+ 7 0 7 0000000111111111111111111111111111111111111111111111111111111111
+ 8 0 8 0000000011111111111111111111111111111111111111111111111111111111
+ 9 0 9 0000000001111111111111111111111111111111111111111111111111111111
+ 10 0 10 0000000000111111111111111111111111111111111111111111111111111111
+ 11 0 11 0000000000011111111111111111111111111111111111111111111111111111
+ 12 0 12 0000000000001111111111111111111111111111111111111111111111111111
+ 13 0 13 0000000000000111111111111111111111111111111111111111111111111111
+ 14 0 14 0000000000000011111111111111111111111111111111111111111111111111
+ 15 0 15 0000000000000001111111111111111111111111111111111111111111111111
+ 16 0 16 0000000000000000111111111111111111111111111111111111111111111111
+ 17 0 17 0000000000000000011111111111111111111111111111111111111111111111
+ 18 0 18 0000000000000000001111111111111111111111111111111111111111111111
+ 19 0 19 0000000000000000000111111111111111111111111111111111111111111111
+ 20 0 20 0000000000000000000011111111111111111111111111111111111111111111
+ 21 0 21 0000000000000000000001111111111111111111111111111111111111111111
+ 22 0 22 0000000000000000000000111111111111111111111111111111111111111111
+ 23 0 23 0000000000000000000000011111111111111111111111111111111111111111
+ 24 0 24 0000000000000000000000001111111111111111111111111111111111111111
+ 25 0 25 0000000000000000000000000111111111111111111111111111111111111111
+ 26 0 26 0000000000000000000000000011111111111111111111111111111111111111
+ 27 0 27 0000000000000000000000000001111111111111111111111111111111111111
+ 28 0 28 0000000000000000000000000000111111111111111111111111111111111111
+ 29 0 29 0000000000000000000000000000011111111111111111111111111111111111
+ 30 0 30 0000000000000000000000000000001111111111111111111111111111111111
+ 31 0 31 0000000000000000000000000000000111111111111111111111111111111111
+ 32 0 32 0000000000000000000000000000000011111111111111111111111111111111
+ 33 0 33 0000000000000000000000000000000001111111111111111111111111111111
+ 34 0 34 0000000000000000000000000000000000111111111111111111111111111111
+ 35 0 35 0000000000000000000000000000000000011111111111111111111111111111
+ 36 0 36 0000000000000000000000000000000000001111111111111111111111111111
+ 37 0 37 0000000000000000000000000000000000000111111111111111111111111111
+ 38 0 38 0000000000000000000000000000000000000011111111111111111111111111
+ 39 0 39 0000000000000000000000000000000000000001111111111111111111111111
+ 40 0 40 0000000000000000000000000000000000000000111111111111111111111111
+ 41 0 41 0000000000000000000000000000000000000000011111111111111111111111
+ 42 0 42 0000000000000000000000000000000000000000001111111111111111111111
+ 43 0 43 0000000000000000000000000000000000000000000111111111111111111111
+ 44 0 44 0000000000000000000000000000000000000000000011111111111111111111
+ 45 0 45 0000000000000000000000000000000000000000000001111111111111111111
+ 46 0 46 0000000000000000000000000000000000000000000000111111111111111111
+ 47 0 47 0000000000000000000000000000000000000000000000011111111111111111
+ 48 0 48 0000000000000000000000000000000000000000000000001111111111111111
+ 49 0 49 0000000000000000000000000000000000000000000000000111111111111111
+ 50 0 50 0000000000000000000000000000000000000000000000000011111111111111
+ 51 0 51 0000000000000000000000000000000000000000000000000001111111111111
+ 52 0 52 0000000000000000000000000000000000000000000000000000111111111111
+ 53 0 53 0000000000000000000000000000000000000000000000000000011111111111
+ 54 0 54 0000000000000000000000000000000000000000000000000000001111111111
+ 55 0 55 0000000000000000000000000000000000000000000000000000000111111111
+ 56 0 56 0000000000000000000000000000000000000000000000000000000011111111
+ 57 0 57 0000000000000000000000000000000000000000000000000000000001111111
+ 58 0 58 0000000000000000000000000000000000000000000000000000000000111111
+ 59 0 59 0000000000000000000000000000000000000000000000000000000000011111
+ 60 0 60 0000000000000000000000000000000000000000000000000000000000001111
+ 61 0 61 0000000000000000000000000000000000000000000000000000000000000111
+ 62 0 62 0000000000000000000000000000000000000000000000000000000000000011
+ 63 0 63 0000000000000000000000000000000000000000000000000000000000000001
+
+first 0 bit should move right 1 position each line
+ 0 0 -1 0000000000000000000000000000000000000000000000000000000000000000
+ 1 1 0 1000000000000000000000000000000000000000000000000000000000000000
+ 2 2 0 1100000000000000000000000000000000000000000000000000000000000000
+ 3 3 0 1110000000000000000000000000000000000000000000000000000000000000
+ 4 4 0 1111000000000000000000000000000000000000000000000000000000000000
+ 5 5 0 1111100000000000000000000000000000000000000000000000000000000000
+ 6 6 0 1111110000000000000000000000000000000000000000000000000000000000
+ 7 7 0 1111111000000000000000000000000000000000000000000000000000000000
+ 8 8 0 1111111100000000000000000000000000000000000000000000000000000000
+ 9 9 0 1111111110000000000000000000000000000000000000000000000000000000
+ 10 10 0 1111111111000000000000000000000000000000000000000000000000000000
+ 11 11 0 1111111111100000000000000000000000000000000000000000000000000000
+ 12 12 0 1111111111110000000000000000000000000000000000000000000000000000
+ 13 13 0 1111111111111000000000000000000000000000000000000000000000000000
+ 14 14 0 1111111111111100000000000000000000000000000000000000000000000000
+ 15 15 0 1111111111111110000000000000000000000000000000000000000000000000
+ 16 16 0 1111111111111111000000000000000000000000000000000000000000000000
+ 17 17 0 1111111111111111100000000000000000000000000000000000000000000000
+ 18 18 0 1111111111111111110000000000000000000000000000000000000000000000
+ 19 19 0 1111111111111111111000000000000000000000000000000000000000000000
+ 20 20 0 1111111111111111111100000000000000000000000000000000000000000000
+ 21 21 0 1111111111111111111110000000000000000000000000000000000000000000
+ 22 22 0 1111111111111111111111000000000000000000000000000000000000000000
+ 23 23 0 1111111111111111111111100000000000000000000000000000000000000000
+ 24 24 0 1111111111111111111111110000000000000000000000000000000000000000
+ 25 25 0 1111111111111111111111111000000000000000000000000000000000000000
+ 26 26 0 1111111111111111111111111100000000000000000000000000000000000000
+ 27 27 0 1111111111111111111111111110000000000000000000000000000000000000
+ 28 28 0 1111111111111111111111111111000000000000000000000000000000000000
+ 29 29 0 1111111111111111111111111111100000000000000000000000000000000000
+ 30 30 0 1111111111111111111111111111110000000000000000000000000000000000
+ 31 31 0 1111111111111111111111111111111000000000000000000000000000000000
+ 32 32 0 1111111111111111111111111111111100000000000000000000000000000000
+ 33 33 0 1111111111111111111111111111111110000000000000000000000000000000
+ 34 34 0 1111111111111111111111111111111111000000000000000000000000000000
+ 35 35 0 1111111111111111111111111111111111100000000000000000000000000000
+ 36 36 0 1111111111111111111111111111111111110000000000000000000000000000
+ 37 37 0 1111111111111111111111111111111111111000000000000000000000000000
+ 38 38 0 1111111111111111111111111111111111111100000000000000000000000000
+ 39 39 0 1111111111111111111111111111111111111110000000000000000000000000
+ 40 40 0 1111111111111111111111111111111111111111000000000000000000000000
+ 41 41 0 1111111111111111111111111111111111111111100000000000000000000000
+ 42 42 0 1111111111111111111111111111111111111111110000000000000000000000
+ 43 43 0 1111111111111111111111111111111111111111111000000000000000000000
+ 44 44 0 1111111111111111111111111111111111111111111100000000000000000000
+ 45 45 0 1111111111111111111111111111111111111111111110000000000000000000
+ 46 46 0 1111111111111111111111111111111111111111111111000000000000000000
+ 47 47 0 1111111111111111111111111111111111111111111111100000000000000000
+ 48 48 0 1111111111111111111111111111111111111111111111110000000000000000
+ 49 49 0 1111111111111111111111111111111111111111111111111000000000000000
+ 50 50 0 1111111111111111111111111111111111111111111111111100000000000000
+ 51 51 0 1111111111111111111111111111111111111111111111111110000000000000
+ 52 52 0 1111111111111111111111111111111111111111111111111111000000000000
+ 53 53 0 1111111111111111111111111111111111111111111111111111100000000000
+ 54 54 0 1111111111111111111111111111111111111111111111111111110000000000
+ 55 55 0 1111111111111111111111111111111111111111111111111111111000000000
+ 56 56 0 1111111111111111111111111111111111111111111111111111111100000000
+ 57 57 0 1111111111111111111111111111111111111111111111111111111110000000
+ 58 58 0 1111111111111111111111111111111111111111111111111111111111000000
+ 59 59 0 1111111111111111111111111111111111111111111111111111111111100000
+ 60 60 0 1111111111111111111111111111111111111111111111111111111111110000
+ 61 61 0 1111111111111111111111111111111111111111111111111111111111111000
+ 62 62 0 1111111111111111111111111111111111111111111111111111111111111100
+ 63 63 0 1111111111111111111111111111111111111111111111111111111111111110
+
+first 0 bit should move left 1 position each line
+ 0 -1 0 1111111111111111111111111111111111111111111111111111111111111111
+ 1 63 0 1111111111111111111111111111111111111111111111111111111111111110
+ 2 62 0 1111111111111111111111111111111111111111111111111111111111111100
+ 3 61 0 1111111111111111111111111111111111111111111111111111111111111000
+ 4 60 0 1111111111111111111111111111111111111111111111111111111111110000
+ 5 59 0 1111111111111111111111111111111111111111111111111111111111100000
+ 6 58 0 1111111111111111111111111111111111111111111111111111111111000000
+ 7 57 0 1111111111111111111111111111111111111111111111111111111110000000
+ 8 56 0 1111111111111111111111111111111111111111111111111111111100000000
+ 9 55 0 1111111111111111111111111111111111111111111111111111111000000000
+ 10 54 0 1111111111111111111111111111111111111111111111111111110000000000
+ 11 53 0 1111111111111111111111111111111111111111111111111111100000000000
+ 12 52 0 1111111111111111111111111111111111111111111111111111000000000000
+ 13 51 0 1111111111111111111111111111111111111111111111111110000000000000
+ 14 50 0 1111111111111111111111111111111111111111111111111100000000000000
+ 15 49 0 1111111111111111111111111111111111111111111111111000000000000000
+ 16 48 0 1111111111111111111111111111111111111111111111110000000000000000
+ 17 47 0 1111111111111111111111111111111111111111111111100000000000000000
+ 18 46 0 1111111111111111111111111111111111111111111111000000000000000000
+ 19 45 0 1111111111111111111111111111111111111111111110000000000000000000
+ 20 44 0 1111111111111111111111111111111111111111111100000000000000000000
+ 21 43 0 1111111111111111111111111111111111111111111000000000000000000000
+ 22 42 0 1111111111111111111111111111111111111111110000000000000000000000
+ 23 41 0 1111111111111111111111111111111111111111100000000000000000000000
+ 24 40 0 1111111111111111111111111111111111111111000000000000000000000000
+ 25 39 0 1111111111111111111111111111111111111110000000000000000000000000
+ 26 38 0 1111111111111111111111111111111111111100000000000000000000000000
+ 27 37 0 1111111111111111111111111111111111111000000000000000000000000000
+ 28 36 0 1111111111111111111111111111111111110000000000000000000000000000
+ 29 35 0 1111111111111111111111111111111111100000000000000000000000000000
+ 30 34 0 1111111111111111111111111111111111000000000000000000000000000000
+ 31 33 0 1111111111111111111111111111111110000000000000000000000000000000
+ 32 32 0 1111111111111111111111111111111100000000000000000000000000000000
+ 33 31 0 1111111111111111111111111111111000000000000000000000000000000000
+ 34 30 0 1111111111111111111111111111110000000000000000000000000000000000
+ 35 29 0 1111111111111111111111111111100000000000000000000000000000000000
+ 36 28 0 1111111111111111111111111111000000000000000000000000000000000000
+ 37 27 0 1111111111111111111111111110000000000000000000000000000000000000
+ 38 26 0 1111111111111111111111111100000000000000000000000000000000000000
+ 39 25 0 1111111111111111111111111000000000000000000000000000000000000000
+ 40 24 0 1111111111111111111111110000000000000000000000000000000000000000
+ 41 23 0 1111111111111111111111100000000000000000000000000000000000000000
+ 42 22 0 1111111111111111111111000000000000000000000000000000000000000000
+ 43 21 0 1111111111111111111110000000000000000000000000000000000000000000
+ 44 20 0 1111111111111111111100000000000000000000000000000000000000000000
+ 45 19 0 1111111111111111111000000000000000000000000000000000000000000000
+ 46 18 0 1111111111111111110000000000000000000000000000000000000000000000
+ 47 17 0 1111111111111111100000000000000000000000000000000000000000000000
+ 48 16 0 1111111111111111000000000000000000000000000000000000000000000000
+ 49 15 0 1111111111111110000000000000000000000000000000000000000000000000
+ 50 14 0 1111111111111100000000000000000000000000000000000000000000000000
+ 51 13 0 1111111111111000000000000000000000000000000000000000000000000000
+ 52 12 0 1111111111110000000000000000000000000000000000000000000000000000
+ 53 11 0 1111111111100000000000000000000000000000000000000000000000000000
+ 54 10 0 1111111111000000000000000000000000000000000000000000000000000000
+ 55 9 0 1111111110000000000000000000000000000000000000000000000000000000
+ 56 8 0 1111111100000000000000000000000000000000000000000000000000000000
+ 57 7 0 1111111000000000000000000000000000000000000000000000000000000000
+ 58 6 0 1111110000000000000000000000000000000000000000000000000000000000
+ 59 5 0 1111100000000000000000000000000000000000000000000000000000000000
+ 60 4 0 1111000000000000000000000000000000000000000000000000000000000000
+ 61 3 0 1110000000000000000000000000000000000000000000000000000000000000
+ 62 2 0 1100000000000000000000000000000000000000000000000000000000000000
+ 63 1 0 1000000000000000000000000000000000000000000000000000000000000000
+
+first 1 bit should move left 1 position each line
+ 0 0 -1 0000000000000000000000000000000000000000000000000000000000000000
+ 1 0 63 0000000000000000000000000000000000000000000000000000000000000001
+ 2 0 62 0000000000000000000000000000000000000000000000000000000000000011
+ 3 0 61 0000000000000000000000000000000000000000000000000000000000000111
+ 4 0 60 0000000000000000000000000000000000000000000000000000000000001111
+ 5 0 59 0000000000000000000000000000000000000000000000000000000000011111
+ 6 0 58 0000000000000000000000000000000000000000000000000000000000111111
+ 7 0 57 0000000000000000000000000000000000000000000000000000000001111111
+ 8 0 56 0000000000000000000000000000000000000000000000000000000011111111
+ 9 0 55 0000000000000000000000000000000000000000000000000000000111111111
+ 10 0 54 0000000000000000000000000000000000000000000000000000001111111111
+ 11 0 53 0000000000000000000000000000000000000000000000000000011111111111
+ 12 0 52 0000000000000000000000000000000000000000000000000000111111111111
+ 13 0 51 0000000000000000000000000000000000000000000000000001111111111111
+ 14 0 50 0000000000000000000000000000000000000000000000000011111111111111
+ 15 0 49 0000000000000000000000000000000000000000000000000111111111111111
+ 16 0 48 0000000000000000000000000000000000000000000000001111111111111111
+ 17 0 47 0000000000000000000000000000000000000000000000011111111111111111
+ 18 0 46 0000000000000000000000000000000000000000000000111111111111111111
+ 19 0 45 0000000000000000000000000000000000000000000001111111111111111111
+ 20 0 44 0000000000000000000000000000000000000000000011111111111111111111
+ 21 0 43 0000000000000000000000000000000000000000000111111111111111111111
+ 22 0 42 0000000000000000000000000000000000000000001111111111111111111111
+ 23 0 41 0000000000000000000000000000000000000000011111111111111111111111
+ 24 0 40 0000000000000000000000000000000000000000111111111111111111111111
+ 25 0 39 0000000000000000000000000000000000000001111111111111111111111111
+ 26 0 38 0000000000000000000000000000000000000011111111111111111111111111
+ 27 0 37 0000000000000000000000000000000000000111111111111111111111111111
+ 28 0 36 0000000000000000000000000000000000001111111111111111111111111111
+ 29 0 35 0000000000000000000000000000000000011111111111111111111111111111
+ 30 0 34 0000000000000000000000000000000000111111111111111111111111111111
+ 31 0 33 0000000000000000000000000000000001111111111111111111111111111111
+ 32 0 32 0000000000000000000000000000000011111111111111111111111111111111
+ 33 0 31 0000000000000000000000000000000111111111111111111111111111111111
+ 34 0 30 0000000000000000000000000000001111111111111111111111111111111111
+ 35 0 29 0000000000000000000000000000011111111111111111111111111111111111
+ 36 0 28 0000000000000000000000000000111111111111111111111111111111111111
+ 37 0 27 0000000000000000000000000001111111111111111111111111111111111111
+ 38 0 26 0000000000000000000000000011111111111111111111111111111111111111
+ 39 0 25 0000000000000000000000000111111111111111111111111111111111111111
+ 40 0 24 0000000000000000000000001111111111111111111111111111111111111111
+ 41 0 23 0000000000000000000000011111111111111111111111111111111111111111
+ 42 0 22 0000000000000000000000111111111111111111111111111111111111111111
+ 43 0 21 0000000000000000000001111111111111111111111111111111111111111111
+ 44 0 20 0000000000000000000011111111111111111111111111111111111111111111
+ 45 0 19 0000000000000000000111111111111111111111111111111111111111111111
+ 46 0 18 0000000000000000001111111111111111111111111111111111111111111111
+ 47 0 17 0000000000000000011111111111111111111111111111111111111111111111
+ 48 0 16 0000000000000000111111111111111111111111111111111111111111111111
+ 49 0 15 0000000000000001111111111111111111111111111111111111111111111111
+ 50 0 14 0000000000000011111111111111111111111111111111111111111111111111
+ 51 0 13 0000000000000111111111111111111111111111111111111111111111111111
+ 52 0 12 0000000000001111111111111111111111111111111111111111111111111111
+ 53 0 11 0000000000011111111111111111111111111111111111111111111111111111
+ 54 0 10 0000000000111111111111111111111111111111111111111111111111111111
+ 55 0 9 0000000001111111111111111111111111111111111111111111111111111111
+ 56 0 8 0000000011111111111111111111111111111111111111111111111111111111
+ 57 0 7 0000000111111111111111111111111111111111111111111111111111111111
+ 58 0 6 0000001111111111111111111111111111111111111111111111111111111111
+ 59 0 5 0000011111111111111111111111111111111111111111111111111111111111
+ 60 0 4 0000111111111111111111111111111111111111111111111111111111111111
+ 61 0 3 0001111111111111111111111111111111111111111111111111111111111111
+ 62 0 2 0011111111111111111111111111111111111111111111111111111111111111
+ 63 0 1 0111111111111111111111111111111111111111111111111111111111111111
+
+0 bit should move right 1 position each line
+ 0 0 1 0111111111111111111111111111111111111111111111111111111111111111
+ 1 1 0 1011111111111111111111111111111111111111111111111111111111111111
+ 2 2 0 1101111111111111111111111111111111111111111111111111111111111111
+ 3 3 0 1110111111111111111111111111111111111111111111111111111111111111
+ 4 4 0 1111011111111111111111111111111111111111111111111111111111111111
+ 5 5 0 1111101111111111111111111111111111111111111111111111111111111111
+ 6 6 0 1111110111111111111111111111111111111111111111111111111111111111
+ 7 7 0 1111111011111111111111111111111111111111111111111111111111111111
+ 8 8 0 1111111101111111111111111111111111111111111111111111111111111111
+ 9 9 0 1111111110111111111111111111111111111111111111111111111111111111
+ 10 10 0 1111111111011111111111111111111111111111111111111111111111111111
+ 11 11 0 1111111111101111111111111111111111111111111111111111111111111111
+ 12 12 0 1111111111110111111111111111111111111111111111111111111111111111
+ 13 13 0 1111111111111011111111111111111111111111111111111111111111111111
+ 14 14 0 1111111111111101111111111111111111111111111111111111111111111111
+ 15 15 0 1111111111111110111111111111111111111111111111111111111111111111
+ 16 16 0 1111111111111111011111111111111111111111111111111111111111111111
+ 17 17 0 1111111111111111101111111111111111111111111111111111111111111111
+ 18 18 0 1111111111111111110111111111111111111111111111111111111111111111
+ 19 19 0 1111111111111111111011111111111111111111111111111111111111111111
+ 20 20 0 1111111111111111111101111111111111111111111111111111111111111111
+ 21 21 0 1111111111111111111110111111111111111111111111111111111111111111
+ 22 22 0 1111111111111111111111011111111111111111111111111111111111111111
+ 23 23 0 1111111111111111111111101111111111111111111111111111111111111111
+ 24 24 0 1111111111111111111111110111111111111111111111111111111111111111
+ 25 25 0 1111111111111111111111111011111111111111111111111111111111111111
+ 26 26 0 1111111111111111111111111101111111111111111111111111111111111111
+ 27 27 0 1111111111111111111111111110111111111111111111111111111111111111
+ 28 28 0 1111111111111111111111111111011111111111111111111111111111111111
+ 29 29 0 1111111111111111111111111111101111111111111111111111111111111111
+ 30 30 0 1111111111111111111111111111110111111111111111111111111111111111
+ 31 31 0 1111111111111111111111111111111011111111111111111111111111111111
+ 32 32 0 1111111111111111111111111111111101111111111111111111111111111111
+ 33 33 0 1111111111111111111111111111111110111111111111111111111111111111
+ 34 34 0 1111111111111111111111111111111111011111111111111111111111111111
+ 35 35 0 1111111111111111111111111111111111101111111111111111111111111111
+ 36 36 0 1111111111111111111111111111111111110111111111111111111111111111
+ 37 37 0 1111111111111111111111111111111111111011111111111111111111111111
+ 38 38 0 1111111111111111111111111111111111111101111111111111111111111111
+ 39 39 0 1111111111111111111111111111111111111110111111111111111111111111
+ 40 40 0 1111111111111111111111111111111111111111011111111111111111111111
+ 41 41 0 1111111111111111111111111111111111111111101111111111111111111111
+ 42 42 0 1111111111111111111111111111111111111111110111111111111111111111
+ 43 43 0 1111111111111111111111111111111111111111111011111111111111111111
+ 44 44 0 1111111111111111111111111111111111111111111101111111111111111111
+ 45 45 0 1111111111111111111111111111111111111111111110111111111111111111
+ 46 46 0 1111111111111111111111111111111111111111111111011111111111111111
+ 47 47 0 1111111111111111111111111111111111111111111111101111111111111111
+ 48 48 0 1111111111111111111111111111111111111111111111110111111111111111
+ 49 49 0 1111111111111111111111111111111111111111111111111011111111111111
+ 50 50 0 1111111111111111111111111111111111111111111111111101111111111111
+ 51 51 0 1111111111111111111111111111111111111111111111111110111111111111
+ 52 52 0 1111111111111111111111111111111111111111111111111111011111111111
+ 53 53 0 1111111111111111111111111111111111111111111111111111101111111111
+ 54 54 0 1111111111111111111111111111111111111111111111111111110111111111
+ 55 55 0 1111111111111111111111111111111111111111111111111111111011111111
+ 56 56 0 1111111111111111111111111111111111111111111111111111111101111111
+ 57 57 0 1111111111111111111111111111111111111111111111111111111110111111
+ 58 58 0 1111111111111111111111111111111111111111111111111111111111011111
+ 59 59 0 1111111111111111111111111111111111111111111111111111111111101111
+ 60 60 0 1111111111111111111111111111111111111111111111111111111111110111
+ 61 61 0 1111111111111111111111111111111111111111111111111111111111111011
+ 62 62 0 1111111111111111111111111111111111111111111111111111111111111101
+ 63 63 0 1111111111111111111111111111111111111111111111111111111111111110
+
+1 bit should move right 1 position each line
+ 0 1 0 1000000000000000000000000000000000000000000000000000000000000000
+ 1 0 1 0100000000000000000000000000000000000000000000000000000000000000
+ 2 0 2 0010000000000000000000000000000000000000000000000000000000000000
+ 3 0 3 0001000000000000000000000000000000000000000000000000000000000000
+ 4 0 4 0000100000000000000000000000000000000000000000000000000000000000
+ 5 0 5 0000010000000000000000000000000000000000000000000000000000000000
+ 6 0 6 0000001000000000000000000000000000000000000000000000000000000000
+ 7 0 7 0000000100000000000000000000000000000000000000000000000000000000
+ 8 0 8 0000000010000000000000000000000000000000000000000000000000000000
+ 9 0 9 0000000001000000000000000000000000000000000000000000000000000000
+ 10 0 10 0000000000100000000000000000000000000000000000000000000000000000
+ 11 0 11 0000000000010000000000000000000000000000000000000000000000000000
+ 12 0 12 0000000000001000000000000000000000000000000000000000000000000000
+ 13 0 13 0000000000000100000000000000000000000000000000000000000000000000
+ 14 0 14 0000000000000010000000000000000000000000000000000000000000000000
+ 15 0 15 0000000000000001000000000000000000000000000000000000000000000000
+ 16 0 16 0000000000000000100000000000000000000000000000000000000000000000
+ 17 0 17 0000000000000000010000000000000000000000000000000000000000000000
+ 18 0 18 0000000000000000001000000000000000000000000000000000000000000000
+ 19 0 19 0000000000000000000100000000000000000000000000000000000000000000
+ 20 0 20 0000000000000000000010000000000000000000000000000000000000000000
+ 21 0 21 0000000000000000000001000000000000000000000000000000000000000000
+ 22 0 22 0000000000000000000000100000000000000000000000000000000000000000
+ 23 0 23 0000000000000000000000010000000000000000000000000000000000000000
+ 24 0 24 0000000000000000000000001000000000000000000000000000000000000000
+ 25 0 25 0000000000000000000000000100000000000000000000000000000000000000
+ 26 0 26 0000000000000000000000000010000000000000000000000000000000000000
+ 27 0 27 0000000000000000000000000001000000000000000000000000000000000000
+ 28 0 28 0000000000000000000000000000100000000000000000000000000000000000
+ 29 0 29 0000000000000000000000000000010000000000000000000000000000000000
+ 30 0 30 0000000000000000000000000000001000000000000000000000000000000000
+ 31 0 31 0000000000000000000000000000000100000000000000000000000000000000
+ 32 0 32 0000000000000000000000000000000010000000000000000000000000000000
+ 33 0 33 0000000000000000000000000000000001000000000000000000000000000000
+ 34 0 34 0000000000000000000000000000000000100000000000000000000000000000
+ 35 0 35 0000000000000000000000000000000000010000000000000000000000000000
+ 36 0 36 0000000000000000000000000000000000001000000000000000000000000000
+ 37 0 37 0000000000000000000000000000000000000100000000000000000000000000
+ 38 0 38 0000000000000000000000000000000000000010000000000000000000000000
+ 39 0 39 0000000000000000000000000000000000000001000000000000000000000000
+ 40 0 40 0000000000000000000000000000000000000000100000000000000000000000
+ 41 0 41 0000000000000000000000000000000000000000010000000000000000000000
+ 42 0 42 0000000000000000000000000000000000000000001000000000000000000000
+ 43 0 43 0000000000000000000000000000000000000000000100000000000000000000
+ 44 0 44 0000000000000000000000000000000000000000000010000000000000000000
+ 45 0 45 0000000000000000000000000000000000000000000001000000000000000000
+ 46 0 46 0000000000000000000000000000000000000000000000100000000000000000
+ 47 0 47 0000000000000000000000000000000000000000000000010000000000000000
+ 48 0 48 0000000000000000000000000000000000000000000000001000000000000000
+ 49 0 49 0000000000000000000000000000000000000000000000000100000000000000
+ 50 0 50 0000000000000000000000000000000000000000000000000010000000000000
+ 51 0 51 0000000000000000000000000000000000000000000000000001000000000000
+ 52 0 52 0000000000000000000000000000000000000000000000000000100000000000
+ 53 0 53 0000000000000000000000000000000000000000000000000000010000000000
+ 54 0 54 0000000000000000000000000000000000000000000000000000001000000000
+ 55 0 55 0000000000000000000000000000000000000000000000000000000100000000
+ 56 0 56 0000000000000000000000000000000000000000000000000000000010000000
+ 57 0 57 0000000000000000000000000000000000000000000000000000000001000000
+ 58 0 58 0000000000000000000000000000000000000000000000000000000000100000
+ 59 0 59 0000000000000000000000000000000000000000000000000000000000010000
+ 60 0 60 0000000000000000000000000000000000000000000000000000000000001000
+ 61 0 61 0000000000000000000000000000000000000000000000000000000000000100
+ 62 0 62 0000000000000000000000000000000000000000000000000000000000000010
+ 63 0 63 0000000000000000000000000000000000000000000000000000000000000001
diff --git a/contrib/netbsd-tests/include/d_bitstring_67.out b/contrib/netbsd-tests/include/d_bitstring_67.out
new file mode 100644
index 000000000000..e5decc3b4bdf
--- /dev/null
+++ b/contrib/netbsd-tests/include/d_bitstring_67.out
@@ -0,0 +1,583 @@
+Testing with TEST_LENGTH = 67
+
+test _bit_byte, _bit_mask, and bitstr_size
+ i _bit_byte(i) _bit_mask(i) bitstr_size(i)
+ 0 0 1 0
+ 1 0 2 1
+ 2 0 4 1
+ 3 0 8 1
+ 4 0 16 1
+ 5 0 32 1
+ 6 0 64 1
+ 7 0 128 1
+ 8 1 1 1
+ 9 1 2 2
+ 10 1 4 2
+ 11 1 8 2
+ 12 1 16 2
+ 13 1 32 2
+ 14 1 64 2
+ 15 1 128 2
+ 16 2 1 2
+ 17 2 2 3
+ 18 2 4 3
+ 19 2 8 3
+ 20 2 16 3
+ 21 2 32 3
+ 22 2 64 3
+ 23 2 128 3
+ 24 3 1 3
+ 25 3 2 4
+ 26 3 4 4
+ 27 3 8 4
+ 28 3 16 4
+ 29 3 32 4
+ 30 3 64 4
+ 31 3 128 4
+ 32 4 1 4
+ 33 4 2 5
+ 34 4 4 5
+ 35 4 8 5
+ 36 4 16 5
+ 37 4 32 5
+ 38 4 64 5
+ 39 4 128 5
+ 40 5 1 5
+ 41 5 2 6
+ 42 5 4 6
+ 43 5 8 6
+ 44 5 16 6
+ 45 5 32 6
+ 46 5 64 6
+ 47 5 128 6
+ 48 6 1 6
+ 49 6 2 7
+ 50 6 4 7
+ 51 6 8 7
+ 52 6 16 7
+ 53 6 32 7
+ 54 6 64 7
+ 55 6 128 7
+ 56 7 1 7
+ 57 7 2 8
+ 58 7 4 8
+ 59 7 8 8
+ 60 7 16 8
+ 61 7 32 8
+ 62 7 64 8
+ 63 7 128 8
+ 64 8 1 8
+ 65 8 2 9
+ 66 8 4 9
+
+test bit_alloc, clearbits, bit_ffc, bit_ffs
+be: 0 -1 0000000000000000000000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000000000000000000000
+
+test bit_set
+be: 1 0 1001001001001001001001001001001001001001001001001001001001001001001
+is: 1 0 1001001001001001001001001001001001001001001001001001001001001001001
+
+test bit_clear
+be: 0 3 0001000001000001000001000001000001000001000001000001000001000001000
+is: 0 3 0001000001000001000001000001000001000001000001000001000001000001000
+
+test bit_test using previous bitstring
+ i bit_test(i)
+ 0 0
+ 1 0
+ 2 0
+ 3 8
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+ 8 0
+ 9 2
+ 10 0
+ 11 0
+ 12 0
+ 13 0
+ 14 0
+ 15 128
+ 16 0
+ 17 0
+ 18 0
+ 19 0
+ 20 0
+ 21 32
+ 22 0
+ 23 0
+ 24 0
+ 25 0
+ 26 0
+ 27 8
+ 28 0
+ 29 0
+ 30 0
+ 31 0
+ 32 0
+ 33 2
+ 34 0
+ 35 0
+ 36 0
+ 37 0
+ 38 0
+ 39 128
+ 40 0
+ 41 0
+ 42 0
+ 43 0
+ 44 0
+ 45 32
+ 46 0
+ 47 0
+ 48 0
+ 49 0
+ 50 0
+ 51 8
+ 52 0
+ 53 0
+ 54 0
+ 55 0
+ 56 0
+ 57 2
+ 58 0
+ 59 0
+ 60 0
+ 61 0
+ 62 0
+ 63 128
+ 64 0
+ 65 0
+ 66 0
+
+test clearbits
+be: 0 -1 0000000000000000000000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000000000000000000000
+
+test bit_nset and bit_nclear
+be: 0 1 0111111111111111111111111111111111111111111111111111111111111111110
+is: 0 1 0111111111111111111111111111111111111111111111111111111111111111110
+be: 0 1 0100000000000000000000000000000000000000000000000000000000000000010
+is: 0 1 0100000000000000000000000000000000000000000000000000000000000000010
+be: 0 -1 0000000000000000000000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000000000000000000000
+be: 66 0 1111111111111111111111111111111111111111111111111111111111111111110
+is: 66 0 1111111111111111111111111111111111111111111111111111111111111111110
+be: 0 -1 0000000000000000000000000000000000000000000000000000000000000000000
+is: 0 -1 0000000000000000000000000000000000000000000000000000000000000000000
+
+first 1 bit should move right 1 position each line
+ 0 -1 0 1111111111111111111111111111111111111111111111111111111111111111111
+ 1 0 1 0111111111111111111111111111111111111111111111111111111111111111111
+ 2 0 2 0011111111111111111111111111111111111111111111111111111111111111111
+ 3 0 3 0001111111111111111111111111111111111111111111111111111111111111111
+ 4 0 4 0000111111111111111111111111111111111111111111111111111111111111111
+ 5 0 5 0000011111111111111111111111111111111111111111111111111111111111111
+ 6 0 6 0000001111111111111111111111111111111111111111111111111111111111111
+ 7 0 7 0000000111111111111111111111111111111111111111111111111111111111111
+ 8 0 8 0000000011111111111111111111111111111111111111111111111111111111111
+ 9 0 9 0000000001111111111111111111111111111111111111111111111111111111111
+ 10 0 10 0000000000111111111111111111111111111111111111111111111111111111111
+ 11 0 11 0000000000011111111111111111111111111111111111111111111111111111111
+ 12 0 12 0000000000001111111111111111111111111111111111111111111111111111111
+ 13 0 13 0000000000000111111111111111111111111111111111111111111111111111111
+ 14 0 14 0000000000000011111111111111111111111111111111111111111111111111111
+ 15 0 15 0000000000000001111111111111111111111111111111111111111111111111111
+ 16 0 16 0000000000000000111111111111111111111111111111111111111111111111111
+ 17 0 17 0000000000000000011111111111111111111111111111111111111111111111111
+ 18 0 18 0000000000000000001111111111111111111111111111111111111111111111111
+ 19 0 19 0000000000000000000111111111111111111111111111111111111111111111111
+ 20 0 20 0000000000000000000011111111111111111111111111111111111111111111111
+ 21 0 21 0000000000000000000001111111111111111111111111111111111111111111111
+ 22 0 22 0000000000000000000000111111111111111111111111111111111111111111111
+ 23 0 23 0000000000000000000000011111111111111111111111111111111111111111111
+ 24 0 24 0000000000000000000000001111111111111111111111111111111111111111111
+ 25 0 25 0000000000000000000000000111111111111111111111111111111111111111111
+ 26 0 26 0000000000000000000000000011111111111111111111111111111111111111111
+ 27 0 27 0000000000000000000000000001111111111111111111111111111111111111111
+ 28 0 28 0000000000000000000000000000111111111111111111111111111111111111111
+ 29 0 29 0000000000000000000000000000011111111111111111111111111111111111111
+ 30 0 30 0000000000000000000000000000001111111111111111111111111111111111111
+ 31 0 31 0000000000000000000000000000000111111111111111111111111111111111111
+ 32 0 32 0000000000000000000000000000000011111111111111111111111111111111111
+ 33 0 33 0000000000000000000000000000000001111111111111111111111111111111111
+ 34 0 34 0000000000000000000000000000000000111111111111111111111111111111111
+ 35 0 35 0000000000000000000000000000000000011111111111111111111111111111111
+ 36 0 36 0000000000000000000000000000000000001111111111111111111111111111111
+ 37 0 37 0000000000000000000000000000000000000111111111111111111111111111111
+ 38 0 38 0000000000000000000000000000000000000011111111111111111111111111111
+ 39 0 39 0000000000000000000000000000000000000001111111111111111111111111111
+ 40 0 40 0000000000000000000000000000000000000000111111111111111111111111111
+ 41 0 41 0000000000000000000000000000000000000000011111111111111111111111111
+ 42 0 42 0000000000000000000000000000000000000000001111111111111111111111111
+ 43 0 43 0000000000000000000000000000000000000000000111111111111111111111111
+ 44 0 44 0000000000000000000000000000000000000000000011111111111111111111111
+ 45 0 45 0000000000000000000000000000000000000000000001111111111111111111111
+ 46 0 46 0000000000000000000000000000000000000000000000111111111111111111111
+ 47 0 47 0000000000000000000000000000000000000000000000011111111111111111111
+ 48 0 48 0000000000000000000000000000000000000000000000001111111111111111111
+ 49 0 49 0000000000000000000000000000000000000000000000000111111111111111111
+ 50 0 50 0000000000000000000000000000000000000000000000000011111111111111111
+ 51 0 51 0000000000000000000000000000000000000000000000000001111111111111111
+ 52 0 52 0000000000000000000000000000000000000000000000000000111111111111111
+ 53 0 53 0000000000000000000000000000000000000000000000000000011111111111111
+ 54 0 54 0000000000000000000000000000000000000000000000000000001111111111111
+ 55 0 55 0000000000000000000000000000000000000000000000000000000111111111111
+ 56 0 56 0000000000000000000000000000000000000000000000000000000011111111111
+ 57 0 57 0000000000000000000000000000000000000000000000000000000001111111111
+ 58 0 58 0000000000000000000000000000000000000000000000000000000000111111111
+ 59 0 59 0000000000000000000000000000000000000000000000000000000000011111111
+ 60 0 60 0000000000000000000000000000000000000000000000000000000000001111111
+ 61 0 61 0000000000000000000000000000000000000000000000000000000000000111111
+ 62 0 62 0000000000000000000000000000000000000000000000000000000000000011111
+ 63 0 63 0000000000000000000000000000000000000000000000000000000000000001111
+ 64 0 64 0000000000000000000000000000000000000000000000000000000000000000111
+ 65 0 65 0000000000000000000000000000000000000000000000000000000000000000011
+ 66 0 66 0000000000000000000000000000000000000000000000000000000000000000001
+
+first 0 bit should move right 1 position each line
+ 0 0 -1 0000000000000000000000000000000000000000000000000000000000000000000
+ 1 1 0 1000000000000000000000000000000000000000000000000000000000000000000
+ 2 2 0 1100000000000000000000000000000000000000000000000000000000000000000
+ 3 3 0 1110000000000000000000000000000000000000000000000000000000000000000
+ 4 4 0 1111000000000000000000000000000000000000000000000000000000000000000
+ 5 5 0 1111100000000000000000000000000000000000000000000000000000000000000
+ 6 6 0 1111110000000000000000000000000000000000000000000000000000000000000
+ 7 7 0 1111111000000000000000000000000000000000000000000000000000000000000
+ 8 8 0 1111111100000000000000000000000000000000000000000000000000000000000
+ 9 9 0 1111111110000000000000000000000000000000000000000000000000000000000
+ 10 10 0 1111111111000000000000000000000000000000000000000000000000000000000
+ 11 11 0 1111111111100000000000000000000000000000000000000000000000000000000
+ 12 12 0 1111111111110000000000000000000000000000000000000000000000000000000
+ 13 13 0 1111111111111000000000000000000000000000000000000000000000000000000
+ 14 14 0 1111111111111100000000000000000000000000000000000000000000000000000
+ 15 15 0 1111111111111110000000000000000000000000000000000000000000000000000
+ 16 16 0 1111111111111111000000000000000000000000000000000000000000000000000
+ 17 17 0 1111111111111111100000000000000000000000000000000000000000000000000
+ 18 18 0 1111111111111111110000000000000000000000000000000000000000000000000
+ 19 19 0 1111111111111111111000000000000000000000000000000000000000000000000
+ 20 20 0 1111111111111111111100000000000000000000000000000000000000000000000
+ 21 21 0 1111111111111111111110000000000000000000000000000000000000000000000
+ 22 22 0 1111111111111111111111000000000000000000000000000000000000000000000
+ 23 23 0 1111111111111111111111100000000000000000000000000000000000000000000
+ 24 24 0 1111111111111111111111110000000000000000000000000000000000000000000
+ 25 25 0 1111111111111111111111111000000000000000000000000000000000000000000
+ 26 26 0 1111111111111111111111111100000000000000000000000000000000000000000
+ 27 27 0 1111111111111111111111111110000000000000000000000000000000000000000
+ 28 28 0 1111111111111111111111111111000000000000000000000000000000000000000
+ 29 29 0 1111111111111111111111111111100000000000000000000000000000000000000
+ 30 30 0 1111111111111111111111111111110000000000000000000000000000000000000
+ 31 31 0 1111111111111111111111111111111000000000000000000000000000000000000
+ 32 32 0 1111111111111111111111111111111100000000000000000000000000000000000
+ 33 33 0 1111111111111111111111111111111110000000000000000000000000000000000
+ 34 34 0 1111111111111111111111111111111111000000000000000000000000000000000
+ 35 35 0 1111111111111111111111111111111111100000000000000000000000000000000
+ 36 36 0 1111111111111111111111111111111111110000000000000000000000000000000
+ 37 37 0 1111111111111111111111111111111111111000000000000000000000000000000
+ 38 38 0 1111111111111111111111111111111111111100000000000000000000000000000
+ 39 39 0 1111111111111111111111111111111111111110000000000000000000000000000
+ 40 40 0 1111111111111111111111111111111111111111000000000000000000000000000
+ 41 41 0 1111111111111111111111111111111111111111100000000000000000000000000
+ 42 42 0 1111111111111111111111111111111111111111110000000000000000000000000
+ 43 43 0 1111111111111111111111111111111111111111111000000000000000000000000
+ 44 44 0 1111111111111111111111111111111111111111111100000000000000000000000
+ 45 45 0 1111111111111111111111111111111111111111111110000000000000000000000
+ 46 46 0 1111111111111111111111111111111111111111111111000000000000000000000
+ 47 47 0 1111111111111111111111111111111111111111111111100000000000000000000
+ 48 48 0 1111111111111111111111111111111111111111111111110000000000000000000
+ 49 49 0 1111111111111111111111111111111111111111111111111000000000000000000
+ 50 50 0 1111111111111111111111111111111111111111111111111100000000000000000
+ 51 51 0 1111111111111111111111111111111111111111111111111110000000000000000
+ 52 52 0 1111111111111111111111111111111111111111111111111111000000000000000
+ 53 53 0 1111111111111111111111111111111111111111111111111111100000000000000
+ 54 54 0 1111111111111111111111111111111111111111111111111111110000000000000
+ 55 55 0 1111111111111111111111111111111111111111111111111111111000000000000
+ 56 56 0 1111111111111111111111111111111111111111111111111111111100000000000
+ 57 57 0 1111111111111111111111111111111111111111111111111111111110000000000
+ 58 58 0 1111111111111111111111111111111111111111111111111111111111000000000
+ 59 59 0 1111111111111111111111111111111111111111111111111111111111100000000
+ 60 60 0 1111111111111111111111111111111111111111111111111111111111110000000
+ 61 61 0 1111111111111111111111111111111111111111111111111111111111111000000
+ 62 62 0 1111111111111111111111111111111111111111111111111111111111111100000
+ 63 63 0 1111111111111111111111111111111111111111111111111111111111111110000
+ 64 64 0 1111111111111111111111111111111111111111111111111111111111111111000
+ 65 65 0 1111111111111111111111111111111111111111111111111111111111111111100
+ 66 66 0 1111111111111111111111111111111111111111111111111111111111111111110
+
+first 0 bit should move left 1 position each line
+ 0 -1 0 1111111111111111111111111111111111111111111111111111111111111111111
+ 1 66 0 1111111111111111111111111111111111111111111111111111111111111111110
+ 2 65 0 1111111111111111111111111111111111111111111111111111111111111111100
+ 3 64 0 1111111111111111111111111111111111111111111111111111111111111111000
+ 4 63 0 1111111111111111111111111111111111111111111111111111111111111110000
+ 5 62 0 1111111111111111111111111111111111111111111111111111111111111100000
+ 6 61 0 1111111111111111111111111111111111111111111111111111111111111000000
+ 7 60 0 1111111111111111111111111111111111111111111111111111111111110000000
+ 8 59 0 1111111111111111111111111111111111111111111111111111111111100000000
+ 9 58 0 1111111111111111111111111111111111111111111111111111111111000000000
+ 10 57 0 1111111111111111111111111111111111111111111111111111111110000000000
+ 11 56 0 1111111111111111111111111111111111111111111111111111111100000000000
+ 12 55 0 1111111111111111111111111111111111111111111111111111111000000000000
+ 13 54 0 1111111111111111111111111111111111111111111111111111110000000000000
+ 14 53 0 1111111111111111111111111111111111111111111111111111100000000000000
+ 15 52 0 1111111111111111111111111111111111111111111111111111000000000000000
+ 16 51 0 1111111111111111111111111111111111111111111111111110000000000000000
+ 17 50 0 1111111111111111111111111111111111111111111111111100000000000000000
+ 18 49 0 1111111111111111111111111111111111111111111111111000000000000000000
+ 19 48 0 1111111111111111111111111111111111111111111111110000000000000000000
+ 20 47 0 1111111111111111111111111111111111111111111111100000000000000000000
+ 21 46 0 1111111111111111111111111111111111111111111111000000000000000000000
+ 22 45 0 1111111111111111111111111111111111111111111110000000000000000000000
+ 23 44 0 1111111111111111111111111111111111111111111100000000000000000000000
+ 24 43 0 1111111111111111111111111111111111111111111000000000000000000000000
+ 25 42 0 1111111111111111111111111111111111111111110000000000000000000000000
+ 26 41 0 1111111111111111111111111111111111111111100000000000000000000000000
+ 27 40 0 1111111111111111111111111111111111111111000000000000000000000000000
+ 28 39 0 1111111111111111111111111111111111111110000000000000000000000000000
+ 29 38 0 1111111111111111111111111111111111111100000000000000000000000000000
+ 30 37 0 1111111111111111111111111111111111111000000000000000000000000000000
+ 31 36 0 1111111111111111111111111111111111110000000000000000000000000000000
+ 32 35 0 1111111111111111111111111111111111100000000000000000000000000000000
+ 33 34 0 1111111111111111111111111111111111000000000000000000000000000000000
+ 34 33 0 1111111111111111111111111111111110000000000000000000000000000000000
+ 35 32 0 1111111111111111111111111111111100000000000000000000000000000000000
+ 36 31 0 1111111111111111111111111111111000000000000000000000000000000000000
+ 37 30 0 1111111111111111111111111111110000000000000000000000000000000000000
+ 38 29 0 1111111111111111111111111111100000000000000000000000000000000000000
+ 39 28 0 1111111111111111111111111111000000000000000000000000000000000000000
+ 40 27 0 1111111111111111111111111110000000000000000000000000000000000000000
+ 41 26 0 1111111111111111111111111100000000000000000000000000000000000000000
+ 42 25 0 1111111111111111111111111000000000000000000000000000000000000000000
+ 43 24 0 1111111111111111111111110000000000000000000000000000000000000000000
+ 44 23 0 1111111111111111111111100000000000000000000000000000000000000000000
+ 45 22 0 1111111111111111111111000000000000000000000000000000000000000000000
+ 46 21 0 1111111111111111111110000000000000000000000000000000000000000000000
+ 47 20 0 1111111111111111111100000000000000000000000000000000000000000000000
+ 48 19 0 1111111111111111111000000000000000000000000000000000000000000000000
+ 49 18 0 1111111111111111110000000000000000000000000000000000000000000000000
+ 50 17 0 1111111111111111100000000000000000000000000000000000000000000000000
+ 51 16 0 1111111111111111000000000000000000000000000000000000000000000000000
+ 52 15 0 1111111111111110000000000000000000000000000000000000000000000000000
+ 53 14 0 1111111111111100000000000000000000000000000000000000000000000000000
+ 54 13 0 1111111111111000000000000000000000000000000000000000000000000000000
+ 55 12 0 1111111111110000000000000000000000000000000000000000000000000000000
+ 56 11 0 1111111111100000000000000000000000000000000000000000000000000000000
+ 57 10 0 1111111111000000000000000000000000000000000000000000000000000000000
+ 58 9 0 1111111110000000000000000000000000000000000000000000000000000000000
+ 59 8 0 1111111100000000000000000000000000000000000000000000000000000000000
+ 60 7 0 1111111000000000000000000000000000000000000000000000000000000000000
+ 61 6 0 1111110000000000000000000000000000000000000000000000000000000000000
+ 62 5 0 1111100000000000000000000000000000000000000000000000000000000000000
+ 63 4 0 1111000000000000000000000000000000000000000000000000000000000000000
+ 64 3 0 1110000000000000000000000000000000000000000000000000000000000000000
+ 65 2 0 1100000000000000000000000000000000000000000000000000000000000000000
+ 66 1 0 1000000000000000000000000000000000000000000000000000000000000000000
+
+first 1 bit should move left 1 position each line
+ 0 0 -1 0000000000000000000000000000000000000000000000000000000000000000000
+ 1 0 66 0000000000000000000000000000000000000000000000000000000000000000001
+ 2 0 65 0000000000000000000000000000000000000000000000000000000000000000011
+ 3 0 64 0000000000000000000000000000000000000000000000000000000000000000111
+ 4 0 63 0000000000000000000000000000000000000000000000000000000000000001111
+ 5 0 62 0000000000000000000000000000000000000000000000000000000000000011111
+ 6 0 61 0000000000000000000000000000000000000000000000000000000000000111111
+ 7 0 60 0000000000000000000000000000000000000000000000000000000000001111111
+ 8 0 59 0000000000000000000000000000000000000000000000000000000000011111111
+ 9 0 58 0000000000000000000000000000000000000000000000000000000000111111111
+ 10 0 57 0000000000000000000000000000000000000000000000000000000001111111111
+ 11 0 56 0000000000000000000000000000000000000000000000000000000011111111111
+ 12 0 55 0000000000000000000000000000000000000000000000000000000111111111111
+ 13 0 54 0000000000000000000000000000000000000000000000000000001111111111111
+ 14 0 53 0000000000000000000000000000000000000000000000000000011111111111111
+ 15 0 52 0000000000000000000000000000000000000000000000000000111111111111111
+ 16 0 51 0000000000000000000000000000000000000000000000000001111111111111111
+ 17 0 50 0000000000000000000000000000000000000000000000000011111111111111111
+ 18 0 49 0000000000000000000000000000000000000000000000000111111111111111111
+ 19 0 48 0000000000000000000000000000000000000000000000001111111111111111111
+ 20 0 47 0000000000000000000000000000000000000000000000011111111111111111111
+ 21 0 46 0000000000000000000000000000000000000000000000111111111111111111111
+ 22 0 45 0000000000000000000000000000000000000000000001111111111111111111111
+ 23 0 44 0000000000000000000000000000000000000000000011111111111111111111111
+ 24 0 43 0000000000000000000000000000000000000000000111111111111111111111111
+ 25 0 42 0000000000000000000000000000000000000000001111111111111111111111111
+ 26 0 41 0000000000000000000000000000000000000000011111111111111111111111111
+ 27 0 40 0000000000000000000000000000000000000000111111111111111111111111111
+ 28 0 39 0000000000000000000000000000000000000001111111111111111111111111111
+ 29 0 38 0000000000000000000000000000000000000011111111111111111111111111111
+ 30 0 37 0000000000000000000000000000000000000111111111111111111111111111111
+ 31 0 36 0000000000000000000000000000000000001111111111111111111111111111111
+ 32 0 35 0000000000000000000000000000000000011111111111111111111111111111111
+ 33 0 34 0000000000000000000000000000000000111111111111111111111111111111111
+ 34 0 33 0000000000000000000000000000000001111111111111111111111111111111111
+ 35 0 32 0000000000000000000000000000000011111111111111111111111111111111111
+ 36 0 31 0000000000000000000000000000000111111111111111111111111111111111111
+ 37 0 30 0000000000000000000000000000001111111111111111111111111111111111111
+ 38 0 29 0000000000000000000000000000011111111111111111111111111111111111111
+ 39 0 28 0000000000000000000000000000111111111111111111111111111111111111111
+ 40 0 27 0000000000000000000000000001111111111111111111111111111111111111111
+ 41 0 26 0000000000000000000000000011111111111111111111111111111111111111111
+ 42 0 25 0000000000000000000000000111111111111111111111111111111111111111111
+ 43 0 24 0000000000000000000000001111111111111111111111111111111111111111111
+ 44 0 23 0000000000000000000000011111111111111111111111111111111111111111111
+ 45 0 22 0000000000000000000000111111111111111111111111111111111111111111111
+ 46 0 21 0000000000000000000001111111111111111111111111111111111111111111111
+ 47 0 20 0000000000000000000011111111111111111111111111111111111111111111111
+ 48 0 19 0000000000000000000111111111111111111111111111111111111111111111111
+ 49 0 18 0000000000000000001111111111111111111111111111111111111111111111111
+ 50 0 17 0000000000000000011111111111111111111111111111111111111111111111111
+ 51 0 16 0000000000000000111111111111111111111111111111111111111111111111111
+ 52 0 15 0000000000000001111111111111111111111111111111111111111111111111111
+ 53 0 14 0000000000000011111111111111111111111111111111111111111111111111111
+ 54 0 13 0000000000000111111111111111111111111111111111111111111111111111111
+ 55 0 12 0000000000001111111111111111111111111111111111111111111111111111111
+ 56 0 11 0000000000011111111111111111111111111111111111111111111111111111111
+ 57 0 10 0000000000111111111111111111111111111111111111111111111111111111111
+ 58 0 9 0000000001111111111111111111111111111111111111111111111111111111111
+ 59 0 8 0000000011111111111111111111111111111111111111111111111111111111111
+ 60 0 7 0000000111111111111111111111111111111111111111111111111111111111111
+ 61 0 6 0000001111111111111111111111111111111111111111111111111111111111111
+ 62 0 5 0000011111111111111111111111111111111111111111111111111111111111111
+ 63 0 4 0000111111111111111111111111111111111111111111111111111111111111111
+ 64 0 3 0001111111111111111111111111111111111111111111111111111111111111111
+ 65 0 2 0011111111111111111111111111111111111111111111111111111111111111111
+ 66 0 1 0111111111111111111111111111111111111111111111111111111111111111111
+
+0 bit should move right 1 position each line
+ 0 0 1 0111111111111111111111111111111111111111111111111111111111111111111
+ 1 1 0 1011111111111111111111111111111111111111111111111111111111111111111
+ 2 2 0 1101111111111111111111111111111111111111111111111111111111111111111
+ 3 3 0 1110111111111111111111111111111111111111111111111111111111111111111
+ 4 4 0 1111011111111111111111111111111111111111111111111111111111111111111
+ 5 5 0 1111101111111111111111111111111111111111111111111111111111111111111
+ 6 6 0 1111110111111111111111111111111111111111111111111111111111111111111
+ 7 7 0 1111111011111111111111111111111111111111111111111111111111111111111
+ 8 8 0 1111111101111111111111111111111111111111111111111111111111111111111
+ 9 9 0 1111111110111111111111111111111111111111111111111111111111111111111
+ 10 10 0 1111111111011111111111111111111111111111111111111111111111111111111
+ 11 11 0 1111111111101111111111111111111111111111111111111111111111111111111
+ 12 12 0 1111111111110111111111111111111111111111111111111111111111111111111
+ 13 13 0 1111111111111011111111111111111111111111111111111111111111111111111
+ 14 14 0 1111111111111101111111111111111111111111111111111111111111111111111
+ 15 15 0 1111111111111110111111111111111111111111111111111111111111111111111
+ 16 16 0 1111111111111111011111111111111111111111111111111111111111111111111
+ 17 17 0 1111111111111111101111111111111111111111111111111111111111111111111
+ 18 18 0 1111111111111111110111111111111111111111111111111111111111111111111
+ 19 19 0 1111111111111111111011111111111111111111111111111111111111111111111
+ 20 20 0 1111111111111111111101111111111111111111111111111111111111111111111
+ 21 21 0 1111111111111111111110111111111111111111111111111111111111111111111
+ 22 22 0 1111111111111111111111011111111111111111111111111111111111111111111
+ 23 23 0 1111111111111111111111101111111111111111111111111111111111111111111
+ 24 24 0 1111111111111111111111110111111111111111111111111111111111111111111
+ 25 25 0 1111111111111111111111111011111111111111111111111111111111111111111
+ 26 26 0 1111111111111111111111111101111111111111111111111111111111111111111
+ 27 27 0 1111111111111111111111111110111111111111111111111111111111111111111
+ 28 28 0 1111111111111111111111111111011111111111111111111111111111111111111
+ 29 29 0 1111111111111111111111111111101111111111111111111111111111111111111
+ 30 30 0 1111111111111111111111111111110111111111111111111111111111111111111
+ 31 31 0 1111111111111111111111111111111011111111111111111111111111111111111
+ 32 32 0 1111111111111111111111111111111101111111111111111111111111111111111
+ 33 33 0 1111111111111111111111111111111110111111111111111111111111111111111
+ 34 34 0 1111111111111111111111111111111111011111111111111111111111111111111
+ 35 35 0 1111111111111111111111111111111111101111111111111111111111111111111
+ 36 36 0 1111111111111111111111111111111111110111111111111111111111111111111
+ 37 37 0 1111111111111111111111111111111111111011111111111111111111111111111
+ 38 38 0 1111111111111111111111111111111111111101111111111111111111111111111
+ 39 39 0 1111111111111111111111111111111111111110111111111111111111111111111
+ 40 40 0 1111111111111111111111111111111111111111011111111111111111111111111
+ 41 41 0 1111111111111111111111111111111111111111101111111111111111111111111
+ 42 42 0 1111111111111111111111111111111111111111110111111111111111111111111
+ 43 43 0 1111111111111111111111111111111111111111111011111111111111111111111
+ 44 44 0 1111111111111111111111111111111111111111111101111111111111111111111
+ 45 45 0 1111111111111111111111111111111111111111111110111111111111111111111
+ 46 46 0 1111111111111111111111111111111111111111111111011111111111111111111
+ 47 47 0 1111111111111111111111111111111111111111111111101111111111111111111
+ 48 48 0 1111111111111111111111111111111111111111111111110111111111111111111
+ 49 49 0 1111111111111111111111111111111111111111111111111011111111111111111
+ 50 50 0 1111111111111111111111111111111111111111111111111101111111111111111
+ 51 51 0 1111111111111111111111111111111111111111111111111110111111111111111
+ 52 52 0 1111111111111111111111111111111111111111111111111111011111111111111
+ 53 53 0 1111111111111111111111111111111111111111111111111111101111111111111
+ 54 54 0 1111111111111111111111111111111111111111111111111111110111111111111
+ 55 55 0 1111111111111111111111111111111111111111111111111111111011111111111
+ 56 56 0 1111111111111111111111111111111111111111111111111111111101111111111
+ 57 57 0 1111111111111111111111111111111111111111111111111111111110111111111
+ 58 58 0 1111111111111111111111111111111111111111111111111111111111011111111
+ 59 59 0 1111111111111111111111111111111111111111111111111111111111101111111
+ 60 60 0 1111111111111111111111111111111111111111111111111111111111110111111
+ 61 61 0 1111111111111111111111111111111111111111111111111111111111111011111
+ 62 62 0 1111111111111111111111111111111111111111111111111111111111111101111
+ 63 63 0 1111111111111111111111111111111111111111111111111111111111111110111
+ 64 64 0 1111111111111111111111111111111111111111111111111111111111111111011
+ 65 65 0 1111111111111111111111111111111111111111111111111111111111111111101
+ 66 66 0 1111111111111111111111111111111111111111111111111111111111111111110
+
+1 bit should move right 1 position each line
+ 0 1 0 1000000000000000000000000000000000000000000000000000000000000000000
+ 1 0 1 0100000000000000000000000000000000000000000000000000000000000000000
+ 2 0 2 0010000000000000000000000000000000000000000000000000000000000000000
+ 3 0 3 0001000000000000000000000000000000000000000000000000000000000000000
+ 4 0 4 0000100000000000000000000000000000000000000000000000000000000000000
+ 5 0 5 0000010000000000000000000000000000000000000000000000000000000000000
+ 6 0 6 0000001000000000000000000000000000000000000000000000000000000000000
+ 7 0 7 0000000100000000000000000000000000000000000000000000000000000000000
+ 8 0 8 0000000010000000000000000000000000000000000000000000000000000000000
+ 9 0 9 0000000001000000000000000000000000000000000000000000000000000000000
+ 10 0 10 0000000000100000000000000000000000000000000000000000000000000000000
+ 11 0 11 0000000000010000000000000000000000000000000000000000000000000000000
+ 12 0 12 0000000000001000000000000000000000000000000000000000000000000000000
+ 13 0 13 0000000000000100000000000000000000000000000000000000000000000000000
+ 14 0 14 0000000000000010000000000000000000000000000000000000000000000000000
+ 15 0 15 0000000000000001000000000000000000000000000000000000000000000000000
+ 16 0 16 0000000000000000100000000000000000000000000000000000000000000000000
+ 17 0 17 0000000000000000010000000000000000000000000000000000000000000000000
+ 18 0 18 0000000000000000001000000000000000000000000000000000000000000000000
+ 19 0 19 0000000000000000000100000000000000000000000000000000000000000000000
+ 20 0 20 0000000000000000000010000000000000000000000000000000000000000000000
+ 21 0 21 0000000000000000000001000000000000000000000000000000000000000000000
+ 22 0 22 0000000000000000000000100000000000000000000000000000000000000000000
+ 23 0 23 0000000000000000000000010000000000000000000000000000000000000000000
+ 24 0 24 0000000000000000000000001000000000000000000000000000000000000000000
+ 25 0 25 0000000000000000000000000100000000000000000000000000000000000000000
+ 26 0 26 0000000000000000000000000010000000000000000000000000000000000000000
+ 27 0 27 0000000000000000000000000001000000000000000000000000000000000000000
+ 28 0 28 0000000000000000000000000000100000000000000000000000000000000000000
+ 29 0 29 0000000000000000000000000000010000000000000000000000000000000000000
+ 30 0 30 0000000000000000000000000000001000000000000000000000000000000000000
+ 31 0 31 0000000000000000000000000000000100000000000000000000000000000000000
+ 32 0 32 0000000000000000000000000000000010000000000000000000000000000000000
+ 33 0 33 0000000000000000000000000000000001000000000000000000000000000000000
+ 34 0 34 0000000000000000000000000000000000100000000000000000000000000000000
+ 35 0 35 0000000000000000000000000000000000010000000000000000000000000000000
+ 36 0 36 0000000000000000000000000000000000001000000000000000000000000000000
+ 37 0 37 0000000000000000000000000000000000000100000000000000000000000000000
+ 38 0 38 0000000000000000000000000000000000000010000000000000000000000000000
+ 39 0 39 0000000000000000000000000000000000000001000000000000000000000000000
+ 40 0 40 0000000000000000000000000000000000000000100000000000000000000000000
+ 41 0 41 0000000000000000000000000000000000000000010000000000000000000000000
+ 42 0 42 0000000000000000000000000000000000000000001000000000000000000000000
+ 43 0 43 0000000000000000000000000000000000000000000100000000000000000000000
+ 44 0 44 0000000000000000000000000000000000000000000010000000000000000000000
+ 45 0 45 0000000000000000000000000000000000000000000001000000000000000000000
+ 46 0 46 0000000000000000000000000000000000000000000000100000000000000000000
+ 47 0 47 0000000000000000000000000000000000000000000000010000000000000000000
+ 48 0 48 0000000000000000000000000000000000000000000000001000000000000000000
+ 49 0 49 0000000000000000000000000000000000000000000000000100000000000000000
+ 50 0 50 0000000000000000000000000000000000000000000000000010000000000000000
+ 51 0 51 0000000000000000000000000000000000000000000000000001000000000000000
+ 52 0 52 0000000000000000000000000000000000000000000000000000100000000000000
+ 53 0 53 0000000000000000000000000000000000000000000000000000010000000000000
+ 54 0 54 0000000000000000000000000000000000000000000000000000001000000000000
+ 55 0 55 0000000000000000000000000000000000000000000000000000000100000000000
+ 56 0 56 0000000000000000000000000000000000000000000000000000000010000000000
+ 57 0 57 0000000000000000000000000000000000000000000000000000000001000000000
+ 58 0 58 0000000000000000000000000000000000000000000000000000000000100000000
+ 59 0 59 0000000000000000000000000000000000000000000000000000000000010000000
+ 60 0 60 0000000000000000000000000000000000000000000000000000000000001000000
+ 61 0 61 0000000000000000000000000000000000000000000000000000000000000100000
+ 62 0 62 0000000000000000000000000000000000000000000000000000000000000010000
+ 63 0 63 0000000000000000000000000000000000000000000000000000000000000001000
+ 64 0 64 0000000000000000000000000000000000000000000000000000000000000000100
+ 65 0 65 0000000000000000000000000000000000000000000000000000000000000000010
+ 66 0 66 0000000000000000000000000000000000000000000000000000000000000000001
diff --git a/contrib/netbsd-tests/include/d_bitstring_8.out b/contrib/netbsd-tests/include/d_bitstring_8.out
new file mode 100644
index 000000000000..aba64404b457
--- /dev/null
+++ b/contrib/netbsd-tests/include/d_bitstring_8.out
@@ -0,0 +1,111 @@
+Testing with TEST_LENGTH = 8
+
+test _bit_byte, _bit_mask, and bitstr_size
+ i _bit_byte(i) _bit_mask(i) bitstr_size(i)
+ 0 0 1 0
+ 1 0 2 1
+ 2 0 4 1
+ 3 0 8 1
+ 4 0 16 1
+ 5 0 32 1
+ 6 0 64 1
+ 7 0 128 1
+
+test bit_alloc, clearbits, bit_ffc, bit_ffs
+be: 0 -1 00000000
+is: 0 -1 00000000
+
+test bit_set
+be: 1 0 10010010
+is: 1 0 10010010
+
+test bit_clear
+be: 0 3 00010000
+is: 0 3 00010000
+
+test bit_test using previous bitstring
+ i bit_test(i)
+ 0 0
+ 1 0
+ 2 0
+ 3 8
+ 4 0
+ 5 0
+ 6 0
+ 7 0
+
+test clearbits
+be: 0 -1 00000000
+is: 0 -1 00000000
+
+test bit_nset and bit_nclear
+be: 0 1 01111110
+is: 0 1 01111110
+be: 0 1 01000010
+is: 0 1 01000010
+be: 0 -1 00000000
+is: 0 -1 00000000
+be: 7 0 11111110
+is: 7 0 11111110
+be: 0 -1 00000000
+is: 0 -1 00000000
+
+first 1 bit should move right 1 position each line
+ 0 -1 0 11111111
+ 1 0 1 01111111
+ 2 0 2 00111111
+ 3 0 3 00011111
+ 4 0 4 00001111
+ 5 0 5 00000111
+ 6 0 6 00000011
+ 7 0 7 00000001
+
+first 0 bit should move right 1 position each line
+ 0 0 -1 00000000
+ 1 1 0 10000000
+ 2 2 0 11000000
+ 3 3 0 11100000
+ 4 4 0 11110000
+ 5 5 0 11111000
+ 6 6 0 11111100
+ 7 7 0 11111110
+
+first 0 bit should move left 1 position each line
+ 0 -1 0 11111111
+ 1 7 0 11111110
+ 2 6 0 11111100
+ 3 5 0 11111000
+ 4 4 0 11110000
+ 5 3 0 11100000
+ 6 2 0 11000000
+ 7 1 0 10000000
+
+first 1 bit should move left 1 position each line
+ 0 0 -1 00000000
+ 1 0 7 00000001
+ 2 0 6 00000011
+ 3 0 5 00000111
+ 4 0 4 00001111
+ 5 0 3 00011111
+ 6 0 2 00111111
+ 7 0 1 01111111
+
+0 bit should move right 1 position each line
+ 0 0 1 01111111
+ 1 1 0 10111111
+ 2 2 0 11011111
+ 3 3 0 11101111
+ 4 4 0 11110111
+ 5 5 0 11111011
+ 6 6 0 11111101
+ 7 7 0 11111110
+
+1 bit should move right 1 position each line
+ 0 1 0 10000000
+ 1 0 1 01000000
+ 2 0 2 00100000
+ 3 0 3 00010000
+ 4 0 4 00001000
+ 5 0 5 00000100
+ 6 0 6 00000010
+ 7 0 7 00000001
diff --git a/contrib/netbsd-tests/include/machine/t_bswap.c b/contrib/netbsd-tests/include/machine/t_bswap.c
new file mode 100644
index 000000000000..a7bb42a85ffc
--- /dev/null
+++ b/contrib/netbsd-tests/include/machine/t_bswap.c
@@ -0,0 +1,178 @@
+/* $NetBSD: t_bswap.c,v 1.1 2011/05/05 05:39:11 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_bswap.c,v 1.1 2011/05/05 05:39:11 jruoho Exp $");
+
+#include <sys/types.h>
+#include <machine/bswap.h>
+
+#include <atf-c.h>
+
+static uint16_t x16;
+static uint32_t x32;
+static uint64_t x64;
+
+static uint16_t unconst16(uint16_t);
+static uint32_t unconst32(uint32_t);
+static uint64_t unconst64(uint64_t);
+
+/*
+ * Given the use of __builtin_constant_p(3),
+ * these functions try to avoid gcc(1) from
+ * treating the arguments as constants.
+ */
+static uint16_t
+unconst16(uint16_t val)
+{
+ return val + x16;
+}
+
+static uint32_t
+unconst32(uint32_t val)
+{
+ return val + x32;
+}
+
+static uint64_t
+unconst64(uint64_t val)
+{
+ return val + x64;
+}
+
+ATF_TC(bswap16_basic);
+ATF_TC_HEAD(bswap16_basic, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "A naive test of bswap16(3), #1");
+}
+
+ATF_TC_BODY(bswap16_basic, tc)
+{
+ ATF_REQUIRE_EQ(bswap16(0x0000), 0x0000);
+ ATF_REQUIRE_EQ(bswap16(0xff00), 0x00ff);
+ ATF_REQUIRE_EQ(bswap16(0xffff), 0xffff);
+ ATF_REQUIRE_EQ(bswap16(0x1234), 0x3412);
+}
+
+ATF_TC(bswap16_unconst);
+ATF_TC_HEAD(bswap16_unconst, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "A naive test of bswap16(3), #2");
+}
+
+ATF_TC_BODY(bswap16_unconst, tc)
+{
+ x16 = 0;
+
+ ATF_REQUIRE_EQ(bswap16(unconst16(0x0000)), 0x0000);
+ ATF_REQUIRE_EQ(bswap16(unconst16(0xff00)), 0x00ff);
+ ATF_REQUIRE_EQ(bswap16(unconst16(0xffff)), 0xffff);
+ ATF_REQUIRE_EQ(bswap16(unconst16(0x1234)), 0x3412);
+}
+
+ATF_TC(bswap32_basic);
+ATF_TC_HEAD(bswap32_basic, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "A naive test of bswap32(3), #1");
+}
+
+ATF_TC_BODY(bswap32_basic, tc)
+{
+ ATF_REQUIRE_EQ(bswap32(0x00000000), 0x00000000);
+ ATF_REQUIRE_EQ(bswap32(0xffff0000), 0x0000ffff);
+ ATF_REQUIRE_EQ(bswap32(0xffffffff), 0xffffffff);
+ ATF_REQUIRE_EQ(bswap32(0x12345678), 0x78563412);
+}
+
+ATF_TC(bswap32_unconst);
+ATF_TC_HEAD(bswap32_unconst, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "A naive test of bswap32(3), #2");
+}
+
+ATF_TC_BODY(bswap32_unconst, tc)
+{
+ x32 = 0;
+
+ ATF_REQUIRE_EQ(bswap32(unconst32(0x00000000)), 0x00000000);
+ ATF_REQUIRE_EQ(bswap32(unconst32(0xffff0000)), 0x0000ffff);
+ ATF_REQUIRE_EQ(bswap32(unconst32(0xffffffff)), 0xffffffff);
+ ATF_REQUIRE_EQ(bswap32(unconst32(0x12345678)), 0x78563412);
+}
+
+ATF_TC(bswap64_basic);
+ATF_TC_HEAD(bswap64_basic, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "A naive test of bswap64(3), #1");
+}
+
+ATF_TC_BODY(bswap64_basic, tc)
+{
+ ATF_REQUIRE_EQ(bswap64(0x0000000000000000), 0x0000000000000000);
+ ATF_REQUIRE_EQ(bswap64(0xffffffff00000000), 0x00000000ffffffff);
+ ATF_REQUIRE_EQ(bswap64(0xffffffffffffffff), 0xffffffffffffffff);
+ ATF_REQUIRE_EQ(bswap64(0x123456789abcdeff), 0xffdebc9a78563412);
+}
+
+ATF_TC(bswap64_unconst);
+ATF_TC_HEAD(bswap64_unconst, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "A naive test of bswap64(3), #2");
+}
+
+ATF_TC_BODY(bswap64_unconst, tc)
+{
+ x64 = 0;
+
+ ATF_REQUIRE_EQ(bswap64(unconst64(0x0000000000000000)),
+ 0x0000000000000000);
+
+ ATF_REQUIRE_EQ(bswap64(unconst64(0xffffffff00000000)),
+ 0x00000000ffffffff);
+
+ ATF_REQUIRE_EQ(bswap64(unconst64(0xffffffffffffffff)),
+ 0xffffffffffffffff);
+
+ ATF_REQUIRE_EQ(bswap64(unconst64(0x123456789abcdeff)),
+ 0xffdebc9a78563412);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, bswap16_basic);
+ ATF_TP_ADD_TC(tp, bswap16_unconst);
+ ATF_TP_ADD_TC(tp, bswap32_basic);
+ ATF_TP_ADD_TC(tp, bswap32_unconst);
+ ATF_TP_ADD_TC(tp, bswap64_basic);
+ ATF_TP_ADD_TC(tp, bswap64_unconst);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/sys/t_bitops.c b/contrib/netbsd-tests/include/sys/t_bitops.c
new file mode 100644
index 000000000000..7c90da0d4c0d
--- /dev/null
+++ b/contrib/netbsd-tests/include/sys/t_bitops.c
@@ -0,0 +1,238 @@
+/* $NetBSD: t_bitops.c,v 1.16 2012/12/07 02:28:19 christos Exp $ */
+
+/*-
+ * Copyright (c) 2011, 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas and 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_bitops.c,v 1.16 2012/12/07 02:28:19 christos Exp $");
+
+#include <atf-c.h>
+
+#include <sys/cdefs.h>
+#include <sys/bitops.h>
+
+#include <math.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <string.h>
+
+static const struct {
+ uint32_t val;
+ int ffs;
+ int fls;
+} bits[] = {
+
+ { 0x00, 0, 0 }, { 0x01, 1, 1 }, { 0x02, 2, 2 }, { 0x03, 1, 2 },
+ { 0x04, 3, 3 }, { 0x05, 1, 3 }, { 0x06, 2, 3 }, { 0x07, 1, 3 },
+ { 0x08, 4, 4 }, { 0x09, 1, 4 }, { 0x0A, 2, 4 }, { 0x0B, 1, 4 },
+ { 0x0C, 3, 4 }, { 0x0D, 1, 4 }, { 0x0E, 2, 4 }, { 0x0F, 1, 4 },
+
+ { 0x10, 5, 5 }, { 0x11, 1, 5 }, { 0x12, 2, 5 }, { 0x13, 1, 5 },
+ { 0x14, 3, 5 }, { 0x15, 1, 5 }, { 0x16, 2, 5 }, { 0x17, 1, 5 },
+ { 0x18, 4, 5 }, { 0x19, 1, 5 }, { 0x1A, 2, 5 }, { 0x1B, 1, 5 },
+ { 0x1C, 3, 5 }, { 0x1D, 1, 5 }, { 0x1E, 2, 5 }, { 0x1F, 1, 5 },
+
+ { 0xF0, 5, 8 }, { 0xF1, 1, 8 }, { 0xF2, 2, 8 }, { 0xF3, 1, 8 },
+ { 0xF4, 3, 8 }, { 0xF5, 1, 8 }, { 0xF6, 2, 8 }, { 0xF7, 1, 8 },
+ { 0xF8, 4, 8 }, { 0xF9, 1, 8 }, { 0xFA, 2, 8 }, { 0xFB, 1, 8 },
+ { 0xFC, 3, 8 }, { 0xFD, 1, 8 }, { 0xFE, 2, 8 }, { 0xFF, 1, 8 },
+
+};
+
+ATF_TC(bitmap_basic);
+ATF_TC_HEAD(bitmap_basic, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "A basic test of __BITMAP_*");
+}
+
+ATF_TC_BODY(bitmap_basic, tc)
+{
+ __BITMAP_TYPE(, uint32_t, 65536) bm;
+ __BITMAP_ZERO(&bm);
+
+ ATF_REQUIRE(__BITMAP_SIZE(uint32_t, 65536) == 2048);
+
+ ATF_REQUIRE(__BITMAP_SHIFT(uint32_t) == 5);
+
+ ATF_REQUIRE(__BITMAP_MASK(uint32_t) == 31);
+
+ for (size_t i = 0; i < 65536; i += 2)
+ __BITMAP_SET(i, &bm);
+
+ for (size_t i = 0; i < 2048; i++)
+ ATF_REQUIRE(bm._b[i] == 0x55555555);
+
+ for (size_t i = 0; i < 65536; i++)
+ if (i & 1)
+ ATF_REQUIRE(!__BITMAP_ISSET(i, &bm));
+ else {
+ ATF_REQUIRE(__BITMAP_ISSET(i, &bm));
+ __BITMAP_CLR(i, &bm);
+ }
+
+ for (size_t i = 0; i < 65536; i += 2)
+ ATF_REQUIRE(!__BITMAP_ISSET(i, &bm));
+}
+
+ATF_TC(fast_divide32);
+ATF_TC_HEAD(fast_divide32, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "A basic test of fast_divide32(3)");
+}
+
+ATF_TC_BODY(fast_divide32, tc)
+{
+ uint32_t a, b, q, r, m;
+ uint8_t i, s1, s2;
+
+ a = 0xFFFF;
+ b = 0x000F;
+
+ fast_divide32_prepare(b, &m, &s1, &s2);
+
+ q = fast_divide32(a, b, m, s1, s2);
+ r = fast_remainder32(a, b, m, s1, s2);
+
+ ATF_REQUIRE(q == 0x1111 && r == 0);
+
+ for (i = 1; i < __arraycount(bits); i++) {
+
+ a = bits[i].val;
+ b = bits[i].ffs;
+
+ fast_divide32_prepare(b, &m, &s1, &s2);
+
+ q = fast_divide32(a, b, m, s1, s2);
+ r = fast_remainder32(a, b, m, s1, s2);
+
+ ATF_REQUIRE(q == a / b);
+ ATF_REQUIRE(r == a % b);
+ }
+}
+
+ATF_TC(ffsfls);
+ATF_TC_HEAD(ffsfls, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test ffs32(3)-family for correctness");
+}
+
+ATF_TC_BODY(ffsfls, tc)
+{
+ uint8_t i;
+
+ ATF_REQUIRE(ffs32(0) == 0x00);
+ ATF_REQUIRE(fls32(0) == 0x00);
+ ATF_REQUIRE(ffs64(0) == 0x00);
+ ATF_REQUIRE(fls64(0) == 0x00);
+
+ ATF_REQUIRE(ffs32(UINT32_MAX) == 0x01);
+ ATF_REQUIRE(fls32(UINT32_MAX) == 0x20);
+ ATF_REQUIRE(ffs64(UINT64_MAX) == 0x01);
+ ATF_REQUIRE(fls64(UINT64_MAX) == 0x40);
+
+ for (i = 1; i < __arraycount(bits); i++) {
+
+ ATF_REQUIRE(ffs32(bits[i].val) == bits[i].ffs);
+ ATF_REQUIRE(fls32(bits[i].val) == bits[i].fls);
+ ATF_REQUIRE(ffs64(bits[i].val) == bits[i].ffs);
+ ATF_REQUIRE(fls64(bits[i].val) == bits[i].fls);
+
+ ATF_REQUIRE(ffs32(bits[i].val << 1) == bits[i].ffs + 1);
+ ATF_REQUIRE(fls32(bits[i].val << 1) == bits[i].fls + 1);
+ ATF_REQUIRE(ffs64(bits[i].val << 1) == bits[i].ffs + 1);
+ ATF_REQUIRE(fls64(bits[i].val << 1) == bits[i].fls + 1);
+
+ ATF_REQUIRE(ffs32(bits[i].val << 9) == bits[i].ffs + 9);
+ ATF_REQUIRE(fls32(bits[i].val << 9) == bits[i].fls + 9);
+ ATF_REQUIRE(ffs64(bits[i].val << 9) == bits[i].ffs + 9);
+ ATF_REQUIRE(fls64(bits[i].val << 9) == bits[i].fls + 9);
+ }
+}
+
+ATF_TC(ilog2_basic);
+ATF_TC_HEAD(ilog2_basic, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test ilog2(3) for correctness");
+}
+
+ATF_TC_BODY(ilog2_basic, tc)
+{
+ uint64_t i, x;
+
+ for (i = x = 0; i < 64; i++) {
+
+ x = (uint64_t)1 << i;
+
+ ATF_REQUIRE(i == (uint64_t)ilog2(x));
+ }
+}
+
+ATF_TC(ilog2_log2);
+ATF_TC_HEAD(ilog2_log2, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test log2(3) vs. ilog2(3)");
+}
+
+ATF_TC_BODY(ilog2_log2, tc)
+{
+#ifdef __vax__
+ atf_tc_skip("Test is unavailable on vax because of lack of log2()");
+#else
+ double x, y;
+ uint64_t i;
+
+ /*
+ * This may fail under QEMU; see PR misc/44767.
+ */
+ for (i = 1; i < UINT32_MAX; i += UINT16_MAX) {
+
+ x = log2(i);
+ y = (double)(ilog2(i));
+
+ ATF_REQUIRE(ceil(x) >= y);
+
+ if (fabs(floor(x) - y) > 1.0e-40) {
+ atf_tc_expect_fail("PR misc/44767");
+ atf_tc_fail("log2(%"PRIu64") != "
+ "ilog2(%"PRIu64")", i, i);
+ }
+ }
+#endif
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, bitmap_basic);
+ ATF_TP_ADD_TC(tp, fast_divide32);
+ ATF_TP_ADD_TC(tp, ffsfls);
+ ATF_TP_ADD_TC(tp, ilog2_basic);
+ ATF_TP_ADD_TC(tp, ilog2_log2);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/sys/t_bootblock.c b/contrib/netbsd-tests/include/sys/t_bootblock.c
new file mode 100644
index 000000000000..13af2dd05829
--- /dev/null
+++ b/contrib/netbsd-tests/include/sys/t_bootblock.c
@@ -0,0 +1,73 @@
+/* $NetBSD: t_bootblock.c,v 1.1 2010/07/17 19:26:27 jmmv Exp $ */
+
+/*
+ * Copyright (c) 2004, 2008, 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008, 2010\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_bootblock.c,v 1.1 2010/07/17 19:26:27 jmmv Exp $");
+
+#include <sys/types.h>
+#include <sys/bootblock.h>
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+ATF_TC_WITHOUT_HEAD(mbr_sector);
+ATF_TC_BODY(mbr_sector, tc)
+{
+ ATF_CHECK_EQ(512, sizeof(struct mbr_sector));
+
+ ATF_CHECK_EQ(MBR_BPB_OFFSET, offsetof(struct mbr_sector, mbr_bpb));
+ ATF_CHECK_EQ(MBR_BS_OFFSET, offsetof(struct mbr_sector, mbr_bootsel));
+
+ ATF_CHECK_EQ(440, offsetof(struct mbr_sector, mbr_dsn));
+
+ ATF_CHECK_EQ(446, MBR_PART_OFFSET);
+ ATF_CHECK_EQ(MBR_PART_OFFSET, offsetof(struct mbr_sector, mbr_parts));
+
+ ATF_CHECK_EQ(510, MBR_MAGIC_OFFSET);
+ ATF_CHECK_EQ(MBR_MAGIC_OFFSET, offsetof(struct mbr_sector, mbr_magic));
+}
+
+ATF_TC_WITHOUT_HEAD(mbr_partition);
+ATF_TC_BODY(mbr_partition, tc)
+{
+ ATF_CHECK_EQ(16, sizeof(struct mbr_partition));
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, mbr_sector);
+ ATF_TP_ADD_TC(tp, mbr_partition);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/sys/t_cdefs.c b/contrib/netbsd-tests/include/sys/t_cdefs.c
new file mode 100644
index 000000000000..a47300969fc9
--- /dev/null
+++ b/contrib/netbsd-tests/include/sys/t_cdefs.c
@@ -0,0 +1,267 @@
+/* $NetBSD: t_cdefs.c,v 1.3 2013/09/05 09:01:27 gsutre Exp $ */
+
+/*-
+ * Copyright (c) 2012 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>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_cdefs.c,v 1.3 2013/09/05 09:01:27 gsutre Exp $");
+
+#include <atf-c.h>
+#include <sys/types.h>
+#include <limits.h>
+#include <stdint.h>
+
+static const struct {
+ const char *name;
+ intmax_t min;
+ intmax_t max;
+} s[] = {
+ { "signed char", SCHAR_MIN, SCHAR_MAX },
+ { "signed short", SHRT_MIN, SHRT_MAX },
+ { "signed int", INT_MIN, INT_MAX },
+ { "signed long", LONG_MIN, LONG_MAX },
+ { "signed long long", LLONG_MIN, LLONG_MAX },
+};
+
+static const struct {
+ const char *name;
+ uintmax_t min;
+ uintmax_t max;
+} u[] = {
+ { "unsigned char", 0, UCHAR_MAX },
+ { "unsigned short", 0, USHRT_MAX },
+ { "unsigned int", 0, UINT_MAX },
+ { "unsigned long", 0, ULONG_MAX },
+ { "unsigned long long", 0, ULLONG_MAX },
+};
+
+ATF_TC(stypeminmax);
+ATF_TC_HEAD(stypeminmax, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks signed type min/max macros");
+}
+
+
+ATF_TC_BODY(stypeminmax, tc)
+{
+#define CHECK(a, b) ATF_REQUIRE(__type_min(a) == s[b].min); \
+ ATF_REQUIRE(__type_max(a) == s[b].max)
+
+ CHECK(signed char, 0);
+ CHECK(signed short, 1);
+ CHECK(signed int, 2);
+ CHECK(signed long, 3);
+ CHECK(signed long long, 4);
+#undef CHECK
+}
+
+ATF_TC(utypeminmax);
+ATF_TC_HEAD(utypeminmax, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks unsigned type min/max macros");
+}
+
+ATF_TC_BODY(utypeminmax, tc)
+{
+#define CHECK(a, b) ATF_REQUIRE(__type_min(a) == u[b].min); \
+ ATF_REQUIRE(__type_max(a) == u[b].max)
+
+ CHECK(unsigned char, 0);
+ CHECK(unsigned short, 1);
+ CHECK(unsigned int, 2);
+ CHECK(unsigned long, 3);
+ CHECK(unsigned long long, 4);
+#undef CHECK
+}
+
+ATF_TC(sissigned);
+ATF_TC_HEAD(sissigned, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks issigned macro for signed");
+}
+
+ATF_TC_BODY(sissigned, tc)
+{
+#define CHECK(a) ATF_REQUIRE(__type_is_signed(a) == 1)
+
+ CHECK(signed char);
+ CHECK(signed short);
+ CHECK(signed int);
+ CHECK(signed long);
+ CHECK(signed long long);
+#undef CHECK
+}
+
+ATF_TC(uissigned);
+ATF_TC_HEAD(uissigned, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks issigned macro for unsigned");
+}
+
+ATF_TC_BODY(uissigned, tc)
+{
+#define CHECK(a) ATF_REQUIRE(__type_is_signed(a) == 0)
+
+ CHECK(unsigned char);
+ CHECK(unsigned short);
+ CHECK(unsigned int);
+ CHECK(unsigned long);
+ CHECK(unsigned long long);
+#undef CHECK
+}
+
+ATF_TC(utypemask);
+ATF_TC_HEAD(utypemask, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks type mask macro for unsigned");
+}
+
+ATF_TC_BODY(utypemask, tc)
+{
+#define CHECK(a, b) ATF_REQUIRE(__type_mask(a) == b)
+
+ CHECK(unsigned char, 0xffffffffffffff00ULL);
+ CHECK(unsigned short, 0xffffffffffff0000ULL);
+ CHECK(unsigned int, 0xffffffff00000000ULL);
+ CHECK(unsigned long long, 0x0000000000000000ULL);
+#undef CHECK
+}
+
+ATF_TC(stypemask);
+ATF_TC_HEAD(stypemask, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks type mask macro for signed");
+}
+
+ATF_TC_BODY(stypemask, tc)
+{
+#define CHECK(a, b) ATF_REQUIRE(__type_mask(a) == b)
+
+ CHECK(signed char, 0xffffffffffffff00LL);
+ CHECK(signed short, 0xffffffffffff0000LL);
+ CHECK(signed int, 0xffffffff00000000LL);
+ CHECK(signed long long, 0x0000000000000000LL);
+#undef CHECK
+}
+
+ATF_TC(stypefit);
+ATF_TC_HEAD(stypefit, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks typefit macro for signed");
+}
+
+ATF_TC_BODY(stypefit, tc)
+{
+#define CHECK(a, b, c) ATF_REQUIRE(!__type_fit(a, b) == c)
+
+ CHECK(signed char, -1, 0);
+ CHECK(signed char, 1, 0);
+ CHECK(signed char, 0x7f, 0);
+ CHECK(signed char, 0x80, 1);
+ CHECK(signed char, 0xff, 1);
+ CHECK(signed char, 0x1ff, 1);
+
+ CHECK(signed short, -1, 0);
+ CHECK(signed short, 1, 0);
+ CHECK(signed short, 0x7fff, 0);
+ CHECK(signed short, 0x8000, 1);
+ CHECK(signed short, 0xffff, 1);
+ CHECK(signed short, 0x1ffff, 1);
+
+ CHECK(signed int, -1, 0);
+ CHECK(signed int, 1, 0);
+ CHECK(signed int, 0x7fffffff, 0);
+ CHECK(signed int, 0x80000000, 1);
+ CHECK(signed int, 0xffffffff, 1);
+ CHECK(signed int, 0x1ffffffffLL, 1);
+
+ CHECK(signed long long, -1, 0);
+ CHECK(signed long long, 1, 0);
+ CHECK(signed long long, 0x7fffffffffffffffLL, 0);
+ CHECK(signed long long, 0x8000000000000000LL, 1);
+ CHECK(signed long long, 0xffffffffffffffffLL, 1);
+
+#undef CHECK
+}
+
+ATF_TC(utypefit);
+ATF_TC_HEAD(utypefit, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks typefit macro for unsigned");
+}
+
+ATF_TC_BODY(utypefit, tc)
+{
+#define CHECK(a, b, c) ATF_REQUIRE(!__type_fit(a, b) == c)
+
+ CHECK(unsigned char, -1, 1);
+ CHECK(unsigned char, 1, 0);
+ CHECK(unsigned char, 0x7f, 0);
+ CHECK(unsigned char, 0x80, 0);
+ CHECK(unsigned char, 0xff, 0);
+ CHECK(unsigned char, 0x1ff, 1);
+
+ CHECK(unsigned short, -1, 1);
+ CHECK(unsigned short, 1, 0);
+ CHECK(unsigned short, 0x7fff, 0);
+ CHECK(unsigned short, 0x8000, 0);
+ CHECK(unsigned short, 0xffff, 0);
+ CHECK(unsigned short, 0x1ffff, 1);
+
+ CHECK(unsigned int, -1, 1);
+ CHECK(unsigned int, 1, 0);
+ CHECK(unsigned int, 0x7fffffff, 0);
+ CHECK(unsigned int, 0x80000000, 0);
+ CHECK(unsigned int, 0xffffffff, 0);
+ CHECK(unsigned int, 0x1ffffffffLL, 1);
+
+ CHECK(unsigned long long, -1, 1);
+ CHECK(unsigned long long, 1, 0);
+ CHECK(unsigned long long, 0x7fffffffffffffffULL, 0);
+ CHECK(unsigned long long, 0x8000000000000000ULL, 0);
+ CHECK(unsigned long long, 0xffffffffffffffffULL, 0);
+
+#undef CHECK
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, stypeminmax);
+ ATF_TP_ADD_TC(tp, utypeminmax);
+ ATF_TP_ADD_TC(tp, sissigned);
+ ATF_TP_ADD_TC(tp, uissigned);
+ ATF_TP_ADD_TC(tp, stypemask);
+ ATF_TP_ADD_TC(tp, utypemask);
+ ATF_TP_ADD_TC(tp, stypefit);
+ ATF_TP_ADD_TC(tp, utypefit);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/sys/t_socket.c b/contrib/netbsd-tests/include/sys/t_socket.c
new file mode 100644
index 000000000000..ad4d2e6c29d3
--- /dev/null
+++ b/contrib/netbsd-tests/include/sys/t_socket.c
@@ -0,0 +1,205 @@
+/* $NetBSD: t_socket.c,v 1.3 2013/10/19 17:45:00 christos Exp $ */
+
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include <atf-c.h>
+#include <fcntl.h>
+#include <err.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <util.h>
+
+#include "../../h_macros.h"
+
+ATF_TC(cmsg_sendfd_bounds);
+ATF_TC_HEAD(cmsg_sendfd_bounds, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks that attempting to pass an "
+ "invalid fd returns an error");
+}
+
+ATF_TC_BODY(cmsg_sendfd_bounds, tc)
+{
+ struct cmsghdr *cmp;
+ struct msghdr msg;
+ struct iovec iov;
+ int s[2];
+ int fd;
+
+ rump_init();
+
+ if (rump_sys_socketpair(AF_LOCAL, SOCK_STREAM, 0, s) == -1)
+ atf_tc_fail("rump_sys_socket");
+
+ cmp = malloc(CMSG_SPACE(sizeof(int)));
+
+ iov.iov_base = &fd;
+ iov.iov_len = sizeof(int);
+
+ cmp->cmsg_level = SOL_SOCKET;
+ cmp->cmsg_type = SCM_RIGHTS;
+ cmp->cmsg_len = CMSG_LEN(sizeof(int));
+
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+ msg.msg_name = NULL;
+ msg.msg_namelen = 0;
+ msg.msg_control = cmp;
+ msg.msg_controllen = CMSG_SPACE(sizeof(int));
+
+ /*
+ * ERROR HERE: trying to pass invalid fd
+ * (This value was previously directly used to index the fd
+ * array and therefore we are passing a hyperspace index)
+ */
+ *(int *)CMSG_DATA(cmp) = 0x12345678;
+
+ rump_sys_sendmsg(s[0], &msg, 0);
+ if (errno != EBADF)
+ atf_tc_fail("descriptor passing failed: expected EBADF (9), "
+ "got %d\n(%s)", errno, strerror(errno));
+}
+
+
+ATF_TC(cmsg_sendfd);
+ATF_TC_HEAD(cmsg_sendfd, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks that fd passing works");
+ atf_tc_set_md_var(tc, "timeout", "2");
+}
+
+ATF_TC_BODY(cmsg_sendfd, tc)
+{
+ char buf[128];
+ struct cmsghdr *cmp;
+ struct msghdr msg;
+ struct sockaddr_un sun;
+ struct lwp *l1;
+ struct iovec iov;
+ socklen_t sl;
+ int s1, s2, sgot;
+ int rfd, fd[2], storage;
+
+ rump_init();
+
+ RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG));
+ l1 = rump_pub_lwproc_curlwp();
+
+ /* create unix socket and bind it to a path */
+ memset(&sun, 0, sizeof(sun));
+ sun.sun_family = AF_LOCAL;
+#define SOCKPATH "/com"
+ strncpy(sun.sun_path, SOCKPATH, sizeof(SOCKPATH));
+ s1 = rump_sys_socket(AF_LOCAL, SOCK_STREAM, 0);
+ if (s1 == -1)
+ atf_tc_fail_errno("socket 1");
+ if (rump_sys_bind(s1, (struct sockaddr *)&sun, SUN_LEN(&sun)) == -1)
+ atf_tc_fail_errno("socket 1 bind");
+ if (rump_sys_listen(s1, 1) == -1)
+ atf_tc_fail_errno("socket 1 listen");
+
+ /* create second process for test */
+ RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG));
+ (void)rump_pub_lwproc_curlwp();
+
+ /* connect to unix domain socket */
+ memset(&sun, 0, sizeof(sun));
+ sun.sun_family = AF_LOCAL;
+ strncpy(sun.sun_path, SOCKPATH, sizeof(SOCKPATH));
+ s2 = rump_sys_socket(AF_LOCAL, SOCK_STREAM, 0);
+ if (s2 == -1)
+ atf_tc_fail_errno("socket 2");
+ if (rump_sys_connect(s2, (struct sockaddr *)&sun, SUN_LEN(&sun)) == -1)
+ atf_tc_fail_errno("socket 2 connect");
+
+ /* open a pipe and write stuff to it */
+ if (rump_sys_pipe(fd) == -1)
+ atf_tc_fail_errno("can't open pipe");
+#define MAGICSTRING "duam xnaht"
+ if (rump_sys_write(fd[1], MAGICSTRING, sizeof(MAGICSTRING)) !=
+ sizeof(MAGICSTRING))
+ atf_tc_fail_errno("pipe write"); /* XXX: errno */
+
+ cmp = malloc(CMSG_SPACE(sizeof(int)));
+
+ iov.iov_base = &storage;
+ iov.iov_len = sizeof(int);
+
+ cmp->cmsg_level = SOL_SOCKET;
+ cmp->cmsg_type = SCM_RIGHTS;
+ cmp->cmsg_len = CMSG_LEN(sizeof(int));
+
+ msg.msg_iov = &iov;
+ msg.msg_iovlen = 1;
+ msg.msg_name = NULL;
+ msg.msg_namelen = 0;
+ msg.msg_control = cmp;
+ msg.msg_controllen = CMSG_SPACE(sizeof(int));
+ *(int *)CMSG_DATA(cmp) = fd[0];
+
+ /* pass the fd */
+ if (rump_sys_sendmsg(s2, &msg, 0) == -1)
+ atf_tc_fail_errno("sendmsg failed");
+
+ /*
+ * We will read to the same cmsg space. Overwrite the space
+ * with an invalid fd to make sure we get an explicit error
+ * if we don't manage to read the fd.
+ */
+ *(int *)CMSG_DATA(cmp) = -1;
+
+ /* switch back to original proc */
+ rump_pub_lwproc_switch(l1);
+
+ /* accept connection and read fd */
+ sl = sizeof(sun);
+ sgot = rump_sys_accept(s1, (struct sockaddr *)&sun, &sl);
+ if (sgot == -1)
+ atf_tc_fail_errno("accept");
+ if (rump_sys_recvmsg(sgot, &msg, 0) == -1)
+ atf_tc_fail_errno("recvmsg failed");
+ rfd = *(int *)CMSG_DATA(cmp);
+
+ /* read from the fd */
+ memset(buf, 0, sizeof(buf));
+ if (rump_sys_read(rfd, buf, sizeof(buf)) == -1)
+ atf_tc_fail_errno("read rfd");
+
+ /* check that we got the right stuff */
+ if (strcmp(buf, MAGICSTRING) != 0)
+ atf_tc_fail("expected \"%s\", got \"%s\"", MAGICSTRING, buf);
+}
+
+ATF_TC(sock_cloexec);
+ATF_TC_HEAD(sock_cloexec, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "SOCK_CLOEXEC kernel invariant failure");
+}
+
+ATF_TC_BODY(sock_cloexec, tc)
+{
+
+ rump_init();
+ rump_pub_lwproc_rfork(RUMP_RFFDG);
+ if (rump_sys_socket(-1, SOCK_CLOEXEC, 0) != -1)
+ atf_tc_fail("invalid socket parameters unexpectedly worked");
+ rump_pub_lwproc_releaselwp();
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, cmsg_sendfd);
+ ATF_TP_ADD_TC(tp, cmsg_sendfd_bounds);
+ ATF_TP_ADD_TC(tp, sock_cloexec);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/sys/t_tree.c b/contrib/netbsd-tests/include/sys/t_tree.c
new file mode 100644
index 000000000000..498f7ee4c64f
--- /dev/null
+++ b/contrib/netbsd-tests/include/sys/t_tree.c
@@ -0,0 +1,124 @@
+/* $NetBSD: t_tree.c,v 1.1 2011/05/05 13:36:05 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/tree.h>
+
+#include <atf-c.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+struct mist {
+ RB_ENTRY(mist) rbentry;
+ int key;
+};
+RB_HEAD(head, mist) tt;
+
+static int
+mistcmp(struct mist *a, struct mist *b)
+{
+#if 0
+ return (b->key - a->key); /* wrong, can overflow */
+#else
+ if (b->key > a->key)
+ return 1;
+ else if (b->key < a->key)
+ return (-1);
+ else
+ return 0;
+#endif
+}
+
+RB_PROTOTYPE(head, mist, rbentry, mistcmp)
+RB_GENERATE(head, mist, rbentry, mistcmp)
+
+static struct mist *
+addmist(int key)
+{
+ struct mist *m;
+
+ m = malloc(sizeof(struct mist));
+ m->key = key;
+ RB_INSERT(head, &tt, m);
+ return m;
+}
+
+static int
+findmist(struct mist *m)
+{
+
+ return (!!RB_FIND(head, &tt, m));
+}
+
+#define N 1000
+static int
+test(void)
+{
+ struct mist *m[N];
+ int fail, i, j;
+
+ RB_INIT(&tt);
+ fail = 0;
+ for (i = 0; i < N; i++) {
+ m[i] = addmist(random() << 1); /* use all 32 bits */
+ for (j = 0; j <= i; j++)
+ if (!findmist(m[j]))
+ fail++;
+ }
+ return fail;
+}
+
+ATF_TC(tree_rbstress);
+ATF_TC_HEAD(tree_rbstress, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "rb-tree stress test");
+}
+
+ATF_TC_BODY(tree_rbstress, tc)
+{
+ int i, fail, f;
+
+ srandom(4711);
+ fail = 0;
+ for (i = 0; i < 10; i++) {
+ f = test();
+ if (f) {
+ atf_tc_fail_nonfatal("loop %d: %d errors\n", i, f);
+ fail += f;
+ }
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, tree_rbstress);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/sys/t_types.c b/contrib/netbsd-tests/include/sys/t_types.c
new file mode 100644
index 000000000000..45b715fc8c63
--- /dev/null
+++ b/contrib/netbsd-tests/include/sys/t_types.c
@@ -0,0 +1,144 @@
+/* $NetBSD: t_types.c,v 1.4 2012/03/18 07:14:08 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_types.c,v 1.4 2012/03/18 07:14:08 jruoho Exp $");
+
+#include <sys/types.h>
+
+#include <atf-c.h>
+#include <limits.h>
+#include <stdint.h>
+
+#include <stdio.h>
+
+ATF_TC(types_limits);
+ATF_TC_HEAD(types_limits, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Known limits for types(3)");
+}
+
+ATF_TC_BODY(types_limits, tc)
+{
+ useconds_t usec;
+ ssize_t size;
+
+ /*
+ * IEEE Std 1003.1-2008:
+ *
+ * "The type ssize_t shall be capable of storing
+ * values at least in the range [-1, {SSIZE_MAX}]."
+ *
+ */
+ size = SSIZE_MAX;
+ ATF_REQUIRE(size > 0);
+
+ size = size + 1;
+ ATF_REQUIRE(size < 0);
+
+ /*
+ * IEEE Std 1003.1-2008:
+ *
+ * "The type suseconds_t shall be a signed integer type capable
+ * of storing values at least in the range [-1, 1000000]."
+ */
+ usec = 1000000;
+ ATF_REQUIRE(usec > 0);
+}
+
+ATF_TC(types_signed);
+ATF_TC_HEAD(types_signed, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Signed types(3)"
+ " (PR standards/44847)");
+}
+
+ATF_TC_BODY(types_signed, tc)
+{
+ blkcnt_t bc;
+ blksize_t bs;
+ ssize_t size;
+ off_t off;
+ pid_t pid;
+
+ /*
+ * As noted in types(3), the following
+ * types should be signed integers.
+ */
+ bc = 0;
+ bs = 0;
+ off = 0;
+ pid = 0;
+ size = 0;
+
+ ATF_CHECK((bc - 1) <= 0);
+ ATF_CHECK((bs - 1) <= 0);
+ ATF_CHECK((off - 1) <= 0);
+ ATF_CHECK((pid - 1) <= 0);
+ ATF_CHECK((size - 1) <= 0);
+}
+
+ATF_TC(types_unsigned);
+ATF_TC_HEAD(types_unsigned, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Unsigned types(3)"
+ " (PR standards/18067)");
+}
+
+ATF_TC_BODY(types_unsigned, tc)
+{
+ fsblkcnt_t fb;
+ fsfilcnt_t ff;
+ size_t size;
+ rlim_t lim;
+ ino_t ino;
+
+ fb = 0;
+ ff = 0;
+ ino = 0;
+ lim = 0;
+ size = 0;
+
+ ATF_CHECK((fb - 1) > 0);
+ ATF_CHECK((ff - 1) > 0);
+ ATF_CHECK((ino - 1) > 0);
+ ATF_CHECK((lim - 1) > 0);
+ ATF_CHECK((size - 1) > 0);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, types_limits);
+ ATF_TP_ADD_TC(tp, types_signed);
+ ATF_TP_ADD_TC(tp, types_unsigned);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/t_bitstring.c b/contrib/netbsd-tests/include/t_bitstring.c
new file mode 100644
index 000000000000..1dda3c25d556
--- /dev/null
+++ b/contrib/netbsd-tests/include/t_bitstring.c
@@ -0,0 +1,298 @@
+/* $NetBSD: t_bitstring.c,v 1.4 2012/03/25 06:54:04 joerg Exp $ */
+
+/*-
+ * Copyright (c) 1993, 2008, 2010 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 <assert.h>
+#include <bitstring.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <atf-c.h>
+
+static void
+clearbits(bitstr_t *b, int n)
+{
+ int i = bitstr_size(n);
+
+ while(i--)
+ *(b + i) = 0;
+}
+
+static void
+printbits(FILE *file, bitstr_t *b, int n)
+{
+ int i;
+ int jc, js;
+
+ bit_ffc(b, n, &jc);
+ bit_ffs(b, n, &js);
+
+ (void) fprintf(file, "%3d %3d ", jc, js);
+
+ for (i=0; i < n; i++) {
+ (void) fprintf(file, "%c", (bit_test(b, i) ? '1' : '0'));
+ }
+
+ (void) fprintf(file, "%c", '\n');
+}
+
+static void
+calculate_data(FILE *file, const int test_length)
+{
+ int i;
+ bitstr_t *bs;
+
+ assert(test_length >= 4);
+
+ (void) fprintf(file, "Testing with TEST_LENGTH = %d\n\n", test_length);
+
+ (void) fprintf(file, "test _bit_byte, _bit_mask, and bitstr_size\n");
+ (void) fprintf(file, " i _bit_byte(i) _bit_mask(i) bitstr_size(i)\n");
+
+ for (i=0; i < test_length; i++) {
+ (void) fprintf(file, "%3d%15u%15u%15zu\n",
+ i, _bit_byte(i), _bit_mask(i), bitstr_size(i));
+ }
+
+ bs = bit_alloc(test_length);
+ clearbits(bs, test_length);
+ (void) fprintf(file, "\ntest bit_alloc, clearbits, bit_ffc, bit_ffs\n");
+ (void) fprintf(file, "be: 0 -1 ");
+ for (i=0; i < test_length; i++)
+ (void) fprintf(file, "%c", '0');
+ (void) fprintf(file, "\nis: ");
+ printbits(file, bs, test_length);
+
+ (void) fprintf(file, "\ntest bit_set\n");
+ for (i=0; i < test_length; i+=3)
+ bit_set(bs, i);
+ (void) fprintf(file, "be: 1 0 ");
+ for (i=0; i < test_length; i++)
+ (void) fprintf(file, "%c", "100"[i % 3]);
+ (void) fprintf(file, "\nis: ");
+ printbits(file, bs, test_length);
+
+ (void) fprintf(file, "\ntest bit_clear\n");
+ for (i=0; i < test_length; i+=6)
+ bit_clear(bs, i);
+ (void) fprintf(file, "be: 0 3 ");
+ for (i=0; i < test_length; i++)
+ (void) fprintf(file, "%c", "000100"[i % 6]);
+ (void) fprintf(file, "\nis: ");
+ printbits(file, bs, test_length);
+
+ (void) fprintf(file, "\ntest bit_test using previous bitstring\n");
+ (void) fprintf(file, " i bit_test(i)\n");
+ for (i=0; i < test_length; i++)
+ (void) fprintf(file, "%3d%15d\n", i, bit_test(bs, i));
+
+ clearbits(bs, test_length);
+ (void) fprintf(file, "\ntest clearbits\n");
+ (void) fprintf(file, "be: 0 -1 ");
+ for (i=0; i < test_length; i++)
+ (void) fprintf(file, "%c", '0');
+ (void) fprintf(file, "\nis: ");
+ printbits(file, bs, test_length);
+
+ (void) fprintf(file, "\ntest bit_nset and bit_nclear\n");
+ bit_nset(bs, 1, test_length - 2);
+ (void) fprintf(file, "be: 0 1 0");
+ for (i=0; i < test_length - 2; i++)
+ (void) fprintf(file, "%c", '1');
+ (void) fprintf(file, "0\nis: ");
+ printbits(file, bs, test_length);
+
+ bit_nclear(bs, 2, test_length - 3);
+ (void) fprintf(file, "be: 0 1 01");
+ for (i=0; i < test_length - 4; i++)
+ (void) fprintf(file, "%c", '0');
+ (void) fprintf(file, "10\nis: ");
+ printbits(file, bs, test_length);
+
+ bit_nclear(bs, 0, test_length - 1);
+ (void) fprintf(file, "be: 0 -1 ");
+ for (i=0; i < test_length; i++)
+ (void) fprintf(file, "%c", '0');
+ (void) fprintf(file, "\nis: ");
+ printbits(file, bs, test_length);
+ bit_nset(bs, 0, test_length - 2);
+ (void) fprintf(file, "be: %3d 0 ",test_length - 1);
+ for (i=0; i < test_length - 1; i++)
+ (void) fprintf(file, "%c", '1');
+ fprintf(file, "%c", '0');
+ (void) fprintf(file, "\nis: ");
+ printbits(file, bs, test_length);
+ bit_nclear(bs, 0, test_length - 1);
+ (void) fprintf(file, "be: 0 -1 ");
+ for (i=0; i < test_length; i++)
+ (void) fprintf(file, "%c", '0');
+ (void) fprintf(file, "\nis: ");
+ printbits(file, bs, test_length);
+
+ (void) fprintf(file, "\n");
+ (void) fprintf(file, "first 1 bit should move right 1 position each line\n");
+ for (i=0; i < test_length; i++) {
+ bit_nclear(bs, 0, test_length - 1);
+ bit_nset(bs, i, test_length - 1);
+ (void) fprintf(file, "%3d ", i); printbits(file, bs, test_length);
+ }
+
+ (void) fprintf(file, "\n");
+ (void) fprintf(file, "first 0 bit should move right 1 position each line\n");
+ for (i=0; i < test_length; i++) {
+ bit_nset(bs, 0, test_length - 1);
+ bit_nclear(bs, i, test_length - 1);
+ (void) fprintf(file, "%3d ", i); printbits(file, bs, test_length);
+ }
+
+ (void) fprintf(file, "\n");
+ (void) fprintf(file, "first 0 bit should move left 1 position each line\n");
+ for (i=0; i < test_length; i++) {
+ bit_nclear(bs, 0, test_length - 1);
+ bit_nset(bs, 0, test_length - 1 - i);
+ (void) fprintf(file, "%3d ", i); printbits(file, bs, test_length);
+ }
+
+ (void) fprintf(file, "\n");
+ (void) fprintf(file, "first 1 bit should move left 1 position each line\n");
+ for (i=0; i < test_length; i++) {
+ bit_nset(bs, 0, test_length - 1);
+ bit_nclear(bs, 0, test_length - 1 - i);
+ (void) fprintf(file, "%3d ", i); printbits(file, bs, test_length);
+ }
+
+ (void) fprintf(file, "\n");
+ (void) fprintf(file, "0 bit should move right 1 position each line\n");
+ for (i=0; i < test_length; i++) {
+ bit_nset(bs, 0, test_length - 1);
+ bit_nclear(bs, i, i);
+ (void) fprintf(file, "%3d ", i); printbits(file, bs, test_length);
+ }
+
+ (void) fprintf(file, "\n");
+ (void) fprintf(file, "1 bit should move right 1 position each line\n");
+ for (i=0; i < test_length; i++) {
+ bit_nclear(bs, 0, test_length - 1);
+ bit_nset(bs, i, i);
+ (void) fprintf(file, "%3d ", i); printbits(file, bs, test_length);
+ }
+
+ (void) free(bs);
+}
+
+static void
+one_check(const atf_tc_t *tc, const int test_length)
+{
+ FILE *out;
+ char command[1024];
+
+ ATF_REQUIRE((out = fopen("out", "w")) != NULL);
+ calculate_data(out, test_length);
+ fclose(out);
+
+ /* XXX The following is a huge hack that was added to simplify the
+ * conversion of these tests from src/regress/ to src/tests/. The
+ * tests in this file should be checking their own results, without
+ * having to resort to external data files. */
+ snprintf(command, sizeof(command), "diff -u %s/d_bitstring_%d.out out",
+ atf_tc_get_config_var(tc, "srcdir"), test_length);
+ if (system(command) != EXIT_SUCCESS)
+ atf_tc_fail("Test failed; see output for details");
+}
+
+ATF_TC(bits_8);
+ATF_TC_HEAD(bits_8, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks 8-bit long bitstrings");
+}
+ATF_TC_BODY(bits_8, tc)
+{
+ one_check(tc, 8);
+}
+
+ATF_TC(bits_27);
+ATF_TC_HEAD(bits_27, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks 27-bit long bitstrings");
+}
+ATF_TC_BODY(bits_27, tc)
+{
+ one_check(tc, 27);
+}
+
+ATF_TC(bits_32);
+ATF_TC_HEAD(bits_32, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks 32-bit long bitstrings");
+}
+ATF_TC_BODY(bits_32, tc)
+{
+ one_check(tc, 32);
+}
+
+ATF_TC(bits_49);
+ATF_TC_HEAD(bits_49, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks 49-bit long bitstrings");
+}
+ATF_TC_BODY(bits_49, tc)
+{
+ one_check(tc, 49);
+}
+
+ATF_TC(bits_64);
+ATF_TC_HEAD(bits_64, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks 64-bit long bitstrings");
+}
+ATF_TC_BODY(bits_64, tc)
+{
+ one_check(tc, 64);
+}
+
+ATF_TC(bits_67);
+ATF_TC_HEAD(bits_67, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Checks 67-bit long bitstrings");
+}
+ATF_TC_BODY(bits_67, tc)
+{
+ one_check(tc, 67);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, bits_8);
+ ATF_TP_ADD_TC(tp, bits_27);
+ ATF_TP_ADD_TC(tp, bits_32);
+ ATF_TP_ADD_TC(tp, bits_49);
+ ATF_TP_ADD_TC(tp, bits_64);
+ ATF_TP_ADD_TC(tp, bits_67);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/t_errno.c b/contrib/netbsd-tests/include/t_errno.c
new file mode 100644
index 000000000000..763e5697aadf
--- /dev/null
+++ b/contrib/netbsd-tests/include/t_errno.c
@@ -0,0 +1,765 @@
+/* $NetBSD: t_errno.c,v 1.1 2011/05/01 17:07:05 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_errno.c,v 1.1 2011/05/01 17:07:05 jruoho Exp $");
+
+#include <atf-c.h>
+#include <errno.h>
+
+ATF_TC(errno_constants);
+ATF_TC_HEAD(errno_constants, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test POSIX constants in <errno.h>");
+}
+
+ATF_TC_BODY(errno_constants, tc)
+{
+ bool fail;
+
+ /*
+ * The following definitions should be available
+ * according to IEEE Std 1003.1-2008, issue 7.
+ */
+ atf_tc_expect_fail("PR standards/44921");
+
+ fail = true;
+
+#ifdef E2BIG
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("E2BIG not defined");
+
+ fail = true;
+
+#ifdef EACCES
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EACCES not defined");
+
+ fail = true;
+
+#ifdef EADDRINUSE
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EADDRINUSE not defined");
+
+ fail = true;
+
+#ifdef EADDRNOTAVAIL
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EADDRNOTAVAIL not defined");
+
+ fail = true;
+
+#ifdef EAFNOSUPPORT
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAFNOSUPPORT not defined");
+
+ fail = true;
+
+#ifdef EAGAIN
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAGAIN not defined");
+
+ fail = true;
+
+#ifdef EALREADY
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EALREADY not defined");
+
+ fail = true;
+
+#ifdef EBADF
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EBADF not defined");
+
+ fail = true;
+
+#ifdef EBADMSG
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EBADMSG not defined");
+
+ fail = true;
+
+#ifdef EBUSY
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EBUSY not defined");
+
+ fail = true;
+
+#ifdef ECANCELED
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("ECANCELED not defined");
+
+ fail = true;
+
+#ifdef ECHILD
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("ECHILD not defined");
+
+ fail = true;
+
+#ifdef ECONNABORTED
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("ECONNABORTED not defined");
+
+ fail = true;
+
+#ifdef ECONNREFUSED
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("ECONNREFUSED not defined");
+
+ fail = true;
+
+#ifdef ECONNRESET
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("ECONNRESET not defined");
+
+ fail = true;
+
+#ifdef EDEADLK
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EDEADLK not defined");
+
+ fail = true;
+
+#ifdef EDESTADDRREQ
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EDESTADDRREQ not defined");
+
+ fail = true;
+
+#ifdef EDOM
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EDOM not defined");
+
+ fail = true;
+
+#ifdef EDQUOT
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EDQUOT not defined");
+
+ fail = true;
+
+#ifdef EEXIST
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EEXIST not defined");
+
+ fail = true;
+
+#ifdef EFAULT
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EFAULT not defined");
+
+ fail = true;
+
+#ifdef EFBIG
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EFBIG not defined");
+
+ fail = true;
+
+#ifdef EHOSTUNREACH
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EHOSTUNREACH not defined");
+
+ fail = true;
+
+#ifdef EIDRM
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EIDRM not defined");
+
+ fail = true;
+
+#ifdef EILSEQ
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EILSEQ not defined");
+
+ fail = true;
+
+#ifdef EINPROGRESS
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EINPROGRESS not defined");
+
+ fail = true;
+
+#ifdef EINTR
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EINTR not defined");
+
+ fail = true;
+
+#ifdef EINVAL
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EINVAL not defined");
+
+ fail = true;
+
+#ifdef EIO
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EIO not defined");
+
+ fail = true;
+
+#ifdef EISCONN
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EISCONN not defined");
+
+ fail = true;
+
+#ifdef EISDIR
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EISDIR not defined");
+
+ fail = true;
+
+#ifdef ELOOP
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ELOOP not defined");
+
+ fail = true;
+
+#ifdef EMFILE
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EMFILE not defined");
+
+ fail = true;
+
+#ifdef EMLINK
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EMLINK not defined");
+
+ fail = true;
+
+#ifdef EMSGSIZE
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EMSGSIZE not defined");
+
+ fail = true;
+
+#ifdef EMULTIHOP
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EMULTIHOP not defined");
+
+ fail = true;
+
+#ifdef ENAMETOOLONG
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENAMETOOLONG not defined");
+
+ fail = true;
+
+#ifdef ENETDOWN
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENETDOWN not defined");
+
+ fail = true;
+
+#ifdef ENETRESET
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENETRESET not defined");
+
+ fail = true;
+
+#ifdef ENETUNREACH
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENETUNREACH not defined");
+
+ fail = true;
+
+#ifdef ENFILE
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENFILE not defined");
+
+ fail = true;
+
+#ifdef ENOBUFS
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOBUFS not defined");
+
+ fail = true;
+
+#ifdef ENODATA
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENODATA not defined");
+
+ fail = true;
+
+#ifdef ENODEV
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENODEV not defined");
+
+ fail = true;
+
+#ifdef ENOENT
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOENT not defined");
+
+ fail = true;
+
+#ifdef ENOEXEC
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOEXEC not defined");
+
+ fail = true;
+
+#ifdef ENOLCK
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOLCK not defined");
+
+ fail = true;
+
+#ifdef ENOLINK
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOLINK not defined");
+
+ fail = true;
+
+#ifdef ENOMEM
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOMEM not defined");
+
+ fail = true;
+
+#ifdef ENOMSG
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOMSG not defined");
+
+ fail = true;
+
+#ifdef ENOPROTOOPT
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOPROTOOPT not defined");
+
+ fail = true;
+
+#ifdef ENOSPC
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOSPC not defined");
+
+ fail = true;
+
+#ifdef ENOSR
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOSR not defined");
+
+ fail = true;
+
+#ifdef ENOSTR
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOSTR not defined");
+
+ fail = true;
+
+#ifdef ENOSYS
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOSYS not defined");
+
+ fail = true;
+
+#ifdef ENOTCONN
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOTCONN not defined");
+
+ fail = true;
+
+#ifdef ENOTDIR
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOTDIR not defined");
+
+ fail = true;
+
+#ifdef ENOTEMPTY
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOTEMPTY not defined");
+
+ fail = true;
+
+#ifdef ENOTRECOVERABLE
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOTRECOVERABLE not defined");
+
+ fail = true;
+
+#ifdef ENOTSOCK
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOTSOCK not defined");
+
+ fail = true;
+
+#ifdef ENOTSUP
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOTSUP not defined");
+
+ fail = true;
+
+#ifdef ENOTTY
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENOTTY not defined");
+
+ fail = true;
+
+#ifdef ENXIO
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ENXIO not defined");
+
+ fail = true;
+
+#ifdef EOPNOTSUPP
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EOPNOTSUPP not defined");
+
+ fail = true;
+
+#ifdef EOVERFLOW
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EOVERFLOW not defined");
+
+ fail = true;
+
+#ifdef EOWNERDEAD
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EOWNERDEAD not defined");
+
+ fail = true;
+
+#ifdef EPERM
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EPERM not defined");
+
+ fail = true;
+
+#ifdef EPIPE
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EPIPE not defined");
+
+ fail = true;
+
+#ifdef EPROTO
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EPROTO not defined");
+
+ fail = true;
+
+#ifdef EPROTONOSUPPORT
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EPROTONOSUPPORT not defined");
+
+ fail = true;
+
+#ifdef EPROTOTYPE
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EPROTOTYPE not defined");
+
+ fail = true;
+
+#ifdef ERANGE
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ERANGE not defined");
+
+ fail = true;
+
+#ifdef EROFS
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EROFS not defined");
+
+ fail = true;
+
+#ifdef ESPIPE
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ESPIPE not defined");
+
+ fail = true;
+
+#ifdef ESRCH
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ESRCH not defined");
+
+ fail = true;
+
+#ifdef ESTALE
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ESTALE not defined");
+
+ fail = true;
+
+#ifdef ETIME
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ETIME not defined");
+
+ fail = true;
+
+#ifdef ETIMEDOUT
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ETIMEDOUT not defined");
+
+ fail = true;
+
+#ifdef ETXTBSY
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("ETXTBSY not defined");
+
+ fail = true;
+
+#ifdef EWOULDBLOCK
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EWOULDBLOCK not defined");
+
+ fail = true;
+
+#ifdef EXDEV
+ fail = false;
+#endif
+
+ if (fail != false)
+ atf_tc_fail_nonfatal("EXDEV not defined");
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, errno_constants);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/t_glob.c b/contrib/netbsd-tests/include/t_glob.c
new file mode 100644
index 000000000000..da6a4ad5747e
--- /dev/null
+++ b/contrib/netbsd-tests/include/t_glob.c
@@ -0,0 +1,75 @@
+/* $NetBSD: t_glob.c,v 1.1 2011/04/10 08:35:48 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_glob.c,v 1.1 2011/04/10 08:35:48 jruoho Exp $");
+
+#include <atf-c.h>
+#include <glob.h>
+#include <string.h>
+
+ATF_TC(glob_types);
+ATF_TC_HEAD(glob_types, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test glob(3) types");
+}
+
+ATF_TC_BODY(glob_types, tc)
+{
+ glob_t g;
+
+ /*
+ * IEEE Std 1003.1-2008:
+ *
+ * "The <glob.h> header shall define the glob_t structure type,
+ * which shall include at least the following members:
+ *
+ * size_t gl_pathc Count of paths matched by pattern.
+ * char **gl_pathv Pointer to a list of matched pathnames.
+ * size_t gl_offs Slots to reserve at the beginning of gl_pathv."
+ *
+ * Verify that gl_pathc and gl_offs are unsigned; PR standards/21401.
+ */
+ (void)memset(&g, 0, sizeof(glob_t));
+
+ g.gl_offs = g.gl_offs - 1;
+ g.gl_pathc = g.gl_pathc - 1;
+
+ ATF_REQUIRE(g.gl_pathc > 0);
+ ATF_REQUIRE(g.gl_offs > 0);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, glob_types);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/t_inttypes.c b/contrib/netbsd-tests/include/t_inttypes.c
new file mode 100644
index 000000000000..d713615ea0db
--- /dev/null
+++ b/contrib/netbsd-tests/include/t_inttypes.c
@@ -0,0 +1,250 @@
+/* $NetBSD: t_inttypes.c,v 1.3 2013/10/19 17:44:37 christos Exp $ */
+
+/*-
+ * Copyright (c) 2001 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 <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <atf-c.h>
+
+ATF_TC_WITHOUT_HEAD(int_fmtio);
+ATF_TC_BODY(int_fmtio, tc)
+{
+ char buf[64];
+
+ int8_t i8 = 0;
+ int16_t i16 = 0;
+ int32_t i32 = 0;
+ int64_t i64 = 0;
+ int_least8_t il8 = 0;
+ int_least16_t il16 = 0;
+ int_least32_t il32 = 0;
+ int_least64_t il64 = 0;
+ int_fast8_t if8 = 0;
+ int_fast16_t if16 = 0;
+ int_fast32_t if32 = 0;
+ int_fast64_t if64 = 0;
+ intmax_t im = 0;
+ intptr_t ip = 0;
+ uint8_t ui8 = 0;
+ uint16_t ui16 = 0;
+ uint32_t ui32 = 0;
+ uint64_t ui64 = 0;
+ uint_least8_t uil8 = 0;
+ uint_least16_t uil16 = 0;
+ uint_least32_t uil32 = 0;
+ uint_least64_t uil64 = 0;
+ uint_fast8_t uif8 = 0;
+ uint_fast16_t uif16 = 0;
+ uint_fast32_t uif32 = 0;
+ uint_fast64_t uif64 = 0;
+ uintmax_t uim = 0;
+ uintptr_t uip = 0;
+
+#define PRINT(fmt, var) \
+ snprintf(buf, sizeof(buf), "%" fmt, var)
+#define SCAN(fmt, var) \
+ sscanf(buf, "%" fmt, &var)
+
+ PRINT(PRId8, i8);
+ PRINT(PRId16, i16);
+ PRINT(PRId32, i32);
+ PRINT(PRId64, i64);
+ PRINT(PRIdLEAST8, il8);
+ PRINT(PRIdLEAST16, il16);
+ PRINT(PRIdLEAST32, il32);
+ PRINT(PRIdLEAST64, il64);
+ PRINT(PRIdFAST8, if8);
+ PRINT(PRIdFAST16, if16);
+ PRINT(PRIdFAST32, if32);
+ PRINT(PRIdFAST64, if64);
+ PRINT(PRIdMAX, im);
+ PRINT(PRIdPTR, ip);
+
+ PRINT(PRIi8, i8);
+ PRINT(PRIi16, i16);
+ PRINT(PRIi32, i32);
+ PRINT(PRIi64, i64);
+ PRINT(PRIiLEAST8, il8);
+ PRINT(PRIiLEAST16, il16);
+ PRINT(PRIiLEAST32, il32);
+ PRINT(PRIiLEAST64, il64);
+ PRINT(PRIiFAST8, if8);
+ PRINT(PRIiFAST16, if16);
+ PRINT(PRIiFAST32, if32);
+ PRINT(PRIiFAST64, if64);
+ PRINT(PRIiMAX, im);
+ PRINT(PRIiPTR, ip);
+
+ PRINT(PRIo8, ui8);
+ PRINT(PRIo16, ui16);
+ PRINT(PRIo32, ui32);
+ PRINT(PRIo64, ui64);
+ PRINT(PRIoLEAST8, uil8);
+ PRINT(PRIoLEAST16, uil16);
+ PRINT(PRIoLEAST32, uil32);
+ PRINT(PRIoLEAST64, uil64);
+ PRINT(PRIoFAST8, uif8);
+ PRINT(PRIoFAST16, uif16);
+ PRINT(PRIoFAST32, uif32);
+ PRINT(PRIoFAST64, uif64);
+ PRINT(PRIoMAX, uim);
+ PRINT(PRIoPTR, uip);
+
+ PRINT(PRIu8, ui8);
+ PRINT(PRIu16, ui16);
+ PRINT(PRIu32, ui32);
+ PRINT(PRIu64, ui64);
+ PRINT(PRIuLEAST8, uil8);
+ PRINT(PRIuLEAST16, uil16);
+ PRINT(PRIuLEAST32, uil32);
+ PRINT(PRIuLEAST64, uil64);
+ PRINT(PRIuFAST8, uif8);
+ PRINT(PRIuFAST16, uif16);
+ PRINT(PRIuFAST32, uif32);
+ PRINT(PRIuFAST64, uif64);
+ PRINT(PRIuMAX, uim);
+ PRINT(PRIuPTR, uip);
+
+ PRINT(PRIx8, ui8);
+ PRINT(PRIx16, ui16);
+ PRINT(PRIx32, ui32);
+ PRINT(PRIx64, ui64);
+ PRINT(PRIxLEAST8, uil8);
+ PRINT(PRIxLEAST16, uil16);
+ PRINT(PRIxLEAST32, uil32);
+ PRINT(PRIxLEAST64, uil64);
+ PRINT(PRIxFAST8, uif8);
+ PRINT(PRIxFAST16, uif16);
+ PRINT(PRIxFAST32, uif32);
+ PRINT(PRIxFAST64, uif64);
+ PRINT(PRIxMAX, uim);
+ PRINT(PRIxPTR, uip);
+
+ PRINT(PRIX8, ui8);
+ PRINT(PRIX16, ui16);
+ PRINT(PRIX32, ui32);
+ PRINT(PRIX64, ui64);
+ PRINT(PRIXLEAST8, uil8);
+ PRINT(PRIXLEAST16, uil16);
+ PRINT(PRIXLEAST32, uil32);
+ PRINT(PRIXLEAST64, uil64);
+ PRINT(PRIXFAST8, uif8);
+ PRINT(PRIXFAST16, uif16);
+ PRINT(PRIXFAST32, uif32);
+ PRINT(PRIXFAST64, uif64);
+ PRINT(PRIXMAX, uim);
+ PRINT(PRIXPTR, uip);
+
+
+ SCAN(SCNd8, i8);
+ SCAN(SCNd16, i16);
+ SCAN(SCNd32, i32);
+ SCAN(SCNd64, i64);
+ SCAN(SCNdLEAST8, il8);
+ SCAN(SCNdLEAST16, il16);
+ SCAN(SCNdLEAST32, il32);
+ SCAN(SCNdLEAST64, il64);
+ SCAN(SCNdFAST8, if8);
+ SCAN(SCNdFAST16, if16);
+ SCAN(SCNdFAST32, if32);
+ SCAN(SCNdFAST64, if64);
+ SCAN(SCNdMAX, im);
+ SCAN(SCNdPTR, ip);
+
+ SCAN(SCNi8, i8);
+ SCAN(SCNi16, i16);
+ SCAN(SCNi32, i32);
+ SCAN(SCNi64, i64);
+ SCAN(SCNiLEAST8, il8);
+ SCAN(SCNiLEAST16, il16);
+ SCAN(SCNiLEAST32, il32);
+ SCAN(SCNiLEAST64, il64);
+ SCAN(SCNiFAST8, if8);
+ SCAN(SCNiFAST16, if16);
+ SCAN(SCNiFAST32, if32);
+ SCAN(SCNiFAST64, if64);
+ SCAN(SCNiMAX, im);
+ SCAN(SCNiPTR, ip);
+
+ SCAN(SCNo8, ui8);
+ SCAN(SCNo16, ui16);
+ SCAN(SCNo32, ui32);
+ SCAN(SCNo64, ui64);
+ SCAN(SCNoLEAST8, uil8);
+ SCAN(SCNoLEAST16, uil16);
+ SCAN(SCNoLEAST32, uil32);
+ SCAN(SCNoLEAST64, uil64);
+ SCAN(SCNoFAST8, uif8);
+ SCAN(SCNoFAST16, uif16);
+ SCAN(SCNoFAST32, uif32);
+ SCAN(SCNoFAST64, uif64);
+ SCAN(SCNoMAX, uim);
+ SCAN(SCNoPTR, uip);
+
+ SCAN(SCNu8, ui8);
+ SCAN(SCNu16, ui16);
+ SCAN(SCNu32, ui32);
+ SCAN(SCNu64, ui64);
+ SCAN(SCNuLEAST8, uil8);
+ SCAN(SCNuLEAST16, uil16);
+ SCAN(SCNuLEAST32, uil32);
+ SCAN(SCNuLEAST64, uil64);
+ SCAN(SCNuFAST8, uif8);
+ SCAN(SCNuFAST16, uif16);
+ SCAN(SCNuFAST32, uif32);
+ SCAN(SCNuFAST64, uif64);
+ SCAN(SCNuMAX, uim);
+ SCAN(SCNuPTR, uip);
+
+ SCAN(SCNx8, ui8);
+ SCAN(SCNx16, ui16);
+ SCAN(SCNx32, ui32);
+ SCAN(SCNx64, ui64);
+ SCAN(SCNxLEAST8, uil8);
+ SCAN(SCNxLEAST16, uil16);
+ SCAN(SCNxLEAST32, uil32);
+ SCAN(SCNxLEAST64, uil64);
+ SCAN(SCNxFAST8, uif8);
+ SCAN(SCNxFAST16, uif16);
+ SCAN(SCNxFAST32, uif32);
+ SCAN(SCNxFAST64, uif64);
+ SCAN(SCNxMAX, uim);
+ SCAN(SCNxPTR, uip);
+
+#undef SCAN
+#undef PRINT
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, int_fmtio);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/t_limits.c b/contrib/netbsd-tests/include/t_limits.c
new file mode 100644
index 000000000000..625750a133de
--- /dev/null
+++ b/contrib/netbsd-tests/include/t_limits.c
@@ -0,0 +1,287 @@
+/* $NetBSD: t_limits.c,v 1.2 2011/04/04 18:02:01 jruoho Exp $ */
+
+/*
+ * Copyright (c) 2008, 2010 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.
+ */
+
+/*
+ * Copyright (c) 2009, Stathis Kamperis
+ * 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 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 HOLDERS 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) 2008, 2010\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_limits.c,v 1.2 2011/04/04 18:02:01 jruoho Exp $");
+
+#include <limits.h>
+
+#include <atf-c.h>
+
+struct psxentry {
+ const char *psx_desc;
+ int psx_constant;
+ int psx_minval;
+} psxtable[] = {
+
+ /*
+ * POSIX symbolic constants.
+ */
+#ifdef _POSIX_AIO_LISTIO_MAX
+ { "_POSIX_AIO_LISTIO_MAX", _POSIX_AIO_LISTIO_MAX, 2 },
+#endif
+#ifdef _POSIX_AIO_MAX
+ { "_POSIX_AIO_MAX", _POSIX_AIO_MAX, 1 },
+#endif
+#ifdef _POSIX_ARG_MAX
+ { "_POSIX_ARG_MAX", _POSIX_ARG_MAX, 4096 },
+#endif
+#ifdef _POSIX_CHILD_MAX
+ { "_POSIX_CHILD_MAX" , _POSIX_CHILD_MAX, 25 },
+#endif
+#ifdef _POSIX_DELAYTIMER_MAX
+ { "_POSIX_DELAYTIMER_MAX", _POSIX_DELAYTIMER_MAX, 32 },
+#endif
+#ifdef _POSIX_HOST_NAME_MAX
+ { "_POSIX_HOST_NAME_MAX", _POSIX_HOST_NAME_MAX, 255 },
+#endif
+#ifdef _POSIX_LINK_MAX
+ { "_POSIX_LINK_MAX", _POSIX_LINK_MAX, 8 },
+#endif
+#ifdef _POSIX_LOGIN_NAME_MAX
+ { "_POSIX_LOGIN_NAME_MAX", _POSIX_LOGIN_NAME_MAX, 9 },
+#endif
+#ifdef _POSIX_MAX_CANON
+ { "_POSIX_MAX_CANON", _POSIX_MAX_CANON, 255 },
+#endif
+#ifdef _POSIX_MAX_INPUT
+ { "_POSIX_MAX_INPUT", _POSIX_MAX_INPUT, 255 },
+#endif
+#ifdef _POSIX_MQ_OPEN_MAX
+ { "_POSIX_MQ_OPEN_MAX", _POSIX_MQ_OPEN_MAX, 8 },
+#endif
+#ifdef _POSIX_MQ_PRIO_MAX
+ { "_POSIX_MQ_PRIO_MAX", _POSIX_MQ_PRIO_MAX, 32 },
+#endif
+#ifdef _POSIX_NAME_MAX
+ { "_POSIX_NAME_MAX", _POSIX_NAME_MAX, 9 },
+#endif
+#ifdef _POSIX_NGROUPS_MAX
+ { "_POSIX_NGROUPS_MAX", _POSIX_NGROUPS_MAX, 8 },
+#endif
+#ifdef _POSIX_OPEN_MAX
+ { "_POSIX_OPEN_MAX", _POSIX_OPEN_MAX, 20 },
+#endif
+#ifdef _POSIX_PATH_MAX
+ { "_POSIX_PATH_MAX", _POSIX_PATH_MAX, 256 },
+#endif
+#ifdef _POSIX_PIPE_BUF
+ { "_POSIX_PIPE_BUF", _POSIX_PIPE_BUF, 512 },
+#endif
+#ifdef _POSIX_RE_DUP_MAX
+ { "_POSIX_RE_DUP_MAX", _POSIX_RE_DUP_MAX, 255 },
+#endif
+#ifdef _POSIX_RTSIG_MAX
+ { "_POSIX_RTSIG_MAX", _POSIX_RTSIG_MAX, 8 },
+#endif
+#ifdef _POSIX_SEM_NSEMS_MAX
+ { "_POSIX_SEM_NSEMS_MAX", _POSIX_SEM_NSEMS_MAX, 256 },
+#endif
+#ifdef _POSIX_SEM_VALUE_MAX
+ { "_POSIX_SEM_VALUE_MAX", _POSIX_SEM_VALUE_MAX, 32767},
+#endif
+#ifdef _POSIX_SIGQUEUE_MAX
+ { "_POSIX_SIGQUEUE_MAX", _POSIX_SIGQUEUE_MAX, 32 },
+#endif
+#ifdef _POSIX_SSIZE_MAX
+ { "_POSIX_SSIZE_MAX", _POSIX_SSIZE_MAX, 32767},
+#endif
+#ifdef _POSIX_STREAM_MAX
+ { "_POSIX_STREAM_MAX", _POSIX_STREAM_MAX, 8 },
+#endif
+#ifdef _POSIX_SS_REPL_MAX
+ { "_POSIX_SS_REPL_MAX", _POSIX_SS_REPL_MAX, 4 },
+#endif
+#ifdef _POSIX_SYMLINK_MAX
+ { "_POSIX_SYMLINK_MAX", _POSIX_SYMLINK_MAX, 255 },
+#endif
+#ifdef _POSIX_SYMLOOP_MAX
+ { "_POSIX_SYMLOOP_MAX", _POSIX_SYMLOOP_MAX, 8 },
+#endif
+#ifdef _POSIX_THREAD_DESTRUCTOR_ITERATIONS
+ { "_POSIX_THREAD_DESTRUCTOR_ITERATIONS",
+ _POSIX_THREAD_DESTRUCTOR_ITERATIONS, 4 },
+#endif
+#ifdef _POSIX_THREAD_KEYS_MAX
+ { "_POSIX_THREAD_KEYS_MAX", _POSIX_THREAD_KEYS_MAX, 128 },
+#endif
+#ifdef _POSIX_THREAD_THREADS_MAX
+ { "_POSIX_THREAD_THREADS_MAX", _POSIX_THREAD_THREADS_MAX, 64 },
+#endif
+#ifdef _POSIX_TIMER_MAX
+ { "_POSIX_TIMER_MAX", _POSIX_TIMER_MAX, 32 },
+#endif
+#ifdef _POSIX_TRACE_EVENT_NAME_MAX
+ { "_POSIX_TRACE_EVENT_NAME_MAX",_POSIX_TRACE_EVENT_NAME_MAX, 30 },
+#endif
+#ifdef _POSIX_TRACE_NAME_MAX
+ { "_POSIX_TRACE_NAME_MAX", _POSIX_TRACE_NAME_MAX, 8 },
+#endif
+#ifdef _POSIX_TRACE_SYS_MAX
+ { "_POSIX_TRACE_SYS_MAX", _POSIX_TRACE_SYS_MAX, 8 },
+#endif
+#ifdef _POSIX_TRACE_USER_EVENT_MAX
+ { "_POSIX_TRACE_USER_EVENT_MAX",_POSIX_TRACE_USER_EVENT_MAX, 32 },
+#endif
+#ifdef _POSIX_TTY_NAME_MAX
+ { "_POSIX_TTY_NAME_MAX", _POSIX_TTY_NAME_MAX, 9 },
+#endif
+#ifdef _POSIX_TZNAME_MAX
+ { "_POSIX_TZNAME_MAX", _POSIX_TZNAME_MAX, 6 },
+#endif
+#ifdef _POSIX2_BC_BASE_MAX
+ { "_POSIX2_BC_BASE_MAX", _POSIX2_BC_BASE_MAX, 99 },
+#endif
+#ifdef _POSIX2_BC_DIM_MAX
+ { "_POSIX2_BC_DIM_MAX", _POSIX2_BC_DIM_MAX, 2048 },
+#endif
+#ifdef _POSIX2_BC_SCALE_MAX
+ { "_POSIX2_BC_SCALE_MAX", _POSIX2_BC_SCALE_MAX, 99 },
+#endif
+#ifdef _POSIX2_BC_STRING_MAX
+ { "_POSIX2_BC_STRING_MAX", _POSIX2_BC_STRING_MAX, 1000 },
+#endif
+#ifdef _POSIX2_CHARCLASS_NAME_MAX
+ { "_POSIX2_CHARCLASS_NAME_MAX", _POSIX2_CHARCLASS_NAME_MAX, 14 },
+#endif
+#ifdef _POSIX2_COLL_WEIGHTS_MAX
+ { "_POSIX2_COLL_WEIGHTS_MAX", _POSIX2_COLL_WEIGHTS_MAX, 2 },
+#endif
+#ifdef _POSIX2_EXPR_NEST_MAX
+ { "_POSIX2_EXPR_NEST_MAX", _POSIX2_EXPR_NEST_MAX, 32 },
+#endif
+#ifdef _POSIX2_LINE_MAX
+ { "_POSIX2_LINE_MAX", _POSIX2_LINE_MAX, 2048 },
+#endif
+#ifdef _POSIX2_RE_DUP_MAX
+ { "_POSIX2_RE_DUP_MAX", _POSIX2_RE_DUP_MAX, 255 },
+#endif
+#ifdef _XOPEN_IOV_MAX
+ { "_XOPEN_IOV_MAX", _XOPEN_IOV_MAX, 16 },
+#endif
+#ifdef _XOPEN_NAME_MAX
+ { "_XOPEN_NAME_MAX", _XOPEN_NAME_MAX, 255 },
+#endif
+#ifdef _XOPEN_PATH_MAX
+ { "_XOPEN_PATH_MAX", _XOPEN_PATH_MAX, 1024 },
+#endif
+
+ /*
+ * Other invariant values.
+ */
+#ifdef NL_ARGMAX
+ { "NL_ARGMAX", NL_ARGMAX, 9 },
+#endif
+#ifdef NL_LANGMAX
+ { "NL_LANGMAX", NL_LANGMAX, 14 },
+#endif
+#ifdef NL_MSGMAX
+ { "NL_MSGMAX", NL_MSGMAX, 32767},
+#endif
+#ifdef NL_SETMAX
+ { "NL_SETMAX", NL_SETMAX, 255 },
+#endif
+#ifdef NL_TEXTMAX
+#ifdef _POSIX2_LINE_MAX
+ { "NL_TEXTMAX", NL_TEXTMAX, _POSIX2_LINE_MAX},
+#endif
+#endif
+#ifdef NZERO
+ { "NZERO", NZERO, 20 },
+#endif
+};
+
+ATF_TC_WITHOUT_HEAD(char);
+ATF_TC_BODY(char, tc)
+{
+ ATF_CHECK(CHAR_MIN < UCHAR_MAX);
+}
+
+ATF_TC(posix);
+ATF_TC_HEAD(posix, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test POSIX limits");
+}
+
+ATF_TC_BODY(posix, tc)
+{
+ size_t i;
+
+ for (i = 0; i < __arraycount(psxtable); i++) {
+
+ if (psxtable[i].psx_constant < psxtable[i].psx_minval) {
+
+ atf_tc_fail("%s is less than the minimum",
+ psxtable[i].psx_desc);
+ }
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(short);
+ATF_TC_BODY(short, tc)
+{
+ ATF_CHECK(SHRT_MIN < USHRT_MAX);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, char);
+ ATF_TP_ADD_TC(tp, posix);
+ ATF_TP_ADD_TC(tp, short);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/t_netdb.c b/contrib/netbsd-tests/include/t_netdb.c
new file mode 100644
index 000000000000..c7f946fb6c19
--- /dev/null
+++ b/contrib/netbsd-tests/include/t_netdb.c
@@ -0,0 +1,244 @@
+/* $NetBSD: t_netdb.c,v 1.2 2011/04/25 20:51:14 njoly Exp $ */
+
+/*-
+ * Copyright (c) 2011 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_netdb.c,v 1.2 2011/04/25 20:51:14 njoly Exp $");
+
+#include <atf-c.h>
+#include <netdb.h>
+
+ATF_TC(netdb_constants);
+ATF_TC_HEAD(netdb_constants, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "Test constants in <netdb.h>");
+}
+
+ATF_TC_BODY(netdb_constants, tc)
+{
+ bool fail;
+
+ /*
+ * The following definitions should be available
+ * according to IEEE Std 1003.1-2008, issue 7.
+ */
+ atf_tc_expect_fail("PR standards/44777");
+
+ fail = true;
+
+#ifdef AI_PASSIVE
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("AI_PASSIVE not defined");
+
+ fail = true;
+
+#ifdef AI_CANONNAME
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("AI_CANONNAME not defined");
+
+ fail = true;
+
+#ifdef AI_NUMERICHOST
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("AI_NUMERICHOST not defined");
+
+ fail = true;
+
+#ifdef AI_NUMERICSERV
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("AI_NUMERICSERV not defined");
+
+ fail = true;
+
+#ifdef AI_V4MAPPED
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("AI_V4MAPPED not defined");
+
+ fail = true;
+
+#ifdef AI_ALL
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("AI_ALL not defined");
+
+ fail = true;
+
+#ifdef AI_ADDRCONFIG
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("AI_ADDRCONFIG not defined");
+
+ fail = true;
+
+#ifdef NI_NOFQDN
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("NI_NOFQDN not defined");
+
+ fail = true;
+
+#ifdef NI_NUMERICHOST
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("NI_NUMERICHOST not defined");
+
+ fail = true;
+
+#ifdef NI_NAMEREQD
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("NI_NAMEREQD not defined");
+
+ fail = true;
+
+#ifdef NI_NUMERICSERV
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("NI_NUMERICSERV not defined");
+
+ fail = true;
+
+#ifdef NI_NUMERICSCOPE
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("NI_NUMERICSCOPE not defined");
+
+ fail = true;
+
+#ifdef NI_DGRAM
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("NI_DGRAM not defined");
+
+ fail = true;
+
+#ifdef EAI_AGAIN
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAI_AGAIN not defined");
+
+ fail = true;
+
+#ifdef EAI_BADFLAGS
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAI_BADFLAGS not defined");
+
+ fail = true;
+
+#ifdef EAI_FAIL
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAI_FAIL not defined");
+
+ fail = true;
+
+#ifdef EAI_FAMILY
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAI_FAMILY not defined");
+
+ fail = true;
+
+#ifdef EAI_MEMORY
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAI_MEMORY not defined");
+
+ fail = true;
+
+#ifdef EAI_NONAME
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAI_NONAME not defined");
+
+ fail = true;
+
+#ifdef EAI_SERVICE
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAI_SERVICE not defined");
+
+ fail = true;
+
+#ifdef EAI_SOCKTYPE
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAI_SOCKTYPE not defined");
+
+ fail = true;
+
+#ifdef EAI_SYSTEM
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAI_SYSTEM not defined");
+
+ fail = true;
+
+#ifdef EAI_OVERFLOW
+ fail = false;
+#endif
+ if (fail != false)
+ atf_tc_fail_nonfatal("EAI_OVERFLOW not defined");
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, netdb_constants);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/t_paths.c b/contrib/netbsd-tests/include/t_paths.c
new file mode 100644
index 000000000000..925bb3a8b740
--- /dev/null
+++ b/contrib/netbsd-tests/include/t_paths.c
@@ -0,0 +1,205 @@
+/* $NetBSD: t_paths.c,v 1.13 2014/02/09 21:26:07 jmmv Exp $ */
+
+/*-
+ * Copyright (c) 2011 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.
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_paths.c,v 1.13 2014/02/09 21:26:07 jmmv Exp $");
+
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include <errno.h>
+#include <fcntl.h>
+#include <paths.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+#include <atf-c/config.h>
+
+#define PATH_DEV __BIT(0) /* A device node */
+#define PATH_DIR __BIT(1) /* A directory */
+#define PATH_FILE __BIT(2) /* A file */
+#define PATH_ROOT __BIT(3) /* Access for root only */
+
+static const struct {
+ const char *path;
+ int flags;
+} paths[] = {
+ { _PATH_AUDIO, PATH_DEV },
+ { _PATH_AUDIO0, PATH_DEV },
+ { _PATH_AUDIOCTL, PATH_DEV },
+ { _PATH_AUDIOCTL0, PATH_DEV },
+ { _PATH_BPF, PATH_DEV | PATH_ROOT },
+ { _PATH_CLOCKCTL, PATH_DEV | PATH_ROOT },
+ { _PATH_CONSOLE, PATH_DEV | PATH_ROOT },
+ { _PATH_CONSTTY, PATH_DEV | PATH_ROOT },
+ { _PATH_CPUCTL, PATH_DEV },
+ { _PATH_CSMAPPER, PATH_DIR },
+ { _PATH_DEFTAPE, PATH_DEV | PATH_ROOT },
+ { _PATH_DEVCDB, PATH_FILE },
+ { _PATH_DEVDB, PATH_FILE },
+ { _PATH_DEVNULL, PATH_DEV },
+ { _PATH_DRUM, PATH_DEV | PATH_ROOT },
+ { _PATH_ESDB, PATH_DIR },
+ { _PATH_FTPUSERS, PATH_FILE },
+ { _PATH_GETTYTAB, PATH_FILE },
+ { _PATH_I18NMODULE, PATH_DIR },
+ { _PATH_ICONV, PATH_DIR },
+ { _PATH_KMEM, PATH_DEV | PATH_ROOT },
+ { _PATH_KSYMS, PATH_DEV },
+ { _PATH_KVMDB, PATH_FILE },
+ { _PATH_LOCALE, PATH_DIR },
+ { _PATH_MAILDIR, PATH_DIR },
+ { _PATH_MAN, PATH_DIR },
+ { _PATH_MEM, PATH_DEV | PATH_ROOT },
+ { _PATH_MIXER, PATH_DEV },
+ { _PATH_MIXER0, PATH_DEV },
+ { _PATH_NOLOGIN, PATH_FILE },
+ { _PATH_POWER, PATH_DEV | PATH_ROOT },
+ { _PATH_PRINTCAP, PATH_FILE },
+ { _PATH_PUD, PATH_DEV | PATH_ROOT },
+ { _PATH_PUFFS, PATH_DEV | PATH_ROOT },
+ { _PATH_RANDOM, PATH_DEV },
+ { _PATH_SENDMAIL, PATH_FILE },
+ { _PATH_SHELLS, PATH_FILE },
+ { _PATH_SKEYKEYS, PATH_FILE | PATH_ROOT },
+ { _PATH_SOUND, PATH_DEV },
+ { _PATH_SOUND0, PATH_DEV },
+ { _PATH_SYSMON, PATH_DEV },
+ { _PATH_TTY, PATH_DEV },
+ { _PATH_UNIX, PATH_FILE | PATH_ROOT },
+ { _PATH_URANDOM, PATH_DEV },
+ { _PATH_VIDEO, PATH_DEV },
+ { _PATH_VIDEO0, PATH_DEV },
+
+ { _PATH_DEV, PATH_DIR },
+ { _PATH_DEV_PTS, PATH_DIR },
+ { _PATH_EMUL_AOUT, PATH_DIR },
+ { _PATH_TMP, PATH_DIR },
+ { _PATH_VARDB, PATH_DIR },
+ { _PATH_VARRUN, PATH_DIR },
+ { _PATH_VARTMP, PATH_DIR },
+
+ { _PATH_BSHELL, PATH_FILE },
+ { _PATH_CSHELL, PATH_FILE },
+ { _PATH_VI, PATH_FILE },
+};
+
+ATF_TC(paths);
+ATF_TC_HEAD(paths, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "A basic test for <paths.h>");
+}
+
+ATF_TC_BODY(paths, tc)
+{
+ struct stat st;
+ uid_t uid;
+ mode_t m;
+ size_t i;
+ int fd;
+
+#if defined(__sparc__)
+ atf_tc_skip("PR port-sparc/45580");
+#endif
+
+ uid = getuid();
+
+ for (i = 0; i < __arraycount(paths); i++) {
+
+ (void)fprintf(stderr, "testing '%s'\n", paths[i].path);
+
+ errno = 0;
+ fd = open(paths[i].path, O_RDONLY);
+
+ if (fd < 0) {
+
+ switch (errno) {
+
+ case EPERM: /* FALLTHROUGH */
+ case EACCES: /* FALLTHROUGH */
+
+ if ((paths[i].flags & PATH_ROOT) == 0) {
+
+ atf_tc_fail("UID %u failed to open %s",
+ (uint32_t)uid, paths[i].path);
+ }
+
+ case EBUSY: /* FALLTHROUGH */
+ case ENXIO: /* FALLTHROUGH */
+ case ENOENT: /* FALLTHROUGH */
+
+ default:
+ continue;
+ }
+ }
+
+ (void)memset(&st, 0, sizeof(struct stat));
+
+ ATF_REQUIRE(fstat(fd, &st) == 0);
+
+ m = st.st_mode;
+
+ if ((paths[i].flags & PATH_DEV) != 0) {
+
+ ATF_CHECK(S_ISBLK(m) != 0 || S_ISCHR(m) != 0);
+
+ ATF_CHECK((paths[i].flags & PATH_DIR) == 0);
+ ATF_CHECK((paths[i].flags & PATH_FILE) == 0);
+ }
+
+ if ((paths[i].flags & PATH_DIR) != 0) {
+
+ ATF_CHECK(S_ISDIR(m) != 0);
+
+ ATF_CHECK((paths[i].flags & PATH_DEV) == 0);
+ ATF_CHECK((paths[i].flags & PATH_FILE) == 0);
+ }
+
+ if ((paths[i].flags & PATH_FILE) != 0) {
+
+ ATF_CHECK(S_ISREG(m) != 0);
+
+ ATF_CHECK((paths[i].flags & PATH_DEV) == 0);
+ ATF_CHECK((paths[i].flags & PATH_DIR) == 0);
+ }
+
+ ATF_REQUIRE(close(fd) == 0);
+ }
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, paths);
+
+ return atf_no_error();
+}
diff --git a/contrib/netbsd-tests/include/t_stdint.c b/contrib/netbsd-tests/include/t_stdint.c
new file mode 100644
index 000000000000..6a57d9a8e3ff
--- /dev/null
+++ b/contrib/netbsd-tests/include/t_stdint.c
@@ -0,0 +1,57 @@
+/* $NetBSD: t_stdint.c,v 1.1 2010/07/17 19:26:27 jmmv Exp $ */
+
+/*
+ * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008, 2010\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_stdint.c,v 1.1 2010/07/17 19:26:27 jmmv Exp $");
+
+#include <stdint.h>
+
+#include <atf-c.h>
+
+ATF_TC_WITHOUT_HEAD(int8);
+ATF_TC_BODY(int8, tc)
+{
+ ATF_CHECK(INT8_MIN < UINT8_MAX);
+}
+
+ATF_TC_WITHOUT_HEAD(int16);
+ATF_TC_BODY(int16, tc)
+{
+ ATF_CHECK(INT16_MIN < UINT16_MAX);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, int8);
+ ATF_TP_ADD_TC(tp, int16);
+
+ return atf_no_error();
+}