From a4f10b37035e781770724661a37a45a83b65c25f Mon Sep 17 00:00:00 2001 From: espie <> Date: Fri, 30 Apr 2004 17:15:12 +0000 Subject: Add tests for strerror. --- src/regress/lib/libc/Makefile | 4 ++-- src/regress/lib/libc/strerror/Makefile | 12 ++++++++++++ src/regress/lib/libc/strerror/strerror_test.c | 28 +++++++++++++++++++++++++++ src/regress/lib/libc/strerror/valid.ok | 5 +++++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 src/regress/lib/libc/strerror/Makefile create mode 100644 src/regress/lib/libc/strerror/strerror_test.c create mode 100644 src/regress/lib/libc/strerror/valid.ok (limited to 'src') 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 @@ -# $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/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 @@ +# $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 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 @@ +/* $OpenBSD: strerror_test.c,v 1.1 2004/04/30 17:15:12 espie Exp $ */ +/* + * Copyright (c) 2004 Marc Espie + * + * 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 +#include +#include +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/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 @@ +Unknown error: 21345 +Unknown error: -21345 +Undefined error: 0 +Unknown error: 2147483647 +Unknown error: -2147483648 -- cgit v1.2.3-55-g6feb