summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorespie <>2004-04-30 17:15:12 +0000
committerespie <>2004-04-30 17:15:12 +0000
commita4f10b37035e781770724661a37a45a83b65c25f (patch)
tree6a61d7d91122d65d5385f9cc2fabd4ad8758be91 /src
parent0a296eded866d7ff51a920ebce2ab8399cf97cf3 (diff)
downloadopenbsd-a4f10b37035e781770724661a37a45a83b65c25f.tar.gz
openbsd-a4f10b37035e781770724661a37a45a83b65c25f.tar.bz2
openbsd-a4f10b37035e781770724661a37a45a83b65c25f.zip
Add tests for strerror.
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libc/Makefile4
-rw-r--r--src/regress/lib/libc/strerror/Makefile12
-rw-r--r--src/regress/lib/libc/strerror/strerror_test.c28
-rw-r--r--src/regress/lib/libc/strerror/valid.ok5
4 files changed, 47 insertions, 2 deletions
diff --git a/src/regress/lib/libc/Makefile b/src/regress/lib/libc/Makefile
index 86c2e4b59a..935ca659d7 100644
--- a/src/regress/lib/libc/Makefile
+++ b/src/regress/lib/libc/Makefile
@@ -1,8 +1,8 @@
1# $OpenBSD: Makefile,v 1.13 2004/02/11 23:38:11 deraadt Exp $ 1# $OpenBSD: Makefile,v 1.14 2004/04/30 17:15:12 espie Exp $
2 2
3SUBDIR+= _setjmp alloca atexit db getaddrinfo longjmp malloc 3SUBDIR+= _setjmp alloca atexit db getaddrinfo longjmp malloc
4SUBDIR+= popen regex setjmp setjmp-signal sigreturn sigsetjmp 4SUBDIR+= popen regex setjmp setjmp-signal sigreturn sigsetjmp
5SUBDIR+= sprintf time 5SUBDIR+= sprintf strerror time
6 6
7.if (${MACHINE_ARCH} != "vax") 7.if (${MACHINE_ARCH} != "vax")
8SUBDIR+= ieeefp 8SUBDIR+= ieeefp
diff --git a/src/regress/lib/libc/strerror/Makefile b/src/regress/lib/libc/strerror/Makefile
new file mode 100644
index 0000000000..448b6da903
--- /dev/null
+++ b/src/regress/lib/libc/strerror/Makefile
@@ -0,0 +1,12 @@
1# $OpenBSD: Makefile,v 1.1 2004/04/30 17:15:12 espie Exp $
2
3NOMAN=
4PROG=strerror_test
5CPPFLAGS+=-I${.CURDIR}/../../../../lib/libc
6CLEANFILES+= invalid.out valid.out
7
8run-regress-strerror_test: ${PROG}
9 ./${PROG} >${.OBJDIR}/valid.out
10 cmp -s ${.OBJDIR}/valid.out ${.CURDIR}/valid.ok
11
12.include <bsd.regress.mk>
diff --git a/src/regress/lib/libc/strerror/strerror_test.c b/src/regress/lib/libc/strerror/strerror_test.c
new file mode 100644
index 0000000000..5b74df3a6a
--- /dev/null
+++ b/src/regress/lib/libc/strerror/strerror_test.c
@@ -0,0 +1,28 @@
1/* $OpenBSD: strerror_test.c,v 1.1 2004/04/30 17:15:12 espie Exp $ */
2/*
3 * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17#include <string.h>
18#include <stdio.h>
19#include <limits.h>
20int main()
21{
22 printf("%s\n", strerror(21345));
23 printf("%s\n", strerror(-21345));
24 printf("%s\n", strerror(0));
25 printf("%s\n", strerror(INT_MAX));
26 printf("%s\n", strerror(INT_MIN));
27 return 0;
28}
diff --git a/src/regress/lib/libc/strerror/valid.ok b/src/regress/lib/libc/strerror/valid.ok
new file mode 100644
index 0000000000..25b39d3afb
--- /dev/null
+++ b/src/regress/lib/libc/strerror/valid.ok
@@ -0,0 +1,5 @@
1Unknown error: 21345
2Unknown error: -21345
3Undefined error: 0
4Unknown error: 2147483647
5Unknown error: -2147483648