Wed Nov 3 16:10:26 2010 UTC ()
add Makefile.inc everywhere so that we can set WARNS=4 by default. Amazing
how many bugs this found :-)


(christos)
diff -r0 -r1.1 src/tests/Makefile.inc
diff -r0 -r1.1 src/tests/crypto/Makefile.inc
diff -r1.3 -r1.4 src/tests/crypto/libcrypto/Makefile.inc
diff -r0 -r1.1 src/tests/dev/Makefile.inc
diff -r0 -r1.1 src/tests/fs/Makefile.inc
diff -r0 -r1.1 src/tests/include/Makefile.inc
diff -r1.1 -r1.2 src/tests/include/t_bitstring.c
diff -r0 -r1.1 src/tests/kernel/Makefile.inc
diff -r1.1 -r1.2 src/tests/kernel/t_extent.c
diff -r1.3 -r1.4 src/tests/kernel/t_filedesc.c
diff -r0 -r1.1 src/tests/kernel/kqueue/Makefile.inc
diff -r1.1 -r1.2 src/tests/kernel/kqueue/t_sig.c
diff -r1.2 -r1.3 src/tests/kernel/tty/t_pr.c
diff -r0 -r1.1 src/tests/lib/Makefile.inc
diff -r0 -r1.1 src/tests/lib/csu/Makefile.inc
diff -r1.6 -r1.7 src/tests/lib/libc/Makefile
diff -r0 -r1.1 src/tests/lib/libc/Makefile.inc
diff -r1.5 -r1.6 src/tests/lib/libc/gen/t_glob_star.c
diff -r1.1 -r1.2 src/tests/lib/libc/hash/t_sha2.c
diff -r1.1 -r1.2 src/tests/lib/libc/stdio/t_fmemopen.c
diff -r1.1 -r1.2 src/tests/lib/libprop/t_basic.c
diff -r1.1 -r1.2 src/tests/lib/libpthread/h_resolv.c
diff -r1.1 -r1.2 src/tests/lib/libpthread/t_barrier.c
diff -r1.1 -r1.2 src/tests/lib/libpthread/t_cond.c
diff -r1.1 -r1.2 src/tests/lib/libpthread/t_preempt.c
diff -r1.1 -r1.2 src/tests/lib/libpthread/t_sigmask.c
diff -r1.1 -r1.2 src/tests/lib/libpthread/t_status.c
diff -r1.4 -r1.5 src/tests/lib/libpthread/t_sem.c
diff -r0 -r1.1 src/tests/lib/semaphore/Makefile.inc
diff -r0 -r1.1 src/tests/libexec/Makefile.inc
diff -r1.1 -r1.2 src/tests/libexec/ld.elf_so/t_dlinfo.c
diff -r0 -r1.1 src/tests/modules/Makefile.inc
diff -r1.1 -r1.2 src/tests/modules/t_builtin.c
diff -r1.4 -r1.5 src/tests/modules/t_modctl.c
diff -r1.4 -r1.5 src/tests/modules/k_helper/k_helper.c
diff -r1.1 -r1.2 src/tests/modules/k_helper2/k_helper2.c
diff -r0 -r1.1 src/tests/net/Makefile.inc
diff -r1.2 -r1.3 src/tests/net/bpf/t_div-by-zero.c
diff -r1.2 -r1.3 src/tests/net/carp/t_basic.c
diff -r1.5 -r1.6 src/tests/net/icmp/t_forward.c
diff -r1.8 -r1.9 src/tests/net/icmp/t_ping.c
diff -r1.2 -r1.3 src/tests/net/if_loop/t_pr.c
diff -r1.3 -r1.4 src/tests/net/sys/t_connect.c
diff -r1.1 -r1.2 src/tests/net/sys/t_listen.c
diff -r0 -r1.1 src/tests/rump/Makefile.inc
diff -r0 -r1.1 src/tests/util/Makefile.inc
diff -r1.3 -r1.4 src/tests/util/df/getmntinfo.c
diff -r1.2 -r1.3 src/tests/util/id/pwgr.c

File Added: src/tests/Makefile.inc
# $NetBSD: Makefile.inc,v 1.1 2010/11/03 16:10:19 christos Exp $
WARNS ?= 4

File Added: src/tests/crypto/Makefile.inc
.include "../Makefile.inc"

cvs diff -r1.3 -r1.4 src/tests/crypto/libcrypto/Makefile.inc (expand / switch to unified diff)

--- src/tests/crypto/libcrypto/Makefile.inc 2010/07/13 21:13:21 1.3
+++ src/tests/crypto/libcrypto/Makefile.inc 2010/11/03 16:10:19 1.4
@@ -1,17 +1,18 @@ @@ -1,17 +1,18 @@
1# $NetBSD: Makefile.inc,v 1.3 2010/07/13 21:13:21 jmmv Exp $ 1# $NetBSD: Makefile.inc,v 1.4 2010/11/03 16:10:19 christos Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4# Not yet
 5# .include "../Makefile.inc"
5TESTSDIR= ${TESTSBASE}/crypto/libcrypto 6TESTSDIR= ${TESTSBASE}/crypto/libcrypto
6ATFFILE= no 7ATFFILE= no
7 8
8.if defined(HELPER_NAME) 9.if defined(HELPER_NAME)
9HELPER_SRCS?= ${HELPER_NAME}.c 10HELPER_SRCS?= ${HELPER_NAME}.c
10 11
11PROG= h_${HELPER_NAME} 12PROG= h_${HELPER_NAME}
12SRCS= ${HELPER_SRCS} 13SRCS= ${HELPER_SRCS}
13MAN= # empty 14MAN= # empty
14BINDIR= ${TESTSDIR} 15BINDIR= ${TESTSDIR}
15 16
16DPADD+= ${LIBCRYPTO} ${LIBCRYPT} 17DPADD+= ${LIBCRYPTO} ${LIBCRYPT}
17LDADD+= -lcrypto -lcrypt 18LDADD+= -lcrypto -lcrypt

File Added: src/tests/dev/Makefile.inc
.include "../Makefile.inc"

File Added: src/tests/fs/Makefile.inc
.include "../Makefile.inc"

File Added: src/tests/include/Makefile.inc
.include "../Makefile.inc"

cvs diff -r1.1 -r1.2 src/tests/include/t_bitstring.c (expand / switch to unified diff)

--- src/tests/include/t_bitstring.c 2010/07/17 19:26:27 1.1
+++ src/tests/include/t_bitstring.c 2010/11/03 16:10:20 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_bitstring.c,v 1.1 2010/07/17 19:26:27 jmmv Exp $ */ 1/* $NetBSD: t_bitstring.c,v 1.2 2010/11/03 16:10:20 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1993, 2008, 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 1993, 2008, 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -53,39 +53,38 @@ printbits(FILE *file, bitstr_t *b, int n @@ -53,39 +53,38 @@ printbits(FILE *file, bitstr_t *b, int n
53 53
54 (void) fprintf(file, "%3d %3d ", jc, js); 54 (void) fprintf(file, "%3d %3d ", jc, js);
55 55
56 for (i=0; i < n; i++) { 56 for (i=0; i < n; i++) {
57 (void) fprintf(file, "%c", (bit_test(b, i) ? '1' : '0')); 57 (void) fprintf(file, "%c", (bit_test(b, i) ? '1' : '0'));
58 } 58 }
59 59
60 (void) fprintf(file, "%c", '\n'); 60 (void) fprintf(file, "%c", '\n');
61} 61}
62 62
63static void 63static void
64calculate_data(FILE *file, const int test_length) 64calculate_data(FILE *file, const int test_length)
65{ 65{
66 int b, i; 66 int i;
67 bitstr_t *bs; 67 bitstr_t *bs;
68 bitstr_t bit_decl(bss, 37); /* Mostly a random number. */ 
69 68
70 assert(test_length >= 4); 69 assert(test_length >= 4);
71 70
72 (void) fprintf(file, "Testing with TEST_LENGTH = %d\n\n", test_length); 71 (void) fprintf(file, "Testing with TEST_LENGTH = %d\n\n", test_length);
73 72
74 (void) fprintf(file, "test _bit_byte, _bit_mask, and bitstr_size\n"); 73 (void) fprintf(file, "test _bit_byte, _bit_mask, and bitstr_size\n");
75 (void) fprintf(file, " i _bit_byte(i) _bit_mask(i) bitstr_size(i)\n"); 74 (void) fprintf(file, " i _bit_byte(i) _bit_mask(i) bitstr_size(i)\n");
76 75
77 for (i=0; i < test_length; i++) { 76 for (i=0; i < test_length; i++) {
78 (void) fprintf(file, "%3d%15d%15d%15d\n", 77 (void) fprintf(file, "%3d%15u%15u%15zu\n",
79 i, _bit_byte(i), _bit_mask(i), bitstr_size(i)); 78 i, _bit_byte(i), _bit_mask(i), bitstr_size(i));
80 } 79 }
81 80
82 bs = bit_alloc(test_length); 81 bs = bit_alloc(test_length);
83 clearbits(bs, test_length); 82 clearbits(bs, test_length);
84 (void) fprintf(file, "\ntest bit_alloc, clearbits, bit_ffc, bit_ffs\n"); 83 (void) fprintf(file, "\ntest bit_alloc, clearbits, bit_ffc, bit_ffs\n");
85 (void) fprintf(file, "be: 0 -1 "); 84 (void) fprintf(file, "be: 0 -1 ");
86 for (i=0; i < test_length; i++) 85 for (i=0; i < test_length; i++)
87 (void) fprintf(file, "%c", '0'); 86 (void) fprintf(file, "%c", '0');
88 (void) fprintf(file, "\nis: "); 87 (void) fprintf(file, "\nis: ");
89 printbits(file, bs, test_length); 88 printbits(file, bs, test_length);
90 89
91 (void) fprintf(file, "\ntest bit_set\n"); 90 (void) fprintf(file, "\ntest bit_set\n");
@@ -195,27 +194,27 @@ calculate_data(FILE *file, const int tes @@ -195,27 +194,27 @@ calculate_data(FILE *file, const int tes
195 } 194 }
196 195
197 (void) fprintf(file, "\n"); 196 (void) fprintf(file, "\n");
198 (void) fprintf(file, "1 bit should move right 1 position each line\n"); 197 (void) fprintf(file, "1 bit should move right 1 position each line\n");
199 for (i=0; i < test_length; i++) { 198 for (i=0; i < test_length; i++) {
200 bit_nclear(bs, 0, test_length - 1); 199 bit_nclear(bs, 0, test_length - 1);
201 bit_nset(bs, i, i); 200 bit_nset(bs, i, i);
202 (void) fprintf(file, "%3d ", i); printbits(file, bs, test_length); 201 (void) fprintf(file, "%3d ", i); printbits(file, bs, test_length);
203 } 202 }
204 203
205 (void) free(bs); 204 (void) free(bs);
206} 205}
207 206
208void 207static void
209one_check(const atf_tc_t *tc, const int test_length) 208one_check(const atf_tc_t *tc, const int test_length)
210{ 209{
211 FILE *out; 210 FILE *out;
212 char command[1024]; 211 char command[1024];
213 212
214 ATF_REQUIRE((out = fopen("out", "w")) != NULL); 213 ATF_REQUIRE((out = fopen("out", "w")) != NULL);
215 calculate_data(out, test_length); 214 calculate_data(out, test_length);
216 fclose(out); 215 fclose(out);
217 216
218 /* XXX The following is a huge hack that was added to simplify the 217 /* XXX The following is a huge hack that was added to simplify the
219 * conversion of these tests from src/regress/ to src/tests/. The 218 * conversion of these tests from src/regress/ to src/tests/. The
220 * tests in this file should be checking their own results, without 219 * tests in this file should be checking their own results, without
221 * having to resort to external data files. */ 220 * having to resort to external data files. */

File Added: src/tests/kernel/Makefile.inc
.include "../Makefile.inc"

cvs diff -r1.1 -r1.2 src/tests/kernel/t_extent.c (expand / switch to unified diff)

--- src/tests/kernel/t_extent.c 2009/02/20 21:39:57 1.1
+++ src/tests/kernel/t_extent.c 2010/11/03 16:10:20 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_extent.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ 1/* $NetBSD: t_extent.c,v 1.2 2010/11/03 16:10:20 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__COPYRIGHT("@(#) Copyright (c) 2008\ 30__COPYRIGHT("@(#) Copyright (c) 2008\
31 The NetBSD Foundation, inc. All rights reserved."); 31 The NetBSD Foundation, inc. All rights reserved.");
32__RCSID("$NetBSD: t_extent.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); 32__RCSID("$NetBSD: t_extent.c,v 1.2 2010/11/03 16:10:20 christos Exp $");
33 33
34#include <sys/types.h> 34#include <sys/types.h>
35#include <sys/queue.h> 35#include <sys/queue.h>
36#include <sys/extent.h> 36#include <sys/extent.h>
37 37
38#include <stdio.h> 38#include <stdio.h>
39#include <stdlib.h> 39#include <stdlib.h>
40#include <string.h> 40#include <string.h>
41 41
42#include <atf-c.h> 42#include <atf-c.h>
43 43
44#include "../h_macros.h" 44#include "../h_macros.h"
45 45
@@ -72,27 +72,27 @@ h_alloc_subregion(u_long substart, u_lon @@ -72,27 +72,27 @@ h_alloc_subregion(u_long substart, u_lon
72 ret = extent_alloc_subregion1(ex, substart, subend, size, 72 ret = extent_alloc_subregion1(ex, substart, subend, size,
73 alignment, 0, boundary, 0, &result); 73 alignment, 0, boundary, 0, &result);
74 74
75 if (ret != expret) 75 if (ret != expret)
76 FAIL("%s", strerror(errno)); 76 FAIL("%s", strerror(errno));
77 77
78 if (expret == 0 && result != expres) 78 if (expret == 0 && result != expres)
79 FAIL("result should be: %#lx, got: %#lx", expres, result); 79 FAIL("result should be: %#lx, got: %#lx", expres, result);
80#undef FAIL 80#undef FAIL
81} 81}
82 82
83static void 83static void
84h_require(const char *name, u_long start, 84h_require(const char *name, u_long start,
85 u_long end, u_long flags, const char *exp) 85 u_long end, long flags, const char *exp)
86{ 86{
87 char buf[4096]; 87 char buf[4096];
88 struct extent_region *rp; 88 struct extent_region *rp;
89 int n = 0; 89 int n = 0;
90 90
91 ATF_REQUIRE_STREQ_MSG(ex->ex_name, name, 91 ATF_REQUIRE_STREQ_MSG(ex->ex_name, name,
92 "expected: \"%s\", got: \"%s\"", name, ex->ex_name); 92 "expected: \"%s\", got: \"%s\"", name, ex->ex_name);
93 ATF_REQUIRE_EQ_MSG(ex->ex_start, start, 93 ATF_REQUIRE_EQ_MSG(ex->ex_start, start,
94 "expected: %#lx, got: %#lx", start, ex->ex_start); 94 "expected: %#lx, got: %#lx", start, ex->ex_start);
95 ATF_REQUIRE_EQ_MSG(ex->ex_end, end, 95 ATF_REQUIRE_EQ_MSG(ex->ex_end, end,
96 "expected: %#lx, got: %#lx", end, ex->ex_end); 96 "expected: %#lx, got: %#lx", end, ex->ex_end);
97 ATF_REQUIRE_EQ_MSG(ex->ex_flags, flags, 97 ATF_REQUIRE_EQ_MSG(ex->ex_flags, flags,
98 "expected: %#lx, got: %#lx", flags, ex->ex_flags); 98 "expected: %#lx, got: %#lx", flags, ex->ex_flags);

cvs diff -r1.3 -r1.4 src/tests/kernel/t_filedesc.c (expand / switch to unified diff)

--- src/tests/kernel/t_filedesc.c 2010/08/04 14:28:28 1.3
+++ src/tests/kernel/t_filedesc.c 2010/11/03 16:10:20 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_filedesc.c,v 1.3 2010/08/04 14:28:28 pooka Exp $ */ 1/* $NetBSD: t_filedesc.c,v 1.4 2010/11/03 16:10:20 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,34 +17,35 @@ @@ -17,34 +17,35 @@
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__RCSID("$NetBSD: t_filedesc.c,v 1.3 2010/08/04 14:28:28 pooka Exp $"); 30__RCSID("$NetBSD: t_filedesc.c,v 1.4 2010/11/03 16:10:20 christos Exp $");
31 31
32#include <sys/types.h> 32#include <sys/types.h>
33 33
34#include <assert.h> 34#include <assert.h>
35#include <atf-c.h> 35#include <atf-c.h>
36#include <fcntl.h> 36#include <fcntl.h>
37#include <stdlib.h> 37#include <stdlib.h>
 38#include <pthread.h>
38 39
39#include <rump/rump.h> 40#include <rump/rump.h>
40#include <rump/rump_syscalls.h> 41#include <rump/rump_syscalls.h>
41 42
42#include "../h_macros.h" 43#include "../h_macros.h"
43 44
44ATF_TC(getfilerace); 45ATF_TC(getfilerace);
45ATF_TC_HEAD(getfilerace, tc) 46ATF_TC_HEAD(getfilerace, tc)
46{ 47{
47 48
48 atf_tc_set_md_var(tc, "descr", "race between multithreaded proc. " 49 atf_tc_set_md_var(tc, "descr", "race between multithreaded proc. "
49 "fd_getfile() and fd_close()"); 50 "fd_getfile() and fd_close()");
50 /* PR kern/43694 */ 51 /* PR kern/43694 */

File Added: src/tests/kernel/kqueue/Makefile.inc
.include "../Makefile.inc"

cvs diff -r1.1 -r1.2 src/tests/kernel/kqueue/t_sig.c (expand / switch to unified diff)

--- src/tests/kernel/kqueue/t_sig.c 2009/02/20 21:39:57 1.1
+++ src/tests/kernel/kqueue/t_sig.c 2010/11/03 16:10:20 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_sig.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $ */ 1/* $NetBSD: t_sig.c,v 1.2 2010/11/03 16:10:20 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Luke Mewburn and Jaromir Dolecek. 8 * by Luke Mewburn and Jaromir Dolecek.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__COPYRIGHT("@(#) Copyright (c) 2008\ 33__COPYRIGHT("@(#) Copyright (c) 2008\
34 The NetBSD Foundation, inc. All rights reserved."); 34 The NetBSD Foundation, inc. All rights reserved.");
35__RCSID("$NetBSD: t_sig.c,v 1.1 2009/02/20 21:39:57 jmmv Exp $"); 35__RCSID("$NetBSD: t_sig.c,v 1.2 2010/11/03 16:10:20 christos Exp $");
36 36
37#include <sys/event.h> 37#include <sys/event.h>
38#include <sys/ioctl.h> 38#include <sys/ioctl.h>
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/time.h> 40#include <sys/time.h>
41#include <sys/wait.h> 41#include <sys/wait.h>
42 42
43#include <inttypes.h> 43#include <inttypes.h>
44#include <signal.h> 44#include <signal.h>
45#include <stdio.h> 45#include <stdio.h>
46#include <stdlib.h> 46#include <stdlib.h>
47#include <unistd.h> 47#include <unistd.h>
48 48
@@ -101,28 +101,28 @@ ATF_TC_BODY(sig, tc) @@ -101,28 +101,28 @@ ATF_TC_BODY(sig, tc)
101 (void)sleep(1); 101 (void)sleep(1);
102 102
103 timeout.tv_sec = 1; 103 timeout.tv_sec = 1;
104 timeout.tv_nsec = 0; 104 timeout.tv_nsec = 0;
105 105
106 for (num = 0; num < NSIGNALS; num += n) { 106 for (num = 0; num < NSIGNALS; num += n) {
107 struct timeval then, now, diff; 107 struct timeval then, now, diff;
108 108
109 RL(gettimeofday(&then, NULL)); 109 RL(gettimeofday(&then, NULL));
110 RL(n = kevent(kq, NULL, 0, event, 1, &timeout)); 110 RL(n = kevent(kq, NULL, 0, event, 1, &timeout));
111 RL(gettimeofday(&now, NULL)); 111 RL(gettimeofday(&now, NULL));
112 timersub(&now, &then, &diff); 112 timersub(&now, &then, &diff);
113 113
114 (void)printf("sig: kevent returned %d in %ld.%06ld\n", 114 (void)printf("sig: kevent returned %d in %lld.%06ld\n",
115 n, diff.tv_sec, diff.tv_usec); 115 n, (long long)diff.tv_sec, (long)diff.tv_usec);
116 116
117 if (n == 0) 117 if (n == 0)
118 continue; 118 continue;
119 119
120 (void)printf("sig: kevent flags: 0x%x, data: %" PRId64 " (# " 120 (void)printf("sig: kevent flags: 0x%x, data: %" PRId64 " (# "
121 "times signal posted)\n", event[0].flags, event[0].data); 121 "times signal posted)\n", event[0].flags, event[0].data);
122 } 122 }
123 123
124 (void)waitpid(child, &status, 0); 124 (void)waitpid(child, &status, 0);
125 (void)printf("sig: finished successfully\n"); 125 (void)printf("sig: finished successfully\n");
126} 126}
127 127
128ATF_TP_ADD_TCS(tp) 128ATF_TP_ADD_TCS(tp)

cvs diff -r1.2 -r1.3 src/tests/kernel/tty/t_pr.c (expand / switch to unified diff)

--- src/tests/kernel/tty/t_pr.c 2010/07/03 08:18:30 1.2
+++ src/tests/kernel/tty/t_pr.c 2010/11/03 16:10:20 1.3
@@ -1,41 +1,40 @@ @@ -1,41 +1,40 @@
1/* $NetBSD: t_pr.c,v 1.2 2010/07/03 08:18:30 jmmv Exp $ */ 1/* $NetBSD: t_pr.c,v 1.3 2010/11/03 16:10:20 christos Exp $ */
2 2
3#include <sys/types.h> 3#include <sys/types.h>
4#include <sys/ioctl.h> 4#include <sys/ioctl.h>
5#include <sys/tty.h> 5#include <sys/tty.h>
6 6
7#include <atf-c.h> 7#include <atf-c.h>
8#include <fcntl.h> 8#include <fcntl.h>
9 9
10#include <rump/rump.h> 10#include <rump/rump.h>
11#include <rump/rump_syscalls.h> 11#include <rump/rump_syscalls.h>
12 12
13ATF_TC(ptyioctl); 13ATF_TC(ptyioctl);
14ATF_TC_HEAD(ptyioctl, tc) 14ATF_TC_HEAD(ptyioctl, tc)
15{ 15{
16 16
17 atf_tc_set_md_var(tc, "descr", "ioctl on pty"); 17 atf_tc_set_md_var(tc, "descr", "ioctl on pty");
18} 18}
19 19
20ATF_TC_BODY(ptyioctl, tc) 20ATF_TC_BODY(ptyioctl, tc)
21{ 21{
22 struct termios tio; 22 struct termios tio;
23 int fd; 23 int fd;
24 24
25 rump_init(); 25 rump_init();
26 fd = rump_sys_open("/dev/ptyp1", O_RDWR); 26 fd = rump_sys_open("/dev/ptyp1", O_RDWR);
27 if (fd == -1) 27 ATF_CHECK(fd != -1);
28 err(1, "open"); 
29 28
30 /* boom, dies with null deref under ptcwakeup() */ 29 /* boom, dies with null deref under ptcwakeup() */
31 atf_tc_expect_signal(-1, "PR kern/40688"); 30 atf_tc_expect_signal(-1, "PR kern/40688");
32 rump_sys_ioctl(fd, TIOCGETA, &tio); 31 rump_sys_ioctl(fd, TIOCGETA, &tio);
33} 32}
34 33
35ATF_TP_ADD_TCS(tp) 34ATF_TP_ADD_TCS(tp)
36{ 35{
37 36
38 ATF_TP_ADD_TC(tp, ptyioctl); 37 ATF_TP_ADD_TC(tp, ptyioctl);
39 38
40 return atf_no_error(); 39 return atf_no_error();
41} 40}

File Added: src/tests/lib/Makefile.inc
.include "../Makefile.inc"

File Added: src/tests/lib/csu/Makefile.inc
.include "../Makefile.inc"

cvs diff -r1.6 -r1.7 src/tests/lib/libc/Makefile (expand / switch to unified diff)

--- src/tests/lib/libc/Makefile 2010/09/09 22:25:38 1.6
+++ src/tests/lib/libc/Makefile 2010/11/03 16:10:21 1.7
@@ -1,12 +1,12 @@ @@ -1,12 +1,12 @@
1# $NetBSD: Makefile,v 1.6 2010/09/09 22:25:38 christos Exp $ 1# $NetBSD: Makefile,v 1.7 2010/11/03 16:10:21 christos Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
5TESTS_SUBDIRS+= gen hash stdlib 5TESTS_SUBDIRS+= gen hash stdlib stdio
6 6
7# Disabled for now, only test in there is very expensive 7# Disabled for now, only test in there is very expensive
8#SUBDIR+= string 8SUBDIR+= string
9 9
10TESTSDIR= ${TESTSBASE}/lib/libc 10TESTSDIR= ${TESTSBASE}/lib/libc
11 11
12.include <bsd.test.mk> 12.include <bsd.test.mk>

File Added: src/tests/lib/libc/Makefile.inc
.include "../Makefile.inc"

cvs diff -r1.5 -r1.6 src/tests/lib/libc/gen/Attic/t_glob_star.c (expand / switch to unified diff)

--- src/tests/lib/libc/gen/Attic/t_glob_star.c 2010/10/13 11:19:28 1.5
+++ src/tests/lib/libc/gen/Attic/t_glob_star.c 2010/11/03 16:10:21 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_glob_star.c,v 1.5 2010/10/13 11:19:28 pooka Exp $ */ 1/* $NetBSD: t_glob_star.c,v 1.6 2010/11/03 16:10:21 christos Exp $ */
2/*- 2/*-
3 * Copyright (c) 2010 The NetBSD Foundation, Inc. 3 * Copyright (c) 2010 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Christos Zoulas 7 * by Christos Zoulas
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 12 *
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE. 31 * SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__RCSID("$NetBSD: t_glob_star.c,v 1.5 2010/10/13 11:19:28 pooka Exp $"); 35__RCSID("$NetBSD: t_glob_star.c,v 1.6 2010/11/03 16:10:21 christos Exp $");
36 36
37#include <atf-c.h> 37#include <atf-c.h>
38 38
39#include <sys/param.h> 39#include <sys/param.h>
40#include <sys/stat.h> 40#include <sys/stat.h>
41 41
42#include <dirent.h> 42#include <dirent.h>
43#include <glob.h> 43#include <glob.h>
44#include <stdio.h> 44#include <stdio.h>
45#include <stdlib.h> 45#include <stdlib.h>
46#include <string.h> 46#include <string.h>
47#include <errno.h> 47#include <errno.h>
48 48
@@ -117,32 +117,32 @@ gl_opendir(const char *dir) @@ -117,32 +117,32 @@ gl_opendir(const char *dir)
117 for (i = 0; i < __arraycount(d); i++) 117 for (i = 0; i < __arraycount(d); i++)
118 if (strcmp(buf, d[i].name) == 0) { 118 if (strcmp(buf, d[i].name) == 0) {
119 DPRINTF(("opendir %s %zu\n", buf, i)); 119 DPRINTF(("opendir %s %zu\n", buf, i));
120 return &d[i]; 120 return &d[i];
121 } 121 }
122 errno = ENOENT; 122 errno = ENOENT;
123 return NULL; 123 return NULL;
124} 124}
125 125
126static struct dirent * 126static struct dirent *
127gl_readdir(void *v) 127gl_readdir(void *v)
128{ 128{
129 static struct dirent dir; 129 static struct dirent dir;
130 struct gl_dir *d = v; 130 struct gl_dir *dd = v;
131 if (d->pos < d->len) { 131 if (dd->pos < dd->len) {
132 const struct gl_file *f = &d->dir[d->pos++]; 132 const struct gl_file *f = &dd->dir[dd->pos++];
133 strcpy(dir.d_name, f->name); 133 strcpy(dir.d_name, f->name);
134 dir.d_namlen = strlen(f->name); 134 dir.d_namlen = strlen(f->name);
135 dir.d_ino = d->pos; 135 dir.d_ino = dd->pos;
136 dir.d_type = f->dir ? DT_DIR : DT_REG; 136 dir.d_type = f->dir ? DT_DIR : DT_REG;
137 DPRINTF(("readdir %s %d\n", dir.d_name, dir.d_type)); 137 DPRINTF(("readdir %s %d\n", dir.d_name, dir.d_type));
138 dir.d_reclen = _DIRENT_RECLEN(&dir, dir.d_namlen); 138 dir.d_reclen = _DIRENT_RECLEN(&dir, dir.d_namlen);
139 return &dir; 139 return &dir;
140 } 140 }
141 return NULL; 141 return NULL;
142} 142}
143 143
144static int 144static int
145gl_stat(const char *name , __gl_stat_t *st) 145gl_stat(const char *name , __gl_stat_t *st)
146{ 146{
147 char buf[MAXPATHLEN]; 147 char buf[MAXPATHLEN];
148 trim(buf, sizeof(buf), name); 148 trim(buf, sizeof(buf), name);
@@ -152,29 +152,29 @@ gl_stat(const char *name , __gl_stat_t * @@ -152,29 +152,29 @@ gl_stat(const char *name , __gl_stat_t *
152 DPRINTF(("stat %s %d\n", buf, st->st_mode)); 152 DPRINTF(("stat %s %d\n", buf, st->st_mode));
153 return 0; 153 return 0;
154} 154}
155 155
156static int 156static int
157gl_lstat(const char *name , __gl_stat_t *st) 157gl_lstat(const char *name , __gl_stat_t *st)
158{ 158{
159 return gl_stat(name, st); 159 return gl_stat(name, st);
160} 160}
161 161
162static void 162static void
163gl_closedir(void *v) 163gl_closedir(void *v)
164{ 164{
165 struct gl_dir *d = v; 165 struct gl_dir *dd = v;
166 d->pos = 0; 166 dd->pos = 0;
167 DPRINTF(("closedir %p\n", d)); 167 DPRINTF(("closedir %p\n", dd));
168} 168}
169 169
170static void 170static void
171run(const char *p, int flags, const char **res, size_t len) 171run(const char *p, int flags, const char **res, size_t len)
172{ 172{
173 glob_t gl; 173 glob_t gl;
174 size_t i; 174 size_t i;
175 175
176 memset(&gl, 0, sizeof(gl)); 176 memset(&gl, 0, sizeof(gl));
177 gl.gl_opendir = gl_opendir; 177 gl.gl_opendir = gl_opendir;
178 gl.gl_readdir = gl_readdir; 178 gl.gl_readdir = gl_readdir;
179 gl.gl_closedir = gl_closedir; 179 gl.gl_closedir = gl_closedir;
180 gl.gl_stat = gl_stat; 180 gl.gl_stat = gl_stat;

cvs diff -r1.1 -r1.2 src/tests/lib/libc/hash/t_sha2.c (expand / switch to unified diff)

--- src/tests/lib/libc/hash/t_sha2.c 2010/01/24 21:12:17 1.1
+++ src/tests/lib/libc/hash/t_sha2.c 2010/11/03 16:10:22 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_sha2.c,v 1.1 2010/01/24 21:12:17 joerg Exp $ */ 1/* $NetBSD: t_sha2.c,v 1.2 2010/11/03 16:10:22 christos Exp $ */
2/*- 2/*-
3 * Copyright (c) 20010 The NetBSD Foundation, Inc. 3 * Copyright (c) 20010 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Joerg Sonnenberger. 7 * by Joerg Sonnenberger.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 12 *
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE. 31 * SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__RCSID("$NetBSD: t_sha2.c,v 1.1 2010/01/24 21:12:17 joerg Exp $"); 35__RCSID("$NetBSD: t_sha2.c,v 1.2 2010/11/03 16:10:22 christos Exp $");
36 36
37#include <atf-c.h> 37#include <atf-c.h>
38#include <sys/types.h> 38#include <sys/types.h>
39#include <sha2.h> 39#include <sha2.h>
40#include <string.h> 40#include <string.h>
41 41
42ATF_TC(t_sha256); 42ATF_TC(t_sha256);
43ATF_TC(t_sha384); 43ATF_TC(t_sha384);
44ATF_TC(t_sha512); 44ATF_TC(t_sha512);
45 45
46ATF_TP_ADD_TCS(tp) 46ATF_TP_ADD_TCS(tp)
47{ 47{
48 ATF_TP_ADD_TC(tp, t_sha256); 48 ATF_TP_ADD_TC(tp, t_sha256);
@@ -134,109 +134,109 @@ static const struct testvector test512[] @@ -134,109 +134,109 @@ static const struct testvector test512[]
134 { "abcdefghijklmn", "8334134081070bf7fcc8bf1c242d24bb3182a5119e5fb19d8bbf6b9d0cdb7fed5336e83415fce93094c0e55123cf69e14d7ae41b22289232699824e31125b6d9" }, 134 { "abcdefghijklmn", "8334134081070bf7fcc8bf1c242d24bb3182a5119e5fb19d8bbf6b9d0cdb7fed5336e83415fce93094c0e55123cf69e14d7ae41b22289232699824e31125b6d9" },
135 { "abcdefghijklmno", "db723f341a042d8de1aa813efd5e02fc1745ccbe259486257514804e2ec4bcebb2a46f1e4ad442154943f9e97e1bc47c3ae0eddab7de0c01a9c51f15342a5b19" }, 135 { "abcdefghijklmno", "db723f341a042d8de1aa813efd5e02fc1745ccbe259486257514804e2ec4bcebb2a46f1e4ad442154943f9e97e1bc47c3ae0eddab7de0c01a9c51f15342a5b19" },
136 { "abcdefghijklmnop", "d0cadd6834fa0c157b36cca30ee8b0b1435d841aa5b5ac850c11ae80a1440f51743e98fb1f1e7376c70f2f65404f088c28bcb4a511df2e64111f8f7424364b60" }, 136 { "abcdefghijklmnop", "d0cadd6834fa0c157b36cca30ee8b0b1435d841aa5b5ac850c11ae80a1440f51743e98fb1f1e7376c70f2f65404f088c28bcb4a511df2e64111f8f7424364b60" },
137 { "abcdefghijklmnopq", "6196942a8495b721f82bbc385c74c1f10eeadf35db8adc9cf1a05ddeed19351228279644cd5d686ee48a31631ebb64747a2b68b733dd6015e3d27750878fa875" }, 137 { "abcdefghijklmnopq", "6196942a8495b721f82bbc385c74c1f10eeadf35db8adc9cf1a05ddeed19351228279644cd5d686ee48a31631ebb64747a2b68b733dd6015e3d27750878fa875" },
138 { "abcdefghijklmnopqr", "fb3bd1fc157ea6f7a6728986a59b271b766fb723f6b7cf2b4194437435f2c497f33b6a56ae7eb3830fa9e04d5ebb4cb5e3f4d4bd812c498bdf0167e125de3fba" }, 138 { "abcdefghijklmnopqr", "fb3bd1fc157ea6f7a6728986a59b271b766fb723f6b7cf2b4194437435f2c497f33b6a56ae7eb3830fa9e04d5ebb4cb5e3f4d4bd812c498bdf0167e125de3fba" },
139 { "abcdefghijklmnopqrs", "836f9ecf2aa02f522a94f1370af45a9fd538ac3c70e3b709d614b2f8981881d6b0070fc6387b74ee371fc2549309f82926e78084b401deb61a106c399089bee8" }, 139 { "abcdefghijklmnopqrs", "836f9ecf2aa02f522a94f1370af45a9fd538ac3c70e3b709d614b2f8981881d6b0070fc6387b74ee371fc2549309f82926e78084b401deb61a106c399089bee8" },
140 { "abcdefghijklmnopqrst", "8cd9c137651425fb32d193d99b281735ec68eb5fd296f16459d1b33eac7badcfce0dca22eadaa5f209fa4ac3bbecd41342bac8b8a5dc3626e7f22cdc96e17cb4" }, 140 { "abcdefghijklmnopqrst", "8cd9c137651425fb32d193d99b281735ec68eb5fd296f16459d1b33eac7badcfce0dca22eadaa5f209fa4ac3bbecd41342bac8b8a5dc3626e7f22cdc96e17cb4" },
141 { "abcdefghijklmnopqrstu", "7079853a3e36241a8d83639f168ef38e883d7f72851a84ef3ed4d91c6a3896cf542b8b4518c2816fb19d4692a4b9aae65cb857e3642ce0a3936e20363bcbd4ca" }, 141 { "abcdefghijklmnopqrstu", "7079853a3e36241a8d83639f168ef38e883d7f72851a84ef3ed4d91c6a3896cf542b8b4518c2816fb19d4692a4b9aae65cb857e3642ce0a3936e20363bcbd4ca" },
142 { "abcdefghijklmnopqrstuv", "a4e8a90b7058fb078e6cdcfd0c6a33c366437eb9084eac657830356804c9f9b53f121496d8e972d8707a4cf02615e6f58ed1a770c28ac79ffd845401fe18a928" }, 142 { "abcdefghijklmnopqrstuv", "a4e8a90b7058fb078e6cdcfd0c6a33c366437eb9084eac657830356804c9f9b53f121496d8e972d8707a4cf02615e6f58ed1a770c28ac79ffd845401fe18a928" },
143 { "abcdefghijklmnopqrstuvw", "d91b1fd7c7785975493826719f333d090b214ff42351c84d8f8b2538509a28d2d59a36d0ac798d99d3908083b072a4be606ae391def5daa74156350fec71dd24" }, 143 { "abcdefghijklmnopqrstuvw", "d91b1fd7c7785975493826719f333d090b214ff42351c84d8f8b2538509a28d2d59a36d0ac798d99d3908083b072a4be606ae391def5daa74156350fec71dd24" },
144 { "abcdefghijklmnopqrstuvwq", "404eb5652173323320cac6bf8d9714aef0747693a8ab4570700c6262268d367f30e31c44fa66860568ff058fe39c9aa8dac76bc78566c691a884cb9052c4aa0a" }, 144 { "abcdefghijklmnopqrstuvwq", "404eb5652173323320cac6bf8d9714aef0747693a8ab4570700c6262268d367f30e31c44fa66860568ff058fe39c9aa8dac76bc78566c691a884cb9052c4aa0a" },
145}; 145};
146 146
147void 147static void
148digest2string(const uint8_t *digest, char *string, size_t len) 148digest2string(const uint8_t *digest, char *string, size_t len)
149{ 149{
150 while (len--) { 150 while (len--) {
151 if (*digest / 16 < 10) 151 if (*digest / 16 < 10)
152 *string++ = '0' + *digest / 16; 152 *string++ = '0' + *digest / 16;
153 else 153 else
154 *string++ = 'a' + *digest / 16 - 10; 154 *string++ = 'a' + *digest / 16 - 10;
155 if (*digest % 16 < 10) 155 if (*digest % 16 < 10)
156 *string++ = '0' + *digest % 16; 156 *string++ = '0' + *digest % 16;
157 else 157 else
158 *string++ = 'a' + *digest % 16 - 10; 158 *string++ = 'a' + *digest % 16 - 10;
159 ++digest; 159 ++digest;
160 } 160 }
161 *string = '\0'; 161 *string = '\0';
162} 162}
163 163
164ATF_TC_HEAD(t_sha256, tc) 164ATF_TC_HEAD(t_sha256, tc)
165{ 165{
166 atf_tc_set_md_var(tc, "descr", 166 atf_tc_set_md_var(tc, "descr",
167 "Test SHA256 functions for consistent results"); 167 "Test SHA256 functions for consistent results");
168} 168}
169 169
170ATF_TC_BODY(t_sha256, tc) 170ATF_TC_BODY(t_sha256, tc)
171{ 171{
172 size_t i, j, len; 172 size_t i, j, len;
173 SHA256_CTX ctx; 173 SHA256_CTX ctx;
174 char buf[256]; 174 unsigned char buf[256];
175 char digest[8 + SHA256_DIGEST_LENGTH]; 175 unsigned char digest[8 + SHA256_DIGEST_LENGTH];
176 char output[SHA256_DIGEST_STRING_LENGTH]; 176 char output[SHA256_DIGEST_STRING_LENGTH];
177 177
178 for (i = 0; i < sizeof(test256) / sizeof(test256[0]); ++i) { 178 for (i = 0; i < sizeof(test256) / sizeof(test256[0]); ++i) {
179 len = strlen(test256[i].vector); 179 len = strlen(test256[i].vector);
180 for (j = 0; j < 8; ++j) { 180 for (j = 0; j < 8; ++j) {
181 SHA256_Init(&ctx); 181 SHA256_Init(&ctx);
182 memcpy(buf + j, test256[i].vector, len); 182 memcpy(buf + j, test256[i].vector, len);
183 SHA256_Update(&ctx, buf + j, len); 183 SHA256_Update(&ctx, buf + j, len);
184 SHA256_Final(digest + j, &ctx); 184 SHA256_Final(digest + j, &ctx);
185 digest2string(digest + j, output, SHA256_DIGEST_LENGTH); 185 digest2string(digest + j, output, SHA256_DIGEST_LENGTH);
186 ATF_CHECK_STREQ(test256[i].hash, output); 186 ATF_CHECK_STREQ(test256[i].hash, output);
187 } 187 }
188 } 188 }
189} 189}
190 190
191ATF_TC_HEAD(t_sha384, tc) 191ATF_TC_HEAD(t_sha384, tc)
192{ 192{
193 atf_tc_set_md_var(tc, "descr", 193 atf_tc_set_md_var(tc, "descr",
194 "Test SHA384 functions for consistent results"); 194 "Test SHA384 functions for consistent results");
195} 195}
196 196
197ATF_TC_BODY(t_sha384, tc) 197ATF_TC_BODY(t_sha384, tc)
198{ 198{
199 size_t i, j, len; 199 size_t i, j, len;
200 SHA384_CTX ctx; 200 SHA384_CTX ctx;
201 char buf[384]; 201 unsigned char buf[384];
202 char digest[8 + SHA384_DIGEST_LENGTH]; 202 unsigned char digest[8 + SHA384_DIGEST_LENGTH];
203 char output[SHA384_DIGEST_STRING_LENGTH]; 203 char output[SHA384_DIGEST_STRING_LENGTH];
204 204
205 for (i = 0; i < sizeof(test384) / sizeof(test384[0]); ++i) { 205 for (i = 0; i < sizeof(test384) / sizeof(test384[0]); ++i) {
206 len = strlen(test384[i].vector); 206 len = strlen(test384[i].vector);
207 for (j = 0; j < 8; ++j) { 207 for (j = 0; j < 8; ++j) {
208 SHA384_Init(&ctx); 208 SHA384_Init(&ctx);
209 memcpy(buf + j, test384[i].vector, len); 209 memcpy(buf + j, test384[i].vector, len);
210 SHA384_Update(&ctx, buf + j, len); 210 SHA384_Update(&ctx, buf + j, len);
211 SHA384_Final(digest + j, &ctx); 211 SHA384_Final(digest + j, &ctx);
212 digest2string(digest + j, output, SHA384_DIGEST_LENGTH); 212 digest2string(digest + j, output, SHA384_DIGEST_LENGTH);
213 ATF_CHECK_STREQ(test384[i].hash, output); 213 ATF_CHECK_STREQ(test384[i].hash, output);
214 } 214 }
215 } 215 }
216} 216}
217 217
218ATF_TC_HEAD(t_sha512, tc) 218ATF_TC_HEAD(t_sha512, tc)
219{ 219{
220 atf_tc_set_md_var(tc, "descr", 220 atf_tc_set_md_var(tc, "descr",
221 "Test SHA512 functions for consistent results"); 221 "Test SHA512 functions for consistent results");
222} 222}
223 223
224ATF_TC_BODY(t_sha512, tc) 224ATF_TC_BODY(t_sha512, tc)
225{ 225{
226 size_t i, j, len; 226 size_t i, j, len;
227 SHA512_CTX ctx; 227 SHA512_CTX ctx;
228 char buf[512]; 228 unsigned char buf[512];
229 char digest[8 + SHA512_DIGEST_LENGTH]; 229 unsigned char digest[8 + SHA512_DIGEST_LENGTH];
230 char output[SHA512_DIGEST_STRING_LENGTH]; 230 char output[SHA512_DIGEST_STRING_LENGTH];
231 231
232 for (i = 0; i < sizeof(test512) / sizeof(test512[0]); ++i) { 232 for (i = 0; i < sizeof(test512) / sizeof(test512[0]); ++i) {
233 len = strlen(test512[i].vector); 233 len = strlen(test512[i].vector);
234 for (j = 0; j < 8; ++j) { 234 for (j = 0; j < 8; ++j) {
235 SHA512_Init(&ctx); 235 SHA512_Init(&ctx);
236 memcpy(buf + j, test512[i].vector, len); 236 memcpy(buf + j, test512[i].vector, len);
237 SHA512_Update(&ctx, buf + j, len); 237 SHA512_Update(&ctx, buf + j, len);
238 SHA512_Final(digest + j, &ctx); 238 SHA512_Final(digest + j, &ctx);
239 digest2string(digest + j, output, SHA512_DIGEST_LENGTH); 239 digest2string(digest + j, output, SHA512_DIGEST_LENGTH);
240 ATF_CHECK_STREQ(test512[i].hash, output); 240 ATF_CHECK_STREQ(test512[i].hash, output);
241 } 241 }
242 } 242 }

cvs diff -r1.1 -r1.2 src/tests/lib/libc/stdio/t_fmemopen.c (expand / switch to unified diff)

--- src/tests/lib/libc/stdio/t_fmemopen.c 2010/09/24 09:21:53 1.1
+++ src/tests/lib/libc/stdio/t_fmemopen.c 2010/11/03 16:10:22 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_fmemopen.c,v 1.1 2010/09/24 09:21:53 tnozaki Exp $ */ 1/* $NetBSD: t_fmemopen.c,v 1.2 2010/11/03 16:10:22 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c)2010 Takehiko NOZAKI, 4 * Copyright (c)2010 Takehiko NOZAKI,
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -58,27 +58,27 @@ @@ -58,27 +58,27 @@
58const char *mode_rwa[] = { 58const char *mode_rwa[] = {
59 "r", "rb", "r+", "rb+", "r+b", 59 "r", "rb", "r+", "rb+", "r+b",
60 "w", "wb", "w+", "wb+", "w+b", 60 "w", "wb", "w+", "wb+", "w+b",
61 "a", "ab", "a+", "ab+", "a+b", 61 "a", "ab", "a+", "ab+", "a+b",
62 NULL 62 NULL
63}; 63};
64 64
65const char *mode_r[] = { "r", "rb", "r+", "rb+", "r+b", NULL }; 65const char *mode_r[] = { "r", "rb", "r+", "rb+", "r+b", NULL };
66const char *mode_w[] = { "w", "wb", "w+", "wb+", "w+b", NULL }; 66const char *mode_w[] = { "w", "wb", "w+", "wb+", "w+b", NULL };
67const char *mode_a[] = { "a", "ab", "a+", "ab+", "a+b", NULL };  67const char *mode_a[] = { "a", "ab", "a+", "ab+", "a+b", NULL };
68 68
69struct testcase { 69struct testcase {
70 const char *s; 70 const char *s;
71 size_t n; 71 off_t n;
72} testcases[] = { 72} testcases[] = {
73#define TESTSTR(s) { s, sizeof(s)-1 } 73#define TESTSTR(s) { s, sizeof(s)-1 }
74 TESTSTR("\0he quick brown fox jumps over the lazy dog"), 74 TESTSTR("\0he quick brown fox jumps over the lazy dog"),
75 TESTSTR("T\0e quick brown fox jumps over the lazy dog"), 75 TESTSTR("T\0e quick brown fox jumps over the lazy dog"),
76 TESTSTR("Th\0 quick brown fox jumps over the lazy dog"), 76 TESTSTR("Th\0 quick brown fox jumps over the lazy dog"),
77 TESTSTR("The\0quick brown fox jumps over the lazy dog"), 77 TESTSTR("The\0quick brown fox jumps over the lazy dog"),
78 TESTSTR("The \0uick brown fox jumps over the lazy dog"), 78 TESTSTR("The \0uick brown fox jumps over the lazy dog"),
79 TESTSTR("The q\0ick brown fox jumps over the lazy dog"), 79 TESTSTR("The q\0ick brown fox jumps over the lazy dog"),
80 TESTSTR("The qu\0ck brown fox jumps over the lazy dog"), 80 TESTSTR("The qu\0ck brown fox jumps over the lazy dog"),
81 TESTSTR("The qui\0k brown fox jumps over the lazy dog"), 81 TESTSTR("The qui\0k brown fox jumps over the lazy dog"),
82 TESTSTR("The quic\0 brown fox jumps over the lazy dog"), 82 TESTSTR("The quic\0 brown fox jumps over the lazy dog"),
83 TESTSTR("The quick\0brown fox jumps over the lazy dog"), 83 TESTSTR("The quick\0brown fox jumps over the lazy dog"),
84 TESTSTR("The quick \0rown fox jumps over the lazy dog"), 84 TESTSTR("The quick \0rown fox jumps over the lazy dog"),
@@ -741,40 +741,40 @@ const char *mode_rw1[] = { @@ -741,40 +741,40 @@ const char *mode_rw1[] = {
741 * at the current position or at the end of the buffer, depending on the size 741 * at the current position or at the end of the buffer, depending on the size
742 * of the contents. 742 * of the contents.
743 */ 743 */
744 744
745ATF_TC(test15); 745ATF_TC(test15);
746ATF_TC_HEAD(test15, tc) 746ATF_TC_HEAD(test15, tc)
747{ 747{
748 atf_tc_set_md_var(tc, "descr", "test15"); 748 atf_tc_set_md_var(tc, "descr", "test15");
749} 749}
750ATF_TC_BODY(test15, tc) 750ATF_TC_BODY(test15, tc)
751{ 751{
752 struct testcase *t; 752 struct testcase *t;
753 const char **p; 753 const char **p;
754 char buf0[BUFSIZ], buf1[BUFSIZ]; 754 char buf0[BUFSIZ];
755 FILE *fp; 755 FILE *fp;
756 size_t i; 756 int i;
757 757
758 for (t = &testcases[0]; t->s != NULL; ++t) { 758 for (t = &testcases[0]; t->s != NULL; ++t) {
759 for (p = &mode_rw1[0]; *p != NULL; ++p) { 759 for (p = &mode_rw1[0]; *p != NULL; ++p) {
760 760
761 memcpy(&buf0[0], t->s, t->n); 761 memcpy(&buf0[0], t->s, t->n);
762 fp = fmemopen(&buf0[0], t->n, *p); 762 fp = fmemopen(&buf0[0], t->n, *p);
763 ATF_CHECK(fp != NULL); 763 ATF_CHECK(fp != NULL);
764/* 764/*
765 * test fmemopen_read + fgetc(3) 765 * test fmemopen_read + fgetc(3)
766 */ 766 */
767 for (i = (size_t)0; i < t->n; ++i) { 767 for (i = 0; i < t->n; ++i) {
768 ATF_CHECK(ftello(fp) == (off_t)i); 768 ATF_CHECK(ftello(fp) == (off_t)i);
769 ATF_CHECK(fgetc(fp) == buf0[i]); 769 ATF_CHECK(fgetc(fp) == buf0[i]);
770 ATF_CHECK(feof(fp) == 0); 770 ATF_CHECK(feof(fp) == 0);
771 ATF_CHECK(ftello(fp) == (off_t)i + 1); 771 ATF_CHECK(ftello(fp) == (off_t)i + 1);
772 } 772 }
773 ATF_CHECK(fgetc(fp) == EOF); 773 ATF_CHECK(fgetc(fp) == EOF);
774 ATF_CHECK(feof(fp) != 0); 774 ATF_CHECK(feof(fp) != 0);
775 ATF_CHECK(ftello(fp) == (off_t)t->n); 775 ATF_CHECK(ftello(fp) == (off_t)t->n);
776 ATF_CHECK(fclose(fp) == 0); 776 ATF_CHECK(fclose(fp) == 0);
777 } 777 }
778 } 778 }
779} 779}
780 780
@@ -791,47 +791,48 @@ ATF_TC_BODY(test16, tc) @@ -791,47 +791,48 @@ ATF_TC_BODY(test16, tc)
791 FILE *fp; 791 FILE *fp;
792 792
793 for (t = &testcases[0]; t->s != NULL; ++t) { 793 for (t = &testcases[0]; t->s != NULL; ++t) {
794 for (p = &mode_rw1[0]; *p != NULL; ++p) { 794 for (p = &mode_rw1[0]; *p != NULL; ++p) {
795 795
796 memcpy(&buf0[0], t->s, t->n); 796 memcpy(&buf0[0], t->s, t->n);
797 buf1[t->n] = 0x1; 797 buf1[t->n] = 0x1;
798 fp = fmemopen(&buf0[0], t->n, *p); 798 fp = fmemopen(&buf0[0], t->n, *p);
799 ATF_CHECK(fp != NULL); 799 ATF_CHECK(fp != NULL);
800/* 800/*
801 * test fmemopen_read + fread(4) 801 * test fmemopen_read + fread(4)
802 */ 802 */
803 ATF_CHECK(ftello(fp) == (off_t)0); 803 ATF_CHECK(ftello(fp) == (off_t)0);
804 ATF_CHECK(fread(&buf1[0], 1, sizeof(buf1), fp) == t->n); 804 ATF_CHECK(fread(&buf1[0], 1, sizeof(buf1), fp) == (size_t)t->n);
805 ATF_CHECK(feof(fp) != 0); 805 ATF_CHECK(feof(fp) != 0);
806 ATF_CHECK(memcmp(&buf0[0], &buf1[0], t->n) == 0); 806 ATF_CHECK(memcmp(&buf0[0], &buf1[0], t->n) == 0);
807 ATF_CHECK((unsigned char)buf1[t->n] == 0x1); 807 ATF_CHECK((unsigned char)buf1[t->n] == 0x1);
808 808
809 ATF_CHECK(fclose(fp) == 0); 809 ATF_CHECK(fclose(fp) == 0);
810 } 810 }
811 } 811 }
812} 812}
813 813
814const char *mode_a1[] = { "a+", "ab+", NULL }; 814const char *mode_a1[] = { "a+", "ab+", NULL };
815 815
816ATF_TC(test17); 816ATF_TC(test17);
817ATF_TC_HEAD(test17, tc) 817ATF_TC_HEAD(test17, tc)
818{ 818{
819 atf_tc_set_md_var(tc, "descr", "test17"); 819 atf_tc_set_md_var(tc, "descr", "test17");
820} 820}
821ATF_TC_BODY(test17, tc) 821ATF_TC_BODY(test17, tc)
822{ 822{
823 struct testcase *t; 823 struct testcase *t;
824 size_t len, i; 824 size_t len;
 825 int i;
825 const char **p; 826 const char **p;
826 char buf[BUFSIZ]; 827 char buf[BUFSIZ];
827 FILE *fp; 828 FILE *fp;
828 829
829 for (t = &testcases[0]; t->s != NULL; ++t) { 830 for (t = &testcases[0]; t->s != NULL; ++t) {
830 len = strnlen(t->s, t->n); 831 len = strnlen(t->s, t->n);
831 for (p = &mode_a1[0]; *p != NULL; ++p) { 832 for (p = &mode_a1[0]; *p != NULL; ++p) {
832 833
833 memcpy(&buf[0], t->s, t->n); 834 memcpy(&buf[0], t->s, t->n);
834 fp = fmemopen(&buf[0], t->n, *p); 835 fp = fmemopen(&buf[0], t->n, *p);
835 ATF_CHECK(fp != NULL); 836 ATF_CHECK(fp != NULL);
836/* 837/*
837 * test fmemopen_read + fgetc(3) 838 * test fmemopen_read + fgetc(3)
@@ -839,52 +840,52 @@ ATF_TC_BODY(test17, tc) @@ -839,52 +840,52 @@ ATF_TC_BODY(test17, tc)
839#if defined(__GLIBC__) 840#if defined(__GLIBC__)
840 if (i < t->n) { 841 if (i < t->n) {
841#endif 842#endif
842 for (i = len; i < t->n; ++i) { 843 for (i = len; i < t->n; ++i) {
843 ATF_CHECK(ftello(fp) == (off_t)i); 844 ATF_CHECK(ftello(fp) == (off_t)i);
844 ATF_CHECK(fgetc(fp) == buf[i]); 845 ATF_CHECK(fgetc(fp) == buf[i]);
845 ATF_CHECK(feof(fp) == 0); 846 ATF_CHECK(feof(fp) == 0);
846 ATF_CHECK(ftello(fp) == (off_t)i + 1); 847 ATF_CHECK(ftello(fp) == (off_t)i + 1);
847 } 848 }
848 ATF_CHECK(fgetc(fp) == EOF); 849 ATF_CHECK(fgetc(fp) == EOF);
849 ATF_CHECK(feof(fp) != 0); 850 ATF_CHECK(feof(fp) != 0);
850 ATF_CHECK(ftello(fp) == (off_t)t->n); 851 ATF_CHECK(ftello(fp) == (off_t)t->n);
851 rewind(fp); 852 rewind(fp);
852 for (i = (size_t)0; i < t->n; ++i) { 853 for (i = 0; i < t->n; ++i) {
853 ATF_CHECK(ftello(fp) == (off_t)i); 854 ATF_CHECK(ftello(fp) == (off_t)i);
854 ATF_CHECK(fgetc(fp) == buf[i]); 855 ATF_CHECK(fgetc(fp) == buf[i]);
855 ATF_CHECK(feof(fp) == 0); 856 ATF_CHECK(feof(fp) == 0);
856 ATF_CHECK(ftello(fp) == (off_t)i + 1); 857 ATF_CHECK(ftello(fp) == (off_t)i + 1);
857 } 858 }
858 ATF_CHECK(fgetc(fp) == EOF); 859 ATF_CHECK(fgetc(fp) == EOF);
859 ATF_CHECK(feof(fp) != 0); 860 ATF_CHECK(feof(fp) != 0);
860 ATF_CHECK(ftello(fp) == (off_t)t->n); 861 ATF_CHECK(ftello(fp) == (off_t)t->n);
861#if defined(__GLIBC__) 862#if defined(__GLIBC__)
862 } 863 }
863#endif 864#endif
864 ATF_CHECK(fclose(fp) == 0); 865 ATF_CHECK(fclose(fp) == 0);
865 } 866 }
866 } 867 }
867} 868}
868 869
869ATF_TC(test18); 870ATF_TC(test18);
870ATF_TC_HEAD(test18, tc) 871ATF_TC_HEAD(test18, tc)
871{ 872{
872 atf_tc_set_md_var(tc, "descr", "test18"); 873 atf_tc_set_md_var(tc, "descr", "test18");
873} 874}
874ATF_TC_BODY(test18, tc) 875ATF_TC_BODY(test18, tc)
875{ 876{
876 struct testcase *t; 877 struct testcase *t;
877 size_t len, i; 878 size_t len;
878 const char **p; 879 const char **p;
879 char buf0[BUFSIZ], buf1[BUFSIZ]; 880 char buf0[BUFSIZ], buf1[BUFSIZ];
880 FILE *fp; 881 FILE *fp;
881 882
882 for (t = &testcases[0]; t->s != NULL; ++t) { 883 for (t = &testcases[0]; t->s != NULL; ++t) {
883 len = strnlen(t->s, t->n); 884 len = strnlen(t->s, t->n);
884 for (p = &mode_a1[0]; *p != NULL; ++p) { 885 for (p = &mode_a1[0]; *p != NULL; ++p) {
885 886
886 memcpy(&buf0[0], t->s, t->n); 887 memcpy(&buf0[0], t->s, t->n);
887 buf1[t->n - len] = 0x1; 888 buf1[t->n - len] = 0x1;
888 fp = fmemopen(&buf0[0], t->n, *p); 889 fp = fmemopen(&buf0[0], t->n, *p);
889 ATF_CHECK(fp != NULL); 890 ATF_CHECK(fp != NULL);
890/* 891/*
@@ -893,27 +894,27 @@ ATF_TC_BODY(test18, tc) @@ -893,27 +894,27 @@ ATF_TC_BODY(test18, tc)
893#if defined(__GLIBC__) 894#if defined(__GLIBC__)
894 if (i < t->n) { 895 if (i < t->n) {
895#endif 896#endif
896 ATF_CHECK(ftello(fp) == (off_t)len); 897 ATF_CHECK(ftello(fp) == (off_t)len);
897 ATF_CHECK(fread(&buf1[0], 1, sizeof(buf1), fp) 898 ATF_CHECK(fread(&buf1[0], 1, sizeof(buf1), fp)
898 == t->n - len); 899 == t->n - len);
899 ATF_CHECK(feof(fp) != 0); 900 ATF_CHECK(feof(fp) != 0);
900 ATF_CHECK(!memcmp(&buf0[len], &buf1[0], t->n - len)); 901 ATF_CHECK(!memcmp(&buf0[len], &buf1[0], t->n - len));
901 ATF_CHECK((unsigned char)buf1[t->n - len] == 0x1); 902 ATF_CHECK((unsigned char)buf1[t->n - len] == 0x1);
902 rewind(fp); 903 rewind(fp);
903 buf1[t->n] = 0x1; 904 buf1[t->n] = 0x1;
904 ATF_CHECK(ftello(fp) == (off_t)0); 905 ATF_CHECK(ftello(fp) == (off_t)0);
905 ATF_CHECK(fread(&buf1[0], 1, sizeof(buf1), fp) 906 ATF_CHECK(fread(&buf1[0], 1, sizeof(buf1), fp)
906 == t->n); 907 == (size_t)t->n);
907 ATF_CHECK(feof(fp) != 0); 908 ATF_CHECK(feof(fp) != 0);
908 ATF_CHECK(!memcmp(&buf0[0], &buf1[0], t->n)); 909 ATF_CHECK(!memcmp(&buf0[0], &buf1[0], t->n));
909 ATF_CHECK((unsigned char)buf1[t->n] == 0x1); 910 ATF_CHECK((unsigned char)buf1[t->n] == 0x1);
910#if defined(__GLIBC__) 911#if defined(__GLIBC__)
911 } 912 }
912#endif 913#endif
913 ATF_CHECK(fclose(fp) == 0); 914 ATF_CHECK(fclose(fp) == 0);
914 } 915 }
915 } 916 }
916} 917}
917 918
918/* 919/*
919 * test19 - test22: 920 * test19 - test22:
@@ -926,44 +927,45 @@ const char *mode_rw2[] = { @@ -926,44 +927,45 @@ const char *mode_rw2[] = {
926 "r+", "rb+", "r+b", 927 "r+", "rb+", "r+b",
927 "w", "wb", "w+", "wb+", "w+b", 928 "w", "wb", "w+", "wb+", "w+b",
928 NULL 929 NULL
929}; 930};
930 931
931ATF_TC(test19); 932ATF_TC(test19);
932ATF_TC_HEAD(test19, tc) 933ATF_TC_HEAD(test19, tc)
933{ 934{
934 atf_tc_set_md_var(tc, "descr", "test19"); 935 atf_tc_set_md_var(tc, "descr", "test19");
935} 936}
936ATF_TC_BODY(test19, tc) 937ATF_TC_BODY(test19, tc)
937{ 938{
938 struct testcase *t; 939 struct testcase *t;
939 size_t len, i; 940 size_t len;
 941 int i;
940 const char **p; 942 const char **p;
941 char buf[BUFSIZ]; 943 char buf[BUFSIZ];
942 FILE *fp; 944 FILE *fp;
943 945
944 for (t = &testcases[0]; t->s != NULL; ++t) { 946 for (t = &testcases[0]; t->s != NULL; ++t) {
945 len = strnlen(t->s, t->n); 947 len = strnlen(t->s, t->n);
946 for (p = &mode_rw2[0]; *p != NULL; ++p) { 948 for (p = &mode_rw2[0]; *p != NULL; ++p) {
947 949
948 memcpy(&buf[0], t->s, t->n); 950 memcpy(&buf[0], t->s, t->n);
949 buf[t->n] = 0x1; 951 buf[t->n] = 0x1;
950 fp = fmemopen(&buf[0], t->n + 1, *p); 952 fp = fmemopen(&buf[0], t->n + 1, *p);
951 ATF_CHECK(fp != NULL); 953 ATF_CHECK(fp != NULL);
952 setbuf(fp, NULL); 954 setbuf(fp, NULL);
953/* 955/*
954 * test fmemopen_write + fputc(3) 956 * test fmemopen_write + fputc(3)
955 */ 957 */
956 for (i = (size_t)0; i < t->n; ++i) { 958 for (i = 0; i < t->n; ++i) {
957 ATF_CHECK(ftello(fp) == (off_t)i); 959 ATF_CHECK(ftello(fp) == (off_t)i);
958 ATF_CHECK(fputc(t->s[i], fp) == t->s[i]); 960 ATF_CHECK(fputc(t->s[i], fp) == t->s[i]);
959 ATF_CHECK(buf[i] == t->s[i]); 961 ATF_CHECK(buf[i] == t->s[i]);
960 ATF_CHECK(ftello(fp) == (off_t)i + 1); 962 ATF_CHECK(ftello(fp) == (off_t)i + 1);
961 ATF_CHECK(buf[i] == t->s[i]); 963 ATF_CHECK(buf[i] == t->s[i]);
962#if !defined(__GLIBC__) 964#if !defined(__GLIBC__)
963 ATF_CHECK(buf[i + 1] == '\0'); 965 ATF_CHECK(buf[i + 1] == '\0');
964#endif 966#endif
965 } 967 }
966 968
967/* don't accept non nul character at end of buffer */ 969/* don't accept non nul character at end of buffer */
968 ATF_CHECK(fputc(0x1, fp) == EOF); 970 ATF_CHECK(fputc(0x1, fp) == EOF);
969 ATF_CHECK(ftello(fp) == (off_t)t->n); 971 ATF_CHECK(ftello(fp) == (off_t)t->n);
@@ -985,41 +987,41 @@ ATF_TC_BODY(test19, tc) @@ -985,41 +987,41 @@ ATF_TC_BODY(test19, tc)
985 ATF_CHECK(fclose(fp) == 0); 987 ATF_CHECK(fclose(fp) == 0);
986 } 988 }
987 } 989 }
988} 990}
989 991
990ATF_TC(test20); 992ATF_TC(test20);
991ATF_TC_HEAD(test20, tc) 993ATF_TC_HEAD(test20, tc)
992{ 994{
993 atf_tc_set_md_var(tc, "descr", "test20"); 995 atf_tc_set_md_var(tc, "descr", "test20");
994} 996}
995ATF_TC_BODY(test20, tc) 997ATF_TC_BODY(test20, tc)
996{ 998{
997 struct testcase *t; 999 struct testcase *t;
998 size_t len, i; 1000 size_t len;
999 const char **p; 1001 const char **p;
1000 char buf[BUFSIZ]; 1002 char buf[BUFSIZ];
1001 FILE *fp; 1003 FILE *fp;
1002 1004
1003 for (t = &testcases[0]; t->s != NULL; ++t) { 1005 for (t = &testcases[0]; t->s != NULL; ++t) {
1004 len = strnlen(t->s, t->n); 1006 len = strnlen(t->s, t->n);
1005 for (p = &mode_rw2[0]; *p != NULL; ++p) { 1007 for (p = &mode_rw2[0]; *p != NULL; ++p) {
1006 1008
1007 memcpy(&buf[0], t->s, t->n); 1009 memcpy(&buf[0], t->s, t->n);
1008 buf[t->n] = 0x1; 1010 buf[t->n] = 0x1;
1009 fp = fmemopen(&buf[0], t->n + 1, *p); 1011 fp = fmemopen(&buf[0], t->n + 1, *p);
1010 ATF_CHECK(fp != NULL); 1012 ATF_CHECK(fp != NULL);
1011 setbuf(fp, NULL); 1013 setbuf(fp, NULL);
1012 ATF_CHECK(fwrite(t->s, 1, t->n, fp) == t->n); 1014 ATF_CHECK(fwrite(t->s, 1, t->n, fp) == (size_t)t->n);
1013/* 1015/*
1014 * test fmemopen_write + fwrite(3) 1016 * test fmemopen_write + fwrite(3)
1015 */ 1017 */
1016#if !defined(__GLIBC__) 1018#if !defined(__GLIBC__)
1017 ATF_CHECK(buf[t->n] == '\0'); 1019 ATF_CHECK(buf[t->n] == '\0');
1018 1020
1019/* don't accept non nul character at end of buffer */ 1021/* don't accept non nul character at end of buffer */
1020 ATF_CHECK(fwrite("\x1", 1, 1, fp) == 0); 1022 ATF_CHECK(fwrite("\x1", 1, 1, fp) == 0);
1021 ATF_CHECK(ftello(fp) == (off_t)t->n); 1023 ATF_CHECK(ftello(fp) == (off_t)t->n);
1022 ATF_CHECK(feof(fp) == 0); 1024 ATF_CHECK(feof(fp) == 0);
1023#endif 1025#endif
1024 1026
1025/* accept nul character at end of buffer */ 1027/* accept nul character at end of buffer */
@@ -1038,27 +1040,27 @@ ATF_TC_BODY(test20, tc) @@ -1038,27 +1040,27 @@ ATF_TC_BODY(test20, tc)
1038 ATF_CHECK(fclose(fp) == 0); 1040 ATF_CHECK(fclose(fp) == 0);
1039 } 1041 }
1040 } 1042 }
1041} 1043}
1042 1044
1043ATF_TC(test21); 1045ATF_TC(test21);
1044ATF_TC_HEAD(test21, tc) 1046ATF_TC_HEAD(test21, tc)
1045{ 1047{
1046 atf_tc_set_md_var(tc, "descr", "test21"); 1048 atf_tc_set_md_var(tc, "descr", "test21");
1047} 1049}
1048ATF_TC_BODY(test21, tc) 1050ATF_TC_BODY(test21, tc)
1049{ 1051{
1050 struct testcase *t; 1052 struct testcase *t;
1051 size_t len, i; 1053 int len, i;
1052 const char **p; 1054 const char **p;
1053 char buf[BUFSIZ]; 1055 char buf[BUFSIZ];
1054 FILE *fp; 1056 FILE *fp;
1055 1057
1056 for (t = &testcases[0]; t->s != NULL; ++t) { 1058 for (t = &testcases[0]; t->s != NULL; ++t) {
1057 len = strnlen(t->s, t->n); 1059 len = strnlen(t->s, t->n);
1058 for (p = &mode_a[0]; *p != NULL; ++p) { 1060 for (p = &mode_a[0]; *p != NULL; ++p) {
1059 memcpy(&buf[0], t->s, t->n); 1061 memcpy(&buf[0], t->s, t->n);
1060 fp = fmemopen(&buf[0], t->n, *p); 1062 fp = fmemopen(&buf[0], t->n, *p);
1061 ATF_CHECK(fp != NULL); 1063 ATF_CHECK(fp != NULL);
1062 setbuf(fp, NULL); 1064 setbuf(fp, NULL);
1063/* 1065/*
1064 * test fmemopen_write + fputc(3) 1066 * test fmemopen_write + fputc(3)
@@ -1094,27 +1096,27 @@ ATF_TC_BODY(test21, tc) @@ -1094,27 +1096,27 @@ ATF_TC_BODY(test21, tc)
1094 ATF_CHECK(fclose(fp) == 0); 1096 ATF_CHECK(fclose(fp) == 0);
1095 } 1097 }
1096 } 1098 }
1097} 1099}
1098 1100
1099ATF_TC(test22); 1101ATF_TC(test22);
1100ATF_TC_HEAD(test22, tc) 1102ATF_TC_HEAD(test22, tc)
1101{ 1103{
1102 atf_tc_set_md_var(tc, "descr", "test22"); 1104 atf_tc_set_md_var(tc, "descr", "test22");
1103} 1105}
1104ATF_TC_BODY(test22, tc) 1106ATF_TC_BODY(test22, tc)
1105{ 1107{
1106 struct testcase *t0, *t1; 1108 struct testcase *t0, *t1;
1107 size_t len0, len1, i, nleft; 1109 size_t len0, len1, nleft;
1108 const char **p; 1110 const char **p;
1109 char buf[BUFSIZ]; 1111 char buf[BUFSIZ];
1110 FILE *fp; 1112 FILE *fp;
1111 1113
1112 for (t0 = &testcases[0]; t0->s != NULL; ++t0) { 1114 for (t0 = &testcases[0]; t0->s != NULL; ++t0) {
1113 len0 = strnlen(t0->s, t0->n); 1115 len0 = strnlen(t0->s, t0->n);
1114 for (t1 = &testcases[0]; t1->s != NULL; ++t1) { 1116 for (t1 = &testcases[0]; t1->s != NULL; ++t1) {
1115 len1 = strnlen(t1->s, t1->n); 1117 len1 = strnlen(t1->s, t1->n);
1116 for (p = &mode_a[0]; *p != NULL; ++p) { 1118 for (p = &mode_a[0]; *p != NULL; ++p) {
1117 1119
1118 memcpy(&buf[0], t0->s, t0->n); 1120 memcpy(&buf[0], t0->s, t0->n);
1119 fp = fmemopen(&buf[0], t0->n, *p); 1121 fp = fmemopen(&buf[0], t0->n, *p);
1120 ATF_CHECK(fp != NULL); 1122 ATF_CHECK(fp != NULL);

cvs diff -r1.1 -r1.2 src/tests/lib/libprop/Attic/t_basic.c (expand / switch to unified diff)

--- src/tests/lib/libprop/Attic/t_basic.c 2010/07/16 13:56:31 1.1
+++ src/tests/lib/libprop/Attic/t_basic.c 2010/11/03 16:10:22 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_basic.c,v 1.1 2010/07/16 13:56:31 jmmv Exp $ */ 1/* $NetBSD: t_basic.c,v 1.2 2010/11/03 16:10:22 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,30 +24,31 @@ @@ -24,30 +24,31 @@
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29/* 29/*
30 * Written by Jason Thorpe 5/26/2006. 30 * Written by Jason Thorpe 5/26/2006.
31 * Public domain. 31 * Public domain.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35__COPYRIGHT("@(#) Copyright (c) 2008\ 35__COPYRIGHT("@(#) Copyright (c) 2008\
36 The NetBSD Foundation, inc. All rights reserved."); 36 The NetBSD Foundation, inc. All rights reserved.");
37__RCSID("$NetBSD: t_basic.c,v 1.1 2010/07/16 13:56:31 jmmv Exp $"); 37__RCSID("$NetBSD: t_basic.c,v 1.2 2010/11/03 16:10:22 christos Exp $");
38 38
39#include <prop/proplib.h> 
40#include <stdlib.h> 39#include <stdlib.h>
 40#include <string.h>
 41#include <prop/proplib.h>
41 42
42#include <atf-c.h> 43#include <atf-c.h>
43 44
44static const char compare1[] = 45static const char compare1[] =
45"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 46"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
46"<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n" 47"<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n"
47"<plist version=\"1.0\">\n" 48"<plist version=\"1.0\">\n"
48"<dict>\n" 49"<dict>\n"
49" <key>false-val</key>\n" 50" <key>false-val</key>\n"
50" <false/>\n" 51" <false/>\n"
51" <key>one</key>\n" 52" <key>one</key>\n"
52" <integer>1</integer>\n" 53" <integer>1</integer>\n"
53" <key>three</key>\n" 54" <key>three</key>\n"

cvs diff -r1.1 -r1.2 src/tests/lib/libpthread/h_resolv.c (expand / switch to unified diff)

--- src/tests/lib/libpthread/h_resolv.c 2010/07/16 15:42:53 1.1
+++ src/tests/lib/libpthread/h_resolv.c 2010/11/03 16:10:22 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: h_resolv.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $ */ 1/* $NetBSD: h_resolv.c,v 1.2 2010/11/03 16:10:22 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2004, 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2004, 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Christos Zoulas. 8 * by Christos Zoulas.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -22,27 +22,27 @@ @@ -22,27 +22,27 @@
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__COPYRIGHT("@(#) Copyright (c) 2008\ 33__COPYRIGHT("@(#) Copyright (c) 2008\
34 The NetBSD Foundation, inc. All rights reserved."); 34 The NetBSD Foundation, inc. All rights reserved.");
35__RCSID("$NetBSD: h_resolv.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $"); 35__RCSID("$NetBSD: h_resolv.c,v 1.2 2010/11/03 16:10:22 christos Exp $");
36 36
37#include <pthread.h> 37#include <pthread.h>
38#include <stdio.h> 38#include <stdio.h>
39#include <netdb.h> 39#include <netdb.h>
40#include <stdlib.h> 40#include <stdlib.h>
41#include <unistd.h> 41#include <unistd.h>
42#include <err.h> 42#include <err.h>
43#include <string.h> 43#include <string.h>
44#include <stringlist.h> 44#include <stringlist.h>
45 45
46#define NTHREADS 10 46#define NTHREADS 10
47#define NHOSTS 100 47#define NHOSTS 100
48#define WS " \t\n\r" 48#define WS " \t\n\r"
@@ -183,26 +183,26 @@ main(int argc, char *argv[]) @@ -183,26 +183,26 @@ main(int argc, char *argv[])
183 } 183 }
184 184
185 for (done = 0; !done;) { 185 for (done = 0; !done;) {
186 done = 1; 186 done = 1;
187 for (i = 0; i < nthreads; i++) { 187 for (i = 0; i < nthreads; i++) {
188 if (nleft[i] != 0) { 188 if (nleft[i] != 0) {
189 done = 0; 189 done = 0;
190 break; 190 break;
191 } 191 }
192 } 192 }
193 sleep(1); 193 sleep(1);
194 } 194 }
195 c = 0; 195 c = 0;
196 for (i = 0; i < hosts->sl_cur; i++) { 196 for (i = 0; i < (int)hosts->sl_cur; i++) {
197 if (ask[i] != got[i] && got[i] != 0) { 197 if (ask[i] != got[i] && got[i] != 0) {
198 warnx("Error: host %s ask %d got %d\n", 198 warnx("Error: host %s ask %d got %d\n",
199 hosts->sl_str[i], ask[i], got[i]); 199 hosts->sl_str[i], ask[i], got[i]);
200 c++; 200 c++;
201 } 201 }
202 } 202 }
203 free(nleft); 203 free(nleft);
204 free(ask); 204 free(ask);
205 free(got); 205 free(got);
206 sl_free(hosts, 1); 206 sl_free(hosts, 1);
207 return c; 207 return c;
208} 208}

cvs diff -r1.1 -r1.2 src/tests/lib/libpthread/t_barrier.c (expand / switch to unified diff)

--- src/tests/lib/libpthread/t_barrier.c 2010/07/16 15:42:53 1.1
+++ src/tests/lib/libpthread/t_barrier.c 2010/11/03 16:10:22 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_barrier.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $ */ 1/* $NetBSD: t_barrier.c,v 1.2 2010/11/03 16:10:22 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,56 +19,56 @@ @@ -19,56 +19,56 @@
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__COPYRIGHT("@(#) Copyright (c) 2008\ 30__COPYRIGHT("@(#) Copyright (c) 2008\
31 The NetBSD Foundation, inc. All rights reserved."); 31 The NetBSD Foundation, inc. All rights reserved.");
32__RCSID("$NetBSD: t_barrier.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $"); 32__RCSID("$NetBSD: t_barrier.c,v 1.2 2010/11/03 16:10:22 christos Exp $");
33 33
34#include <pthread.h> 34#include <pthread.h>
35#include <stdio.h> 35#include <stdio.h>
36#include <unistd.h> 36#include <unistd.h>
37 37
38#include <atf-c.h> 38#include <atf-c.h>
39 39
40#include "h_common.h" 40#include "h_common.h"
41 41
42#define COUNT 5 42#define COUNT 5
43 43
44pthread_barrier_t barrier; 44pthread_barrier_t barrier;
45pthread_mutex_t mutex; 45pthread_mutex_t mutex;
46int serial_count; 46int serial_count;
47int after_barrier_count; 47int after_barrier_count;
48 48
49static void * 49static void *
50threadfunc(void *arg) 50threadfunc(void *arg)
51{ 51{
52 int which = (int)(long)arg; 52 int which = (int)(long)arg;
53 int ret; 53 int rv;
54 54
55 printf("thread %d entering barrier\n", which); 55 printf("thread %d entering barrier\n", which);
56 ret = pthread_barrier_wait(&barrier); 56 rv = pthread_barrier_wait(&barrier);
57 printf("thread %d leaving barrier -> %d\n", which, ret); 57 printf("thread %d leaving barrier -> %d\n", which, rv);
58 58
59 PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); 59 PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
60 after_barrier_count++; 60 after_barrier_count++;
61 if (ret == PTHREAD_BARRIER_SERIAL_THREAD) 61 if (rv == PTHREAD_BARRIER_SERIAL_THREAD)
62 serial_count++; 62 serial_count++;
63 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); 63 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
64 64
65 return NULL; 65 return NULL;
66} 66}
67 67
68ATF_TC(barrier); 68ATF_TC(barrier);
69ATF_TC_HEAD(barrier, tc) 69ATF_TC_HEAD(barrier, tc)
70{ 70{
71 atf_tc_set_md_var(tc, "descr", "Checks barriers"); 71 atf_tc_set_md_var(tc, "descr", "Checks barriers");
72} 72}
73ATF_TC_BODY(barrier, tc) 73ATF_TC_BODY(barrier, tc)
74{ 74{

cvs diff -r1.1 -r1.2 src/tests/lib/libpthread/t_cond.c (expand / switch to unified diff)

--- src/tests/lib/libpthread/t_cond.c 2010/07/16 15:42:53 1.1
+++ src/tests/lib/libpthread/t_cond.c 2010/11/03 16:10:22 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_cond.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $ */ 1/* $NetBSD: t_cond.c,v 1.2 2010/11/03 16:10:22 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,57 +19,57 @@ @@ -19,57 +19,57 @@
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__COPYRIGHT("@(#) Copyright (c) 2008\ 30__COPYRIGHT("@(#) Copyright (c) 2008\
31 The NetBSD Foundation, inc. All rights reserved."); 31 The NetBSD Foundation, inc. All rights reserved.");
32__RCSID("$NetBSD: t_cond.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $"); 32__RCSID("$NetBSD: t_cond.c,v 1.2 2010/11/03 16:10:22 christos Exp $");
33 33
34#include <sys/time.h> 34#include <sys/time.h>
35 35
36#include <errno.h> 36#include <errno.h>
37#include <pthread.h> 37#include <pthread.h>
38#include <stdio.h> 38#include <stdio.h>
39#include <unistd.h> 39#include <unistd.h>
40 40
41#include <atf-c.h> 41#include <atf-c.h>
42 42
43#include "h_common.h" 43#include "h_common.h"
44 44
45static pthread_mutex_t mutex; 45static pthread_mutex_t mutex;
46static pthread_cond_t cond; 46static pthread_cond_t cond;
47static pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER; 47static pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER;
48static pthread_cond_t static_cond = PTHREAD_COND_INITIALIZER; 48static pthread_cond_t static_cond = PTHREAD_COND_INITIALIZER;
49static int count, share, toggle, total; 49static int count, share, toggle, total;
50 50
51static void * 51static void *
52signal_delay_wait_threadfunc(void *arg) 52signal_delay_wait_threadfunc(void *arg)
53{ 53{
54 int *share = (int *) arg; 54 int *shared = (int *) arg;
55 55
56 printf("2: Second thread.\n"); 56 printf("2: Second thread.\n");
57 57
58 printf("2: Locking mutex\n"); 58 printf("2: Locking mutex\n");
59 PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); 59 PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
60 printf("2: Got mutex.\n"); 60 printf("2: Got mutex.\n");
61 printf("Shared value: %d. Changing to 0.\n", *share); 61 printf("Shared value: %d. Changing to 0.\n", *shared);
62 *share = 0; 62 *shared = 0;
63 63
64 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); 64 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
65 PTHREAD_REQUIRE(pthread_cond_signal(&cond)); 65 PTHREAD_REQUIRE(pthread_cond_signal(&cond));
66 66
67 return NULL; 67 return NULL;
68} 68}
69 69
70ATF_TC(signal_delay_wait); 70ATF_TC(signal_delay_wait);
71ATF_TC_HEAD(signal_delay_wait, tc) 71ATF_TC_HEAD(signal_delay_wait, tc)
72{ 72{
73 atf_tc_set_md_var(tc, "descr", "Checks condition variables"); 73 atf_tc_set_md_var(tc, "descr", "Checks condition variables");
74} 74}
75ATF_TC_BODY(signal_delay_wait, tc) 75ATF_TC_BODY(signal_delay_wait, tc)
@@ -102,35 +102,35 @@ ATF_TC_BODY(signal_delay_wait, tc) @@ -102,35 +102,35 @@ ATF_TC_BODY(signal_delay_wait, tc)
102 printf("1: After the loop.\n"); 102 printf("1: After the loop.\n");
103 103
104 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); 104 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
105 105
106 printf("1: After releasing the mutex.\n"); 106 printf("1: After releasing the mutex.\n");
107 PTHREAD_REQUIRE(pthread_join(new, &joinval)); 107 PTHREAD_REQUIRE(pthread_join(new, &joinval));
108 108
109 printf("1: Thread joined.\n"); 109 printf("1: Thread joined.\n");
110} 110}
111 111
112static void * 112static void *
113signal_before_unlock_threadfunc(void *arg) 113signal_before_unlock_threadfunc(void *arg)
114{ 114{
115 int *share = (int *) arg; 115 int *shared = (int *) arg;
116 116
117 printf("2: Second thread.\n"); 117 printf("2: Second thread.\n");
118 118
119 printf("2: Locking mutex\n"); 119 printf("2: Locking mutex\n");
120 PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); 120 PTHREAD_REQUIRE(pthread_mutex_lock(&mutex));
121 printf("2: Got mutex.\n"); 121 printf("2: Got mutex.\n");
122 printf("Shared value: %d. Changing to 0.\n", *share); 122 printf("Shared value: %d. Changing to 0.\n", *shared);
123 *share = 0; 123 *shared = 0;
124 124
125 /* Signal first, then unlock, for a different test than #1. */ 125 /* Signal first, then unlock, for a different test than #1. */
126 PTHREAD_REQUIRE(pthread_cond_signal(&cond)); 126 PTHREAD_REQUIRE(pthread_cond_signal(&cond));
127 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); 127 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
128 128
129 return NULL; 129 return NULL;
130} 130}
131 131
132ATF_TC(signal_before_unlock); 132ATF_TC(signal_before_unlock);
133ATF_TC_HEAD(signal_before_unlock, tc) 133ATF_TC_HEAD(signal_before_unlock, tc)
134{ 134{
135 atf_tc_set_md_var(tc, "descr", 135 atf_tc_set_md_var(tc, "descr",
136 "Checks condition variables: signal before unlocking mutex"); 136 "Checks condition variables: signal before unlocking mutex");
@@ -165,35 +165,35 @@ ATF_TC_BODY(signal_before_unlock, tc) @@ -165,35 +165,35 @@ ATF_TC_BODY(signal_before_unlock, tc)
165 printf("1: After the loop.\n"); 165 printf("1: After the loop.\n");
166 166
167 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); 167 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
168 168
169 printf("1: After releasing the mutex.\n"); 169 printf("1: After releasing the mutex.\n");
170 PTHREAD_REQUIRE(pthread_join(new, &joinval)); 170 PTHREAD_REQUIRE(pthread_join(new, &joinval));
171 171
172 printf("1: Thread joined.\n"); 172 printf("1: Thread joined.\n");
173} 173}
174 174
175static void * 175static void *
176signal_before_unlock_static_init_threadfunc(void *arg) 176signal_before_unlock_static_init_threadfunc(void *arg)
177{ 177{
178 int *share = (int *) arg; 178 int *shared = (int *) arg;
179 179
180 printf("2: Second thread.\n"); 180 printf("2: Second thread.\n");
181 181
182 printf("2: Locking mutex\n"); 182 printf("2: Locking mutex\n");
183 PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); 183 PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex));
184 printf("2: Got mutex.\n"); 184 printf("2: Got mutex.\n");
185 printf("Shared value: %d. Changing to 0.\n", *share); 185 printf("Shared value: %d. Changing to 0.\n", *shared);
186 *share = 0; 186 *shared = 0;
187 187
188 /* Signal first, then unlock, for a different test than #1. */ 188 /* Signal first, then unlock, for a different test than #1. */
189 PTHREAD_REQUIRE(pthread_cond_signal(&static_cond)); 189 PTHREAD_REQUIRE(pthread_cond_signal(&static_cond));
190 PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); 190 PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex));
191 191
192 return NULL; 192 return NULL;
193} 193}
194 194
195ATF_TC(signal_before_unlock_static_init); 195ATF_TC(signal_before_unlock_static_init);
196ATF_TC_HEAD(signal_before_unlock_static_init, tc) 196ATF_TC_HEAD(signal_before_unlock_static_init, tc)
197{ 197{
198 atf_tc_set_md_var(tc, "descr", 198 atf_tc_set_md_var(tc, "descr",
199 "Checks condition variables: signal before unlocking " 199 "Checks condition variables: signal before unlocking "

cvs diff -r1.1 -r1.2 src/tests/lib/libpthread/t_preempt.c (expand / switch to unified diff)

--- src/tests/lib/libpthread/t_preempt.c 2010/07/16 15:42:53 1.1
+++ src/tests/lib/libpthread/t_preempt.c 2010/11/03 16:10:22 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_preempt.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $ */ 1/* $NetBSD: t_preempt.c,v 1.2 2010/11/03 16:10:22 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__COPYRIGHT("@(#) Copyright (c) 2008\ 30__COPYRIGHT("@(#) Copyright (c) 2008\
31 The NetBSD Foundation, inc. All rights reserved."); 31 The NetBSD Foundation, inc. All rights reserved.");
32__RCSID("$NetBSD: t_preempt.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $"); 32__RCSID("$NetBSD: t_preempt.c,v 1.2 2010/11/03 16:10:22 christos Exp $");
33 33
34#include <errno.h> 34#include <errno.h>
35#include <fcntl.h> 35#include <fcntl.h>
36#include <pthread.h> 36#include <pthread.h>
37#include <stdio.h> 37#include <stdio.h>
38#include <stdlib.h> 38#include <stdlib.h>
39#include <string.h> 39#include <string.h>
40#include <unistd.h> 40#include <unistd.h>
41 41
42#include <atf-c.h> 42#include <atf-c.h>
43 43
44#include "h_common.h" 44#include "h_common.h"
45 45
@@ -65,27 +65,28 @@ threadfunc(void *arg) @@ -65,27 +65,28 @@ threadfunc(void *arg)
65 sleep(1); 65 sleep(1);
66 66
67 return NULL; 67 return NULL;
68} 68}
69 69
70ATF_TC(preempt1); 70ATF_TC(preempt1);
71ATF_TC_HEAD(preempt1, tc) 71ATF_TC_HEAD(preempt1, tc)
72{ 72{
73 atf_tc_set_md_var(tc, "descr", 73 atf_tc_set_md_var(tc, "descr",
74 "Checks kernel preemption during a large uiomove"); 74 "Checks kernel preemption during a large uiomove");
75} 75}
76ATF_TC_BODY(preempt1, tc) 76ATF_TC_BODY(preempt1, tc)
77{ 77{
78 int ret, i; 78 int i;
 79 ssize_t rv;
79 pthread_t new; 80 pthread_t new;
80 void *joinval; 81 void *joinval;
81 82
82 char *mem; 83 char *mem;
83 int fd; 84 int fd;
84 85
85 mem = malloc(HUGE_BUFFER); 86 mem = malloc(HUGE_BUFFER);
86 ATF_REQUIRE_MSG(mem != NULL, "%s", strerror(errno)); 87 ATF_REQUIRE_MSG(mem != NULL, "%s", strerror(errno));
87 88
88 fd = open("/dev/urandom", O_RDONLY, 0); 89 fd = open("/dev/urandom", O_RDONLY, 0);
89 ATF_REQUIRE_MSG(fd != -1, "%s", strerror(errno)); 90 ATF_REQUIRE_MSG(fd != -1, "%s", strerror(errno));
90 91
91 printf("1: preempt test\n"); 92 printf("1: preempt test\n");
@@ -100,28 +101,28 @@ ATF_TC_BODY(preempt1, tc) @@ -100,28 +101,28 @@ ATF_TC_BODY(preempt1, tc)
100 for (i = 0; i < NTHREADS; i++) { 101 for (i = 0; i < NTHREADS; i++) {
101 PTHREAD_REQUIRE(pthread_create(&new, NULL, threadfunc, NULL)); 102 PTHREAD_REQUIRE(pthread_create(&new, NULL, threadfunc, NULL));
102 } 103 }
103 104
104 while (started < NTHREADS) { 105 while (started < NTHREADS) {
105 PTHREAD_REQUIRE(pthread_cond_wait(&cond, &mutex)); 106 PTHREAD_REQUIRE(pthread_cond_wait(&cond, &mutex));
106 } 107 }
107 108
108 printf("1: Thread has started.\n"); 109 printf("1: Thread has started.\n");
109 110
110 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); 111 PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex));
111 printf("1: After releasing the mutex.\n"); 112 printf("1: After releasing the mutex.\n");
112 113
113 ret = read(fd, mem, HUGE_BUFFER); 114 rv = read(fd, mem, HUGE_BUFFER);
114 close(fd); 115 close(fd);
115 ATF_REQUIRE_EQ(ret, HUGE_BUFFER); 116 ATF_REQUIRE_EQ(rv, HUGE_BUFFER);
116 117
117 PTHREAD_REQUIRE(pthread_join(new, &joinval)); 118 PTHREAD_REQUIRE(pthread_join(new, &joinval));
118 119
119 printf("1: Thread joined.\n"); 120 printf("1: Thread joined.\n");
120} 121}
121 122
122ATF_TP_ADD_TCS(tp) 123ATF_TP_ADD_TCS(tp)
123{ 124{
124 ATF_TP_ADD_TC(tp, preempt1); 125 ATF_TP_ADD_TC(tp, preempt1);
125 126
126 return atf_no_error(); 127 return atf_no_error();
127} 128}

cvs diff -r1.1 -r1.2 src/tests/lib/libpthread/t_sigmask.c (expand / switch to unified diff)

--- src/tests/lib/libpthread/t_sigmask.c 2010/07/16 15:42:53 1.1
+++ src/tests/lib/libpthread/t_sigmask.c 2010/11/03 16:10:22 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_sigmask.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $ */ 1/* $NetBSD: t_sigmask.c,v 1.2 2010/11/03 16:10:22 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__COPYRIGHT("@(#) Copyright (c) 2008, 2010\ 30__COPYRIGHT("@(#) Copyright (c) 2008, 2010\
31 The NetBSD Foundation, inc. All rights reserved."); 31 The NetBSD Foundation, inc. All rights reserved.");
32__RCSID("$NetBSD: t_sigmask.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $"); 32__RCSID("$NetBSD: t_sigmask.c,v 1.2 2010/11/03 16:10:22 christos Exp $");
33 33
34/* 34/*
35 * Regression test for pthread_sigmask when SA upcalls aren't started yet. 35 * Regression test for pthread_sigmask when SA upcalls aren't started yet.
36 * 36 *
37 * Written by Christian Limpach <cl@NetBSD.org>, December 2003. 37 * Written by Christian Limpach <cl@NetBSD.org>, December 2003.
38 * Public domain. 38 * Public domain.
39 */ 39 */
40 40
41#include <errno.h> 41#include <errno.h>
42#include <pthread.h> 42#include <pthread.h>
43#include <signal.h> 43#include <signal.h>
44#include <stdio.h> 44#include <stdio.h>
45#include <unistd.h> 45#include <unistd.h>
@@ -169,39 +169,39 @@ respected_while_running_threadroutine(vo @@ -169,39 +169,39 @@ respected_while_running_threadroutine(vo
169 return NULL; 169 return NULL;
170} 170}
171 171
172ATF_TC(respected_while_running); 172ATF_TC(respected_while_running);
173ATF_TC_HEAD(respected_while_running, tc) 173ATF_TC_HEAD(respected_while_running, tc)
174{ 174{
175 atf_tc_set_md_var(tc, "descr", "Checks that signal masks are respected " 175 atf_tc_set_md_var(tc, "descr", "Checks that signal masks are respected "
176 "while threads are running"); 176 "while threads are running");
177} 177}
178ATF_TC_BODY(respected_while_running, tc) 178ATF_TC_BODY(respected_while_running, tc)
179{ 179{
180 struct sigaction act; 180 struct sigaction act;
181 pthread_t thread; 181 pthread_t thread;
182 int ret; 182 int rv;
183 183
184 act.sa_sigaction = respected_while_running_handler1; 184 act.sa_sigaction = respected_while_running_handler1;
185 sigemptyset(&act.sa_mask); 185 sigemptyset(&act.sa_mask);
186 sigaddset(&act.sa_mask, SIGUSR2); 186 sigaddset(&act.sa_mask, SIGUSR2);
187 act.sa_flags = SA_SIGINFO; 187 act.sa_flags = SA_SIGINFO;
188 188
189 ATF_REQUIRE_EQ(sigaction(SIGUSR1, &act, NULL), 0); 189 ATF_REQUIRE_EQ(sigaction(SIGUSR1, &act, NULL), 0);
190 190
191 act.sa_sigaction = respected_while_running_handler2; 191 act.sa_sigaction = respected_while_running_handler2;
192 sigemptyset(&act.sa_mask); 192 sigemptyset(&act.sa_mask);
193 act.sa_flags = SA_SIGINFO; 193 act.sa_flags = SA_SIGINFO;
194 ret = sigaction(SIGUSR2, &act, NULL); 194 rv = sigaction(SIGUSR2, &act, NULL);
195 195
196 PTHREAD_REQUIRE(pthread_create(&thread, NULL, 196 PTHREAD_REQUIRE(pthread_create(&thread, NULL,
197 respected_while_running_threadroutine, NULL)); 197 respected_while_running_threadroutine, NULL));
198 PTHREAD_REQUIRE(pthread_join(thread, NULL)); 198 PTHREAD_REQUIRE(pthread_join(thread, NULL));
199} 199}
200 200
201static void 201static void
202incorrect_mask_bug_handler(int sig) 202incorrect_mask_bug_handler(int sig)
203{ 203{
204 count++; 204 count++;
205} 205}
206 206
207static void * 207static void *

cvs diff -r1.1 -r1.2 src/tests/lib/libpthread/Attic/t_status.c (expand / switch to unified diff)

--- src/tests/lib/libpthread/Attic/t_status.c 2010/07/16 15:42:53 1.1
+++ src/tests/lib/libpthread/Attic/t_status.c 2010/11/03 16:10:22 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_status.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $ */ 1/* $NetBSD: t_status.c,v 1.2 2010/11/03 16:10:22 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,51 +19,51 @@ @@ -19,51 +19,51 @@
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__COPYRIGHT("@(#) Copyright (c) 2010\ 30__COPYRIGHT("@(#) Copyright (c) 2010\
31 The NetBSD Foundation, inc. All rights reserved."); 31 The NetBSD Foundation, inc. All rights reserved.");
32__RCSID("$NetBSD: t_status.c,v 1.1 2010/07/16 15:42:53 jmmv Exp $"); 32__RCSID("$NetBSD: t_status.c,v 1.2 2010/11/03 16:10:22 christos Exp $");
33 33
34#include <sys/resource.h> 34#include <sys/resource.h>
35#include <sys/wait.h> 35#include <sys/wait.h>
36 36
37#include <err.h> 37#include <err.h>
38#include <pthread.h> 38#include <pthread.h>
39#include <stdio.h> 39#include <stdio.h>
40#include <stdlib.h> 40#include <stdlib.h>
41#include <string.h> 41#include <string.h>
42#include <unistd.h> 42#include <unistd.h>
43 43
44#include <atf-c.h> 44#include <atf-c.h>
45 45
46#define NUM 100 46#define NUM 100
47 47
48static void * 48static void *
49threadfunc(void *arg) 49threadfunc(void *arg)
50{ 50{
51 51
52 sleep(1000); 52 sleep(1000);
53 return 0; 53 return 0;
54} 54}
55 55
56int 56static int
57child(const int seed) 57child(const int seed)
58{ 58{
59 pthread_t thr[NUM]; 59 pthread_t thr[NUM];
60 int i, j, res, errors; 60 int i, j, res, errors;
61 char nam[20]; 61 char nam[20];
62 struct rlimit sl; 62 struct rlimit sl;
63 63
64 srandom(seed); 64 srandom(seed);
65 getrlimit(RLIMIT_STACK, &sl); 65 getrlimit(RLIMIT_STACK, &sl);
66 66
67 errors = 0; 67 errors = 0;
68 for (i = 0; i < NUM; i++) { 68 for (i = 0; i < NUM; i++) {
69 res = pthread_create(&thr[i], 0, threadfunc, 0); 69 res = pthread_create(&thr[i], 0, threadfunc, 0);
@@ -76,27 +76,27 @@ child(const int seed) @@ -76,27 +76,27 @@ child(const int seed)
76 strerror(res)); 76 strerror(res));
77 errors++; 77 errors++;
78 } 78 }
79 } 79 }
80 if (errors) 80 if (errors)
81 break; 81 break;
82 malloc((random() & 7) * sl.rlim_cur); 82 malloc((random() & 7) * sl.rlim_cur);
83 } 83 }
84 if (errors) 84 if (errors)
85 printf("%d errors; seed was %d\n", errors, seed); 85 printf("%d errors; seed was %d\n", errors, seed);
86 return errors > 0 ? EXIT_FAILURE : EXIT_SUCCESS; 86 return errors > 0 ? EXIT_FAILURE : EXIT_SUCCESS;
87} 87}
88 88
89void 89static void
90do_test(const int seed) 90do_test(const int seed)
91{ 91{
92 pid_t pid = fork(); 92 pid_t pid = fork();
93 ATF_REQUIRE(pid != -1); 93 ATF_REQUIRE(pid != -1);
94 if (pid == 0) { 94 if (pid == 0) {
95 exit(child(seed)); 95 exit(child(seed));
96 } else { 96 } else {
97 int status; 97 int status;
98 ATF_CHECK_EQ(pid, waitpid(pid, &status, 0)); 98 ATF_CHECK_EQ(pid, waitpid(pid, &status, 0));
99 if (!(WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS)) 99 if (!(WIFEXITED(status) && WEXITSTATUS(status) == EXIT_SUCCESS))
100 atf_tc_fail_nonfatal("Check with seed %d failed", seed); 100 atf_tc_fail_nonfatal("Check with seed %d failed", seed);
101 } 101 }
102} 102}

cvs diff -r1.4 -r1.5 src/tests/lib/libpthread/t_sem.c (expand / switch to unified diff)

--- src/tests/lib/libpthread/t_sem.c 2010/07/21 17:23:08 1.4
+++ src/tests/lib/libpthread/t_sem.c 2010/11/03 16:10:22 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_sem.c,v 1.4 2010/07/21 17:23:08 jmmv Exp $ */ 1/* $NetBSD: t_sem.c,v 1.5 2010/11/03 16:10:22 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -76,27 +76,27 @@ @@ -76,27 +76,27 @@
76 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 76 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
77 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 77 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
78 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 78 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
79 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 79 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
80 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 80 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
81 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 81 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
82 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 82 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
83 * 83 *
84 ****************************************************************************/ 84 ****************************************************************************/
85 85
86#include <sys/cdefs.h> 86#include <sys/cdefs.h>
87__COPYRIGHT("@(#) Copyright (c) 2008, 2010\ 87__COPYRIGHT("@(#) Copyright (c) 2008, 2010\
88 The NetBSD Foundation, inc. All rights reserved."); 88 The NetBSD Foundation, inc. All rights reserved.");
89__RCSID("$NetBSD: t_sem.c,v 1.4 2010/07/21 17:23:08 jmmv Exp $"); 89__RCSID("$NetBSD: t_sem.c,v 1.5 2010/11/03 16:10:22 christos Exp $");
90 90
91#include <errno.h> 91#include <errno.h>
92#include <fcntl.h> 92#include <fcntl.h>
93#include <pthread.h> 93#include <pthread.h>
94#include <semaphore.h> 94#include <semaphore.h>
95#include <signal.h> 95#include <signal.h>
96#include <stdio.h> 96#include <stdio.h>
97#include <stdlib.h> 97#include <stdlib.h>
98#include <string.h> 98#include <string.h>
99#include <unistd.h> 99#include <unistd.h>
100 100
101#include <atf-c.h> 101#include <atf-c.h>
102#include <atf-c/config.h> 102#include <atf-c/config.h>
@@ -109,55 +109,55 @@ __RCSID("$NetBSD: t_sem.c,v 1.4 2010/07/ @@ -109,55 +109,55 @@ __RCSID("$NetBSD: t_sem.c,v 1.4 2010/07/
109 109
110#define SEM_REQUIRE(x) \ 110#define SEM_REQUIRE(x) \
111 ATF_REQUIRE_EQ_MSG(x, 0, "%s", strerror(errno)) 111 ATF_REQUIRE_EQ_MSG(x, 0, "%s", strerror(errno))
112 112
113static sem_t sem; 113static sem_t sem;
114 114
115ATF_TC(named); 115ATF_TC(named);
116ATF_TC_HEAD(named, tc) 116ATF_TC_HEAD(named, tc)
117{ 117{
118 atf_tc_set_md_var(tc, "descr", "Checks named semaphores"); 118 atf_tc_set_md_var(tc, "descr", "Checks named semaphores");
119} 119}
120ATF_TC_BODY(named, tc) 120ATF_TC_BODY(named, tc)
121{ 121{
122 sem_t *sem; 122 sem_t *semp;
123 123
124 ATF_REQUIRE_MSG(-1 != sysconf(_SC_SEMAPHORES), "%s", strerror(errno)); 124 ATF_REQUIRE_MSG(-1 != sysconf(_SC_SEMAPHORES), "%s", strerror(errno));
125 125
126 printf("Test begin\n"); 126 printf("Test begin\n");
127 127
128 (void) sem_unlink("/foo"); 128 (void) sem_unlink("/foo");
129 sem = sem_open("/foo", O_CREAT | O_EXCL, 0644, 0); 129 semp = sem_open("/foo", O_CREAT | O_EXCL, 0644, 0);
130 ATF_REQUIRE_MSG(sem != SEM_FAILED, "%s", strerror(errno)); 130 ATF_REQUIRE_MSG(semp != SEM_FAILED, "%s", strerror(errno));
131 SEM_REQUIRE(sem_close(sem)); 131 SEM_REQUIRE(sem_close(semp));
132 SEM_REQUIRE(sem_unlink("/foo")); 132 SEM_REQUIRE(sem_unlink("/foo"));
133 133
134 printf("Test end\n"); 134 printf("Test end\n");
135} 135}
136 136
137ATF_TC(unnamed); 137ATF_TC(unnamed);
138ATF_TC_HEAD(unnamed, tc) 138ATF_TC_HEAD(unnamed, tc)
139{ 139{
140 atf_tc_set_md_var(tc, "descr", "Checks unnamed semaphores"); 140 atf_tc_set_md_var(tc, "descr", "Checks unnamed semaphores");
141} 141}
142 142
143static void * 143static void *
144entry(void * a_arg) 144entry(void * a_arg)
145{ 145{
146 pthread_t self = pthread_self(); 146 pthread_t self = pthread_self();
147 sem_t * sem = (sem_t *) a_arg; 147 sem_t *semp = (sem_t *) a_arg;
148 148
149 printf("Thread %p waiting for semaphore...\n", self); 149 printf("Thread %p waiting for semaphore...\n", self);
150 sem_wait(sem); 150 sem_wait(semp);
151 printf("Thread %p got semaphore\n", self); 151 printf("Thread %p got semaphore\n", self);
152 152
153 return NULL; 153 return NULL;
154} 154}
155 155
156ATF_TC_BODY(unnamed, tc) 156ATF_TC_BODY(unnamed, tc)
157{ 157{
158 sem_t sem_a, sem_b; 158 sem_t sem_a, sem_b;
159 pthread_t threads[NTHREADS]; 159 pthread_t threads[NTHREADS];
160 unsigned i, j; 160 unsigned i, j;
161 int val; 161 int val;
162 162
163 ATF_REQUIRE_MSG(-1 != sysconf(_SC_SEMAPHORES), "%s", strerror(errno)); 163 ATF_REQUIRE_MSG(-1 != sysconf(_SC_SEMAPHORES), "%s", strerror(errno));

File Added: src/tests/lib/semaphore/Makefile.inc
.include "../Makefile.inc"

File Added: src/tests/libexec/Makefile.inc
.include "../Makefile.inc"

cvs diff -r1.1 -r1.2 src/tests/libexec/ld.elf_so/t_dlinfo.c (expand / switch to unified diff)

--- src/tests/libexec/ld.elf_so/t_dlinfo.c 2009/09/24 21:33:45 1.1
+++ src/tests/libexec/ld.elf_so/t_dlinfo.c 2010/11/03 16:10:23 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_dlinfo.c,v 1.1 2009/09/24 21:33:45 pooka Exp $ */ 1/* $NetBSD: t_dlinfo.c,v 1.2 2010/11/03 16:10:23 christos Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2009 The NetBSD Foundation, Inc. 4 * Copyright (c) 2009 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -79,14 +79,15 @@ ATF_TC_BODY(rtld_dlinfo_linkmap_dlopen,  @@ -79,14 +79,15 @@ ATF_TC_BODY(rtld_dlinfo_linkmap_dlopen,
79 ATF_CHECK(handle); 79 ATF_CHECK(handle);
80 80
81 rv = dlinfo(handle, RTLD_DI_LINKMAP, &map); 81 rv = dlinfo(handle, RTLD_DI_LINKMAP, &map);
82 ATF_CHECK_EQ(rv, 0); 82 ATF_CHECK_EQ(rv, 0);
83 ATF_CHECK((strstr(map->l_name, "libutil.so") != NULL)); 83 ATF_CHECK((strstr(map->l_name, "libutil.so") != NULL));
84 dlclose(handle); 84 dlclose(handle);
85} 85}
86 86
87ATF_TP_ADD_TCS(tp) 87ATF_TP_ADD_TCS(tp)
88{ 88{
89 ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_self); 89 ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_self);
90 ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_inval); 90 ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_inval);
91 ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_dlopen); 91 ATF_TP_ADD_TC(tp, rtld_dlinfo_linkmap_dlopen);
 92 return 0;
92} 93}

File Added: src/tests/modules/Makefile.inc
.include "../Makefile.inc"

cvs diff -r1.1 -r1.2 src/tests/modules/t_builtin.c (expand / switch to unified diff)

--- src/tests/modules/t_builtin.c 2010/08/27 09:56:40 1.1
+++ src/tests/modules/t_builtin.c 2010/11/03 16:10:23 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_builtin.c,v 1.1 2010/08/27 09:56:40 pooka Exp $ */ 1/* $NetBSD: t_builtin.c,v 1.2 2010/11/03 16:10:23 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. All rights reserved. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -34,26 +34,28 @@ @@ -34,26 +34,28 @@
34#include <fcntl.h> 34#include <fcntl.h>
35#include <stdbool.h> 35#include <stdbool.h>
36 36
37#include <miscfs/kernfs/kernfs.h> 37#include <miscfs/kernfs/kernfs.h>
38 38
39#include <rump/rump.h> 39#include <rump/rump.h>
40#include <rump/rump_syscalls.h> 40#include <rump/rump_syscalls.h>
41 41
42#include "../h_macros.h" 42#include "../h_macros.h"
43 43
44#define MYMP "/mnt" 44#define MYMP "/mnt"
45#define HZFILE MYMP "/hz" 45#define HZFILE MYMP "/hz"
46 46
 47static char kernfs[] = "kernfs";
 48
47static bool 49static bool
48check_kernfs(void) 50check_kernfs(void)
49{ 51{
50 char buf[16]; 52 char buf[16];
51 bool rv = true; 53 bool rv = true;
52 int fd; 54 int fd;
53 55
54 fd = rump_sys_open(HZFILE, O_RDONLY); 56 fd = rump_sys_open(HZFILE, O_RDONLY);
55 if (fd == -1) 57 if (fd == -1)
56 return false; 58 return false;
57 if (rump_sys_read(fd, buf, sizeof(buf)) < 1) 59 if (rump_sys_read(fd, buf, sizeof(buf)) < 1)
58 rv = false; 60 rv = false;
59 RL(rump_sys_close(fd)); 61 RL(rump_sys_close(fd));
@@ -67,126 +69,126 @@ ATF_TC_HEAD(disable, tc) @@ -67,126 +69,126 @@ ATF_TC_HEAD(disable, tc)
67 69
68 atf_tc_set_md_var(tc, "descr", "Tests that builtin modules can " 70 atf_tc_set_md_var(tc, "descr", "Tests that builtin modules can "
69 "be disabled"); 71 "be disabled");
70} 72}
71 73
72ATF_TC_BODY(disable, tc) 74ATF_TC_BODY(disable, tc)
73{ 75{
74 76
75 rump_init(); 77 rump_init();
76 RL(rump_sys_mkdir(MYMP, 0777)); 78 RL(rump_sys_mkdir(MYMP, 0777));
77 RL(rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0)); 79 RL(rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0));
78 ATF_REQUIRE(check_kernfs()); 80 ATF_REQUIRE(check_kernfs());
79 RL(rump_sys_unmount(MYMP, 0)); 81 RL(rump_sys_unmount(MYMP, 0));
80 RL(rump_sys_modctl(MODCTL_UNLOAD, "kernfs")); 82 RL(rump_sys_modctl(MODCTL_UNLOAD, kernfs));
81} 83}
82 84
83ATF_TC(noauto); 85ATF_TC(noauto);
84ATF_TC_HEAD(noauto, tc) 86ATF_TC_HEAD(noauto, tc)
85{ 87{
86 atf_tc_set_md_var(tc, "descr", "Tests that disabled builtin modules " 88 atf_tc_set_md_var(tc, "descr", "Tests that disabled builtin modules "
87 "will not autoload"); 89 "will not autoload");
88} 90}
89 91
90ATF_TC_BODY(noauto, tc) 92ATF_TC_BODY(noauto, tc)
91{ 93{
92 94
93 rump_init(); 95 rump_init();
94 RL(rump_sys_mkdir(MYMP, 0777)); 96 RL(rump_sys_mkdir(MYMP, 0777));
95 97
96 RL(rump_sys_modctl(MODCTL_UNLOAD, "kernfs")); 98 RL(rump_sys_modctl(MODCTL_UNLOAD, kernfs));
97 99
98 ATF_REQUIRE_ERRNO(ENODEV, 100 ATF_REQUIRE_ERRNO(ENODEV,
99 rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0) == -1); 101 rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0) == -1);
100} 102}
101 103
102ATF_TC(forcereload); 104ATF_TC(forcereload);
103ATF_TC_HEAD(forcereload, tc) 105ATF_TC_HEAD(forcereload, tc)
104{ 106{
105 atf_tc_set_md_var(tc, "descr", "Tests that disabled builtin modules " 107 atf_tc_set_md_var(tc, "descr", "Tests that disabled builtin modules "
106 "can be force-reloaded"); 108 "can be force-reloaded");
107} 109}
108 110
109ATF_TC_BODY(forcereload, tc) 111ATF_TC_BODY(forcereload, tc)
110{ 112{
111 struct modctl_load mod; 113 struct modctl_load mod;
112 114
113 rump_init(); 115 rump_init();
114 RL(rump_sys_mkdir(MYMP, 0777)); 116 RL(rump_sys_mkdir(MYMP, 0777));
115 117
116 RL(rump_sys_modctl(MODCTL_UNLOAD, "kernfs")); 118 RL(rump_sys_modctl(MODCTL_UNLOAD, kernfs));
117 ATF_REQUIRE_ERRNO(ENODEV, 119 ATF_REQUIRE_ERRNO(ENODEV,
118 rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0) == -1); 120 rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0) == -1);
119 121
120 memset(&mod, 0, sizeof(mod)); 122 memset(&mod, 0, sizeof(mod));
121 mod.ml_filename = "kernfs"; 123 mod.ml_filename = kernfs;
122 mod.ml_flags = MODCTL_LOAD_FORCE; 124 mod.ml_flags = MODCTL_LOAD_FORCE;
123 125
124 RL(rump_sys_modctl(MODCTL_LOAD, &mod)); 126 RL(rump_sys_modctl(MODCTL_LOAD, &mod));
125 127
126 RL(rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0)); 128 RL(rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0));
127 ATF_REQUIRE(check_kernfs()); 129 ATF_REQUIRE(check_kernfs());
128 RL(rump_sys_unmount(MYMP, 0)); 130 RL(rump_sys_unmount(MYMP, 0));
129} 131}
130 132
131ATF_TC(disabledstat); 133ATF_TC(disabledstat);
132ATF_TC_HEAD(disabledstat, tc) 134ATF_TC_HEAD(disabledstat, tc)
133{ 135{
134 atf_tc_set_md_var(tc, "descr", "Tests that disabled builtin modules " 136 atf_tc_set_md_var(tc, "descr", "Tests that disabled builtin modules "
135 "show up in modstat with refcount -1"); 137 "show up in modstat with refcount -1");
136} 138}
137 139
138ATF_TC_BODY(disabledstat, tc) 140ATF_TC_BODY(disabledstat, tc)
139{ 141{
140 struct modstat ms[128]; 142 struct modstat ms[128];
141 struct iovec iov; 143 struct iovec iov;
142 int i; 144 size_t i;
143 bool found = false; 145 bool found = false;
144 146
145 rump_init(); 147 rump_init();
146 RL(rump_sys_mkdir(MYMP, 0777)); 148 RL(rump_sys_mkdir(MYMP, 0777));
147 149
148 RL(rump_sys_modctl(MODCTL_UNLOAD, "kernfs")); 150 RL(rump_sys_modctl(MODCTL_UNLOAD, kernfs));
149 151
150 iov.iov_base = ms; 152 iov.iov_base = ms;
151 iov.iov_len = sizeof(ms); 153 iov.iov_len = sizeof(ms);
152 RL(rump_sys_modctl(MODCTL_STAT, &iov)); 154 RL(rump_sys_modctl(MODCTL_STAT, &iov));
153 155
154 for (i = 0; i < __arraycount(ms); i++) { 156 for (i = 0; i < __arraycount(ms); i++) {
155 if (strcmp(ms[i].ms_name, "kernfs") == 0) { 157 if (strcmp(ms[i].ms_name, kernfs) == 0) {
156 ATF_REQUIRE_EQ(ms[i].ms_refcnt, -1); 158 ATF_REQUIRE_EQ(ms[i].ms_refcnt, (u_int)-1);
157 found = 1; 159 found = 1;
158 break; 160 break;
159 } 161 }
160 } 162 }
161 ATF_REQUIRE(found); 163 ATF_REQUIRE(found);
162} 164}
163 165
164ATF_TC(busydisable); 166ATF_TC(busydisable);
165ATF_TC_HEAD(busydisable, tc) 167ATF_TC_HEAD(busydisable, tc)
166{ 168{
167 atf_tc_set_md_var(tc, "descr", "Tests that busy builtin modules " 169 atf_tc_set_md_var(tc, "descr", "Tests that busy builtin modules "
168 "cannot be disabled"); 170 "cannot be disabled");
169} 171}
170 172
171ATF_TC_BODY(busydisable, tc) 173ATF_TC_BODY(busydisable, tc)
172{ 174{
173 175
174 rump_init(); 176 rump_init();
175 RL(rump_sys_mkdir(MYMP, 0777)); 177 RL(rump_sys_mkdir(MYMP, 0777));
176 RL(rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0)); 178 RL(rump_sys_mount(MOUNT_KERNFS, MYMP, 0, NULL, 0));
177 ATF_REQUIRE(check_kernfs()); 179 ATF_REQUIRE(check_kernfs());
178 ATF_REQUIRE_ERRNO(EBUSY, 180 ATF_REQUIRE_ERRNO(EBUSY,
179 rump_sys_modctl(MODCTL_UNLOAD, "kernfs") == -1); 181 rump_sys_modctl(MODCTL_UNLOAD, kernfs) == -1);
180} 182}
181 183
182ATF_TP_ADD_TCS(tp) 184ATF_TP_ADD_TCS(tp)
183{ 185{
184 186
185 ATF_TP_ADD_TC(tp, disable); 187 ATF_TP_ADD_TC(tp, disable);
186 ATF_TP_ADD_TC(tp, noauto); 188 ATF_TP_ADD_TC(tp, noauto);
187 ATF_TP_ADD_TC(tp, forcereload); 189 ATF_TP_ADD_TC(tp, forcereload);
188 ATF_TP_ADD_TC(tp, disabledstat); 190 ATF_TP_ADD_TC(tp, disabledstat);
189 ATF_TP_ADD_TC(tp, busydisable); 191 ATF_TP_ADD_TC(tp, busydisable);
190 192
191 return atf_no_error(); 193 return atf_no_error();
192} 194}

cvs diff -r1.4 -r1.5 src/tests/modules/t_modctl.c (expand / switch to unified diff)

--- src/tests/modules/t_modctl.c 2010/08/21 13:21:48 1.4
+++ src/tests/modules/t_modctl.c 2010/11/03 16:10:23 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_modctl.c,v 1.4 2010/08/21 13:21:48 pgoyette Exp $ */ 1/* $NetBSD: t_modctl.c,v 1.5 2010/11/03 16:10:23 christos Exp $ */
2/* 2/*
3 * Copyright (c) 2008 The NetBSD Foundation, Inc. 3 * Copyright (c) 2008 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 19 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: t_modctl.c,v 1.4 2010/08/21 13:21:48 pgoyette Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: t_modctl.c,v 1.5 2010/11/03 16:10:23 christos Exp $");
31 31
32#include <sys/module.h> 32#include <sys/module.h>
33#include <sys/sysctl.h> 33#include <sys/sysctl.h>
34 34
35#include <assert.h> 35#include <assert.h>
36#include <errno.h> 36#include <errno.h>
37#include <stdarg.h> 37#include <stdarg.h>
38#include <stdbool.h> 38#include <stdbool.h>
39#include <stdio.h> 39#include <stdio.h>
40#include <stdlib.h> 40#include <stdlib.h>
41#include <string.h> 41#include <string.h>
42 42
43#include <prop/proplib.h> 43#include <prop/proplib.h>
@@ -192,27 +192,28 @@ k_helper_is_present(enum presence_check  @@ -192,27 +192,28 @@ k_helper_is_present(enum presence_check
192 found = k_helper_is_present_stat(); 192 found = k_helper_is_present_stat();
193 ATF_CHECK(k_helper_is_present_sysctl() == found); 193 ATF_CHECK(k_helper_is_present_sysctl() == found);
194 break; 194 break;
195 195
196 case stat_check: 196 case stat_check:
197 found = k_helper_is_present_stat(); 197 found = k_helper_is_present_stat();
198 break; 198 break;
199 199
200 case sysctl_check: 200 case sysctl_check:
201 found = k_helper_is_present_sysctl(); 201 found = k_helper_is_present_sysctl();
202 break; 202 break;
203 203
204 default: 204 default:
205 assert(false); 205 found = false;
 206 assert(found);
206 } 207 }
207 208
208 return found; 209 return found;
209} 210}
210 211
211/* 212/*
212 * Loads the specified module from a file. If fatal is set and an error 213 * Loads the specified module from a file. If fatal is set and an error
213 * occurs when loading the module, an error message is printed and the 214 * occurs when loading the module, an error message is printed and the
214 * test case is aborted. 215 * test case is aborted.
215 */ 216 */
216static 217static
217int 218int
218load(prop_dictionary_t props, bool fatal, const char *fmt, ...) 219load(prop_dictionary_t props, bool fatal, const char *fmt, ...)
@@ -273,27 +274,27 @@ unload(const char *name, bool fatal) @@ -273,27 +274,27 @@ unload(const char *name, bool fatal)
273 fprintf(stderr, "modctl(MODCTL_UNLOAD, %s) failed: %s\n", 274 fprintf(stderr, "modctl(MODCTL_UNLOAD, %s) failed: %s\n",
274 name, strerror(err)); 275 name, strerror(err));
275 if (fatal) 276 if (fatal)
276 atf_tc_fail("Module unload failed"); 277 atf_tc_fail("Module unload failed");
277 } 278 }
278 return err; 279 return err;
279} 280}
280 281
281/* 282/*
282 * A silent version of unload, to be called as part of the cleanup 283 * A silent version of unload, to be called as part of the cleanup
283 * process only. 284 * process only.
284 */ 285 */
285static 286static
286int 287void
287unload_cleanup(const char *name) 288unload_cleanup(const char *name)
288{ 289{
289 290
290 (void)modctl(MODCTL_UNLOAD, __UNCONST(name)); 291 (void)modctl(MODCTL_UNLOAD, __UNCONST(name));
291} 292}
292 293
293/* --------------------------------------------------------------------- */ 294/* --------------------------------------------------------------------- */
294/* Test cases */ 295/* Test cases */
295/* --------------------------------------------------------------------- */ 296/* --------------------------------------------------------------------- */
296 297
297ATF_TC_WITH_CLEANUP(cmd_load); 298ATF_TC_WITH_CLEANUP(cmd_load);
298ATF_TC_HEAD(cmd_load, tc) 299ATF_TC_HEAD(cmd_load, tc)
299{ 300{

cvs diff -r1.4 -r1.5 src/tests/modules/k_helper/k_helper.c (expand / switch to unified diff)

--- src/tests/modules/k_helper/k_helper.c 2010/08/21 13:21:48 1.4
+++ src/tests/modules/k_helper/k_helper.c 2010/11/03 16:10:23 1.5
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: k_helper.c,v 1.4 2010/08/21 13:21:48 pgoyette Exp $ */ 1/* $NetBSD: k_helper.c,v 1.5 2010/11/03 16:10:23 christos Exp $ */
2/* 2/*
3 * Copyright (c) 2008 The NetBSD Foundation, Inc. 3 * Copyright (c) 2008 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -17,45 +17,45 @@ @@ -17,45 +17,45 @@
17 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 19 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: k_helper.c,v 1.4 2010/08/21 13:21:48 pgoyette Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: k_helper.c,v 1.5 2010/11/03 16:10:23 christos Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/kernel.h> 33#include <sys/kernel.h>
34#include <sys/module.h> 34#include <sys/module.h>
35#include <sys/sysctl.h> 35#include <sys/sysctl.h>
36 36
37#include <prop/proplib.h> 37#include <prop/proplib.h>
38 38
39MODULE(MODULE_CLASS_MISC, k_helper, NULL); 39MODULE(MODULE_CLASS_MISC, k_helper, NULL);
40 40
41/* --------------------------------------------------------------------- */ 41/* --------------------------------------------------------------------- */
42/* Sysctl interface to query information about the module. */ 42/* Sysctl interface to query information about the module. */
43/* --------------------------------------------------------------------- */ 43/* --------------------------------------------------------------------- */
44 44
45/* TODO: Change the integer variables below that represent booleans to 45/* TODO: Change the integer variables below that represent booleans to
46 * bools, once sysctl(8) supports CTLTYPE_BOOL nodes. */ 46 * bools, once sysctl(8) supports CTLTYPE_BOOL nodes. */
47 47
48static struct sysctllog *clog; 48static struct sysctllog *clogp;
49static int present = 1; 49static int present = 1;
50static int prop_str_ok; 50static int prop_str_ok;
51static char prop_str_val[128]; 51static char prop_str_val[128];
52static int prop_int_ok; 52static int prop_int_ok;
53static int64_t prop_int_val; 53static int64_t prop_int_val;
54static int prop_int_load; 54static int prop_int_load;
55 55
56#define K_HELPER 0x12345678 56#define K_HELPER 0x12345678
57#define K_HELPER_PRESENT 0 57#define K_HELPER_PRESENT 0
58#define K_HELPER_PROP_STR_OK 1 58#define K_HELPER_PROP_STR_OK 1
59#define K_HELPER_PROP_STR_VAL 2 59#define K_HELPER_PROP_STR_VAL 2
60#define K_HELPER_PROP_INT_OK 3 60#define K_HELPER_PROP_INT_OK 3
61#define K_HELPER_PROP_INT_VAL 4 61#define K_HELPER_PROP_INT_VAL 4
@@ -153,37 +153,37 @@ k_helper_init(prop_dictionary_t props) @@ -153,37 +153,37 @@ k_helper_init(prop_dictionary_t props)
153 prop_int_val = -1; 153 prop_int_val = -1;
154 154
155 p = prop_dictionary_get(props, "prop_recurse"); 155 p = prop_dictionary_get(props, "prop_recurse");
156 if (p != NULL && prop_object_type(p) == PROP_TYPE_STRING) { 156 if (p != NULL && prop_object_type(p) == PROP_TYPE_STRING) {
157 const char *recurse_name = prop_string_cstring_nocopy(p); 157 const char *recurse_name = prop_string_cstring_nocopy(p);
158 if (recurse_name != NULL) 158 if (recurse_name != NULL)
159 prop_int_load = module_load(recurse_name, 159 prop_int_load = module_load(recurse_name,
160 MODCTL_NO_PROP, NULL, MODULE_CLASS_ANY); 160 MODCTL_NO_PROP, NULL, MODULE_CLASS_ANY);
161 else 161 else
162 prop_int_load = -1; 162 prop_int_load = -1;
163 } else 163 } else
164 prop_int_load = -2; 164 prop_int_load = -2;
165 165
166 sysctl_k_helper_setup(&clog); 166 sysctl_k_helper_setup(&clogp);
167 167
168 return 0; 168 return 0;
169} 169}
170 170
171static 171static
172int 172int
173k_helper_fini(void *arg) 173k_helper_fini(void *arg)
174{ 174{
175 175
176 sysctl_teardown(&clog); 176 sysctl_teardown(&clogp);
177 177
178 return 0; 178 return 0;
179} 179}
180 180
181static 181static
182int 182int
183k_helper_modcmd(modcmd_t cmd, void *arg) 183k_helper_modcmd(modcmd_t cmd, void *arg)
184{ 184{
185 int ret; 185 int ret;
186 186
187 switch (cmd) { 187 switch (cmd) {
188 case MODULE_CMD_INIT: 188 case MODULE_CMD_INIT:
189 ret = k_helper_init(arg); 189 ret = k_helper_init(arg);

cvs diff -r1.1 -r1.2 src/tests/modules/k_helper2/k_helper2.c (expand / switch to unified diff)

--- src/tests/modules/k_helper2/k_helper2.c 2010/08/21 13:21:48 1.1
+++ src/tests/modules/k_helper2/k_helper2.c 2010/11/03 16:10:23 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: k_helper2.c,v 1.1 2010/08/21 13:21:48 pgoyette Exp $ */ 1/* $NetBSD: k_helper2.c,v 1.2 2010/11/03 16:10:23 christos Exp $ */
2/* 2/*
3 * Copyright (c) 2010 The NetBSD Foundation, Inc. 3 * Copyright (c) 2010 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -17,45 +17,45 @@ @@ -17,45 +17,45 @@
17 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 19 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 24 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: k_helper2.c,v 1.1 2010/08/21 13:21:48 pgoyette Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: k_helper2.c,v 1.2 2010/11/03 16:10:23 christos Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/kernel.h> 33#include <sys/kernel.h>
34#include <sys/module.h> 34#include <sys/module.h>
35#include <sys/sysctl.h> 35#include <sys/sysctl.h>
36 36
37#include <prop/proplib.h> 37#include <prop/proplib.h>
38 38
39MODULE(MODULE_CLASS_MISC, k_helper2, NULL); 39MODULE(MODULE_CLASS_MISC, k_helper2, NULL);
40 40
41/* --------------------------------------------------------------------- */ 41/* --------------------------------------------------------------------- */
42/* Sysctl interface to query information about the module. */ 42/* Sysctl interface to query information about the module. */
43/* --------------------------------------------------------------------- */ 43/* --------------------------------------------------------------------- */
44 44
45/* TODO: Change the integer variables below that represent booleans to 45/* TODO: Change the integer variables below that represent booleans to
46 * bools, once sysctl(8) supports CTLTYPE_BOOL nodes. */ 46 * bools, once sysctl(8) supports CTLTYPE_BOOL nodes. */
47 47
48static struct sysctllog *clog; 48static struct sysctllog *clogp;
49static int present = 1; 49static int present = 1;
50 50
51#define K_HELPER2 0x23456781 51#define K_HELPER2 0x23456781
52#define K_HELPER_PRESENT 0 52#define K_HELPER_PRESENT 0
53 53
54SYSCTL_SETUP(sysctl_k_helper2_setup, "sysctl k_helper subtree setup") 54SYSCTL_SETUP(sysctl_k_helper2_setup, "sysctl k_helper subtree setup")
55{ 55{
56 56
57 sysctl_createv(clog, 0, NULL, NULL, 57 sysctl_createv(clog, 0, NULL, NULL,
58 CTLFLAG_PERMANENT, 58 CTLFLAG_PERMANENT,
59 CTLTYPE_NODE, "k_helper2", NULL, 59 CTLTYPE_NODE, "k_helper2", NULL,
60 NULL, 0, NULL, 0, 60 NULL, 0, NULL, 0,
61 CTL_VENDOR, K_HELPER2, CTL_EOL); 61 CTL_VENDOR, K_HELPER2, CTL_EOL);
@@ -66,37 +66,37 @@ SYSCTL_SETUP(sysctl_k_helper2_setup, "sy @@ -66,37 +66,37 @@ SYSCTL_SETUP(sysctl_k_helper2_setup, "sy
66 SYSCTL_DESCR("Whether the module was loaded or not"), 66 SYSCTL_DESCR("Whether the module was loaded or not"),
67 NULL, 0, &present, 0, 67 NULL, 0, &present, 0,
68 CTL_VENDOR, K_HELPER2, K_HELPER_PRESENT, CTL_EOL); 68 CTL_VENDOR, K_HELPER2, K_HELPER_PRESENT, CTL_EOL);
69} 69}
70 70
71/* --------------------------------------------------------------------- */ 71/* --------------------------------------------------------------------- */
72/* Module management. */ 72/* Module management. */
73/* --------------------------------------------------------------------- */ 73/* --------------------------------------------------------------------- */
74 74
75static 75static
76int 76int
77k_helper2_init(prop_dictionary_t props) 77k_helper2_init(prop_dictionary_t props)
78{ 78{
79 sysctl_k_helper2_setup(&clog); 79 sysctl_k_helper2_setup(&clogp);
80 80
81 return 0; 81 return 0;
82} 82}
83 83
84static 84static
85int 85int
86k_helper2_fini(void *arg) 86k_helper2_fini(void *arg)
87{ 87{
88 88
89 sysctl_teardown(&clog); 89 sysctl_teardown(&clogp);
90 90
91 return 0; 91 return 0;
92} 92}
93 93
94static 94static
95int 95int
96k_helper2_modcmd(modcmd_t cmd, void *arg) 96k_helper2_modcmd(modcmd_t cmd, void *arg)
97{ 97{
98 int ret; 98 int ret;
99 99
100 switch (cmd) { 100 switch (cmd) {
101 case MODULE_CMD_INIT: 101 case MODULE_CMD_INIT:
102 ret = k_helper2_init(arg); 102 ret = k_helper2_init(arg);

File Added: src/tests/net/Makefile.inc
.include "../Makefile.inc"

cvs diff -r1.2 -r1.3 src/tests/net/bpf/t_div-by-zero.c (expand / switch to unified diff)

--- src/tests/net/bpf/t_div-by-zero.c 2010/04/21 11:19:44 1.2
+++ src/tests/net/bpf/t_div-by-zero.c 2010/11/03 16:10:24 1.3
@@ -1,23 +1,24 @@ @@ -1,23 +1,24 @@
1#include <sys/types.h> 1#include <sys/types.h>
2#include <sys/ioctl.h> 2#include <sys/ioctl.h>
3 3
4#include <net/bpf.h> 4#include <net/bpf.h>
5 5
6#include <atf-c.h> 6#include <atf-c.h>
7#include <fcntl.h> 7#include <fcntl.h>
8 8
9#include <rump/rump.h> 9#include <rump/rump.h>
10#include <rump/rumpuser.h> 10#include <rump/rumpuser.h>
 11#include <rump/rump_syscalls.h>
11 12
12ATF_TC(div_by_zero); 13ATF_TC(div_by_zero);
13ATF_TC_HEAD(div_by_zero, tc) 14ATF_TC_HEAD(div_by_zero, tc)
14{ 15{
15 16
16 atf_tc_set_md_var(tc, "descr", "Check that BPF rejects a filter " 17 atf_tc_set_md_var(tc, "descr", "Check that BPF rejects a filter "
17 "which divides by 0"); 18 "which divides by 0");
18} 19}
19 20
20ATF_TC_BODY(div_by_zero, tc) 21ATF_TC_BODY(div_by_zero, tc)
21{ 22{
22 struct bpf_program bp; 23 struct bpf_program bp;
23 int fd; 24 int fd;
@@ -29,25 +30,24 @@ ATF_TC_BODY(div_by_zero, tc) @@ -29,25 +30,24 @@ ATF_TC_BODY(div_by_zero, tc)
29 struct bpf_insn bins[] = { 30 struct bpf_insn bins[] = {
30 { 0x20, 0, 0, 0x00000000 }, 31 { 0x20, 0, 0, 0x00000000 },
31 { 0x34, 0, 0, 0x00000000 }, 32 { 0x34, 0, 0, 0x00000000 },
32 { 0x15, 0, 1, 0x00000002 }, 33 { 0x15, 0, 1, 0x00000002 },
33 { 0x6, 0, 0, 0x00000060 }, 34 { 0x6, 0, 0, 0x00000060 },
34 { 0x6, 0, 0, 0x00000000 }, 35 { 0x6, 0, 0, 0x00000000 },
35 }; 36 };
36 37
37 bp.bf_len = __arraycount(bins); 38 bp.bf_len = __arraycount(bins);
38 bp.bf_insns = bins; 39 bp.bf_insns = bins;
39 40
40 rump_init(); 41 rump_init();
41 fd = rump_sys_open("/dev/bpf", O_RDWR); 42 fd = rump_sys_open("/dev/bpf", O_RDWR);
42 if (fd == -1) 43 ATF_CHECK(fd != -1);
43 err(1, "open bpf"); 
44 ATF_REQUIRE_EQ_MSG(rump_sys_ioctl(fd, BIOCSETF, &bp), -1, 44 ATF_REQUIRE_EQ_MSG(rump_sys_ioctl(fd, BIOCSETF, &bp), -1,
45 "bpf accepted program with division by zero"); 45 "bpf accepted program with division by zero");
46} 46}
47 47
48ATF_TP_ADD_TCS(tp) 48ATF_TP_ADD_TCS(tp)
49{ 49{
50 50
51 ATF_TP_ADD_TC(tp, div_by_zero); 51 ATF_TP_ADD_TC(tp, div_by_zero);
52 return atf_no_error(); 52 return atf_no_error();
53} 53}

cvs diff -r1.2 -r1.3 src/tests/net/carp/Attic/t_basic.c (expand / switch to unified diff)

--- src/tests/net/carp/Attic/t_basic.c 2010/08/11 13:10:03 1.2
+++ src/tests/net/carp/Attic/t_basic.c 2010/11/03 16:10:24 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_basic.c,v 1.2 2010/08/11 13:10:03 pooka Exp $ */ 1/* $NetBSD: t_basic.c,v 1.3 2010/11/03 16:10:24 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,31 +19,32 @@ @@ -19,31 +19,32 @@
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31#ifndef lint 31#ifndef lint
32__RCSID("$NetBSD: t_basic.c,v 1.2 2010/08/11 13:10:03 pooka Exp $"); 32__RCSID("$NetBSD: t_basic.c,v 1.3 2010/11/03 16:10:24 christos Exp $");
33#endif /* not lint */ 33#endif /* not lint */
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36#include <sys/socket.h> 36#include <sys/socket.h>
 37#include <sys/wait.h>
37 38
38#include <netinet/in.h> 39#include <netinet/in.h>
39#include <netinet/in_systm.h> 40#include <netinet/in_systm.h>
40#include <netinet/ip_carp.h> 41#include <netinet/ip_carp.h>
41 42
42#include <rump/rump.h> 43#include <rump/rump.h>
43#include <rump/rump_syscalls.h> 44#include <rump/rump_syscalls.h>
44 45
45#include <atf-c.h> 46#include <atf-c.h>
46#include <errno.h> 47#include <errno.h>
47#include <stdio.h> 48#include <stdio.h>
48#include <stdlib.h> 49#include <stdlib.h>
49#include <string.h> 50#include <string.h>
@@ -116,27 +117,27 @@ child(bool master) @@ -116,27 +117,27 @@ child(bool master)
116 netcfg_rump_if(ifname, "10.1.1.2", "255.255.255.0"); 117 netcfg_rump_if(ifname, "10.1.1.2", "255.255.255.0");
117 118
118 /* configure the carp interface */ 119 /* configure the carp interface */
119 ifr.ifr_data = &cr; 120 ifr.ifr_data = &cr;
120 RL(rump_sys_ioctl(s, SIOCGVH, &ifr)); 121 RL(rump_sys_ioctl(s, SIOCGVH, &ifr));
121 122
122 strlcpy(cr.carpr_carpdev, ifname, sizeof(cr.carpr_carpdev)); 123 strlcpy(cr.carpr_carpdev, ifname, sizeof(cr.carpr_carpdev));
123 cr.carpr_vhid = 175; 124 cr.carpr_vhid = 175;
124 if (master) 125 if (master)
125 cr.carpr_advskew = 0; 126 cr.carpr_advskew = 0;
126 else 127 else
127 cr.carpr_advskew = 200; 128 cr.carpr_advskew = 200;
128 cr.carpr_advbase = 1; 129 cr.carpr_advbase = 1;
129 strcpy(cr.carpr_key, "s3cret"); 130 strcpy((char *)cr.carpr_key, "s3cret");
130 131
131 RL(rump_sys_ioctl(s, SIOCSVH, &ifr)); 132 RL(rump_sys_ioctl(s, SIOCSVH, &ifr));
132 netcfg_rump_if(carpif, "10.1.1.100", "255.255.255.0"); 133 netcfg_rump_if(carpif, "10.1.1.100", "255.255.255.0");
133 134
134 /* tassa pause()en enka muuta voi */ 135 /* tassa pause()en enka muuta voi */
135 pause(); 136 pause();
136} 137}
137 138
138ATF_TC_BODY(handover, tc) 139ATF_TC_BODY(handover, tc)
139{ 140{
140 char ifname[IFNAMSIZ]; 141 char ifname[IFNAMSIZ];
141 pid_t mpid, cpid; 142 pid_t mpid, cpid;
142 int i, status; 143 int i, status;

cvs diff -r1.5 -r1.6 src/tests/net/icmp/t_forward.c (expand / switch to unified diff)

--- src/tests/net/icmp/t_forward.c 2010/07/26 14:10:31 1.5
+++ src/tests/net/icmp/t_forward.c 2010/11/03 16:10:24 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_forward.c,v 1.5 2010/07/26 14:10:31 pooka Exp $ */ 1/* $NetBSD: t_forward.c,v 1.6 2010/11/03 16:10:24 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31#ifndef lint 31#ifndef lint
32__RCSID("$NetBSD: t_forward.c,v 1.5 2010/07/26 14:10:31 pooka Exp $"); 32__RCSID("$NetBSD: t_forward.c,v 1.6 2010/11/03 16:10:24 christos Exp $");
33#endif /* not lint */ 33#endif /* not lint */
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36#include <sys/socket.h> 36#include <sys/socket.h>
37#include <sys/time.h> 37#include <sys/time.h>
38#include <sys/sysctl.h> 38#include <sys/sysctl.h>
39#include <sys/wait.h> 39#include <sys/wait.h>
40 40
41#include <arpa/inet.h> 41#include <arpa/inet.h>
42 42
43#include <netinet/in.h> 43#include <netinet/in.h>
44#include <netinet/in_systm.h> 44#include <netinet/in_systm.h>
45#include <netinet/ip.h> 45#include <netinet/ip.h>
@@ -57,27 +57,26 @@ __RCSID("$NetBSD: t_forward.c,v 1.5 2010 @@ -57,27 +57,26 @@ __RCSID("$NetBSD: t_forward.c,v 1.5 2010
57#include <string.h> 57#include <string.h>
58#include <unistd.h> 58#include <unistd.h>
59 59
60#include "../../h_macros.h" 60#include "../../h_macros.h"
61#include "../config/netconfig.c" 61#include "../config/netconfig.c"
62 62
63/* 63/*
64 * Since our maxttl is in our private namespace, we don't need raw packet 64 * Since our maxttl is in our private namespace, we don't need raw packet
65 * construction like traceroute(8) -- we can just use the global maxttl. 65 * construction like traceroute(8) -- we can just use the global maxttl.
66 */ 66 */
67static void 67static void
68sendttl(void) 68sendttl(void)
69{ 69{
70 extern int rumpns_ip_defttl; 
71 struct sockaddr_in sin; 70 struct sockaddr_in sin;
72 char payload[1024]; 71 char payload[1024];
73 char ifname[IFNAMSIZ]; 72 char ifname[IFNAMSIZ];
74 int mib[4] = { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_DEFTTL }; 73 int mib[4] = { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_DEFTTL };
75 int nv; 74 int nv;
76 int s; 75 int s;
77 76
78 netcfg_rump_makeshmif("bus1", ifname); 77 netcfg_rump_makeshmif("bus1", ifname);
79 netcfg_rump_if(ifname, "1.0.0.1", "255.255.255.0"); 78 netcfg_rump_if(ifname, "1.0.0.1", "255.255.255.0");
80 netcfg_rump_route("0.0.0.0", "0.0.0.0", "1.0.0.2"); /* default router */ 79 netcfg_rump_route("0.0.0.0", "0.0.0.0", "1.0.0.2"); /* default router */
81 80
82 /* set global ttl to 1 */ 81 /* set global ttl to 1 */
83 nv = 1; 82 nv = 1;

cvs diff -r1.8 -r1.9 src/tests/net/icmp/t_ping.c (expand / switch to unified diff)

--- src/tests/net/icmp/t_ping.c 2010/08/26 17:24:14 1.8
+++ src/tests/net/icmp/t_ping.c 2010/11/03 16:10:24 1.9
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_ping.c,v 1.8 2010/08/26 17:24:14 pooka Exp $ */ 1/* $NetBSD: t_ping.c,v 1.9 2010/11/03 16:10:24 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31#ifndef lint 31#ifndef lint
32__RCSID("$NetBSD: t_ping.c,v 1.8 2010/08/26 17:24:14 pooka Exp $"); 32__RCSID("$NetBSD: t_ping.c,v 1.9 2010/11/03 16:10:24 christos Exp $");
33#endif /* not lint */ 33#endif /* not lint */
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36#include <sys/resource.h> 36#include <sys/resource.h>
37#include <sys/sysctl.h> 37#include <sys/sysctl.h>
38#include <sys/wait.h> 38#include <sys/wait.h>
39 39
40#include <atf-c.h> 40#include <atf-c.h>
41#include <assert.h> 41#include <assert.h>
42#include <fcntl.h> 42#include <fcntl.h>
43#include <stdio.h> 43#include <stdio.h>
44#include <stdlib.h> 44#include <stdlib.h>
45#include <string.h> 45#include <string.h>
@@ -119,35 +119,35 @@ in_cksum(void *data, size_t len) @@ -119,35 +119,35 @@ in_cksum(void *data, size_t len)
119 119
120 for (sum = 0; len > 1; len -= 2) 120 for (sum = 0; len > 1; len -= 2)
121 sum += *buf++; 121 sum += *buf++;
122 if (len) 122 if (len)
123 sum += *(uint8_t *)buf; 123 sum += *(uint8_t *)buf;
124 124
125 sum = (sum >> 16) + (sum & 0xffff); 125 sum = (sum >> 16) + (sum & 0xffff);
126 sum += (sum >> 16); 126 sum += (sum >> 16);
127 127
128 return ~sum; 128 return ~sum;
129} 129}
130 130
131static int 131static int
132doping(const char *target, int loops, int pktsize) 132doping(const char *target, int loops, size_t pktsize)
133{ 133{
134 char sndbuf[IP_MAXPACKET - sizeof(struct ip)]; 134 char sndbuf[IP_MAXPACKET - sizeof(struct ip)];
135 char recvbuf[IP_MAXPACKET]; 135 char recvbuf[IP_MAXPACKET];
136 struct sockaddr_in dst, pingee; 136 struct sockaddr_in dst, pingee;
137 struct icmp *icmp; 137 struct icmp *icmp;
138 socklen_t slen; 138 socklen_t slen;
139 ssize_t n; 139 ssize_t n;
140 int loop, i, succ; 140 int loop, succ;
141 int x, xnon, s; 141 int x, xnon, s;
142 142
143 RL(s = rump_sys_socket(PF_INET, SOCK_RAW, IPPROTO_ICMP)); 143 RL(s = rump_sys_socket(PF_INET, SOCK_RAW, IPPROTO_ICMP));
144 RL(x = rump_sys_fcntl(s, F_GETFL, 0)); 144 RL(x = rump_sys_fcntl(s, F_GETFL, 0));
145 xnon = x | O_NONBLOCK; 145 xnon = x | O_NONBLOCK;
146 146
147 memset(&dst, 0, sizeof(dst)); 147 memset(&dst, 0, sizeof(dst));
148 dst.sin_len = sizeof(dst); 148 dst.sin_len = sizeof(dst);
149 dst.sin_family = AF_INET; 149 dst.sin_family = AF_INET;
150 dst.sin_addr.s_addr = inet_addr(target); 150 dst.sin_addr.s_addr = inet_addr(target);
151 151
152 icmp = (struct icmp *)sndbuf; 152 icmp = (struct icmp *)sndbuf;
153 memset(icmp, 0, sizeof(*icmp)); 153 memset(icmp, 0, sizeof(*icmp));
@@ -387,27 +387,27 @@ ATF_TC_BODY(ping_of_death, tc) @@ -387,27 +387,27 @@ ATF_TC_BODY(ping_of_death, tc)
387 icmp->icmp_cksum = in_cksum(icmp, sizeof(*icmp)); 387 icmp->icmp_cksum = in_cksum(icmp, sizeof(*icmp));
388 388
389 for (;;) { 389 for (;;) {
390 int status; 390 int status;
391 391
392 /* resolve arp before sending raw stuff */ 392 /* resolve arp before sending raw stuff */
393 netcfg_rump_pingtest("1.1.1.10", 1); 393 netcfg_rump_pingtest("1.1.1.10", 1);
394 394
395 for (tot = 0; 395 for (tot = 0;
396 tot < 65538 - sizeof(*ip); 396 tot < 65538 - sizeof(*ip);
397 tot += (frag - sizeof(*ip))) { 397 tot += (frag - sizeof(*ip))) {
398 frag = MIN(65538 - tot, sizeof(data)); 398 frag = MIN(65538 - tot, sizeof(data));
399 ip->ip_off = tot >> 3; 399 ip->ip_off = tot >> 3;
400 assert(ip->ip_off << 3 == tot); 400 assert((size_t)ip->ip_off << 3 == tot);
401 ip->ip_len = frag; 401 ip->ip_len = frag;
402 402
403 if (frag == sizeof(data)) { 403 if (frag == sizeof(data)) {
404 ip->ip_off |= IP_MF; 404 ip->ip_off |= IP_MF;
405 } 405 }
406 406
407 RL(rump_sys_sendto(s, data, frag, 0, 407 RL(rump_sys_sendto(s, data, frag, 0,
408 (struct sockaddr *)&dst, sizeof(dst))); 408 (struct sockaddr *)&dst, sizeof(dst)));
409 } 409 }
410 if (waitpid(-1, &status, WNOHANG) > 0) { 410 if (waitpid(-1, &status, WNOHANG) > 0) {
411 if (WIFEXITED(status) && WEXITSTATUS(status) == 0) 411 if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
412 break; 412 break;
413 atf_tc_fail("child did not exit clean"); 413 atf_tc_fail("child did not exit clean");

cvs diff -r1.2 -r1.3 src/tests/net/if_loop/t_pr.c (expand / switch to unified diff)

--- src/tests/net/if_loop/t_pr.c 2010/07/26 14:07:04 1.2
+++ src/tests/net/if_loop/t_pr.c 2010/11/03 16:10:25 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_pr.c,v 1.2 2010/07/26 14:07:04 pooka Exp $ */ 1/* $NetBSD: t_pr.c,v 1.3 2010/11/03 16:10:25 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2010 The NetBSD Foundation, Inc. 4 * Copyright (c) 2010 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -19,27 +19,27 @@ @@ -19,27 +19,27 @@
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30#include <sys/cdefs.h> 30#include <sys/cdefs.h>
31#ifndef lint 31#ifndef lint
32__RCSID("$NetBSD: t_pr.c,v 1.2 2010/07/26 14:07:04 pooka Exp $"); 32__RCSID("$NetBSD: t_pr.c,v 1.3 2010/11/03 16:10:25 christos Exp $");
33#endif /* not lint */ 33#endif /* not lint */
34 34
35#include <sys/types.h> 35#include <sys/types.h>
36#include <sys/socket.h> 36#include <sys/socket.h>
37 37
38#include <netinet/in.h> 38#include <netinet/in.h>
39#include <net/route.h> 39#include <net/route.h>
40 40
41#include <rump/rump.h> 41#include <rump/rump.h>
42#include <rump/rump_syscalls.h> 42#include <rump/rump_syscalls.h>
43 43
44#include <atf-c.h> 44#include <atf-c.h>
45#include <errno.h> 45#include <errno.h>
@@ -52,27 +52,26 @@ __RCSID("$NetBSD: t_pr.c,v 1.2 2010/07/2 @@ -52,27 +52,26 @@ __RCSID("$NetBSD: t_pr.c,v 1.2 2010/07/2
52#include "../../h_macros.h" 52#include "../../h_macros.h"
53 53
54ATF_TC(loopmtu); 54ATF_TC(loopmtu);
55ATF_TC_HEAD(loopmtu, tc) 55ATF_TC_HEAD(loopmtu, tc)
56{ 56{
57 57
58 atf_tc_set_md_var(tc, "descr", "test lo0 fragmentation"); 58 atf_tc_set_md_var(tc, "descr", "test lo0 fragmentation");
59 /* PR kern/43664 */ 59 /* PR kern/43664 */
60} 60}
61 61
62ATF_TC_BODY(loopmtu, tc) 62ATF_TC_BODY(loopmtu, tc)
63{ 63{
64 char ifname[IFNAMSIZ]; 64 char ifname[IFNAMSIZ];
65 size_t len; 
66 struct { 65 struct {
67 struct rt_msghdr m_rtm; 66 struct rt_msghdr m_rtm;
68 struct sockaddr_in m_sin; 67 struct sockaddr_in m_sin;
69 } m_rtmsg; 68 } m_rtmsg;
70#define rtm m_rtmsg.m_rtm 69#define rtm m_rtmsg.m_rtm
71#define rsin m_rtmsg.m_sin 70#define rsin m_rtmsg.m_sin
72 struct sockaddr_in sin; 71 struct sockaddr_in sin;
73 struct ifreq ifr; 72 struct ifreq ifr;
74 char data[2000]; 73 char data[2000];
75 int s; 74 int s;
76 75
77 strcpy(ifname, "lo0"); 76 strcpy(ifname, "lo0");
78 rump_init(); 77 rump_init();

cvs diff -r1.3 -r1.4 src/tests/net/sys/Attic/t_connect.c (expand / switch to unified diff)

--- src/tests/net/sys/Attic/t_connect.c 2010/06/12 15:01:04 1.3
+++ src/tests/net/sys/Attic/t_connect.c 2010/11/03 16:10:25 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_connect.c,v 1.3 2010/06/12 15:01:04 wiz Exp $ */ 1/* $NetBSD: t_connect.c,v 1.4 2010/11/03 16:10:25 christos Exp $ */
2/* 2/*
3 * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. 3 * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -64,30 +64,31 @@ ATF_TC_BODY(low_port, tc) @@ -64,30 +64,31 @@ ATF_TC_BODY(low_port, tc)
64 64
65 val = IP_PORTRANGE_LOW; 65 val = IP_PORTRANGE_LOW;
66 if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, &val, 66 if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, &val,
67 sizeof(val)) == -1) 67 sizeof(val)) == -1)
68 atf_tc_fail("setsockopt failed: %s", strerror(errno)); 68 atf_tc_fail("setsockopt failed: %s", strerror(errno));
69 69
70 memset(&sin, 0, sizeof(sin)); 70 memset(&sin, 0, sizeof(sin));
71 71
72 sin.sin_port = htons(31522); 72 sin.sin_port = htons(31522);
73 sin.sin_addr.s_addr = inet_addr("127.0.0.1"); 73 sin.sin_addr.s_addr = inet_addr("127.0.0.1");
74 sin.sin_family = AF_INET; 74 sin.sin_family = AF_INET;
75 75
76 if (connect(sd, (struct sockaddr *)&sin, sizeof(sin)) == -1) { 76 if (connect(sd, (struct sockaddr *)&sin, sizeof(sin)) == -1) {
77 int err = errno; 77 int serrno = errno;
78 atf_tc_fail("connect failed: %s%s", 78 atf_tc_fail("connect failed: %s%s",
79 strerror(err), 79 strerror(serrno),
80 err != EACCES ? "" : " (see http://mail-index.netbsd.org/" 80 serrno != EACCES ? "" :
 81 " (see http://mail-index.netbsd.org/"
81 "source-changes/2007/12/16/0011.html)"); 82 "source-changes/2007/12/16/0011.html)");
82 } 83 }
83 84
84 slen = sizeof(sin); 85 slen = sizeof(sin);
85 ATF_REQUIRE_EQ(getsockname(sd, (struct sockaddr *)&sin, &slen), 0); 86 ATF_REQUIRE_EQ(getsockname(sd, (struct sockaddr *)&sin, &slen), 0);
86 ATF_REQUIRE_EQ(slen, sizeof(sin)); 87 ATF_REQUIRE_EQ(slen, sizeof(sin));
87 ATF_REQUIRE(ntohs(sin.sin_port) <= IPPORT_RESERVEDMAX); 88 ATF_REQUIRE(ntohs(sin.sin_port) <= IPPORT_RESERVEDMAX);
88 89
89 close(sd); 90 close(sd);
90} 91}
91 92
92ATF_TP_ADD_TCS(tp) 93ATF_TP_ADD_TCS(tp)
93{ 94{

cvs diff -r1.1 -r1.2 src/tests/net/sys/Attic/t_listen.c (expand / switch to unified diff)

--- src/tests/net/sys/Attic/t_listen.c 2008/05/01 15:38:17 1.1
+++ src/tests/net/sys/Attic/t_listen.c 2010/11/03 16:10:25 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: t_listen.c,v 1.1 2008/05/01 15:38:17 jmmv Exp $ */ 1/* $NetBSD: t_listen.c,v 1.2 2010/11/03 16:10:25 christos Exp $ */
2/* 2/*
3 * Copyright (c) 2007 The NetBSD Foundation, Inc. 3 * Copyright (c) 2007 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -44,27 +44,29 @@ ATF_TC_HEAD(low_port, tc) @@ -44,27 +44,29 @@ ATF_TC_HEAD(low_port, tc)
44} 44}
45ATF_TC_BODY(low_port, tc) 45ATF_TC_BODY(low_port, tc)
46{ 46{
47 int sd, val; 47 int sd, val;
48 48
49 sd = socket(AF_INET, SOCK_STREAM, 0); 49 sd = socket(AF_INET, SOCK_STREAM, 0);
50 50
51 val = IP_PORTRANGE_LOW; 51 val = IP_PORTRANGE_LOW;
52 if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, &val, 52 if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE, &val,
53 sizeof(val)) == -1) 53 sizeof(val)) == -1)
54 atf_tc_fail("setsockopt failed: %s", strerror(errno)); 54 atf_tc_fail("setsockopt failed: %s", strerror(errno));
55 55
56 if (listen(sd, 5) == -1) { 56 if (listen(sd, 5) == -1) {
57 int err = errno; 57 int serrno = errno;
58 atf_tc_fail("listen failed: %s%s", 58 atf_tc_fail("listen failed: %s%s",
59 strerror(err), 59 strerror(serrno),
60 err != EACCES ? "" : " (see http://mail-index.netbsd.org/" 60 serrno != EACCES ? "" :
 61 " (see http://mail-index.netbsd.org/"
61 "source-changes/2007/12/16/0011.html)"); 62 "source-changes/2007/12/16/0011.html)");
62 } 63 }
63 64
64 close(sd); 65 close(sd);
65} 66}
66 67
67ATF_TP_ADD_TCS(tp) 68ATF_TP_ADD_TCS(tp)
68{ 69{
69 ATF_TP_ADD_TC(tp, low_port); 70 ATF_TP_ADD_TC(tp, low_port);
 71 return 0;
70} 72}

File Added: src/tests/rump/Makefile.inc
.include "../Makefile.inc"

File Added: src/tests/util/Attic/Makefile.inc
.include "../Makefile.inc"

cvs diff -r1.3 -r1.4 src/tests/util/df/Attic/getmntinfo.c (expand / switch to unified diff)

--- src/tests/util/df/Attic/getmntinfo.c 2008/04/28 20:24:12 1.3
+++ src/tests/util/df/Attic/getmntinfo.c 2010/11/03 16:10:25 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: getmntinfo.c,v 1.3 2008/04/28 20:24:12 martin Exp $ */ 1/* $NetBSD: getmntinfo.c,v 1.4 2010/11/03 16:10:25 christos Exp $ */
2/* 2/*
3 * Copyright (c) 2007 The NetBSD Foundation, Inc. 3 * Copyright (c) 2007 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -169,27 +169,27 @@ setup_strpct(void) @@ -169,27 +169,27 @@ setup_strpct(void)
169#undef AVAIL 169#undef AVAIL
170#undef USED 170#undef USED
171#undef TOTAL 171#undef TOTAL
172#undef BSIZE 172#undef BSIZE
173 }; 173 };
174 174
175 *getnewstatvfs() = tmpl; 175 *getnewstatvfs() = tmpl;
176} 176}
177 177
178/* 178/*
179 * Parameter taken from: 179 * Parameter taken from:
180 * http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=23600 180 * http://www.netbsd.org/cgi-bin/query-pr-single.pl?number=23600
181 */ 181 */
182void 182static void
183setup_pr23600(void) 183setup_pr23600(void)
184{ 184{
185 static const struct statvfs tmpl = { 185 static const struct statvfs tmpl = {
186#define BSIZE 512 186#define BSIZE 512
187#define TOTAL 20971376ULL 187#define TOTAL 20971376ULL
188#define USED 5719864ULL 188#define USED 5719864ULL
189#define AVAIL 15251512ULL 189#define AVAIL 15251512ULL
190 .f_bsize = BSIZE, 190 .f_bsize = BSIZE,
191 .f_frsize = BSIZE, 191 .f_frsize = BSIZE,
192 .f_blocks = TOTAL, 192 .f_blocks = TOTAL,
193 .f_bfree = TOTAL - USED, 193 .f_bfree = TOTAL - USED,
194 .f_bavail = AVAIL, 194 .f_bavail = AVAIL,
195 .f_bresvd = TOTAL - USED - AVAIL, 195 .f_bresvd = TOTAL - USED - AVAIL,

cvs diff -r1.2 -r1.3 src/tests/util/id/Attic/pwgr.c (expand / switch to unified diff)

--- src/tests/util/id/Attic/pwgr.c 2008/04/28 20:24:12 1.2
+++ src/tests/util/id/Attic/pwgr.c 2010/11/03 16:10:26 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pwgr.c,v 1.2 2008/04/28 20:24:12 martin Exp $ */ 1/* $NetBSD: pwgr.c,v 1.3 2010/11/03 16:10:26 christos Exp $ */
2/* 2/*
3 * Copyright (c) 2007 The NetBSD Foundation, Inc. 3 * Copyright (c) 2007 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -29,26 +29,27 @@ @@ -29,26 +29,27 @@
29 * This file implements replacements for all user/group-related functions 29 * This file implements replacements for all user/group-related functions
30 * called by id(1). It provides fake but deterministic user and group 30 * called by id(1). It provides fake but deterministic user and group
31 * information. The details are as such: 31 * information. The details are as such:
32 * User root, uid 0, primary group 0 (wheel). 32 * User root, uid 0, primary group 0 (wheel).
33 * User test, uid 100, primary group 100 (users), secondary group 0 (wheel). 33 * User test, uid 100, primary group 100 (users), secondary group 0 (wheel).
34 */ 34 */
35 35
36#include <sys/types.h> 36#include <sys/types.h>
37 37
38#include <errno.h> 38#include <errno.h>
39#include <grp.h> 39#include <grp.h>
40#include <pwd.h> 40#include <pwd.h>
41#include <stdlib.h> 41#include <stdlib.h>
 42#include <unistd.h>
42#include <string.h> 43#include <string.h>
43 44
44char Login[16]; 45char Login[16];
45struct group GrEntry; 46struct group GrEntry;
46struct passwd PwEntry; 47struct passwd PwEntry;
47 48
48gid_t 49gid_t
49getgid(void) 50getgid(void)
50{ 51{
51 return 100; 52 return 100;
52} 53}
53 54
54gid_t 55gid_t
@@ -79,51 +80,51 @@ char * @@ -79,51 +80,51 @@ char *
79getlogin(void) 80getlogin(void)
80{ 81{
81 strcpy(Login, "test"); 82 strcpy(Login, "test");
82 return Login; 83 return Login;
83} 84}
84 85
85struct group * 86struct group *
86getgrgid(gid_t gid) 87getgrgid(gid_t gid)
87{ 88{
88 struct group *g = &GrEntry; 89 struct group *g = &GrEntry;
89 90
90 memset(g, 0, sizeof(*g)); 91 memset(g, 0, sizeof(*g));
91 if (gid == 0) { 92 if (gid == 0) {
92 g->gr_name = "wheel"; 93 g->gr_name = __UNCONST("wheel");
93 g->gr_gid = 0; 94 g->gr_gid = 0;
94 } else if (gid == 100) { 95 } else if (gid == 100) {
95 g->gr_name = "users"; 96 g->gr_name = __UNCONST("users");
96 g->gr_gid = 100; 97 g->gr_gid = 100;
97 } else 98 } else
98 g = NULL; 99 g = NULL;
99 100
100 return g; 101 return g;
101} 102}
102 103
103int 104int
104getgrouplist(const char *name, int basegid, int *groups, int *ngroups) 105getgrouplist(const char *name, gid_t basegid, gid_t *groups, int *ngroups)
105{ 106{
106 int cnt, ret; 107 int cnt, ret;
107 108
108 if (name == "root") { 109 if (strcmp(name, "root") == 0) {
109 if (*ngroups >= 1) { 110 if (*ngroups >= 1) {
110 groups[0] = basegid; 111 groups[0] = basegid;
111 cnt = 1; 112 cnt = 1;
112 } 113 }
113 114
114 ret = (*ngroups >= cnt) ? 0 : -1; 115 ret = (*ngroups >= cnt) ? 0 : -1;
115 *ngroups = cnt; 116 *ngroups = cnt;
116 } else if (name == "test") { 117 } else if (strcmp(name, "test") == 0) {
117 if (*ngroups >= 1) { 118 if (*ngroups >= 1) {
118 groups[0] = basegid; 119 groups[0] = basegid;
119 cnt = 1; 120 cnt = 1;
120 } 121 }
121 122
122 if (*ngroups >= 2) { 123 if (*ngroups >= 2) {
123 groups[1] = 0; 124 groups[1] = 0;
124 cnt = 2; 125 cnt = 2;
125 } 126 }
126 127
127 ret = (*ngroups >= cnt) ? 0 : -1; 128 ret = (*ngroups >= cnt) ? 0 : -1;
128 *ngroups = cnt; 129 *ngroups = cnt;
129 } else 130 } else
@@ -142,45 +143,45 @@ getgroups(int gidsetlen, gid_t *gidset) @@ -142,45 +143,45 @@ getgroups(int gidsetlen, gid_t *gidset)
142 143
143 gidset[0] = 100; 144 gidset[0] = 100;
144 gidset[1] = 0; 145 gidset[1] = 0;
145 return 2; 146 return 2;
146} 147}
147 148
148struct passwd * 149struct passwd *
149getpwnam(const char *login) 150getpwnam(const char *login)
150{ 151{
151 struct passwd *p = &PwEntry; 152 struct passwd *p = &PwEntry;
152 153
153 memset(p, 0, sizeof(*p)); 154 memset(p, 0, sizeof(*p));
154 if (strcmp(login, "root") == 0) { 155 if (strcmp(login, "root") == 0) {
155 p->pw_name = "root"; 156 p->pw_name = __UNCONST("root");
156 p->pw_uid = 0; 157 p->pw_uid = 0;
157 p->pw_gid = 0; 158 p->pw_gid = 0;
158 } else if (strcmp(login, "test") == 0) { 159 } else if (strcmp(login, "test") == 0) {
159 p->pw_name = "test"; 160 p->pw_name = __UNCONST("test");
160 p->pw_uid = 100; 161 p->pw_uid = 100;
161 p->pw_gid = 100; 162 p->pw_gid = 100;
162 } else 163 } else
163 p = NULL; 164 p = NULL;
164 165
165 return p; 166 return p;
166} 167}
167 168
168struct passwd * 169struct passwd *
169getpwuid(uid_t uid) 170getpwuid(uid_t uid)
170{ 171{
171 struct passwd *p = &PwEntry; 172 struct passwd *p = &PwEntry;
172 173
173 memset(p, 0, sizeof(*p)); 174 memset(p, 0, sizeof(*p));
174 if (uid == 0) { 175 if (uid == 0) {
175 p->pw_name = "root"; 176 p->pw_name = __UNCONST("root");
176 p->pw_uid = 0; 177 p->pw_uid = 0;
177 p->pw_gid = 0; 178 p->pw_gid = 0;
178 } else if (uid == 100) { 179 } else if (uid == 100) {
179 p->pw_name = "test"; 180 p->pw_name = __UNCONST("test");
180 p->pw_uid = 100; 181 p->pw_uid = 100;
181 p->pw_gid = 100; 182 p->pw_gid = 100;
182 } else 183 } else
183 p = NULL; 184 p = NULL;
184 185
185 return p; 186 return p;
186} 187}