Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/regress/lib/libc/sys let's try to make sure that the mips ce...
details: https://anonhg.NetBSD.org/src/rev/274b72637397
branches: trunk
changeset: 542803:274b72637397
user: cgd <cgd%NetBSD.org@localhost>
date: Fri Feb 07 21:00:43 2003 +0000
description:
let's try to make sure that the mips cerror botch I just fixed doesn't
happen again. Check that cerror is stuffing errno in the right place
and that 32- and 64-bit returns of -1 happen as expected.
diffstat:
regress/lib/libc/sys/Makefile | 4 +-
regress/lib/libc/sys/cerror/Makefile | 15 ++++++
regress/lib/libc/sys/cerror/cerror.c | 84 ++++++++++++++++++++++++++++++++++++
3 files changed, 101 insertions(+), 2 deletions(-)
diffs (118 lines):
diff -r f95e17044e63 -r 274b72637397 regress/lib/libc/sys/Makefile
--- a/regress/lib/libc/sys/Makefile Fri Feb 07 20:40:37 2003 +0000
+++ b/regress/lib/libc/sys/Makefile Fri Feb 07 21:00:43 2003 +0000
@@ -1,5 +1,5 @@
-# $NetBSD: Makefile,v 1.1 2001/09/20 16:56:52 atatat Exp $
+# $NetBSD: Makefile,v 1.2 2003/02/07 21:00:43 cgd Exp $
-SUBDIR+= ttyio
+SUBDIR+= cerror ttyio
.include <bsd.subdir.mk>
diff -r f95e17044e63 -r 274b72637397 regress/lib/libc/sys/cerror/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libc/sys/cerror/Makefile Fri Feb 07 21:00:43 2003 +0000
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile,v 1.1 2003/02/07 21:00:44 cgd Exp $
+
+NOMAN= # defined
+
+PROG= cerror
+WARNS= 2
+
+regress: ${PROG}
+ @if ./${PROG} > /dev/null; then \
+ echo "PASSED"; \
+ else \
+ echo "FAILED"; \
+ fi
+
+.include <bsd.prog.mk>
diff -r f95e17044e63 -r 274b72637397 regress/lib/libc/sys/cerror/cerror.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libc/sys/cerror/cerror.c Fri Feb 07 21:00:43 2003 +0000
@@ -0,0 +1,84 @@
+/* $NetBSD: cerror.c,v 1.1 2003/02/07 21:00:44 cgd Exp $ */
+
+/*
+ * Copyright (c) 2003 Christopher G. Demetriou
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the
+ * NetBSD Project. See http://www.netbsd.org/ for
+ * information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
+ */
+
+/*
+ * Test program to make sure that libc's cerror (error handler) is doing
+ * approximately the right thing for both 32-bit and 64-bit error returns.
+ */
+
+#include <sys/cdefs.h>
+#if !defined(lint)
+__RCSID("$NetBSD: cerror.c,v 1.1 2003/02/07 21:00:44 cgd Exp $");
+__COPYRIGHT(
+"@(#) Copyright (c) 2003 Christopher G. Demetriou. All rights reserved.\n");
+#endif /* not lint */
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define ERROR(x) do { fprintf(stderr, "%s\n", x); errs++; } while (0)
+
+int
+main(int argc, char *argv[])
+{
+ int rv_int;
+ off_t rv_off;
+ int errs = 0;
+
+ /* Make sure file desc 4 is closed. */
+ (void)close(4);
+
+ /* Check error and 32-bit return code. */
+ errno = 0;
+ rv_int = close(4);
+ if (errno != EBADF)
+ ERROR("close() on closed FD didn't set errno to EBADF");
+ if (rv_int != -1)
+ ERROR("close() on closed FD didn't return -1");
+
+
+ /* Check error and 64-bit return code. */
+ errno = 0;
+ rv_off = lseek(4, (off_t)0, SEEK_SET);
+ if (errno != EBADF)
+ ERROR("lseek() on closed FD didn't set errno to EBADF");
+ if (rv_off != (off_t)-1)
+ ERROR("lseek() on closed FD didn't return -1");
+
+ exit(errs == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+}
Home |
Main Index |
Thread Index |
Old Index