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