summaryrefslogtreecommitdiff
path: root/src/regress
diff options
context:
space:
mode:
Diffstat (limited to 'src/regress')
-rw-r--r--src/regress/lib/libc/Makefile8
-rw-r--r--src/regress/lib/libc/_setjmp/Makefile9
-rw-r--r--src/regress/lib/libc/alloca/Makefile5
-rw-r--r--src/regress/lib/libc/alloca/alloca.c19
-rw-r--r--src/regress/lib/libc/arch/alpha/Makefile3
-rw-r--r--src/regress/lib/libc/arch/alpha/divremtest/Makefile1
-rw-r--r--src/regress/lib/libc/arch/alpha/divremtest/divremtest.c1
-rw-r--r--src/regress/lib/libc/arch/alpha/divremtest/mkcases.c1
-rw-r--r--src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c1
-rw-r--r--src/regress/lib/libc/atexit/Makefile15
-rw-r--r--src/regress/lib/libc/atexit/atexit_test.c139
-rw-r--r--src/regress/lib/libc/atexit/invalid.ok4
-rw-r--r--src/regress/lib/libc/atexit/valid.ok5
-rw-r--r--src/regress/lib/libc/db/Makefile23
-rw-r--r--src/regress/lib/libc/db/README37
-rw-r--r--src/regress/lib/libc/db/dbtest.c347
-rw-r--r--src/regress/lib/libc/db/run.test36
-rw-r--r--src/regress/lib/libc/getaddrinfo/Makefile19
-rw-r--r--src/regress/lib/libc/getaddrinfo/answer104
-rw-r--r--src/regress/lib/libc/getaddrinfo/gaitest.c185
-rw-r--r--src/regress/lib/libc/getaddrinfo/testsuite.sh89
-rw-r--r--src/regress/lib/libc/getopt_long/Makefile32
-rw-r--r--src/regress/lib/libc/getopt_long/getopt_long_test.c119
-rw-r--r--src/regress/lib/libc/getopt_long/test.ok84
-rw-r--r--src/regress/lib/libc/ieeefp/Makefile11
-rw-r--r--src/regress/lib/libc/ieeefp/except/Makefile13
-rw-r--r--src/regress/lib/libc/ieeefp/except/except.c3
-rw-r--r--src/regress/lib/libc/ieeefp/inf/Makefile9
-rw-r--r--src/regress/lib/libc/ieeefp/inf/inf.c16
-rw-r--r--src/regress/lib/libc/ieeefp/round/Makefile11
-rw-r--r--src/regress/lib/libc/ieeefp/round/round.c1
-rw-r--r--src/regress/lib/libc/longjmp/Makefile13
-rw-r--r--src/regress/lib/libc/longjmp/longjmp.c71
-rw-r--r--src/regress/lib/libc/malloc/Makefile5
-rw-r--r--src/regress/lib/libc/malloc/malloc0test.c133
-rw-r--r--src/regress/lib/libc/popen/Makefile5
-rw-r--r--src/regress/lib/libc/popen/popen.c104
-rw-r--r--src/regress/lib/libc/regex/Makefile10
-rw-r--r--src/regress/lib/libc/regex/debug.c3
-rw-r--r--src/regress/lib/libc/regex/debug.ih7
-rw-r--r--src/regress/lib/libc/regex/main.c11
-rw-r--r--src/regress/lib/libc/regex/main.ih17
-rw-r--r--src/regress/lib/libc/regex/split.c1
-rw-r--r--src/regress/lib/libc/regex/tests1
-rw-r--r--src/regress/lib/libc/setjmp-signal/Makefile5
-rw-r--r--src/regress/lib/libc/setjmp-signal/setjmp-signal.c26
-rw-r--r--src/regress/lib/libc/setjmp/Makefile11
-rw-r--r--src/regress/lib/libc/setjmp/jmptest.c12
-rw-r--r--src/regress/lib/libc/sigreturn/Makefile18
-rw-r--r--src/regress/lib/libc/sigreturn/sigret.c181
-rw-r--r--src/regress/lib/libc/sigsetjmp/Makefile12
-rw-r--r--src/regress/lib/libssl/Makefile231
-rw-r--r--src/regress/lib/libssl/README6
-rw-r--r--src/regress/lib/libssl/openssl.cnf29
-rw-r--r--src/regress/lib/libssl/test_client.sh13
-rw-r--r--src/regress/lib/libssl/test_server.sh11
-rw-r--r--src/regress/lib/libssl/testdsa.sh29
-rw-r--r--src/regress/lib/libssl/testenc.sh70
-rw-r--r--src/regress/lib/libssl/testrsa.sh29
59 files changed, 2170 insertions, 244 deletions
diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile
index 7b65e2c1c5..e8c5809eb6 100644
--- a/src/regress/lib/libc/Makefile
+++ b/src/regress/lib/libc/Makefile
@@ -1,6 +1,8 @@
1# $NetBSD: Makefile,v 1.6 1995/04/24 05:52:15 cgd Exp $ 1# $OpenBSD: Makefile,v 1.10 2003/02/12 06:49:04 mickey Exp $
2 2
3SUBDIR+= _setjmp db regex setjmp sigsetjmp 3SUBDIR+= alloca
4SUBDIR+= _setjmp db getaddrinfo regex setjmp sigsetjmp malloc sigreturn popen
5SUBDIR+= longjmp atexit
4.if (${MACHINE_ARCH} != "vax") 6.if (${MACHINE_ARCH} != "vax")
5SUBDIR+= ieeefp 7SUBDIR+= ieeefp
6.endif 8.endif
@@ -9,8 +11,6 @@ SUBDIR+= ieeefp
9SUBDIR+= arch/${MACHINE_ARCH} 11SUBDIR+= arch/${MACHINE_ARCH}
10.endif 12.endif
11 13
12regress: _SUBDIRUSE
13
14install: 14install:
15 15
16.include <bsd.subdir.mk> 16.include <bsd.subdir.mk>
diff --git a/src/regress/lib/libc/_setjmp/Makefile b/src/regress/lib/libc/_setjmp/Makefile
index c2b9dc1aae..5d58242523 100644
--- a/src/regress/lib/libc/_setjmp/Makefile
+++ b/src/regress/lib/libc/_setjmp/Makefile
@@ -1,16 +1,11 @@
1# $OpenBSD: Makefile,v 1.3 2002/01/01 23:00:51 art Exp $
1# $NetBSD: Makefile,v 1.2 1995/04/20 22:38:44 cgd Exp $ 2# $NetBSD: Makefile,v 1.2 1995/04/20 22:38:44 cgd Exp $
2 3
3PROG= _setjmptest 4PROG= _setjmptest
4SRCS= jmptest.c 5SRCS= jmptest.c
5NOMAN= noman, no way, man
6 6
7CFLAGS+= -DTEST_U_SETJMP 7CFLAGS+= -DTEST_U_SETJMP
8 8
9.PATH: ${.CURDIR}/../setjmp 9.PATH: ${.CURDIR}/../setjmp
10 10
11install: 11.include <bsd.regress.mk>
12
13regress: ${PROG}
14 ./${PROG}
15
16.include <bsd.prog.mk>
diff --git a/src/regress/lib/libc/alloca/Makefile b/src/regress/lib/libc/alloca/Makefile
new file mode 100644
index 0000000000..f31417cda7
--- /dev/null
+++ b/src/regress/lib/libc/alloca/Makefile
@@ -0,0 +1,5 @@
1# $OpenBSD: Makefile,v 1.1 2003/02/12 06:49:04 mickey Exp $
2
3PROG= alloca
4
5.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/alloca/alloca.c b/src/regress/lib/libc/alloca/alloca.c
new file mode 100644
index 0000000000..4f1f18396a
--- /dev/null
+++ b/src/regress/lib/libc/alloca/alloca.c
@@ -0,0 +1,19 @@
1/* $OpeBSD$ */
2
3/* Copyright (c) 2003 Michael Shalayeff. Public Domain. */
4
5#include <stdio.h>
6
7int
8main()
9{
10 char *q, *p;
11
12 p = alloca(41);
13 strcpy(p, "hellow world");
14
15 q = alloca(53);
16 strcpy(q, "hellow world");
17
18 exit(strcmp(p, q));
19}
diff --git a/src/regress/lib/libc/arch/alpha/Makefile b/src/regress/lib/libc/arch/alpha/Makefile
index b79a82b0e2..8c4dfb735c 100644
--- a/src/regress/lib/libc/arch/alpha/Makefile
+++ b/src/regress/lib/libc/arch/alpha/Makefile
@@ -1,10 +1,9 @@
1# $OpenBSD: Makefile,v 1.3 2002/02/23 01:25:11 art Exp $
1# $NetBSD: Makefile,v 1.1 1995/04/24 05:53:31 cgd Exp $ 2# $NetBSD: Makefile,v 1.1 1995/04/24 05:53:31 cgd Exp $
2 3
3# do nothing here; none of the tests here can be run automatically 4# do nothing here; none of the tests here can be run automatically
4SUBDIR= 5SUBDIR=
5 6
6regress: _SUBDIRUSE
7
8install: 7install:
9 8
10.include <bsd.subdir.mk> 9.include <bsd.subdir.mk>
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/Makefile b/src/regress/lib/libc/arch/alpha/divremtest/Makefile
index bd3b12f537..1da3ac8494 100644
--- a/src/regress/lib/libc/arch/alpha/divremtest/Makefile
+++ b/src/regress/lib/libc/arch/alpha/divremtest/Makefile
@@ -1,3 +1,4 @@
1# $OpenBSD: Makefile,v 1.2 2001/01/29 02:05:39 niklas Exp $
1# $NetBSD: Makefile,v 1.1 1995/04/24 05:53:34 cgd Exp $ 2# $NetBSD: Makefile,v 1.1 1995/04/24 05:53:34 cgd Exp $
2 3
3PROG= divremtest 4PROG= divremtest
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c b/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c
index fcf64c9384..3d9e8a6de2 100644
--- a/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c
+++ b/src/regress/lib/libc/arch/alpha/divremtest/divremtest.c
@@ -1,3 +1,4 @@
1/* $OpenBSD: divremtest.c,v 1.2 2001/01/29 02:05:39 niklas Exp $ */
1/* $NetBSD: divremtest.c,v 1.1 1995/04/24 05:53:35 cgd Exp $ */ 2/* $NetBSD: divremtest.c,v 1.1 1995/04/24 05:53:35 cgd Exp $ */
2 3
3/* 4/*
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c b/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c
index 65ca17af4c..fcb4765b8c 100644
--- a/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c
+++ b/src/regress/lib/libc/arch/alpha/divremtest/mkcases.c
@@ -1,3 +1,4 @@
1/* $OpenBSD: mkcases.c,v 1.2 2001/01/29 02:05:39 niklas Exp $ */
1/* $NetBSD: mkcases.c,v 1.1 1995/04/24 05:53:36 cgd Exp $ */ 2/* $NetBSD: mkcases.c,v 1.1 1995/04/24 05:53:36 cgd Exp $ */
2 3
3/* 4/*
diff --git a/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c b/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c
index ef02d61d70..3b01653f32 100644
--- a/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c
+++ b/src/regress/lib/libc/arch/alpha/divremtest/mktestcases.c
@@ -1,3 +1,4 @@
1/* $OpenBSD: mktestcases.c,v 1.2 2001/01/29 02:05:40 niklas Exp $ */
1/* $NetBSD: mktestcases.c,v 1.1 1995/04/24 05:53:37 cgd Exp $ */ 2/* $NetBSD: mktestcases.c,v 1.1 1995/04/24 05:53:37 cgd Exp $ */
2 3
3/* 4/*
diff --git a/src/regress/lib/libc/atexit/Makefile b/src/regress/lib/libc/atexit/Makefile
new file mode 100644
index 0000000000..8731e9d421
--- /dev/null
+++ b/src/regress/lib/libc/atexit/Makefile
@@ -0,0 +1,15 @@
1# $OpenBSD: Makefile,v 1.4 2002/10/21 20:40:50 mickey Exp $
2
3NOMAN=
4PROG=atexit_test
5CPPFLAGS+=-I${.CURDIR}/../../../../lib/libc
6
7run-regress-atexit_test: ${PROG}
8 ./${PROG} -valid 2>${.OBJDIR}/valid.out
9 cmp -s ${.OBJDIR}/valid.out ${.CURDIR}/valid.ok
10 ./${PROG} -invalid-atexit 2>${.OBJDIR}/invalid.out
11 cmp -s ${.OBJDIR}/invalid.out ${.CURDIR}/invalid.ok
12 ./${PROG} -invalid-cleanup 2>${.OBJDIR}/invalid.out
13 cmp -s ${.OBJDIR}/invalid.out ${.CURDIR}/invalid.ok
14
15.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/atexit/atexit_test.c b/src/regress/lib/libc/atexit/atexit_test.c
new file mode 100644
index 0000000000..df316e3372
--- /dev/null
+++ b/src/regress/lib/libc/atexit/atexit_test.c
@@ -0,0 +1,139 @@
1/* $OpenBSD: atexit_test.c,v 1.3 2002/10/21 20:40:50 mickey Exp $ */
2
3/*
4 * Copyright (c) 2002 Daniel Hartmeier
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * - Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * - Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 *
31 * Effort sponsored in part by the Defense Advanced Research Projects
32 * Agency (DARPA) and Air Force Research Laboratory, Air Force
33 * Materiel Command, USAF, under agreement number F30602-01-2-0537.
34 *
35 */
36
37#include <stdio.h>
38#include <stdlib.h>
39#include <signal.h>
40#include "stdlib/atexit.h"
41
42void handle_first();
43void handle_middle();
44void handle_last();
45void handle_invalid();
46void handle_cleanup();
47void handle_signal(int);
48
49static int counter;
50
51int
52main(int argc, char *argv[])
53{
54 int i;
55
56 if (argc != 2 || (strcmp(argv[1], "-valid") &&
57 strcmp(argv[1], "-invalid-atexit") &&
58 strcmp(argv[1], "-invalid-cleanup"))) {
59 fprintf(stderr, "%s -valid/-invalid-atexit/-invalid-cleanup\n",
60 argv[0]);
61 return (1);
62 }
63 fprintf(stderr, "main()\n");
64 if (atexit(handle_last)) {
65 perror("atexit(handle_last) failed");
66 return (1);
67 }
68 for (i = 0; i < 65535; ++i) {
69 if (atexit(handle_middle)) {
70 perror("atexit(handle_middle) failed");
71 return (1);
72 }
73 }
74 if (atexit(handle_first)) {
75 perror("atexit(handle_first) failed");
76 return (1);
77 }
78 /* this is supposed to segfault */
79 if (!strcmp(argv[1], "-invalid-atexit")) {
80 signal(SIGSEGV, handle_signal);
81 __atexit->fns[0] = handle_invalid;
82 } else if (!strcmp(argv[1], "-invalid-cleanup")) {
83 struct atexit *p = __atexit;
84
85 signal(SIGSEGV, handle_signal);
86 while (p != NULL && p->next != NULL)
87 p = p->next;
88 if (p == NULL)
89 fprintf(stderr, "p == NULL, no page found\n");
90 p->fns[0] = handle_invalid;
91 }
92 __atexit_register_cleanup(handle_cleanup);
93 counter = 0;
94 fprintf(stderr, "main() returns\n");
95 return (0);
96}
97
98void
99handle_first()
100{
101 fprintf(stderr, "handle_first() counter == %i\n", counter);
102}
103
104void
105handle_middle()
106{
107 counter++;
108}
109
110void
111handle_last()
112{
113 fprintf(stderr, "handle_last() counter == %i\n", counter);
114}
115
116void
117handle_cleanup()
118{
119 fprintf(stderr, "handle_cleanup()\n");
120}
121
122void
123handle_invalid()
124{
125 fprintf(stderr, "handle_invalid() THIS SHOULD HAVE SEGFAULTED INSTEAD!\n");
126}
127
128void
129handle_signal(int sigraised)
130{
131 switch (sigraised) {
132 case SIGSEGV:
133 fprintf(stderr, "SIGSEGV\n");
134 exit(0);
135 default:
136 fprintf(stderr, "unexpected signal caught\n");
137 exit(1);
138 }
139}
diff --git a/src/regress/lib/libc/atexit/invalid.ok b/src/regress/lib/libc/atexit/invalid.ok
new file mode 100644
index 0000000000..98cbf8c1de
--- /dev/null
+++ b/src/regress/lib/libc/atexit/invalid.ok
@@ -0,0 +1,4 @@
1main()
2SIGSEGV
3handle_first() counter == 0
4handle_last() counter == 65535
diff --git a/src/regress/lib/libc/atexit/valid.ok b/src/regress/lib/libc/atexit/valid.ok
new file mode 100644
index 0000000000..6509e827a7
--- /dev/null
+++ b/src/regress/lib/libc/atexit/valid.ok
@@ -0,0 +1,5 @@
1main()
2main() returns
3handle_first() counter == 0
4handle_last() counter == 65535
5handle_cleanup()
diff --git a/src/regress/lib/libc/db/Makefile b/src/regress/lib/libc/db/Makefile
index 5bf343bf64..7d2882594d 100644
--- a/src/regress/lib/libc/db/Makefile
+++ b/src/regress/lib/libc/db/Makefile
@@ -1,17 +1,22 @@
1# $NetBSD: Makefile,v 1.10 1995/04/20 22:39:11 cgd Exp $ 1# $OpenBSD: Makefile,v 1.10 2002/09/02 20:01:43 avsm Exp $
2# @(#)Makefile 8.1 (Berkeley) 6/4/93 2# $NetBSD: Makefile,v 1.11 1995/12/12 01:54:15 cgd Exp $
3 3
4PROG= dbtest 4PROG= dbtest
5 5
6# add -DSTATISTICS to CFLAGS to get usage statistics. Note that 6# add -DSTATISTICS to CFLAGS to get usage statistics. Note that
7# for this to work, libc must be compiled with -DSTATISTICS as well 7# for this to work, libc must be compiled with -DSTATISTICS as well
8CFLAGS= -g -D__DBINTERFACE_PRIVATE -DDEBUG 8CFLAGS+= -g -D__DBINTERFACE_PRIVATE -DDEBUG
9NOMAN= noman 9CLEANFILES+= t1 t2 t3 log
10CLEANFILES+= t1 t2 t3
11 10
12install: 11DBTARGETS=1 2 3 4 5 6 7 8 9 10 11 12 13 20
13 12
14regress: 13.for DT in ${DBTARGETS}
15 sh ${.CURDIR}/run.test 14db-${DT}: ${PROG}
15 sh ${.CURDIR}/run.test ${DT}
16REGRESS_TARGETS+=db-${DT}
17.PHONY: db-${DT}
18.endfor
16 19
17.include <bsd.prog.mk> 20REGRESS_SLOW_TARGETS+=db-3 db-12 db-20
21
22.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/db/README b/src/regress/lib/libc/db/README
index 3b290b09d8..23a1b77221 100644
--- a/src/regress/lib/libc/db/README
+++ b/src/regress/lib/libc/db/README
@@ -1,5 +1,6 @@
1# $NetBSD: README,v 1.4 1995/04/20 22:39:18 cgd Exp $ 1# $OpenBSD: README,v 1.3 2001/01/29 02:05:40 niklas Exp $
2# @(#)README 8.4 (Berkeley) 6/20/94 2# $NetBSD: README,v 1.5 1996/05/03 21:54:19 cgd Exp $
3# @(#)README 8.8 (Berkeley) 7/31/94
3 4
4To run the tests, enter "make regress". 5To run the tests, enter "make regress".
5 6
@@ -9,8 +10,11 @@ the test runs, and even larger files (the database files) are created in
9variable TMPDIR to a directory where the files can be built. 10variable TMPDIR to a directory where the files can be built.
10 11
11=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 12=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
12The script file consists of lines with a initial character which is 13The script file consists of lines with an initial character which is
13the "command" for that line. Legal characters are as follows: 14the command for that line, or an initial character indicating a key
15or data entry for a previous command.
16
17Legal command characters are as follows:
14 18
15c: compare a record 19c: compare a record
16 + must be followed by [kK][dD]; the data value in the database 20 + must be followed by [kK][dD]; the data value in the database
@@ -19,17 +23,24 @@ c: compare a record
19e: echo a string 23e: echo a string
20 + writes out the rest of the line into the output file; if the 24 + writes out the rest of the line into the output file; if the
21 last character is not a carriage-return, a newline is appended. 25 last character is not a carriage-return, a newline is appended.
26f: set the flags for the next command
27 + no value zero's the flags
22g: do a get command 28g: do a get command
23 + must be followed by [kK] 29 + must be followed by [kK]
24 + writes out the retrieved data DBT. 30 + writes out the retrieved data DBT.
31o [r]: dump [reverse]
32 + dump the database out, if 'r' is set, in reverse order.
25p: do a put command 33p: do a put command
26 + must be followed by [kK][dD] 34 + must be followed by [kK][dD]
27r: do a del command 35r: do a del command
28 + must be followed by [kK] 36 + must be followed by [kK] unless R_CURSOR flag set.
37S: sync the database
29s: do a seq command 38s: do a seq command
39 + must be followed by [kK] if R_CURSOR flag set.
30 + writes out the retrieved data DBT. 40 + writes out the retrieved data DBT.
31f: set the flags for the next command 41
32 + no value zero's the flags 42Legal key/data characters are as follows:
43
33D [file]: data file 44D [file]: data file
34 + set the current data value to the contents of the file 45 + set the current data value to the contents of the file
35d [data]: 46d [data]:
@@ -38,17 +49,21 @@ K [file]: key file
38 + set the current key value to the contents of the file 49 + set the current key value to the contents of the file
39k [data]: 50k [data]:
40 + set the current key value to the contents of the line. 51 + set the current key value to the contents of the line.
41o [r]: dump [reverse] 52
42 + dump the database out, if 'r' is set, in reverse order. 53Blank lines, lines with leading white space, and lines with leading
54hash marks (#) are ignored.
43 55
44Options to dbtest are as follows: 56Options to dbtest are as follows:
45 57
58 -d: Set the DB_LOCK flag.
46 -f: Use the file argument as the database file. 59 -f: Use the file argument as the database file.
47 -i: Use the rest of the argument to set elements in the info 60 -i: Use the rest of the argument to set elements in the info
48 structure. If the type is btree, then "-i cachesize=10240" 61 structure. If the type is btree, then "-i cachesize=10240"
49 will set BTREEINFO.cachesize to 10240. 62 will set BTREEINFO.cachesize to 10240.
50 -o: The rest of the argument is the output file instead of 63 -o: The rest of the argument is the output file instead of
51 using stdout. 64 using stdout.
65 -s: Don't delete the database file before opening it, i.e.
66 use the database file from a previous run.
52 67
53Dbtest requires two arguments, the type of access "hash", "recno" or 68Dbtest requires two arguments, the type of access "hash", "recno"
54"btree", and the script name. 69or "btree", and the script name or "-" to indicate stdin.
diff --git a/src/regress/lib/libc/db/dbtest.c b/src/regress/lib/libc/db/dbtest.c
index 1fcf09af97..a48e19c452 100644
--- a/src/regress/lib/libc/db/dbtest.c
+++ b/src/regress/lib/libc/db/dbtest.c
@@ -1,7 +1,8 @@
1/* $NetBSD: dbtest.c,v 1.7 1995/04/20 22:39:22 cgd Exp $ */ 1/* $OpenBSD: dbtest.c,v 1.9 2002/02/19 19:39:38 millert Exp $ */
2/* $NetBSD: dbtest.c,v 1.8 1996/05/03 21:57:48 cgd Exp $ */
2 3
3/*- 4/*-
4 * Copyright (c) 1992, 1993 5 * Copyright (c) 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved. 6 * The Regents of the University of California. All rights reserved.
6 * 7 *
7 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
@@ -35,15 +36,15 @@
35 36
36#ifndef lint 37#ifndef lint
37static char copyright[] = 38static char copyright[] =
38"@(#) Copyright (c) 1992, 1993\n\ 39"@(#) Copyright (c) 1992, 1993, 1994\n\
39 The Regents of the University of California. All rights reserved.\n"; 40 The Regents of the University of California. All rights reserved.\n";
40#endif /* not lint */ 41#endif /* not lint */
41 42
42#ifndef lint 43#ifndef lint
43#if 0 44#if 0
44static char sccsid[] = "@(#)dbtest.c 8.8 (Berkeley) 2/21/94"; 45static char sccsid[] = "@(#)dbtest.c 8.17 (Berkeley) 9/1/94";
45#else 46#else
46static char rcsid[] = "$NetBSD: dbtest.c,v 1.7 1995/04/20 22:39:22 cgd Exp $"; 47static char rcsid[] = "$OpenBSD: dbtest.c,v 1.9 2002/02/19 19:39:38 millert Exp $";
47#endif 48#endif
48#endif /* not lint */ 49#endif /* not lint */
49 50
@@ -57,34 +58,38 @@ static char rcsid[] = "$NetBSD: dbtest.c,v 1.7 1995/04/20 22:39:22 cgd Exp $";
57#include <stdio.h> 58#include <stdio.h>
58#include <stdlib.h> 59#include <stdlib.h>
59#include <string.h> 60#include <string.h>
61#include <stdarg.h>
60#include <unistd.h> 62#include <unistd.h>
61 63
62#include <db.h> 64#include <db.h>
63 65
64enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA }; 66enum S { COMMAND, COMPARE, GET, PUT, REMOVE, SEQ, SEQFLAG, KEY, DATA };
65 67
66void compare __P((DBT *, DBT *)); 68void compare(DBT *, DBT *);
67DBTYPE dbtype __P((char *)); 69DBTYPE dbtype(char *);
68void dump __P((DB *, int)); 70void dump(DB *, int);
69void err __P((const char *, ...)); 71void dberr(const char *, ...);
70void get __P((DB *, DBT *)); 72void get(DB *, DBT *);
71void getdata __P((DB *, DBT *, DBT *)); 73void getdata(DB *, DBT *, DBT *);
72void put __P((DB *, DBT *, DBT *)); 74void put(DB *, DBT *, DBT *);
73void rem __P((DB *, DBT *)); 75void rem(DB *, DBT *);
74void *rfile __P((char *, size_t *)); 76char *sflags(int);
75void seq __P((DB *, DBT *)); 77void synk(DB *);
76u_int setflags __P((char *)); 78void *rfile(char *, size_t *);
77void *setinfo __P((DBTYPE, char *)); 79void seq(DB *, DBT *);
78void usage __P((void)); 80u_int setflags(char *);
79void *xmalloc __P((char *, size_t)); 81void *setinfo(DBTYPE, char *);
80 82void usage(void);
81DBTYPE type; 83void *xmalloc(char *, size_t);
82void *infop; 84
83u_long lineno; 85DBTYPE type; /* Database type. */
84u_int flags; 86void *infop; /* Iflags. */
85int ofd = STDOUT_FILENO; 87u_long lineno; /* Current line in test script. */
88u_int flags; /* Current DB flags. */
89int ofd = STDOUT_FILENO; /* Standard output fd. */
86 90
87DB *XXdbp; /* Global for gdb. */ 91DB *XXdbp; /* Global for gdb. */
92int XXlineno; /* Fast breakpoint for gdb. */
88 93
89int 94int
90main(argc, argv) 95main(argc, argv)
@@ -97,14 +102,15 @@ main(argc, argv)
97 DB *dbp; 102 DB *dbp;
98 DBT data, key, keydata; 103 DBT data, key, keydata;
99 size_t len; 104 size_t len;
100 int ch, oflags; 105 int ch, oflags, sflag;
101 char *fname, *infoarg, *p, buf[8 * 1024]; 106 char *fname, *infoarg, *p, *t, buf[8 * 1024];
102 107
103 infoarg = NULL; 108 infoarg = NULL;
104 fname = NULL; 109 fname = NULL;
105 oflags = O_CREAT | O_RDWR; 110 oflags = O_CREAT | O_RDWR;
106 while ((ch = getopt(argc, argv, "f:i:lo:")) != EOF) 111 sflag = 0;
107 switch(ch) { 112 while ((ch = getopt(argc, argv, "f:i:lo:s")) != -1)
113 switch (ch) {
108 case 'f': 114 case 'f':
109 fname = optarg; 115 fname = optarg;
110 break; 116 break;
@@ -117,7 +123,10 @@ main(argc, argv)
117 case 'o': 123 case 'o':
118 if ((ofd = open(optarg, 124 if ((ofd = open(optarg,
119 O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0) 125 O_WRONLY|O_CREAT|O_TRUNC, 0666)) < 0)
120 err("%s: %s", optarg, strerror(errno)); 126 dberr("%s: %s", optarg, strerror(errno));
127 break;
128 case 's':
129 sflag = 1;
121 break; 130 break;
122 case '?': 131 case '?':
123 default: 132 default:
@@ -133,8 +142,8 @@ main(argc, argv)
133 type = dbtype(*argv++); 142 type = dbtype(*argv++);
134 143
135 /* Open the descriptor file. */ 144 /* Open the descriptor file. */
136 if (freopen(*argv, "r", stdin) == NULL) 145 if (strcmp(*argv, "-") && freopen(*argv, "r", stdin) == NULL)
137 err("%s: %s", *argv, strerror(errno)); 146 dberr("%s: %s", *argv, strerror(errno));
138 147
139 /* Set up the db structure as necessary. */ 148 /* Set up the db structure as necessary. */
140 if (infoarg == NULL) 149 if (infoarg == NULL)
@@ -145,7 +154,10 @@ main(argc, argv)
145 if (*p != '\0') 154 if (*p != '\0')
146 infop = setinfo(type, p); 155 infop = setinfo(type, p);
147 156
148 /* Open the DB. */ 157 /*
158 * Open the DB. Delete any preexisting copy, you almost never
159 * want it around, and it often screws up tests.
160 */
149 if (fname == NULL) { 161 if (fname == NULL) {
150 p = getenv("TMPDIR"); 162 p = getenv("TMPDIR");
151 if (p == NULL) 163 if (p == NULL)
@@ -153,53 +165,82 @@ main(argc, argv)
153 (void)sprintf(buf, "%s/__dbtest", p); 165 (void)sprintf(buf, "%s/__dbtest", p);
154 fname = buf; 166 fname = buf;
155 (void)unlink(buf); 167 (void)unlink(buf);
156 } 168 } else if (!sflag)
169 (void)unlink(fname);
170
157 if ((dbp = dbopen(fname, 171 if ((dbp = dbopen(fname,
158 oflags, S_IRUSR | S_IWUSR, type, infop)) == NULL) 172 oflags, S_IRUSR | S_IWUSR, type, infop)) == NULL)
159 err("dbopen: %s", strerror(errno)); 173 dberr("dbopen: %s", strerror(errno));
160 XXdbp = dbp; 174 XXdbp = dbp;
161 175
162 state = COMMAND; 176 state = COMMAND;
163 for (lineno = 1; 177 for (lineno = 1;
164 (p = fgets(buf, sizeof(buf), stdin)) != NULL; ++lineno) { 178 (p = fgets(buf, sizeof(buf), stdin)) != NULL; ++lineno) {
165 len = strlen(buf); 179 /* Delete the newline, displaying the key/data is easier. */
166 switch(*p) { 180 if (ofd == STDOUT_FILENO && (t = strchr(p, '\n')) != NULL)
181 *t = '\0';
182 if ((len = strlen(buf)) == 0 || isspace(*p) || *p == '#')
183 continue;
184
185 /* Convenient gdb break point. */
186 if (XXlineno == lineno)
187 XXlineno = 1;
188 switch (*p) {
167 case 'c': /* compare */ 189 case 'c': /* compare */
168 if (state != COMMAND) 190 if (state != COMMAND)
169 err("line %lu: not expecting command", lineno); 191 dberr("line %lu: not expecting command",
192 lineno);
170 state = KEY; 193 state = KEY;
171 command = COMPARE; 194 command = COMPARE;
172 break; 195 break;
173 case 'e': /* echo */ 196 case 'e': /* echo */
174 if (state != COMMAND) 197 if (state != COMMAND)
175 err("line %lu: not expecting command", lineno); 198 dberr("line %lu: not expecting command",
199 lineno);
176 /* Don't display the newline, if CR at EOL. */ 200 /* Don't display the newline, if CR at EOL. */
177 if (p[len - 2] == '\r') 201 if (p[len - 2] == '\r')
178 --len; 202 --len;
179 if (write(ofd, p + 1, len - 1) != len - 1) 203 if (write(ofd, p + 1, len - 1) != len - 1 ||
180 err("write: %s", strerror(errno)); 204 write(ofd, "\n", 1) != 1)
205 dberr("write: %s", strerror(errno));
181 break; 206 break;
182 case 'g': /* get */ 207 case 'g': /* get */
183 if (state != COMMAND) 208 if (state != COMMAND)
184 err("line %lu: not expecting command", lineno); 209 dberr("line %lu: not expecting command",
210 lineno);
185 state = KEY; 211 state = KEY;
186 command = GET; 212 command = GET;
187 break; 213 break;
188 case 'p': /* put */ 214 case 'p': /* put */
189 if (state != COMMAND) 215 if (state != COMMAND)
190 err("line %lu: not expecting command", lineno); 216 dberr("line %lu: not expecting command",
217 lineno);
191 state = KEY; 218 state = KEY;
192 command = PUT; 219 command = PUT;
193 break; 220 break;
194 case 'r': /* remove */ 221 case 'r': /* remove */
195 if (state != COMMAND) 222 if (state != COMMAND)
196 err("line %lu: not expecting command", lineno); 223 dberr("line %lu: not expecting command",
197 state = KEY; 224 lineno);
198 command = REMOVE; 225 if (flags == R_CURSOR) {
226 rem(dbp, &key);
227 state = COMMAND;
228 } else {
229 state = KEY;
230 command = REMOVE;
231 }
232 break;
233 case 'S': /* sync */
234 if (state != COMMAND)
235 dberr("line %lu: not expecting command",
236 lineno);
237 synk(dbp);
238 state = COMMAND;
199 break; 239 break;
200 case 's': /* seq */ 240 case 's': /* seq */
201 if (state != COMMAND) 241 if (state != COMMAND)
202 err("line %lu: not expecting command", lineno); 242 dberr("line %lu: not expecting command",
243 lineno);
203 if (flags == R_CURSOR) { 244 if (flags == R_CURSOR) {
204 state = KEY; 245 state = KEY;
205 command = SEQ; 246 command = SEQ;
@@ -211,15 +252,15 @@ main(argc, argv)
211 break; 252 break;
212 case 'D': /* data file */ 253 case 'D': /* data file */
213 if (state != DATA) 254 if (state != DATA)
214 err("line %lu: not expecting data", lineno); 255 dberr("line %lu: not expecting data", lineno);
215 data.data = rfile(p + 1, &data.size); 256 data.data = rfile(p + 1, &data.size);
216 goto ldata; 257 goto ldata;
217 case 'd': /* data */ 258 case 'd': /* data */
218 if (state != DATA) 259 if (state != DATA)
219 err("line %lu: not expecting data", lineno); 260 dberr("line %lu: not expecting data", lineno);
220 data.data = xmalloc(p + 1, len - 1); 261 data.data = xmalloc(p + 1, len - 1);
221 data.size = len - 1; 262 data.size = len - 1;
222ldata: switch(command) { 263ldata: switch (command) {
223 case COMPARE: 264 case COMPARE:
224 compare(&keydata, &data); 265 compare(&keydata, &data);
225 break; 266 break;
@@ -227,7 +268,7 @@ ldata: switch(command) {
227 put(dbp, &key, &data); 268 put(dbp, &key, &data);
228 break; 269 break;
229 default: 270 default:
230 err("line %lu: command doesn't take data", 271 dberr("line %lu: command doesn't take data",
231 lineno); 272 lineno);
232 } 273 }
233 if (type != DB_RECNO) 274 if (type != DB_RECNO)
@@ -237,15 +278,15 @@ ldata: switch(command) {
237 break; 278 break;
238 case 'K': /* key file */ 279 case 'K': /* key file */
239 if (state != KEY) 280 if (state != KEY)
240 err("line %lu: not expecting a key", lineno); 281 dberr("line %lu: not expecting a key", lineno);
241 if (type == DB_RECNO) 282 if (type == DB_RECNO)
242 err("line %lu: 'K' not available for recno", 283 dberr("line %lu: 'K' not available for recno",
243 lineno); 284 lineno);
244 key.data = rfile(p + 1, &key.size); 285 key.data = rfile(p + 1, &key.size);
245 goto lkey; 286 goto lkey;
246 case 'k': /* key */ 287 case 'k': /* key */
247 if (state != KEY) 288 if (state != KEY)
248 err("line %lu: not expecting a key", lineno); 289 dberr("line %lu: not expecting a key", lineno);
249 if (type == DB_RECNO) { 290 if (type == DB_RECNO) {
250 static recno_t recno; 291 static recno_t recno;
251 recno = atoi(p + 1); 292 recno = atoi(p + 1);
@@ -255,7 +296,7 @@ ldata: switch(command) {
255 key.data = xmalloc(p + 1, len - 1); 296 key.data = xmalloc(p + 1, len - 1);
256 key.size = len - 1; 297 key.size = len - 1;
257 } 298 }
258lkey: switch(command) { 299lkey: switch (command) {
259 case COMPARE: 300 case COMPARE:
260 getdata(dbp, &key, &keydata); 301 getdata(dbp, &key, &keydata);
261 state = DATA; 302 state = DATA;
@@ -271,18 +312,18 @@ lkey: switch(command) {
271 break; 312 break;
272 case REMOVE: 313 case REMOVE:
273 rem(dbp, &key); 314 rem(dbp, &key);
274 if (type != DB_RECNO) 315 if ((type != DB_RECNO) && (flags != R_CURSOR))
275 free(key.data); 316 free(key.data);
276 state = COMMAND; 317 state = COMMAND;
277 break; 318 break;
278 case SEQ: 319 case SEQ:
279 seq(dbp, &key); 320 seq(dbp, &key);
280 if (type != DB_RECNO) 321 if ((type != DB_RECNO) && (flags != R_CURSOR))
281 free(key.data); 322 free(key.data);
282 state = COMMAND; 323 state = COMMAND;
283 break; 324 break;
284 default: 325 default:
285 err("line %lu: command doesn't take a key", 326 dberr("line %lu: command doesn't take a key",
286 lineno); 327 lineno);
287 } 328 }
288 break; 329 break;
@@ -290,22 +331,25 @@ lkey: switch(command) {
290 dump(dbp, p[1] == 'r'); 331 dump(dbp, p[1] == 'r');
291 break; 332 break;
292 default: 333 default:
293 err("line %lu: %s: unknown command character", 334 dberr("line %lu: %s: unknown command character",
294 p, lineno); 335 lineno, p);
295 } 336 }
296 } 337 }
297#ifdef STATISTICS 338#ifdef STATISTICS
298 if (type == DB_BTREE) 339 /*
340 * -l must be used (DB_LOCK must be set) for this to be
341 * used, otherwise a page will be locked and it will fail.
342 */
343 if (type == DB_BTREE && oflags & DB_LOCK)
299 __bt_stat(dbp); 344 __bt_stat(dbp);
300#endif 345#endif
301 if (dbp->close(dbp)) 346 if (dbp->close(dbp))
302 err("db->close: %s", strerror(errno)); 347 dberr("db->close: %s", strerror(errno));
303 (void)close(ofd); 348 (void)close(ofd);
304 exit(0); 349 exit(0);
305} 350}
306 351
307#define NOOVERWRITE "put failed, would overwrite key\n" 352#define NOOVERWRITE "put failed, would overwrite key\n"
308#define NOSUCHKEY "get failed, no such key\n"
309 353
310void 354void
311compare(db1, db2) 355compare(db1, db2)
@@ -334,17 +378,23 @@ get(dbp, kp)
334{ 378{
335 DBT data; 379 DBT data;
336 380
337 switch(dbp->get(dbp, kp, &data, flags)) { 381 switch (dbp->get(dbp, kp, &data, flags)) {
338 case 0: 382 case 0:
339 (void)write(ofd, data.data, data.size); 383 (void)write(ofd, data.data, data.size);
384 if (ofd == STDOUT_FILENO)
385 (void)write(ofd, "\n", 1);
340 break; 386 break;
341 case -1: 387 case -1:
342 err("line %lu: get: %s", lineno, strerror(errno)); 388 dberr("line %lu: get: %s", lineno, strerror(errno));
343 /* NOTREACHED */ 389 /* NOTREACHED */
344 case 1: 390 case 1:
345 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); 391#define NOSUCHKEY "get failed, no such key\n"
346 (void)fprintf(stderr, "%d: %.*s: %s\n", 392 if (ofd != STDOUT_FILENO)
347 lineno, kp->size, kp->data, NOSUCHKEY); 393 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
394 else
395 (void)fprintf(stderr, "%d: %.*s: %s",
396 lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
397#undef NOSUCHKEY
348 break; 398 break;
349 } 399 }
350} 400}
@@ -354,14 +404,14 @@ getdata(dbp, kp, dp)
354 DB *dbp; 404 DB *dbp;
355 DBT *kp, *dp; 405 DBT *kp, *dp;
356{ 406{
357 switch(dbp->get(dbp, kp, dp, flags)) { 407 switch (dbp->get(dbp, kp, dp, flags)) {
358 case 0: 408 case 0:
359 return; 409 return;
360 case -1: 410 case -1:
361 err("line %lu: getdata: %s", lineno, strerror(errno)); 411 dberr("line %lu: getdata: %s", lineno, strerror(errno));
362 /* NOTREACHED */ 412 /* NOTREACHED */
363 case 1: 413 case 1:
364 err("line %lu: get failed, no such key", lineno); 414 dberr("line %lu: getdata failed, no such key", lineno);
365 /* NOTREACHED */ 415 /* NOTREACHED */
366 } 416 }
367} 417}
@@ -371,11 +421,11 @@ put(dbp, kp, dp)
371 DB *dbp; 421 DB *dbp;
372 DBT *kp, *dp; 422 DBT *kp, *dp;
373{ 423{
374 switch(dbp->put(dbp, kp, dp, flags)) { 424 switch (dbp->put(dbp, kp, dp, flags)) {
375 case 0: 425 case 0:
376 break; 426 break;
377 case -1: 427 case -1:
378 err("line %lu: put: %s", lineno, strerror(errno)); 428 dberr("line %lu: put: %s", lineno, strerror(errno));
379 /* NOTREACHED */ 429 /* NOTREACHED */
380 case 1: 430 case 1:
381 (void)write(ofd, NOOVERWRITE, sizeof(NOOVERWRITE) - 1); 431 (void)write(ofd, NOOVERWRITE, sizeof(NOOVERWRITE) - 1);
@@ -388,34 +438,67 @@ rem(dbp, kp)
388 DB *dbp; 438 DB *dbp;
389 DBT *kp; 439 DBT *kp;
390{ 440{
391 switch(dbp->del(dbp, kp, flags)) { 441 switch (dbp->del(dbp, kp, flags)) {
392 case 0: 442 case 0:
393 break; 443 break;
394 case -1: 444 case -1:
395 err("line %lu: get: %s", lineno, strerror(errno)); 445 dberr("line %lu: rem: %s", lineno, strerror(errno));
396 /* NOTREACHED */ 446 /* NOTREACHED */
397 case 1: 447 case 1:
398 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); 448#define NOSUCHKEY "rem failed, no such key\n"
449 if (ofd != STDOUT_FILENO)
450 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
451 else if (flags != R_CURSOR)
452 (void)fprintf(stderr, "%d: %.*s: %s",
453 lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
454 else
455 (void)fprintf(stderr,
456 "%d: rem of cursor failed\n", lineno);
457#undef NOSUCHKEY
399 break; 458 break;
400 } 459 }
401} 460}
402 461
403void 462void
463synk(dbp)
464 DB *dbp;
465{
466 switch (dbp->sync(dbp, flags)) {
467 case 0:
468 break;
469 case -1:
470 dberr("line %lu: synk: %s", lineno, strerror(errno));
471 /* NOTREACHED */
472 }
473}
474
475void
404seq(dbp, kp) 476seq(dbp, kp)
405 DB *dbp; 477 DB *dbp;
406 DBT *kp; 478 DBT *kp;
407{ 479{
408 DBT data; 480 DBT data;
409 481
410 switch(dbp->seq(dbp, kp, &data, flags)) { 482 switch (dbp->seq(dbp, kp, &data, flags)) {
411 case 0: 483 case 0:
412 (void)write(ofd, data.data, data.size); 484 (void)write(ofd, data.data, data.size);
485 if (ofd == STDOUT_FILENO)
486 (void)write(ofd, "\n", 1);
413 break; 487 break;
414 case -1: 488 case -1:
415 err("line %lu: seq: %s", lineno, strerror(errno)); 489 dberr("line %lu: seq: %s", lineno, strerror(errno));
416 /* NOTREACHED */ 490 /* NOTREACHED */
417 case 1: 491 case 1:
418 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1); 492#define NOSUCHKEY "seq failed, no such key\n"
493 if (ofd != STDOUT_FILENO)
494 (void)write(ofd, NOSUCHKEY, sizeof(NOSUCHKEY) - 1);
495 else if (flags == R_CURSOR)
496 (void)fprintf(stderr, "%d: %.*s: %s",
497 lineno, MIN(kp->size, 20), kp->data, NOSUCHKEY);
498 else
499 (void)fprintf(stderr,
500 "%d: seq (%s) failed\n", lineno, sflags(flags));
501#undef NOSUCHKEY
419 break; 502 break;
420 } 503 }
421} 504}
@@ -436,14 +519,16 @@ dump(dbp, rev)
436 nflags = R_NEXT; 519 nflags = R_NEXT;
437 } 520 }
438 for (;; flags = nflags) 521 for (;; flags = nflags)
439 switch(dbp->seq(dbp, &key, &data, flags)) { 522 switch (dbp->seq(dbp, &key, &data, flags)) {
440 case 0: 523 case 0:
441 (void)write(ofd, data.data, data.size); 524 (void)write(ofd, data.data, data.size);
525 if (ofd == STDOUT_FILENO)
526 (void)write(ofd, "\n", 1);
442 break; 527 break;
443 case 1: 528 case 1:
444 goto done; 529 goto done;
445 case -1: 530 case -1:
446 err("line %lu: (dump) seq: %s", 531 dberr("line %lu: (dump) seq: %s",
447 lineno, strerror(errno)); 532 lineno, strerror(errno));
448 /* NOTREACHED */ 533 /* NOTREACHED */
449 } 534 }
@@ -454,34 +539,45 @@ u_int
454setflags(s) 539setflags(s)
455 char *s; 540 char *s;
456{ 541{
457 char *p, *index(); 542 char *p;
458 543
459 for (; isspace(*s); ++s); 544 for (; isspace(*s); ++s);
460 if (*s == '\n') 545 if (*s == '\n' || *s == '\0')
461 return (0); 546 return (0);
462 if ((p = index(s, '\n')) != NULL) 547 if ((p = strchr(s, '\n')) != NULL)
463 *p = '\0'; 548 *p = '\0';
464 if (!strcmp(s, "R_CURSOR")) 549 if (!strcmp(s, "R_CURSOR")) return (R_CURSOR);
465 return (R_CURSOR); 550 if (!strcmp(s, "R_FIRST")) return (R_FIRST);
466 if (!strcmp(s, "R_FIRST")) 551 if (!strcmp(s, "R_IAFTER")) return (R_IAFTER);
467 return (R_FIRST); 552 if (!strcmp(s, "R_IBEFORE")) return (R_IBEFORE);
468 if (!strcmp(s, "R_IAFTER")) 553 if (!strcmp(s, "R_LAST")) return (R_LAST);
469 return (R_IAFTER); 554 if (!strcmp(s, "R_NEXT")) return (R_NEXT);
470 if (!strcmp(s, "R_IBEFORE")) 555 if (!strcmp(s, "R_NOOVERWRITE")) return (R_NOOVERWRITE);
471 return (R_IBEFORE); 556 if (!strcmp(s, "R_PREV")) return (R_PREV);
472 if (!strcmp(s, "R_LAST")) 557 if (!strcmp(s, "R_SETCURSOR")) return (R_SETCURSOR);
473 return (R_LAST); 558
474 if (!strcmp(s, "R_NEXT")) 559 dberr("line %lu: %s: unknown flag", lineno, s);
475 return (R_NEXT);
476 if (!strcmp(s, "R_NOOVERWRITE"))
477 return (R_NOOVERWRITE);
478 if (!strcmp(s, "R_PREV"))
479 return (R_PREV);
480 if (!strcmp(s, "R_SETCURSOR"))
481 return (R_SETCURSOR);
482 err("line %lu: %s: unknown flag", lineno, s);
483 /* NOTREACHED */ 560 /* NOTREACHED */
484} 561}
562
563char *
564sflags(flags)
565 int flags;
566{
567 switch (flags) {
568 case R_CURSOR: return ("R_CURSOR");
569 case R_FIRST: return ("R_FIRST");
570 case R_IAFTER: return ("R_IAFTER");
571 case R_IBEFORE: return ("R_IBEFORE");
572 case R_LAST: return ("R_LAST");
573 case R_NEXT: return ("R_NEXT");
574 case R_NOOVERWRITE: return ("R_NOOVERWRITE");
575 case R_PREV: return ("R_PREV");
576 case R_SETCURSOR: return ("R_SETCURSOR");
577 }
578
579 return ("UNKNOWN!");
580}
485 581
486DBTYPE 582DBTYPE
487dbtype(s) 583dbtype(s)
@@ -493,7 +589,7 @@ dbtype(s)
493 return (DB_HASH); 589 return (DB_HASH);
494 if (!strcmp(s, "recno")) 590 if (!strcmp(s, "recno"))
495 return (DB_RECNO); 591 return (DB_RECNO);
496 err("%s: unknown type (use btree, hash or recno)", s); 592 dberr("%s: unknown type (use btree, hash or recno)", s);
497 /* NOTREACHED */ 593 /* NOTREACHED */
498} 594}
499 595
@@ -505,15 +601,15 @@ setinfo(type, s)
505 static BTREEINFO ib; 601 static BTREEINFO ib;
506 static HASHINFO ih; 602 static HASHINFO ih;
507 static RECNOINFO rh; 603 static RECNOINFO rh;
508 char *eq, *index(); 604 char *eq;
509 605
510 if ((eq = index(s, '=')) == NULL) 606 if ((eq = strchr(s, '=')) == NULL)
511 err("%s: illegal structure set statement", s); 607 dberr("%s: illegal structure set statement", s);
512 *eq++ = '\0'; 608 *eq++ = '\0';
513 if (!isdigit(*eq)) 609 if (!isdigit(*eq))
514 err("%s: structure set statement must be a number", s); 610 dberr("%s: structure set statement must be a number", s);
515 611
516 switch(type) { 612 switch (type) {
517 case DB_BTREE: 613 case DB_BTREE:
518 if (!strcmp("flags", s)) { 614 if (!strcmp("flags", s)) {
519 ib.flags = atoi(eq); 615 ib.flags = atoi(eq);
@@ -589,7 +685,7 @@ setinfo(type, s)
589 } 685 }
590 break; 686 break;
591 } 687 }
592 err("%s: unknown structure value", s); 688 dberr("%s: unknown structure value", s);
593 /* NOTREACHED */ 689 /* NOTREACHED */
594} 690}
595 691
@@ -601,20 +697,20 @@ rfile(name, lenp)
601 struct stat sb; 697 struct stat sb;
602 void *p; 698 void *p;
603 int fd; 699 int fd;
604 char *np, *index(); 700 char *np;
605 701
606 for (; isspace(*name); ++name); 702 for (; isspace(*name); ++name);
607 if ((np = index(name, '\n')) != NULL) 703 if ((np = strchr(name, '\n')) != NULL)
608 *np = '\0'; 704 *np = '\0';
609 if ((fd = open(name, O_RDONLY, 0)) < 0 || 705 if ((fd = open(name, O_RDONLY, 0)) < 0 ||
610 fstat(fd, &sb)) 706 fstat(fd, &sb))
611 err("%s: %s\n", name, strerror(errno)); 707 dberr("%s: %s\n", name, strerror(errno));
612#ifdef NOT_PORTABLE 708#ifdef NOT_PORTABLE
613 if (sb.st_size > (off_t)SIZE_T_MAX) 709 if (sb.st_size > (off_t)SIZE_T_MAX)
614 err("%s: %s\n", name, strerror(E2BIG)); 710 dberr("%s: %s\n", name, strerror(E2BIG));
615#endif 711#endif
616 if ((p = (void *)malloc((u_int)sb.st_size)) == NULL) 712 if ((p = (void *)malloc((u_int)sb.st_size)) == NULL)
617 err("%s", strerror(errno)); 713 dberr("%s", strerror(errno));
618 (void)read(fd, p, (int)sb.st_size); 714 (void)read(fd, p, (int)sb.st_size);
619 *lenp = sb.st_size; 715 *lenp = sb.st_size;
620 (void)close(fd); 716 (void)close(fd);
@@ -629,7 +725,7 @@ xmalloc(text, len)
629 void *p; 725 void *p;
630 726
631 if ((p = (void *)malloc(len)) == NULL) 727 if ((p = (void *)malloc(len)) == NULL)
632 err("%s", strerror(errno)); 728 dberr("%s", strerror(errno));
633 memmove(p, text, len); 729 memmove(p, text, len);
634 return (p); 730 return (p);
635} 731}
@@ -642,27 +738,12 @@ usage()
642 exit(1); 738 exit(1);
643} 739}
644 740
645#if __STDC__
646#include <stdarg.h>
647#else
648#include <varargs.h>
649#endif
650
651void 741void
652#if __STDC__ 742dberr(const char *fmt, ...)
653err(const char *fmt, ...)
654#else
655err(fmt, va_alist)
656 char *fmt;
657 va_dcl
658#endif
659{ 743{
660 va_list ap; 744 va_list ap;
661#if __STDC__ 745
662 va_start(ap, fmt); 746 va_start(ap, fmt);
663#else
664 va_start(ap);
665#endif
666 (void)fprintf(stderr, "dbtest: "); 747 (void)fprintf(stderr, "dbtest: ");
667 (void)vfprintf(stderr, fmt, ap); 748 (void)vfprintf(stderr, fmt, ap);
668 va_end(ap); 749 va_end(ap);
diff --git a/src/regress/lib/libc/db/run.test b/src/regress/lib/libc/db/run.test
index 4073310a31..0d6837e360 100644
--- a/src/regress/lib/libc/db/run.test
+++ b/src/regress/lib/libc/db/run.test
@@ -1,19 +1,28 @@
1#!/bin/sh - 1#!/bin/sh -
2# $NetBSD: run.test,v 1.7 1995/04/20 22:39:27 cgd Exp $
3# 2#
4# @(#)run.test 8.8 (Berkeley) 6/16/94 3# $OpenBSD: run.test,v 1.3 2001/01/29 02:05:41 niklas Exp $
4# $NetBSD: run.test,v 1.8 1996/05/03 21:57:51 cgd Exp $
5# @(#)run.test 8.10 (Berkeley) 7/26/94
5# 6#
6 7
7# db regression tests 8# db regression tests
8main() 9main()
9{ 10{
10 11
11DICT=/usr/share/dict/web2 12 PROG=./dbtest
12PROG=./dbtest 13 TMP1=t1
13TMP1=t1 14 TMP2=t2
14TMP2=t2 15 TMP3=t3
15TMP3=t3
16 16
17 if [ -f /usr/share/dict/words ]; then
18 DICT=/usr/share/dict/words
19 elif [ -f /usr/dict/words ]; then
20 DICT=/usr/dict/words
21 else
22 echo 'run.test: no dictionary'
23 exit 1
24 fi
25
17 if [ $# -eq 0 ]; then 26 if [ $# -eq 0 ]; then
18 for t in 1 2 3 4 5 6 7 8 9 10 11 12 13 20; do 27 for t in 1 2 3 4 5 6 7 8 9 10 11 12 13 20; do
19 test$t 28 test$t
@@ -345,7 +354,7 @@ test7()
345 for (i = 1; i <= 120; ++i) 354 for (i = 1; i <= 120; ++i)
346 printf("%05d: input key %d: %s\n", i, i, $0); 355 printf("%05d: input key %d: %s\n", i, i, $0);
347 printf("%05d: input key %d: %s\n", 120, 120, $0); 356 printf("%05d: input key %d: %s\n", 120, 120, $0);
348 printf("get failed, no such key\n"); 357 printf("seq failed, no such key\n");
349 printf("%05d: input key %d: %s\n", 1, 1, $0); 358 printf("%05d: input key %d: %s\n", 1, 1, $0);
350 printf("%05d: input key %d: %s\n", 2, 2, $0); 359 printf("%05d: input key %d: %s\n", 2, 2, $0);
351 exit; 360 exit;
@@ -364,10 +373,10 @@ test7()
364 for (i = 1; i <= 120; ++i) 373 for (i = 1; i <= 120; ++i)
365 printf("s\n"); 374 printf("s\n");
366 printf("fR_CURSOR\ns\nk120\n"); 375 printf("fR_CURSOR\ns\nk120\n");
367 printf("r\nk120\n"); 376 printf("r\n");
368 printf("fR_NEXT\ns\n"); 377 printf("fR_NEXT\ns\n");
369 printf("fR_CURSOR\ns\nk1\n"); 378 printf("fR_CURSOR\ns\nk1\n");
370 printf("r\nk1\n"); 379 printf("r\n");
371 printf("fR_FIRST\ns\n"); 380 printf("fR_FIRST\ns\n");
372 }' > $TMP2 381 }' > $TMP2
373 $PROG -o $TMP3 recno $TMP2 382 $PROG -o $TMP3 recno $TMP2
@@ -397,8 +406,6 @@ test8()
397 printf("e\t%d of 10 \n", i); 406 printf("e\t%d of 10 \n", i);
398 printf("r\nkkey1\nr\nkkey2\n"); 407 printf("r\nkkey1\nr\nkkey2\n");
399 } 408 }
400 printf("e\n");
401 printf("eend of test8 run\n");
402 }' > $TMP1 409 }' > $TMP1
403 $PROG btree $TMP1 410 $PROG btree $TMP1
404# $PROG hash $TMP1 411# $PROG hash $TMP1
@@ -459,7 +466,7 @@ test10()
459 printf("p\nk%d\nd%s\n", ++i, $0); 466 printf("p\nk%d\nd%s\n", ++i, $0);
460 } 467 }
461 END { 468 END {
462 printf("fR_CURSOR\nr\nk1\n"); 469 printf("fR_CURSOR\nr\n");
463 printf("eR_CURSOR SHOULD HAVE FAILED\n"); 470 printf("eR_CURSOR SHOULD HAVE FAILED\n");
464 }' > $TMP2 471 }' > $TMP2
465 $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1 472 $PROG -o $TMP3 $type $TMP2 > /dev/null 2>&1
@@ -573,7 +580,8 @@ test13()
573 echo g 580 echo g
574 echo k$i 581 echo k$i
575 done > $TMP2 582 done > $TMP2
576 $PROG -ilorder=$order -f byte.file -o $TMP3 $type $TMP2 583 $PROG -s \
584 -ilorder=$order -f byte.file -o $TMP3 $type $TMP2
577 if (cmp -s $TMP1 $TMP3) ; then : 585 if (cmp -s $TMP1 $TMP3) ; then :
578 else 586 else
579 echo "test13: $type/$order get failed" 587 echo "test13: $type/$order get failed"
diff --git a/src/regress/lib/libc/getaddrinfo/Makefile b/src/regress/lib/libc/getaddrinfo/Makefile
new file mode 100644
index 0000000000..4d4978a6a2
--- /dev/null
+++ b/src/regress/lib/libc/getaddrinfo/Makefile
@@ -0,0 +1,19 @@
1# $OpenBSD: Makefile,v 1.3 2002/09/02 20:01:43 avsm Exp $
2
3PROG= gaitest
4SRCS= gaitest.c
5NOMAN= # defined
6CLEANFILES+= out
7
8REGRESS_TARGETS=do-test
9
10do-test: ${PROG}
11 sh ${.CURDIR}/testsuite.sh >out 2>&1
12 @if diff -u out ${.CURDIR}/answer; then \
13 echo SUCCESS; \
14 else \
15 echo FAIL; \
16 exit 1; \
17 fi
18
19.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/getaddrinfo/answer b/src/regress/lib/libc/getaddrinfo/answer
new file mode 100644
index 0000000000..f626f8f7d8
--- /dev/null
+++ b/src/regress/lib/libc/getaddrinfo/answer
@@ -0,0 +1,104 @@
1== basic ones
2arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv http
3ai1: flags 0x2 family 24 socktype 1 protocol 6 addrlen 28 host ::1 serv www
4arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv http
5ai1: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv www
6arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv http
7ai1: flags 0x2 family 24 socktype 1 protocol 6 addrlen 28 host ::1 serv www cname "localhost"
8ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv www cname "localhost"
9arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv tftp
10ai1: flags 0x2 family 24 socktype 2 protocol 17 addrlen 28 host ::1 serv 69
11arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv tftp
12ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 69
13arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv tftp
14ai1: flags 0x2 family 24 socktype 2 protocol 17 addrlen 28 host ::1 serv 69 cname "localhost"
15ai2: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 69 cname "localhost"
16arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv echo
17ai1: flags 0x2 family 24 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
18ai2: flags 0x2 family 24 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
19arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv echo
20ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
21ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
22arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv echo
23ai1: flags 0x2 family 24 socktype 2 protocol 17 addrlen 28 host ::1 serv echo cname "localhost"
24ai2: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo cname "localhost"
25ai3: flags 0x2 family 24 socktype 1 protocol 6 addrlen 28 host ::1 serv echo cname "localhost"
26ai4: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo cname "localhost"
27
28== specific address family
29arg: flags 0x2 family 2 socktype 0 protocol 0 addrlen 0 host localhost serv http
30ai1: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv www cname "localhost"
31arg: flags 0x2 family 24 socktype 0 protocol 0 addrlen 0 host localhost serv http
32ai1: flags 0x2 family 24 socktype 1 protocol 6 addrlen 28 host ::1 serv www cname "localhost"
33
34== empty hostname
35arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv http
36ai1: flags 0x2 family 24 socktype 1 protocol 6 addrlen 28 host ::1 serv www
37ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv www
38arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv echo
39ai1: flags 0x2 family 24 socktype 2 protocol 17 addrlen 28 host ::1 serv echo
40ai2: flags 0x2 family 24 socktype 1 protocol 6 addrlen 28 host ::1 serv echo
41ai3: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv echo
42ai4: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv echo
43arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv tftp
44ai1: flags 0x2 family 24 socktype 2 protocol 17 addrlen 28 host ::1 serv 69
45ai2: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 69
46arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv 80
47service not supported for ai_socktype
48arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv http
49ai1: flags 0x3 family 24 socktype 1 protocol 6 addrlen 28 host :: serv www
50ai2: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv www
51arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv echo
52ai1: flags 0x3 family 24 socktype 2 protocol 17 addrlen 28 host :: serv echo
53ai2: flags 0x3 family 24 socktype 1 protocol 6 addrlen 28 host :: serv echo
54ai3: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv echo
55ai4: flags 0x3 family 2 socktype 1 protocol 6 addrlen 16 host 0.0.0.0 serv echo
56arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv tftp
57ai1: flags 0x3 family 24 socktype 2 protocol 17 addrlen 28 host :: serv 69
58ai2: flags 0x3 family 2 socktype 2 protocol 17 addrlen 16 host 0.0.0.0 serv 69
59arg: flags 0x3 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv 80
60service not supported for ai_socktype
61arg: flags 0x2 family 0 socktype 1 protocol 0 addrlen 0 host (empty) serv 80
62ai1: flags 0x2 family 24 socktype 1 protocol 6 addrlen 28 host ::1 serv www
63ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv www
64arg: flags 0x2 family 0 socktype 2 protocol 0 addrlen 0 host (empty) serv 80
65ai1: flags 0x2 family 24 socktype 2 protocol 17 addrlen 28 host ::1 serv www
66ai2: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv www
67
68== empty servname
69arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host ::1 serv (empty)
70ai1: flags 0x2 family 24 socktype 2 protocol 17 addrlen 28 host ::1 serv 0
71ai2: flags 0x2 family 24 socktype 1 protocol 6 addrlen 28 host ::1 serv 0
72arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host 127.0.0.1 serv (empty)
73ai1: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 0
74ai2: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv 0
75arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host localhost serv (empty)
76ai1: flags 0x2 family 24 socktype 2 protocol 17 addrlen 28 host ::1 serv 0 cname "localhost"
77ai2: flags 0x2 family 2 socktype 2 protocol 17 addrlen 16 host 127.0.0.1 serv 0 cname "localhost"
78ai3: flags 0x2 family 24 socktype 1 protocol 6 addrlen 28 host ::1 serv 0 cname "localhost"
79ai4: flags 0x2 family 2 socktype 1 protocol 6 addrlen 16 host 127.0.0.1 serv 0 cname "localhost"
80arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host (empty) serv (empty)
81name or service is not known
82
83== sock_raw
84arg: flags 0x2 family 0 socktype 3 protocol 0 addrlen 0 host localhost serv (empty)
85ai1: flags 0x2 family 24 socktype 3 protocol 0 addrlen 28 host ::1 serv 0 cname "localhost"
86ai2: flags 0x2 family 2 socktype 3 protocol 0 addrlen 16 host 127.0.0.1 serv 0 cname "localhost"
87arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv (empty)
88ai1: flags 0x2 family 24 socktype 3 protocol 59 addrlen 28 host ::1 serv 0 cname "localhost"
89ai2: flags 0x2 family 2 socktype 3 protocol 59 addrlen 16 host 127.0.0.1 serv 0 cname "localhost"
90arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv 80
91service not supported for ai_socktype
92arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host localhost serv www
93service not supported for ai_socktype
94arg: flags 0x2 family 0 socktype 3 protocol 59 addrlen 0 host ::1 serv (empty)
95ai1: flags 0x2 family 24 socktype 3 protocol 59 addrlen 28 host ::1 serv 0
96
97== unsupported family
98arg: flags 0x2 family 99 socktype 0 protocol 0 addrlen 0 host localhost serv (empty)
99ai_family not supported
100
101== the following items are specified in jinmei scopeaddr format doc.
102arg: flags 0x2 family 0 socktype 0 protocol 0 addrlen 0 host fe80::1%lo0 serv http
103ai1: flags 0x2 family 24 socktype 1 protocol 6 addrlen 28 host fe80::1%lo0 serv www
104
diff --git a/src/regress/lib/libc/getaddrinfo/gaitest.c b/src/regress/lib/libc/getaddrinfo/gaitest.c
new file mode 100644
index 0000000000..edd56288f5
--- /dev/null
+++ b/src/regress/lib/libc/getaddrinfo/gaitest.c
@@ -0,0 +1,185 @@
1/* $OpenBSD: gaitest.c,v 1.2 2002/08/09 20:26:44 jsyn Exp $ */
2/* $NetBSD: gaitest.c,v 1.3 2002/07/05 15:47:43 itojun Exp $ */
3
4/*
5 * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, and 2002 WIDE Project.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the project nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#include <sys/types.h>
34#include <sys/socket.h>
35#include <netinet/in.h>
36#include <arpa/inet.h>
37#include <netdb.h>
38#include <stdio.h>
39#include <stdlib.h>
40#include <unistd.h>
41
42struct addrinfo ai;
43
44char host[NI_MAXHOST];
45char serv[NI_MAXSERV];
46int vflag = 0;
47
48static void usage(void);
49static void print1(const char *, const struct addrinfo *, char *, char *);
50int main(int, char *[]);
51
52static void
53usage()
54{
55 fprintf(stderr, "usage: test [-f family] [-s socktype] [-p proto] [-DPRSv46] host serv\n");
56}
57
58static void
59print1(title, res, h, s)
60 const char *title;
61 const struct addrinfo *res;
62 char *h;
63 char *s;
64{
65 char *start, *end;
66 int error;
67 const int niflag = NI_NUMERICHOST;
68
69 if (res->ai_addr) {
70 error = getnameinfo(res->ai_addr, res->ai_addr->sa_len,
71 host, sizeof(host), serv, sizeof(serv),
72 niflag);
73 h = host;
74 s = serv;
75 } else
76 error = 0;
77
78 if (vflag) {
79 start = "\t";
80 end = "\n";
81 } else {
82 start = " ";
83 end = "";
84 }
85 printf("%s%s", title, end);
86 printf("%sflags 0x%x%s", start, res->ai_flags, end);
87 printf("%sfamily %d%s", start, res->ai_family, end);
88 printf("%ssocktype %d%s", start, res->ai_socktype, end);
89 printf("%sprotocol %d%s", start, res->ai_protocol, end);
90 printf("%saddrlen %d%s", start, res->ai_addrlen, end);
91 if (error)
92 printf("%serror %d%s", start, error, end);
93 else {
94 printf("%shost %s%s", start, h, end);
95 printf("%sserv %s%s", start, s, end);
96 }
97 if (res->ai_canonname)
98 printf("%scname \"%s\"%s", start, res->ai_canonname, end);
99 if (!vflag)
100 printf("\n");
101
102}
103
104int
105main(argc, argv)
106 int argc;
107 char *argv[];
108{
109 struct addrinfo *res;
110 int error, i;
111 char *p, *q;
112 extern int optind;
113 extern char *optarg;
114 int c;
115 char nbuf[10];
116
117 memset(&ai, 0, sizeof(ai));
118 ai.ai_family = PF_UNSPEC;
119 ai.ai_flags |= AI_CANONNAME;
120 while ((c = getopt(argc, argv, "Df:p:PRs:Sv46")) != -1) {
121 switch (c) {
122 case 'D':
123 ai.ai_socktype = SOCK_DGRAM;
124 break;
125 case 'f':
126 ai.ai_family = atoi(optarg);
127 break;
128 case 'p':
129 ai.ai_protocol = atoi(optarg);
130 break;
131 case 'P':
132 ai.ai_flags |= AI_PASSIVE;
133 break;
134 case 'R':
135 ai.ai_socktype = SOCK_RAW;
136 break;
137 case 's':
138 ai.ai_socktype = atoi(optarg);
139 break;
140 case 'S':
141 ai.ai_socktype = SOCK_STREAM;
142 break;
143 case 'v':
144 vflag++;
145 break;
146 case '4':
147 ai.ai_family = PF_INET;
148 break;
149 case '6':
150 ai.ai_family = PF_INET6;
151 break;
152 default:
153 usage();
154 exit(1);
155 }
156 }
157 argc -= optind;
158 argv += optind;
159
160 if (argc != 2){
161 usage();
162 exit(1);
163 }
164
165 p = *argv[0] ? argv[0] : NULL;
166 q = *argv[1] ? argv[1] : NULL;
167
168 print1("arg:", &ai, p ? p : "(empty)", q ? q : "(empty)");
169
170 error = getaddrinfo(p, q, &ai, &res);
171 if (error) {
172 printf("%s\n", gai_strerror(error));
173 exit(1);
174 }
175
176 i = 1;
177 do {
178 snprintf(nbuf, sizeof(nbuf), "ai%d:", i);
179 print1(nbuf, res, NULL, NULL);
180
181 i++;
182 } while ((res = res->ai_next) != NULL);
183
184 exit(0);
185}
diff --git a/src/regress/lib/libc/getaddrinfo/testsuite.sh b/src/regress/lib/libc/getaddrinfo/testsuite.sh
new file mode 100644
index 0000000000..1e4e524054
--- /dev/null
+++ b/src/regress/lib/libc/getaddrinfo/testsuite.sh
@@ -0,0 +1,89 @@
1# $OpenBSD: testsuite.sh,v 1.1 2002/07/05 15:54:30 itojun Exp $
2# $NetBSD: testsuite.sh,v 1.3 2002/07/05 15:49:11 itojun Exp $
3
4#
5# Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, and 2002 WIDE Project.
6# All rights reserved.
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
11# 1. Redistributions of source code must retain the above copyright
12# notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14# notice, this list of conditions and the following disclaimer in the
15# documentation and/or other materials provided with the distribution.
16# 3. Neither the name of the project nor the names of its contributors
17# may be used to endorse or promote products derived from this software
18# without specific prior written permission.
19#
20# THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
21# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23# ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
24# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30# SUCH DAMAGE.
31#
32
33TEST=./gaitest
34#TEST='./test -v'
35#IF=`ifconfig -a | grep -v '^ ' | sed -e 's/:.*//' | head -1 | awk '{print $1}'`
36
37echo '== basic ones'
38$TEST ::1 http
39$TEST 127.0.0.1 http
40$TEST localhost http
41$TEST ::1 tftp
42$TEST 127.0.0.1 tftp
43$TEST localhost tftp
44$TEST ::1 echo
45$TEST 127.0.0.1 echo
46$TEST localhost echo
47echo
48
49echo '== specific address family'
50$TEST -4 localhost http
51$TEST -6 localhost http
52echo
53
54echo '== empty hostname'
55$TEST '' http
56$TEST '' echo
57$TEST '' tftp
58$TEST '' 80
59$TEST -P '' http
60$TEST -P '' echo
61$TEST -P '' tftp
62$TEST -P '' 80
63$TEST -S '' 80
64$TEST -D '' 80
65echo
66
67echo '== empty servname'
68$TEST ::1 ''
69$TEST 127.0.0.1 ''
70$TEST localhost ''
71$TEST '' ''
72echo
73
74echo '== sock_raw'
75$TEST -R -p 0 localhost ''
76$TEST -R -p 59 localhost ''
77$TEST -R -p 59 localhost 80
78$TEST -R -p 59 localhost www
79$TEST -R -p 59 ::1 ''
80echo
81
82echo '== unsupported family'
83$TEST -f 99 localhost ''
84echo
85
86echo '== the following items are specified in jinmei scopeaddr format doc.'
87$TEST fe80::1%lo0 http
88#$TEST fe80::1%$IF http
89echo
diff --git a/src/regress/lib/libc/getopt_long/Makefile b/src/regress/lib/libc/getopt_long/Makefile
new file mode 100644
index 0000000000..13a187e190
--- /dev/null
+++ b/src/regress/lib/libc/getopt_long/Makefile
@@ -0,0 +1,32 @@
1# $OpenBSD: Makefile,v 1.4 2002/12/08 19:25:08 millert Exp $
2
3NOMAN=
4PROG=getopt_long_test
5CLEANFILES+=test.out
6
7# test getopt_long and getopt_long_only
8run-regress-${PROG}: ${PROG}
9 @( test -n "$$POSIXLY_CORRECT" && unset POSIXLY_CORRECT; \
10 test -n "$$LONG_ONLY" && unset LONG_ONLY; \
11 ./${PROG} myfile --force -f infile -9 ; \
12 ./${PROG} onefile twofile --best -Williterate -i foo.in threefile ; \
13 ./${PROG} -1bfast - ; \
14 ./${PROG} --fast --drinking=guiness -i foo.in somefile ; \
15 export POSIXLY_CORRECT=1 ; \
16 ./${PROG} myfile --force -f infile -9 ; \
17 ./${PROG} onefile twofile --best -Williterate -i foo.in threefile ; \
18 ./${PROG} -1bfast - ; \
19 ./${PROG} --fast --drinking=guiness -i foo.in somefile ; \
20 unset POSIXLY_CORRECT ; export LONG_ONLY=1 ; \
21 ./${PROG} myfile -force -f infile -9 ; \
22 ./${PROG} onefile twofile -best -Williterate -i foo.in threefile ; \
23 ./${PROG} -1bfast - ; \
24 ./${PROG} --fast -drinking=guiness -i foo.in somefile ; \
25 export POSIXLY_CORRECT=1 ; \
26 ./${PROG} myfile -force -f infile -9 ; \
27 ./${PROG} onefile twofile -best -Williterate -i foo.in threefile ; \
28 ./${PROG} -1bfast - ; \
29 ./${PROG} --fast -drinking=guiness -i foo.in somefile ) >test.out 2>&1
30 cmp -s ${.OBJDIR}/test.out ${.CURDIR}/test.ok
31
32.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/getopt_long/getopt_long_test.c b/src/regress/lib/libc/getopt_long/getopt_long_test.c
new file mode 100644
index 0000000000..27a2dc4a5f
--- /dev/null
+++ b/src/regress/lib/libc/getopt_long/getopt_long_test.c
@@ -0,0 +1,119 @@
1/*
2 * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
15 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
16 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
17 * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#include <stdio.h>
27#include <stdlib.h>
28#include <getopt.h>
29
30/*
31 * Simple getopt_long() and getopt_long_only() excerciser.
32 * ENVIRONMENT:
33 * LONG_ONLY : use getopt_long_only() (default is getopt_long())
34 * POSIXLY_CORRECT : don't permute args
35 */
36
37int
38main(int argc, char **argv)
39{
40 int ch, idx, goggles;
41 int (*gl)(int, char * const *, const char *, const struct option *, int *);
42 struct option longopts[] = {
43 { "force", no_argument, 0, 0 },
44 { "fast", no_argument, 0, '1' },
45 { "best", no_argument, 0, '9' },
46 { "input", required_argument, 0, 'i' },
47 { "illiterate", no_argument, 0, 0 },
48 { "drinking", required_argument, &goggles, 42 },
49 { "help", no_argument, 0, 'h' },
50 { 0, 0, 0, 0 },
51 };
52
53 if (getenv("LONG_ONLY")) {
54 gl = getopt_long_only;
55 printf("getopt_long_only");
56 } else {
57 gl = getopt_long;
58 printf("getopt_long");
59 }
60 if (getenv("POSIXLY_CORRECT"))
61 printf(" (POSIXLY_CORRECT)");
62 printf(": ");
63 for (idx = 1; idx < argc; idx++)
64 printf("%s ", argv[idx]);
65 printf("\n");
66
67 goggles = 0;
68 for (;;) {
69 idx = -1;
70 ch = gl(argc, argv, "19bf:i:hW;-", longopts, &idx);
71 if (ch == -1)
72 break;
73 switch (ch) {
74 case 0:
75 case '1':
76 case '9':
77 case 'h':
78 case 'b':
79 case '-':
80 if (idx != -1) {
81 if (goggles == 42)
82 printf("option %s, arg %s\n",
83 longopts[idx].name, optarg);
84 else
85 printf("option %s\n",
86 longopts[idx].name);
87 } else
88 printf("option %c\n", ch);
89 break;
90 case 'f':
91 case 'i':
92 if (idx != -1)
93 printf("option %s, arg %s\n",
94 longopts[idx].name, optarg);
95 else
96 printf("option %c, arg %s\n", ch, optarg);
97 break;
98
99 case '?':
100 break;
101
102 default:
103 printf("unexpected return value: %c\n", ch);
104 break;
105 }
106 }
107 argc -= optind;
108 argv += optind;
109
110 if (argc > 0) {
111 printf("remaining ARGV: ");
112 while (argc--)
113 printf("%s ", *argv++);
114 printf("\n");
115 }
116 printf("\n");
117
118 exit (0);
119}
diff --git a/src/regress/lib/libc/getopt_long/test.ok b/src/regress/lib/libc/getopt_long/test.ok
new file mode 100644
index 0000000000..9782087f40
--- /dev/null
+++ b/src/regress/lib/libc/getopt_long/test.ok
@@ -0,0 +1,84 @@
1getopt_long: myfile --force -f infile -9
2option force
3option f, arg infile
4option 9
5remaining ARGV: myfile
6
7getopt_long: onefile twofile --best -Williterate -i foo.in threefile
8option best
9option illiterate
10option i, arg foo.in
11remaining ARGV: onefile twofile threefile
12
13getopt_long: -1bfast -
14option 1
15option b
16option f, arg ast
17option -
18
19getopt_long: --fast --drinking=guiness -i foo.in somefile
20option fast
21option drinking, arg guiness
22option i, arg foo.in
23remaining ARGV: somefile
24
25getopt_long (POSIXLY_CORRECT): myfile --force -f infile -9
26remaining ARGV: myfile --force -f infile -9
27
28getopt_long (POSIXLY_CORRECT): onefile twofile --best -Williterate -i foo.in threefile
29remaining ARGV: onefile twofile --best -Williterate -i foo.in threefile
30
31getopt_long (POSIXLY_CORRECT): -1bfast -
32option 1
33option b
34option f, arg ast
35option -
36
37getopt_long (POSIXLY_CORRECT): --fast --drinking=guiness -i foo.in somefile
38option fast
39option drinking, arg guiness
40option i, arg foo.in
41remaining ARGV: somefile
42
43getopt_long_only: myfile -force -f infile -9
44option force
45option f, arg infile
46option 9
47remaining ARGV: myfile
48
49getopt_long_only: onefile twofile -best -Williterate -i foo.in threefile
50option best
51option illiterate
52option i, arg foo.in
53remaining ARGV: onefile twofile threefile
54
55getopt_long_only: -1bfast -
56option 1
57option b
58option fast
59option -
60
61getopt_long_only: --fast -drinking=guiness -i foo.in somefile
62option fast
63option drinking, arg guiness
64option i, arg foo.in
65remaining ARGV: somefile
66
67getopt_long_only (POSIXLY_CORRECT): myfile -force -f infile -9
68remaining ARGV: myfile -force -f infile -9
69
70getopt_long_only (POSIXLY_CORRECT): onefile twofile -best -Williterate -i foo.in threefile
71remaining ARGV: onefile twofile -best -Williterate -i foo.in threefile
72
73getopt_long_only (POSIXLY_CORRECT): -1bfast -
74option 1
75option b
76option fast
77option -
78
79getopt_long_only (POSIXLY_CORRECT): --fast -drinking=guiness -i foo.in somefile
80option fast
81option drinking, arg guiness
82option i, arg foo.in
83remaining ARGV: somefile
84
diff --git a/src/regress/lib/libc/ieeefp/Makefile b/src/regress/lib/libc/ieeefp/Makefile
index 4e2e517b03..f9a6035fa9 100644
--- a/src/regress/lib/libc/ieeefp/Makefile
+++ b/src/regress/lib/libc/ieeefp/Makefile
@@ -1,12 +1,7 @@
1# $NetBSD: Makefile,v 1.4 1995/10/03 21:59:36 phil Exp $ 1# $OpenBSD: Makefile,v 1.5 2002/02/23 01:25:11 art Exp $
2# $NetBSD: Makefile,v 1.5 1996/04/09 16:54:18 phil Exp $
2 3
3.if ${MACHINE} == "pc532" 4SUBDIR+= except inf round
4SUBDIR+= round
5.else
6SUBDIR+= except round
7.endif
8
9regress: _SUBDIRUSE
10 5
11install: 6install:
12 7
diff --git a/src/regress/lib/libc/ieeefp/except/Makefile b/src/regress/lib/libc/ieeefp/except/Makefile
index 91f24f15f6..ff620e016b 100644
--- a/src/regress/lib/libc/ieeefp/except/Makefile
+++ b/src/regress/lib/libc/ieeefp/except/Makefile
@@ -1,12 +1,5 @@
1# $NetBSD: Makefile,v 1.1 1995/04/26 00:27:25 jtc Exp $ 1# $OpenBSD: Makefile,v 1.4 2002/02/18 11:22:26 art Exp $
2 2
3PROG= except 3PROG=except
4SRCS= except.c
5NOMAN=
6 4
7install: 5.include <bsd.regress.mk>
8
9regress: ${PROG}
10 ./${PROG}
11
12.include <bsd.prog.mk>
diff --git a/src/regress/lib/libc/ieeefp/except/except.c b/src/regress/lib/libc/ieeefp/except/except.c
index 0ffdcdd468..6b65e8f3c4 100644
--- a/src/regress/lib/libc/ieeefp/except/except.c
+++ b/src/regress/lib/libc/ieeefp/except/except.c
@@ -1,3 +1,5 @@
1/* $OpenBSD: except.c,v 1.3 2001/01/29 02:05:42 niklas Exp $ */
2
1#include <stdio.h> 3#include <stdio.h>
2#include <signal.h> 4#include <signal.h>
3#include <assert.h> 5#include <assert.h>
@@ -12,6 +14,7 @@ static volatile const double zero = 0.0;
12static volatile const double huge = DBL_MAX; 14static volatile const double huge = DBL_MAX;
13static volatile const double tiny = DBL_MIN; 15static volatile const double tiny = DBL_MIN;
14 16
17int
15main() 18main()
16{ 19{
17 volatile double x; 20 volatile double x;
diff --git a/src/regress/lib/libc/ieeefp/inf/Makefile b/src/regress/lib/libc/ieeefp/inf/Makefile
new file mode 100644
index 0000000000..b9a50e0ce6
--- /dev/null
+++ b/src/regress/lib/libc/ieeefp/inf/Makefile
@@ -0,0 +1,9 @@
1# $OpenBSD: Makefile,v 1.1 2002/02/16 17:22:16 pvalchev Exp $
2
3PROG= inf
4SRCS= inf.c
5
6LDADD+= -lm
7DPADD+= ${LIBM}
8
9.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/ieeefp/inf/inf.c b/src/regress/lib/libc/ieeefp/inf/inf.c
new file mode 100644
index 0000000000..b6116b0df1
--- /dev/null
+++ b/src/regress/lib/libc/ieeefp/inf/inf.c
@@ -0,0 +1,16 @@
1/* $OpenBSD: inf.c,v 1.2 2002/02/18 11:24:13 art Exp $ */
2
3/*
4 * Peter Valchev <pvalchev@openbsd.org> Public Domain, 2002.
5 */
6
7#include <math.h>
8
9int
10main()
11{
12 if (isinf(HUGE_VAL))
13 return 0;
14
15 return 1;
16}
diff --git a/src/regress/lib/libc/ieeefp/round/Makefile b/src/regress/lib/libc/ieeefp/round/Makefile
index 571133436c..9ea6dd8c39 100644
--- a/src/regress/lib/libc/ieeefp/round/Makefile
+++ b/src/regress/lib/libc/ieeefp/round/Makefile
@@ -1,12 +1,5 @@
1# $NetBSD: Makefile,v 1.1 1995/04/26 00:27:27 jtc Exp $ 1# $OpenBSD: Makefile,v 1.4 2002/02/18 11:25:34 art Exp $
2 2
3PROG= round 3PROG= round
4SRCS= round.c
5NOMAN=
6 4
7install: 5.include <bsd.regress.mk>
8
9regress: ${PROG}
10 ./${PROG}
11
12.include <bsd.prog.mk>
diff --git a/src/regress/lib/libc/ieeefp/round/round.c b/src/regress/lib/libc/ieeefp/round/round.c
index b9fcd9771e..086c4fdf10 100644
--- a/src/regress/lib/libc/ieeefp/round/round.c
+++ b/src/regress/lib/libc/ieeefp/round/round.c
@@ -1,3 +1,4 @@
1/* $OpenBSD: round.c,v 1.2 2001/01/29 02:05:43 niklas Exp $ */
1/* $NetBSD: round.c,v 1.1 1995/04/26 00:27:28 jtc Exp $ */ 2/* $NetBSD: round.c,v 1.1 1995/04/26 00:27:28 jtc Exp $ */
2 3
3/* 4/*
diff --git a/src/regress/lib/libc/longjmp/Makefile b/src/regress/lib/libc/longjmp/Makefile
new file mode 100644
index 0000000000..825e0f86d9
--- /dev/null
+++ b/src/regress/lib/libc/longjmp/Makefile
@@ -0,0 +1,13 @@
1# $OpenBSD: Makefile,v 1.4 2002/09/02 20:01:43 avsm Exp $
2PROG= longjmp
3
4do-longjmp: ${PROG}
5 ./longjmp
6
7do-_longjmp: ${PROG}
8 ./longjmp -_
9
10REGRESS_TARGETS=do-longjmp do-_longjmp
11.PHONY: ${REGRESS_TARGETS}
12
13.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/longjmp/longjmp.c b/src/regress/lib/libc/longjmp/longjmp.c
new file mode 100644
index 0000000000..7dea5bd97c
--- /dev/null
+++ b/src/regress/lib/libc/longjmp/longjmp.c
@@ -0,0 +1,71 @@
1/* $OpenBSD: longjmp.c,v 1.4 2002/02/18 11:27:45 art Exp $ */
2/*
3 * Artur Grabowski <art@openbsd.org>, 2002 Public Domain.
4 */
5
6#include <stdio.h>
7#include <stdlib.h>
8#include <unistd.h>
9#include <setjmp.h>
10#include <err.h>
11#include <sys/types.h>
12#include <sys/time.h>
13#include <sys/resource.h>
14
15
16jmp_buf buf;
17
18/*
19 * When longjmp is passed the incorrect arg (0), it should translate it into
20 * something better.
21 *
22 * The rlimit is here in case we start spinning.
23 */
24int
25main(int argc, char **argv)
26{
27 struct rlimit rl;
28 volatile int i, expect;
29 int (*sj)(jmp_buf);
30 void (*lj)(jmp_buf, int);
31 int ch;
32 extern char *__progname;
33
34 sj = setjmp;
35 lj = longjmp;
36
37 while ((ch = getopt(argc, argv, "_")) != -1) {
38 switch (ch) {
39 case '_':
40 sj = _setjmp;
41 lj = _longjmp;
42 break;
43 default:
44 fprintf(stderr, "Usage: %s [-_]\n", __progname);
45 exit(1);
46 }
47 }
48
49 rl.rlim_cur = 2;
50 rl.rlim_max = 2;
51 if (setrlimit(RLIMIT_CPU, &rl) < 0)
52 err(1, "setrlimit");
53
54 expect = 0;
55 i = (*sj)(buf);
56 if (i == 0 && expect != 0)
57 errx(1, "setjmp returns 0 on longjmp(.., 0)");
58 if (expect == 0) {
59 expect = -1;
60 (*lj)(buf, 0);
61 }
62
63 expect = 0;
64 i = (*sj)(buf);
65 if (i != expect)
66 errx(1, "bad return from setjmp %d/%d", expect, i);
67 if (expect < 1000)
68 (*lj)(buf, expect += 2);
69
70 return 0;
71}
diff --git a/src/regress/lib/libc/malloc/Makefile b/src/regress/lib/libc/malloc/Makefile
new file mode 100644
index 0000000000..0e8eee5478
--- /dev/null
+++ b/src/regress/lib/libc/malloc/Makefile
@@ -0,0 +1,5 @@
1# $OpenBSD: Makefile,v 1.3 2002/02/18 11:29:50 art Exp $
2
3PROG= malloc0test
4
5.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/malloc/malloc0test.c b/src/regress/lib/libc/malloc/malloc0test.c
new file mode 100644
index 0000000000..71e077e1c3
--- /dev/null
+++ b/src/regress/lib/libc/malloc/malloc0test.c
@@ -0,0 +1,133 @@
1/* $OpenBSD: malloc0test.c,v 1.5 2002/02/18 11:29:50 art Exp $ */
2/*
3 * Public domain. 2001, Theo de Raadt
4 */
5#include <sys/types.h>
6#include <sys/signal.h>
7#include <stdio.h>
8#include <unistd.h>
9#include <stdlib.h>
10#include <setjmp.h>
11#include <limits.h>
12#include <errno.h>
13
14volatile sig_atomic_t got;
15jmp_buf jmp;
16
17void
18catch(int signo)
19{
20 got++;
21 longjmp(jmp, 1);
22}
23
24int
25test(char *p, int size)
26{
27 signal(SIGSEGV, catch);
28 got = 0;
29 if (setjmp(jmp) == 0)
30 *p = 0;
31 if (setjmp(jmp) == 0)
32 *(p+size-1) = 0;
33 return (got);
34}
35
36char *prot_table[] = {
37 "unprotected",
38 "fuckup",
39 "protected"
40};
41
42#define SIZE 10
43
44/*
45 * Do random memory allocations.
46 *
47 * For each one, ensure that it is at least 16 bytes in size (that
48 * being what our current malloc returns for the minsize of an
49 * object, alignment wise);
50 *
51 * For zero-byte allocations, check that they are still aligned.
52 *
53 * For each object, ensure that they are correctly protected or not
54 * protected.
55 *
56 * Does not regress test malloc + free combinations ... it should.
57 */
58int
59main(int argc, char *argv[])
60{
61 caddr_t rblob = malloc(1);
62 caddr_t zblob = malloc(0);
63 caddr_t *blobp, blob;
64 int size, rsize, tsize;
65 int prot;
66 int rval = 0, fuckup = 0;
67 long limit = 200000, count;
68 int ch, silent = 0;
69 char *ep;
70 extern char *__progname;
71
72 while ((ch = getopt(argc, argv, "sn:")) != -1) {
73 switch (ch) {
74 case 's':
75 silent = 1;
76 break;
77 case 'n':
78 errno = 0;
79 limit = strtol(optarg, &ep, 10);
80 if (optarg[0] == '\0' || *ep != '\0' ||
81 (errno == ERANGE &&
82 (limit == LONG_MAX || limit == LONG_MIN)))
83 goto usage;
84 break;
85 default:
86usage:
87 fprintf(stderr, "Usage: %s [-s][-n <count>]\n",
88 __progname);
89 exit(1);
90 }
91 }
92
93 if (limit == 0)
94 limit = LONG_MAX;
95
96 for (count = 0; count < limit; count++) {
97 size = arc4random() % SIZE;
98 blob = malloc(size);
99 if (blob == NULL) {
100 fprintf(stderr, "success: out of memory\n");
101 exit(rval);
102 }
103
104 if (size == 0) {
105 blobp = &zblob;
106 tsize = 16;
107 } else {
108 blobp = &rblob;
109 tsize = size;
110 }
111
112 rsize = blob - *blobp;
113 fuckup = SIZE < 16 && size >= rsize;
114 prot = test(blob, tsize);
115
116 if (size == 0 && rsize < 16)
117 fuckup = 1;
118 if (size == 0 && prot < 2)
119 fuckup = 1;
120
121 if (fuckup) {
122 printf("%8p %6d %6d %20s %10s\n", blob, size, rsize,
123 prot_table[prot], fuckup ? "fuckup" : "");
124 rval = 1;
125 }
126 *blobp = blob;
127
128 if (!silent && count % 100000 == 0 && count != 0)
129 fprintf(stderr, "count = %d\n", count);
130 }
131
132 return rval;
133} \ No newline at end of file
diff --git a/src/regress/lib/libc/popen/Makefile b/src/regress/lib/libc/popen/Makefile
new file mode 100644
index 0000000000..25b8668a7a
--- /dev/null
+++ b/src/regress/lib/libc/popen/Makefile
@@ -0,0 +1,5 @@
1# $OpenBSD: Makefile,v 1.1 2002/02/16 01:55:09 art Exp $
2
3PROG=popen
4
5.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/popen/popen.c b/src/regress/lib/libc/popen/popen.c
new file mode 100644
index 0000000000..491c5becea
--- /dev/null
+++ b/src/regress/lib/libc/popen/popen.c
@@ -0,0 +1,104 @@
1/* $NetBSD: popen.c,v 1.1 1999/09/30 09:23:23 tron Exp $ */
2
3/*-
4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matthias Scheler.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39#include <sys/param.h>
40
41#include <errno.h>
42#include <paths.h>
43#include <stdio.h>
44#include <stdlib.h>
45#include <time.h>
46#include <unistd.h>
47
48#define _PATH_CAT "/bin/cat"
49#define BUFSIZE (640*1024)
50 /* 640KB ought to be enough for everyone. */
51#define DATAFILE "popen.data"
52
53int
54main(int argc, char **argv)
55{
56 char *buffer, command[MAXPATHLEN];
57 int index, in;
58 FILE *pipe;
59
60 if ((buffer = malloc(BUFSIZE*sizeof(char))) == NULL)
61 err(1, NULL);
62
63 for (index=0; index<BUFSIZE; index++)
64 buffer[index]=arc4random();
65
66 (void)snprintf(command, sizeof(command), "%s >%s",
67 _PATH_CAT, DATAFILE);
68 if ((pipe = popen(command, "w")) == NULL)
69 err(1, "popen write");
70
71 if (fwrite(buffer, sizeof(char), BUFSIZE, pipe) != BUFSIZE)
72 err(1, "write");
73
74 if (pclose(pipe) == -1)
75 err(1, "pclose");
76
77 (void)snprintf(command, sizeof(command), "%s %s",
78 _PATH_CAT, DATAFILE);
79 if ((pipe = popen(command, "r")) == NULL)
80 err(1, "popen read");
81
82 index = 0;
83 while ((in = fgetc(pipe)) != EOF)
84 if (index == BUFSIZE) {
85 errno = EFBIG;
86 err(1, "read");
87 }
88 else
89 if ((char)in != buffer[index++]) {
90 errno = EINVAL;
91 err(1, "read");
92 }
93
94 if (index < BUFSIZE) {
95 errno = EIO;
96 err(1, "read");
97 }
98
99 if (pclose(pipe) == -1)
100 err(1, "pclose");
101
102 (void)unlink(DATAFILE);
103 return 0;
104}
diff --git a/src/regress/lib/libc/regex/Makefile b/src/regress/lib/libc/regex/Makefile
index 93b7bb9052..a29686bca4 100644
--- a/src/regress/lib/libc/regex/Makefile
+++ b/src/regress/lib/libc/regex/Makefile
@@ -1,16 +1,20 @@
1# $OpenBSD: Makefile,v 1.5 2002/09/02 20:01:43 avsm Exp $
1# $NetBSD: Makefile,v 1.2 1995/02/16 19:38:45 cgd Exp $ 2# $NetBSD: Makefile,v 1.2 1995/02/16 19:38:45 cgd Exp $
2 3
3PROG= re 4PROG= re
4SRCS= main.c split.c debug.c 5SRCS= main.c split.c debug.c
5NOMAN=
6 6
7CFLAGS+= -I${.CURDIR}/../../../../lib/libc/regex 7CFLAGS+= -I${.CURDIR}/../../../../lib/libc/regex
8 8
9TESTS= ${.CURDIR}/tests 9TESTS= ${.CURDIR}/tests
10 10
11regress: 11REGRESS_TARGETS=do-reg do-reg-long do-reg-backref
12
13do-reg: ${PROG}
12 ./re < ${TESTS} 14 ./re < ${TESTS}
15do-reg-long: ${PROG}
13 ./re -el < ${TESTS} 16 ./re -el < ${TESTS}
17do-reg-backref: ${PROG}
14 ./re -er < ${TESTS} 18 ./re -er < ${TESTS}
15 19
16.include <bsd.prog.mk> 20.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/regex/debug.c b/src/regress/lib/libc/regex/debug.c
index 861f550611..7834e970c7 100644
--- a/src/regress/lib/libc/regex/debug.c
+++ b/src/regress/lib/libc/regex/debug.c
@@ -1,3 +1,4 @@
1/* $OpenBSD: debug.c,v 1.3 2001/01/29 02:05:43 niklas Exp $ */
1/* $NetBSD: debug.c,v 1.2 1995/04/20 22:39:42 cgd Exp $ */ 2/* $NetBSD: debug.c,v 1.2 1995/04/20 22:39:42 cgd Exp $ */
2 3
3#include <stdio.h> 4#include <stdio.h>
@@ -218,7 +219,7 @@ FILE *d;
218 fprintf(d, ">"); 219 fprintf(d, ">");
219 break; 220 break;
220 default: 221 default:
221 fprintf(d, "!%d(%d)!", OP(*s), opnd); 222 fprintf(d, "!%ld(%ld)!", (long)OP(*s), (long)opnd);
222 break; 223 break;
223 } 224 }
224 if (!done) 225 if (!done)
diff --git a/src/regress/lib/libc/regex/debug.ih b/src/regress/lib/libc/regex/debug.ih
index fb9bac0c75..9eb313af23 100644
--- a/src/regress/lib/libc/regex/debug.ih
+++ b/src/regress/lib/libc/regex/debug.ih
@@ -1,3 +1,4 @@
1/* $OpenBSD: debug.ih,v 1.3 2002/02/16 21:27:32 millert Exp $ */
1/* $NetBSD: debug.ih,v 1.2 1995/04/20 22:39:47 cgd Exp $ */ 2/* $NetBSD: debug.ih,v 1.2 1995/04/20 22:39:47 cgd Exp $ */
2 3
3/* ========= begin header generated by ./mkh ========= */ 4/* ========= begin header generated by ./mkh ========= */
@@ -6,9 +7,9 @@ extern "C" {
6#endif 7#endif
7 8
8/* === debug.c === */ 9/* === debug.c === */
9void regprint __P((regex_t *r, FILE *d)); 10void regprint(regex_t *r, FILE *d);
10static void s_print __P((register struct re_guts *g, FILE *d)); 11static void s_print(register struct re_guts *g, FILE *d);
11static char *regchar __P((int ch)); 12static char *regchar(int ch);
12 13
13#ifdef __cplusplus 14#ifdef __cplusplus
14} 15}
diff --git a/src/regress/lib/libc/regex/main.c b/src/regress/lib/libc/regex/main.c
index 8d88a8b9b8..6e63ffc235 100644
--- a/src/regress/lib/libc/regex/main.c
+++ b/src/regress/lib/libc/regex/main.c
@@ -1,10 +1,13 @@
1/* $OpenBSD: main.c,v 1.3 1997/01/15 23:41:07 millert Exp $ */
1/* $NetBSD: main.c,v 1.2 1995/04/20 22:39:51 cgd Exp $ */ 2/* $NetBSD: main.c,v 1.2 1995/04/20 22:39:51 cgd Exp $ */
2 3
3#include <stdio.h> 4#include <stdio.h>
5#include <stdlib.h>
4#include <string.h> 6#include <string.h>
5#include <sys/types.h> 7#include <sys/types.h>
6#include <regex.h> 8#include <regex.h>
7#include <assert.h> 9#include <assert.h>
10#include <unistd.h>
8 11
9#include "main.ih" 12#include "main.ih"
10 13
@@ -25,6 +28,7 @@ extern void regprint();
25/* 28/*
26 - main - do the simple case, hand off to regress() for regression 29 - main - do the simple case, hand off to regress() for regression
27 */ 30 */
31int
28main(argc, argv) 32main(argc, argv)
29int argc; 33int argc;
30char *argv[]; 34char *argv[];
@@ -43,7 +47,7 @@ char *argv[];
43 47
44 progname = argv[0]; 48 progname = argv[0];
45 49
46 while ((c = getopt(argc, argv, "c:e:S:E:x")) != EOF) 50 while ((c = getopt(argc, argv, "c:e:S:E:x")) != -1)
47 switch (c) { 51 switch (c) {
48 case 'c': /* compile options */ 52 case 'c': /* compile options */
49 copts = options('c', optarg); 53 copts = options('c', optarg);
@@ -102,10 +106,10 @@ char *argv[];
102 exit(status); 106 exit(status);
103 } 107 }
104 if (!(copts&REG_NOSUB)) { 108 if (!(copts&REG_NOSUB)) {
105 len = (int)(subs[0].rm_eo - subs[0].rm_so); 109 len = (size_t)(subs[0].rm_eo - subs[0].rm_so);
106 if (subs[0].rm_so != -1) { 110 if (subs[0].rm_so != -1) {
107 if (len != 0) 111 if (len != 0)
108 printf("match `%.*s'\n", len, 112 printf("match `%.*s'\n", (int)len,
109 argv[optind] + subs[0].rm_so); 113 argv[optind] + subs[0].rm_so);
110 else 114 else
111 printf("match `'@%.1s\n", 115 printf("match `'@%.1s\n",
@@ -501,7 +505,6 @@ efind(name)
501char *name; 505char *name;
502{ 506{
503 static char efbuf[100]; 507 static char efbuf[100];
504 size_t n;
505 regex_t re; 508 regex_t re;
506 509
507 sprintf(efbuf, "REG_%s", name); 510 sprintf(efbuf, "REG_%s", name);
diff --git a/src/regress/lib/libc/regex/main.ih b/src/regress/lib/libc/regex/main.ih
index 135e3e792d..0860e26333 100644
--- a/src/regress/lib/libc/regex/main.ih
+++ b/src/regress/lib/libc/regex/main.ih
@@ -1,3 +1,4 @@
1/* $OpenBSD: main.ih,v 1.3 2002/02/16 21:27:32 millert Exp $ */
1/* $NetBSD: main.ih,v 1.2 1995/04/20 22:39:55 cgd Exp $ */ 2/* $NetBSD: main.ih,v 1.2 1995/04/20 22:39:55 cgd Exp $ */
2 3
3/* ========= begin header generated by ./mkh ========= */ 4/* ========= begin header generated by ./mkh ========= */
@@ -6,14 +7,14 @@ extern "C" {
6#endif 7#endif
7 8
8/* === main.c === */ 9/* === main.c === */
9void regress __P((FILE *in)); 10void regress(FILE *in);
10void try __P((char *f0, char *f1, char *f2, char *f3, char *f4, int opts)); 11void try(char *f0, char *f1, char *f2, char *f3, char *f4, int opts);
11int options __P((int type, char *s)); 12int options(int type, char *s);
12int opt __P((int c, char *s)); 13int opt(int c, char *s);
13void fixstr __P((register char *p)); 14void fixstr(register char *p);
14char *check __P((char *str, regmatch_t sub, char *should)); 15char *check(char *str, regmatch_t sub, char *should);
15static char *eprint __P((int err)); 16static char *eprint(int err);
16static int efind __P((char *name)); 17static int efind(char *name);
17 18
18#ifdef __cplusplus 19#ifdef __cplusplus
19} 20}
diff --git a/src/regress/lib/libc/regex/split.c b/src/regress/lib/libc/regex/split.c
index dd1ca14480..52cb6c681e 100644
--- a/src/regress/lib/libc/regex/split.c
+++ b/src/regress/lib/libc/regex/split.c
@@ -1,3 +1,4 @@
1/* $OpenBSD: split.c,v 1.2 2001/01/29 02:05:44 niklas Exp $ */
1/* $NetBSD: split.c,v 1.2 1995/04/20 22:39:57 cgd Exp $ */ 2/* $NetBSD: split.c,v 1.2 1995/04/20 22:39:57 cgd Exp $ */
2 3
3#include <stdio.h> 4#include <stdio.h>
diff --git a/src/regress/lib/libc/regex/tests b/src/regress/lib/libc/regex/tests
index 8e89f161b1..c89b9ec164 100644
--- a/src/regress/lib/libc/regex/tests
+++ b/src/regress/lib/libc/regex/tests
@@ -1,3 +1,4 @@
1# $OpenBSD: tests,v 1.2 2001/01/29 02:05:44 niklas Exp $
1# $NetBSD: tests,v 1.5 1995/04/20 22:40:00 cgd Exp $ 2# $NetBSD: tests,v 1.5 1995/04/20 22:40:00 cgd Exp $
2 3
3# regular expression test set 4# regular expression test set
diff --git a/src/regress/lib/libc/setjmp-signal/Makefile b/src/regress/lib/libc/setjmp-signal/Makefile
new file mode 100644
index 0000000000..a9649a8abe
--- /dev/null
+++ b/src/regress/lib/libc/setjmp-signal/Makefile
@@ -0,0 +1,5 @@
1# $OpenBSD: Makefile,v 1.1 2002/07/31 05:18:24 art Exp $
2
3PROG= setjmp-signal
4
5.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/setjmp-signal/setjmp-signal.c b/src/regress/lib/libc/setjmp-signal/setjmp-signal.c
new file mode 100644
index 0000000000..310e4052ef
--- /dev/null
+++ b/src/regress/lib/libc/setjmp-signal/setjmp-signal.c
@@ -0,0 +1,26 @@
1/* $OpenBSD: setjmp-signal.c,v 1.3 2003/01/03 20:46:05 miod Exp $ */
2/*
3 * Written by Artur Grabowski <art@openbsd.org> 2002 Public Domain.
4 */
5
6#include <setjmp.h>
7#include <signal.h>
8
9jmp_buf jb;
10
11void
12segv_handler(int signum)
13{
14 longjmp(jb, 1);
15}
16
17int
18main()
19{
20 signal(SIGSEGV, segv_handler);
21 if (setjmp(jb) == 0) {
22 *((int *)0L) = 0;
23 return (1);
24 }
25 return (0);
26}
diff --git a/src/regress/lib/libc/setjmp/Makefile b/src/regress/lib/libc/setjmp/Makefile
index 25bf99d4cb..fc68e8d44c 100644
--- a/src/regress/lib/libc/setjmp/Makefile
+++ b/src/regress/lib/libc/setjmp/Makefile
@@ -1,16 +1,9 @@
1# $OpenBSD: Makefile,v 1.3 2002/01/01 23:00:51 art Exp $
1# $NetBSD: Makefile,v 1.2 1995/04/20 22:40:13 cgd Exp $ 2# $NetBSD: Makefile,v 1.2 1995/04/20 22:40:13 cgd Exp $
2 3
3PROG= setjmptest 4PROG= setjmptest
4SRCS= jmptest.c 5SRCS= jmptest.c
5NOMAN= noman, no way, man
6 6
7CFLAGS+= -DTEST_SETJMP 7CFLAGS+= -DTEST_SETJMP
8 8
9.PATH: ${.CURDIR}/../setjmp 9.include <bsd.regress.mk>
10
11install:
12
13regress: ${PROG}
14 ./${PROG}
15
16.include <bsd.prog.mk>
diff --git a/src/regress/lib/libc/setjmp/jmptest.c b/src/regress/lib/libc/setjmp/jmptest.c
index f2cecc9178..de6e70d9f6 100644
--- a/src/regress/lib/libc/setjmp/jmptest.c
+++ b/src/regress/lib/libc/setjmp/jmptest.c
@@ -1,3 +1,4 @@
1/* $OpenBSD: jmptest.c,v 1.5 2001/11/11 23:26:35 deraadt Exp $ */
1/* $NetBSD: jmptest.c,v 1.2 1995/01/01 20:55:35 jtc Exp $ */ 2/* $NetBSD: jmptest.c,v 1.2 1995/01/01 20:55:35 jtc Exp $ */
2 3
3/* 4/*
@@ -32,6 +33,7 @@
32 */ 33 */
33 34
34#include <sys/types.h> 35#include <sys/types.h>
36#include <err.h>
35#include <setjmp.h> 37#include <setjmp.h>
36#include <signal.h> 38#include <signal.h>
37#include <stdio.h> 39#include <stdio.h>
@@ -68,9 +70,11 @@ aborthandler(signo)
68{ 70{
69 71
70 if (expectsignal) 72 if (expectsignal)
71 exit(0); 73 _exit(0);
72 else 74 else {
73 errx(1, "kill(SIGABRT) succeeded"); 75 warnx("kill(SIGABRT) succeeded");
76 _exit(1);
77 }
74} 78}
75 79
76int 80int
@@ -101,7 +105,7 @@ main(argc, argv)
101#endif 105#endif
102 106
103 sa.sa_handler = aborthandler; 107 sa.sa_handler = aborthandler;
104 sa.sa_mask = 0; 108 sigemptyset(&sa.sa_mask);
105 sa.sa_flags = 0; 109 sa.sa_flags = 0;
106 if (sigaction(SIGABRT, &sa, NULL) == -1) 110 if (sigaction(SIGABRT, &sa, NULL) == -1)
107 err(1, "sigaction failed"); 111 err(1, "sigaction failed");
diff --git a/src/regress/lib/libc/sigreturn/Makefile b/src/regress/lib/libc/sigreturn/Makefile
new file mode 100644
index 0000000000..9891ba9e05
--- /dev/null
+++ b/src/regress/lib/libc/sigreturn/Makefile
@@ -0,0 +1,18 @@
1# $OpenBSD: Makefile,v 1.5 2002/09/02 20:01:43 avsm Exp $
2
3PROG= sigret
4
5DEBUG+= -ggdb
6
7REGRESS_TARGETS+= sigret-normal sigret-indirect sigret-altstack
8
9sigret-normal: ${PROG}
10 ./${PROG}
11
12sigret-indirect: ${PROG}
13 ./${PROG} -i
14
15sigret-altstack: ${PROG}
16 ./${PROG} -a
17
18.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/sigreturn/sigret.c b/src/regress/lib/libc/sigreturn/sigret.c
new file mode 100644
index 0000000000..416869007a
--- /dev/null
+++ b/src/regress/lib/libc/sigreturn/sigret.c
@@ -0,0 +1,181 @@
1/*
2 * $OpenBSD: sigret.c,v 1.4 2002/04/30 01:59:47 deraadt Exp $
3 *
4 * Public Domain
5 *
6 * Playing games with sigreturn. Check if calling sigreturn from a
7 * signal handler screws anything up.
8 *
9 * Run with:
10 * -a: use an alternate signal stack
11 *
12 * -b: call sigreturn from outside of a signal handler
13 * An error is OK
14 *
15 * -c: clobber the sigcontext before calling sigreturn
16 * the program should die
17 *
18 * -f: don't use sigreturn -- fall through the signal handler
19 * -c, and -i options ignored when used
20 *
21 * -i: call sigreturn from a function called by the signal handler
22 *
23 */
24
25#include <sys/time.h>
26
27#include <err.h>
28#include <signal.h>
29#include <stdarg.h>
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33#include <unistd.h>
34
35/*
36 * sigalarm occurs 50 times/second. Stop running after 10 seconds
37 * (100 interrupts).
38 */
39#define MAX_INTERRUPTS 500
40
41int failed;
42int altstack;
43int badcall;
44int clobbercall;
45int fallthru;
46int indirect;
47
48volatile int count;
49struct sigcontext gscp;
50int gscp_loaded;
51
52static void
53usage(const char * err, ...)
54{
55 extern const char * __progname;
56
57 if (err) {
58 va_list ap;
59 va_start(ap, err);
60 vwarnx(err, ap);
61 va_end(ap);
62 }
63 fprintf(stderr, "usage: %s [-abcfi]\n", __progname);
64 exit(1);
65}
66
67void
68indirect_return(struct sigcontext * scp)
69{
70 sigreturn(scp);
71}
72
73void
74sig_handler(int sig, siginfo_t *blah, void *x)
75{
76 struct sigcontext * scp = x;
77
78 count++;
79
80 if (!fallthru) {
81 if (clobbercall)
82 memset(scp, 0, sizeof *scp);
83 if (indirect)
84 indirect_return(scp);
85 else if (badcall) {
86 gscp = *scp;
87 gscp_loaded = 1;
88 } else
89 sigreturn(scp);
90 }
91}
92
93void
94test2(char *fmt)
95{
96 char *ofmt = fmt;
97
98 if (gscp_loaded) {
99 gscp_loaded = 0;
100 sigreturn(&gscp);
101 }
102
103 for (; *fmt; fmt++)
104 switch (*fmt) {
105 case 'i':
106 case 'c':
107 case 'l':
108 case 'p':
109 break;
110 default:
111 failed = 1;
112 fprintf(stderr,
113 "unexpected character 0x%02x `%c' in %s: count %d\n",
114 *fmt, *fmt, ofmt, count);
115 }
116}
117
118int
119main(int argc, char * argv[])
120{
121 extern char *optarg;
122 extern int optind;
123
124 int opt;
125
126 struct sigaction act;
127 struct sigaltstack ss;
128
129 while ((opt = getopt(argc, argv, "abcfi")) != -1) {
130 switch (opt) {
131 case 'a':
132 /* use sigaltstack */
133 altstack = 1;
134 break;
135 case 'b':
136 /* call outside of sig_handler */
137 badcall = 1;
138 break;
139 case 'c':
140 /* force error by munging sigcontext */
141 clobbercall = 1;
142 break;
143 case 'f':
144 /* don't use sigreturn */
145 fallthru = 1;
146 break;
147 case 'i':
148 /* call sigreturn indirectly */
149 indirect = 1;
150 break;
151 }
152 }
153
154 /* make sure there is no other cruft left on the command line */
155 if (optind != argc)
156 usage("unknown argument -- %s", argv[ optind ]);
157
158 if (altstack) {
159 if ((ss.ss_sp = malloc(SIGSTKSZ)) == NULL)
160 errx(1, "ss_sp malloc");
161
162 ss.ss_size = SIGSTKSZ;
163 ss.ss_flags = 0;
164 if (sigaltstack(&ss,0) == -1)
165 err(1, "sigaltstack");
166 }
167
168 sigfillset(&act.sa_mask);
169 act.sa_sigaction = sig_handler;
170 act.sa_flags = SA_RESTART;
171 if (altstack)
172 act.sa_flags |= SA_ONSTACK;
173 sigaction(SIGALRM, &act, NULL);
174
175 ualarm(10000, 10000);
176
177 while (count < MAX_INTERRUPTS)
178 test2("iclp");
179
180 return failed;
181}
diff --git a/src/regress/lib/libc/sigsetjmp/Makefile b/src/regress/lib/libc/sigsetjmp/Makefile
index 41682fcb66..f88bea3b47 100644
--- a/src/regress/lib/libc/sigsetjmp/Makefile
+++ b/src/regress/lib/libc/sigsetjmp/Makefile
@@ -1,17 +1,19 @@
1# $NetBSD: Makefile,v 1.2 1995/04/20 22:40:40 cgd Exp $ 1# $OpenBSD: Makefile,v 1.5 2002/09/02 20:01:43 avsm Exp $
2 2
3PROG= sigsetjmptest 3PROG= sigsetjmptest
4SRCS= jmptest.c 4SRCS= jmptest.c
5NOMAN= noman, no way, man
6 5
7CFLAGS+= -DTEST_SIGSETJMP 6CFLAGS+= -DTEST_SIGSETJMP
8 7
9.PATH: ${.CURDIR}/../setjmp 8.PATH: ${.CURDIR}/../setjmp
10 9
11install: 10REGRESS_TARGETS=sigsetjmp-save sigsetjmp-nosave
12 11
13regress: ${PROG} 12sigsetjmp-save: ${PROG}
14 ./${PROG} save 13 ./${PROG} save
14sigsetjmp-nosave: ${PROG}
15 ./${PROG} nosave 15 ./${PROG} nosave
16 16
17.include <bsd.prog.mk> 17.PHONY: ${REGRESS_TARGETS}
18
19.include <bsd.regress.mk>
diff --git a/src/regress/lib/libssl/Makefile b/src/regress/lib/libssl/Makefile
new file mode 100644
index 0000000000..d69db1b29e
--- /dev/null
+++ b/src/regress/lib/libssl/Makefile
@@ -0,0 +1,231 @@
1# $OpenBSD: Makefile,v 1.10 2002/09/26 11:39:50 markus Exp $
2
3CLEANFILES+= testdsa.key testdsa.pem rsakey.pem rsacert.pem dsa512.pem
4
5REGRESS_TARGETS=ossltests ssl-enc ssl-dsa ssl-rsa
6
7OPENSSL=/usr/sbin/openssl
8CLEAR1=p
9CIPHER=cipher
10CLEAR2=clear
11
12BNTEST= bntest
13ECTEST= ectest
14EXPTEST= exptest
15SHATEST= shatest
16SHA1TEST= sha1test
17RMDTEST= rmdtest
18MD2TEST= md2test
19MD4TEST= md4test
20MD5TEST= md5test
21HMACTEST= hmactest
22RC2TEST= rc2test
23RC4TEST= rc4test
24BFTEST= bftest
25CASTTEST= casttest
26DESTEST= destest
27RANDTEST= randtest
28DHTEST= dhtest
29DSATEST= dsatest
30RSATEST= rsa_test
31ENGINETEST= enginetest
32EVPTEST= evp_test
33
34
35CLEANFILES+= $(BNTEST).c $(ECTEST).c $(HMACTEST).c \
36 $(SHATEST).c $(SHA1TEST).c $(MDC2TEST).c $(RMDTEST).c \
37 $(RANDTEST).c $(DHTEST).c $(ENGINETEST).c \
38 $(CASTTEST).c $(EXPTEST).c $(DSATEST).c $(RSATEST).c \
39 $(EVPTEST).c $(DESTEST).c ${RC2TEST}.c ${RC4TEST}.c ${MD2TEST}.c \
40 ${MD4TEST}.c ${MD5TEST}.c
41
42CLEANFILES+= $(BNTEST) $(ECTEST) $(HMACTEST) \
43 $(SHATEST) $(SHA1TEST) $(MDC2TEST) $(RMDTEST) \
44 $(RANDTEST) $(DHTEST) $(ENGINETEST) \
45 $(CASTTEST) $(EXPTEST) $(DSATEST) $(RSATEST) \
46 $(EVPTEST) $(DESTEST) ${RC2TEST} ${RC4TEST} ${MD2TEST} ${MD4TEST} \
47 ${MD5TEST}\
48
49CLEANFILES+= ${BNTEST}.out
50
51OTESTS= ${ENGINETEST} \
52 ${EXPTEST} ${RANDTEST} \
53 ${MD2TEST} ${MD4TEST} ${MD5TEST} \
54 ${SHATEST} ${SHA1TEST} ${HMACTEST} ${RMDTEST} ${MDC2TEST} \
55 ${CASTTEST} ${RC2TEST} ${RC4TEST} ${DESTEST} \
56 ${DHTEST} ${DSATEST} ${RSATEST} \
57 ${ECTEST}
58
59${CLEAR1}: openssl.cnf
60 cat ${.CURDIR}/openssl.cnf > ${CLEAR1}
61
62CLEANFILES+=${CLEAR1}
63
64ENCTARGETS=rc4 des-cfb des-ede-cfb des-ede3-cfb des-ofb des-ede-ofb des-ede3-ofb
65ENCTARGETS+=des-ecb des-ede des-ede3 desx des-cbc des-ede-cbc des-ede3-cbc
66ENCTARGETS+=rc2-ecb rc2-cfb rc2-ofb rc2-cbc bf-ecb bf-cfb bf-ofb bf-cbc rc4
67ENCTARGETS+=cast5-ecb cast5-cfb cast5-ofb cast5-cbc
68
69.for ENC in ${ENCTARGETS}
70${CIPHER}.${ENC}: ${CLEAR1}
71 ${OPENSSL} ${ENC} -bufsize 113 -e -k test < ${CLEAR1} > ${CIPHER}.${ENC}
72${CIPHER}.${ENC}.b64: ${CLEAR1}
73 ${OPENSSL} ${ENC} -bufsize 113 -a -e -k test < ${CLEAR1} > ${CIPHER}.${ENC}.b64
74
75${CLEAR2}.${ENC}: ${CIPHER}.${ENC}
76 ${OPENSSL} ${ENC} -bufsize 157 -d -k test < ${CIPHER}.${ENC} > ${CLEAR2}.${ENC}
77${CLEAR2}.${ENC}.b64: ${CIPHER}.${ENC}.b64
78 ${OPENSSL} ${ENC} -bufsize 157 -a -d -k test < ${CIPHER}.${ENC}.b64 > ${CLEAR2}.${ENC}.b64
79
80ssl-enc-${ENC}: ${CLEAR1} ${CLEAR2}.${ENC}
81 cmp ${CLEAR1} ${CLEAR2}.${ENC}
82ssl-enc-${ENC}.b64: ${CLEAR1} ${CLEAR2}.${ENC}.b64
83 cmp ${CLEAR1} ${CLEAR2}.${ENC}.b64
84
85REGRESS_TARGETS+=ssl-enc-${ENC} ssl-enc-${ENC}.b64
86CLEANFILES+=${CIPHER}.${ENC} ${CIPHER}.${ENC}.b64 ${CLEAR2}.${ENC} ${CLEAR2}.${ENC}.b64 e_os.h .rnd
87.endfor
88
89ssl-enc:
90 sh ${.CURDIR}/testenc.sh ${.OBJDIR} ${.CURDIR}
91ssl-dsa:
92 sh ${.CURDIR}/testdsa.sh ${.OBJDIR} ${.CURDIR}
93ssl-rsa:
94 sh ${.CURDIR}/testrsa.sh ${.OBJDIR} ${.CURDIR}
95
96e_os.h: ${.CURDIR}/../../../lib/libssl/src/e_os.h
97 cp ${.CURDIR}/../../../lib/libssl/src/e_os.h ${.OBJDIR}
98
99ossltests: ${OTESTS} ${BNTEST} ${EVPTEST}
100 @echo running ${BNTEST}, check ${.OBJDIR}/${BNTEST}.out if this fails.
101 ${.OBJDIR}/${BNTEST} > ${.OBJDIR}/${BNTEST}.out 2>&1
102.for OT in ${OTESTS}
103 @echo running ${OT}
104 ${.OBJDIR}/${OT}
105.endfor
106 @echo running ${EVPTEST}
107 ${.OBJDIR}/${EVPTEST} ${.CURDIR}/../../../lib/libssl/src/crypto/evp/evptests.txt
108
109$(BNTEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/bn/bntest.c
110 cp ${.CURDIR}/../../../lib/libssl/src/crypto/bn/bntest.c ${.OBJDIR}
111
112$(BNTEST): ${BNTEST}.c e_os.h
113 cc -O -o $(BNTEST) ${BNTEST}.c -lcrypto
114
115$(EXPTEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/bn/exptest.c
116 cp ${.CURDIR}/../../../lib/libssl/src/crypto/bn/exptest.c ${.OBJDIR}
117
118$(EXPTEST): ${EXPTEST}.c e_os.h
119 cc -O -o $(EXPTEST) ${EXPTEST}.c -lcrypto
120
121$(ECTEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/ec/ectest.c
122 cp ${.CURDIR}/../../../lib/libssl/src/crypto/ec/ectest.c ${.OBJDIR}
123
124$(ECTEST): ${ECTEST}.c e_os.h
125 cc -O -o $(ECTEST) ${ECTEST}.c -lcrypto
126
127$(EVPTEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/evp/${EVPTEST}.c
128 cp ${.CURDIR}/../../../lib/libssl/src/crypto/evp/${EVPTEST}.c ${.OBJDIR}
129$(EVPTEST): ${EVPTEST}.c e_os.h
130 cc -O -o $(EVPTEST) ${EVPTEST}.c -lcrypto
131
132$(SHATEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/sha/${SHATEST}.c
133 cp ${.CURDIR}/../../../lib/libssl/src/crypto/sha/${SHATEST}.c ${.OBJDIR}
134$(SHATEST): ${SHATEST}.c e_os.h
135 cc -O -o $(SHATEST) ${SHATEST}.c -lcrypto
136
137$(SHA1TEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/sha/${SHA1TEST}.c
138 cp ${.CURDIR}/../../../lib/libssl/src/crypto/sha/${SHA1TEST}.c ${.OBJDIR}
139$(SHA1TEST): ${SHA1TEST}.c e_os.h
140 cc -O -o $(SHA1TEST) ${SHA1TEST}.c -lcrypto
141
142$(RANDTEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/rand/${RANDTEST}.c
143 cp ${.CURDIR}/../../../lib/libssl/src/crypto/rand/${RANDTEST}.c ${.OBJDIR}
144$(RANDTEST): ${RANDTEST}.c e_os.h
145 cc -O -o $(RANDTEST) ${RANDTEST}.c -lcrypto
146
147$(RMDTEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/ripemd/${RMDTEST}.c
148 cp ${.CURDIR}/../../../lib/libssl/src/crypto/ripemd/${RMDTEST}.c ${.OBJDIR}
149$(RMDTEST): ${RMDTEST}.c e_os.h
150 cc -O -o $(RMDTEST) ${RMDTEST}.c -lcrypto
151
152$(DHTEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/dh/${DHTEST}.c
153 cp ${.CURDIR}/../../../lib/libssl/src/crypto/dh/${DHTEST}.c ${.OBJDIR}
154
155$(DHTEST): ${DHTEST}.c e_os.h
156 cc -O -o $(DHTEST) ${DHTEST}.c -lcrypto
157
158$(ENGINETEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/engine/${ENGINETEST}.c
159 cp ${.CURDIR}/../../../lib/libssl/src/crypto/engine/${ENGINETEST}.c ${.OBJDIR}
160
161$(ENGINETEST): ${ENGINETEST}.c e_os.h
162 cc -O -o $(ENGINETEST) ${ENGINETEST}.c -lcrypto
163
164$(CASTTEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/cast/${CASTTEST}.c
165 cp ${.CURDIR}/../../../lib/libssl/src/crypto/cast/${CASTTEST}.c ${.OBJDIR}
166
167$(CASTTEST): ${CASTTEST}.c e_os.h
168 cc -O -o $(CASTTEST) ${CASTTEST}.c -lcrypto
169
170$(RSATEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/rsa/${RSATEST}.c
171 cp ${.CURDIR}/../../../lib/libssl/src/crypto/rsa/${RSATEST}.c ${.OBJDIR}
172
173$(RSATEST): ${RSATEST}.c e_os.h
174 cc -O -o $(RSATEST) ${RSATEST}.c -lcrypto
175
176$(DSATEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/dsa/${DSATEST}.c
177 cp ${.CURDIR}/../../../lib/libssl/src/crypto/dsa/${DSATEST}.c ${.OBJDIR}
178
179$(DSATEST): ${DSATEST}.c e_os.h
180 cc -O -o $(DSATEST) ${DSATEST}.c -lcrypto
181
182
183$(HMACTEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/hmac/${HMACTEST}.c
184 cp ${.CURDIR}/../../../lib/libssl/src/crypto/hmac/${HMACTEST}.c ${.OBJDIR}
185
186$(HMACTEST): ${HMACTEST}.c e_os.h
187 cc -O -o $(HMACTEST) ${HMACTEST}.c -lcrypto
188
189$(DESTEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/des/${DESTEST}.c
190 cp ${.CURDIR}/../../../lib/libssl/src/crypto/des/${DESTEST}.c ${.OBJDIR}
191
192$(DESTEST): ${DESTEST}.c e_os.h
193 cc -O -o $(DESTEST) ${DESTEST}.c -lcrypto
194
195$(BFTEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/bf/${BFTEST}.c
196 cp ${.CURDIR}/../../../lib/libssl/src/crypto/bf/${BFTEST}.c ${.OBJDIR}
197
198$(BFTEST): ${BFTEST}.c e_os.h
199 cc -O -o $(BFTEST) ${BFTEST}.c -lcrypto
200
201$(RC2TEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/rc2/${RC2TEST}.c
202 cp ${.CURDIR}/../../../lib/libssl/src/crypto/rc2/${RC2TEST}.c ${.OBJDIR}
203
204$(RC2TEST): ${RC2TEST}.c e_os.h
205 cc -O -o $(RC2TEST) ${RC2TEST}.c -lcrypto
206
207$(RC4TEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/rc4/${RC4TEST}.c
208 cp ${.CURDIR}/../../../lib/libssl/src/crypto/rc4/${RC4TEST}.c ${.OBJDIR}
209
210$(RC4TEST): ${RC4TEST}.c e_os.h
211 cc -O -o $(RC4TEST) ${RC4TEST}.c -lcrypto
212
213$(MD2TEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/md2/${MD2TEST}.c
214 cp ${.CURDIR}/../../../lib/libssl/src/crypto/md2/${MD2TEST}.c ${.OBJDIR}
215
216$(MD2TEST): ${MD2TEST}.c e_os.h
217 cc -O -o $(MD2TEST) ${MD2TEST}.c -lcrypto
218
219$(MD4TEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/md4/${MD4TEST}.c
220 cp ${.CURDIR}/../../../lib/libssl/src/crypto/md4/${MD4TEST}.c ${.OBJDIR}
221
222$(MD4TEST): ${MD4TEST}.c e_os.h
223 cc -O -o $(MD4TEST) ${MD4TEST}.c -lcrypto
224
225$(MD5TEST).c: ${.CURDIR}/../../../lib/libssl/src/crypto/md5/${MD5TEST}.c
226 cp ${.CURDIR}/../../../lib/libssl/src/crypto/md5/${MD5TEST}.c ${.OBJDIR}
227
228$(MD5TEST): ${MD5TEST}.c e_os.h
229 cc -O -o $(MD5TEST) ${MD5TEST}.c -lcrypto
230
231.include <bsd.regress.mk>
diff --git a/src/regress/lib/libssl/README b/src/regress/lib/libssl/README
new file mode 100644
index 0000000000..878feca400
--- /dev/null
+++ b/src/regress/lib/libssl/README
@@ -0,0 +1,6 @@
1testenc.sh tests encryption routines
2testdsa.sh tests DSA certificate generation
3test_server.sh starts a tls1 server using the above generated certificate
4test_client.sh starts a client to talk to the server.
5testrsa.sh tests RSA certificate generation
6
diff --git a/src/regress/lib/libssl/openssl.cnf b/src/regress/lib/libssl/openssl.cnf
new file mode 100644
index 0000000000..9b6cf400c6
--- /dev/null
+++ b/src/regress/lib/libssl/openssl.cnf
@@ -0,0 +1,29 @@
1# $OpenBSD: openssl.cnf,v 1.2 2001/01/29 02:05:46 niklas Exp $
2
3#
4# SSLeay example configuration file.
5# This is mostly being used for generation of certificate requests.
6#
7# hacked by iang to do DSA certs - Server
8
9RANDFILE = ./.rnd
10
11####################################################################
12[ req ]
13distinguished_name = req_distinguished_name
14encrypt_rsa_key = no
15
16[ req_distinguished_name ]
17countryName = Country Name (2 letter code)
18countryName_default = CA
19countryName_value = CA
20
21organizationName = Organization Name (eg, company)
22organizationName_value = Shake it Vera
23
240.commonName = Common Name (eg, YOUR name)
250.commonName_value = Wastelandus
26
271.commonName = Common Name (eg, YOUR name)
281.commonName_value = Maximus
29
diff --git a/src/regress/lib/libssl/test_client.sh b/src/regress/lib/libssl/test_client.sh
new file mode 100644
index 0000000000..4f17fad80e
--- /dev/null
+++ b/src/regress/lib/libssl/test_client.sh
@@ -0,0 +1,13 @@
1#!/bin/sh
2# $OpenBSD: test_client.sh,v 1.3 2001/01/29 02:05:48 niklas Exp $
3
4
5echo
6echo This starts a tls1 mode client to talk to the server run by
7echo ./testserver.sh. You should start the server first.
8echo
9echo type in this window after ssl negotiation and your output should
10echo be echoed by the server.
11echo
12echo
13/usr/sbin/openssl s_client -tls1
diff --git a/src/regress/lib/libssl/test_server.sh b/src/regress/lib/libssl/test_server.sh
new file mode 100644
index 0000000000..a9e2c84d4f
--- /dev/null
+++ b/src/regress/lib/libssl/test_server.sh
@@ -0,0 +1,11 @@
1#!/bin/sh
2# $OpenBSD: test_server.sh,v 1.3 2001/01/29 02:05:48 niklas Exp $
3
4
5echo This starts a tls1 mode server using the DSA certificate in ./server.pem
6echo Run ./testclient.sh in another window and type at it, you should
7echo see the results of the ssl negotiation, and stuff you type in the client
8echo should echo in this window
9echo
10echo
11/usr/sbin/openssl s_server -tls1 -key testdsa.key -cert testdsa.pem
diff --git a/src/regress/lib/libssl/testdsa.sh b/src/regress/lib/libssl/testdsa.sh
new file mode 100644
index 0000000000..48526eec11
--- /dev/null
+++ b/src/regress/lib/libssl/testdsa.sh
@@ -0,0 +1,29 @@
1#!/bin/sh
2# $OpenBSD: testdsa.sh,v 1.4 2001/01/29 02:05:48 niklas Exp $
3
4
5#Test DSA certificate generation of openssl
6
7cd $1
8
9# Generate DSA paramter set
10openssl dsaparam 512 -out dsa512.pem
11if [ $? != 0 ]; then
12 exit 1;
13fi
14
15
16# Denerate a DSA certificate
17openssl req -config $2/openssl.cnf -x509 -newkey dsa:dsa512.pem -out testdsa.pem -keyout testdsa.key
18if [ $? != 0 ]; then
19 exit 1;
20fi
21
22
23# Now check the certificate
24openssl x509 -text -in testdsa.pem
25if [ $? != 0 ]; then
26 exit 1;
27fi
28
29exit 0
diff --git a/src/regress/lib/libssl/testenc.sh b/src/regress/lib/libssl/testenc.sh
new file mode 100644
index 0000000000..355e9cd923
--- /dev/null
+++ b/src/regress/lib/libssl/testenc.sh
@@ -0,0 +1,70 @@
1#!/bin/sh
2# $OpenBSD: testenc.sh,v 1.6 2002/01/15 18:51:39 art Exp $
3
4
5testsrc=$2/openssl.cnf
6test=$1/p
7cmd=/usr/sbin/openssl
8
9cd $1
10
11cat $testsrc >$test;
12
13echo cat
14$cmd enc < $test > $test.cipher
15$cmd enc < $test.cipher >$test.clear
16cmp $test $test.clear
17if [ $? != 0 ]
18then
19 exit 1
20else
21 /bin/rm $test.cipher $test.clear
22fi
23echo base64
24$cmd enc -a -e < $test > $test.cipher
25$cmd enc -a -d < $test.cipher >$test.clear
26cmp $test $test.clear
27if [ $? != 0 ]
28then
29 exit 1
30else
31 /bin/rm $test.cipher $test.clear
32fi
33
34/bin/rm -f $test
35exit 0
36
37# These tests are now done by the makefile.
38
39for i in rc4 \
40 des-cfb des-ede-cfb des-ede3-cfb \
41 des-ofb des-ede-ofb des-ede3-ofb \
42 des-ecb des-ede des-ede3 desx \
43 des-cbc des-ede-cbc des-ede3-cbc \
44 rc2-ecb rc2-cfb rc2-ofb rc2-cbc \
45 bf-ecb bf-cfb bf-ofb bf-cbc rc4 \
46 cast5-ecb cast5-cfb cast5-ofb cast5-cbc
47do
48 echo $i
49 $cmd $i -bufsize 113 -e -k test < $test > $test.$i.cipher
50 $cmd $i -bufsize 157 -d -k test < $test.$i.cipher >$test.$i.clear
51 cmp $test $test.$i.clear
52 if [ $? != 0 ]
53 then
54 exit 1
55 else
56 /bin/rm $test.$i.cipher $test.$i.clear
57 fi
58
59 echo $i base64
60 $cmd $i -bufsize 113 -a -e -k test < $test > $test.$i.cipher
61 $cmd $i -bufsize 157 -a -d -k test < $test.$i.cipher >$test.$i.clear
62 cmp $test $test.$i.clear
63 if [ $? != 0 ]
64 then
65 exit 1
66 else
67 /bin/rm $test.$i.cipher $test.$i.clear
68 fi
69done
70rm -f $test
diff --git a/src/regress/lib/libssl/testrsa.sh b/src/regress/lib/libssl/testrsa.sh
new file mode 100644
index 0000000000..17c6abf7ce
--- /dev/null
+++ b/src/regress/lib/libssl/testrsa.sh
@@ -0,0 +1,29 @@
1#!/bin/sh
2# $OpenBSD: testrsa.sh,v 1.6 2002/01/02 15:13:18 art Exp $
3
4
5#Test RSA certificate generation of openssl
6
7cd $1
8
9# Generate RSA private key
10openssl genrsa -out rsakey.pem
11if [ $? != 0 ]; then
12 exit 1;
13fi
14
15
16# Generate an RSA certificate
17openssl req -config $2/openssl.cnf -key rsakey.pem -new -x509 -days 365 -out rsacert.pem
18if [ $? != 0 ]; then
19 exit 1;
20fi
21
22
23# Now check the certificate
24openssl x509 -text -in rsacert.pem
25if [ $? != 0 ]; then
26 exit 1;
27fi
28
29exit 0