cerror and ttyio tests have been atf-ified
This commit is contained in:
parent
016a7f9b90
commit
da0ee23dec
|
@ -1,6 +1,6 @@
|
|||
# $NetBSD: Makefile,v 1.74 2011/01/06 17:22:14 pgoyette Exp $
|
||||
# $NetBSD: Makefile,v 1.75 2011/01/07 02:51:38 pgoyette Exp $
|
||||
|
||||
SUBDIR+= citrus db divrem getaddrinfo int_fmtio locale regex rpc sys
|
||||
SUBDIR+= citrus db divrem getaddrinfo int_fmtio locale regex rpc
|
||||
|
||||
.include <bsd.own.mk>
|
||||
.include <bsd.sys.mk>
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.2 2003/02/07 21:00:43 cgd Exp $
|
||||
|
||||
SUBDIR+= cerror ttyio
|
||||
|
||||
.include <bsd.subdir.mk>
|
|
@ -1,4 +0,0 @@
|
|||
# $NetBSD: Makefile.inc,v 1.1 2001/09/20 16:56:52 atatat Exp $
|
||||
#
|
||||
# do not install regression test programs
|
||||
proginstall::
|
|
@ -1,15 +0,0 @@
|
|||
# $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>
|
|
@ -1,84 +0,0 @@
|
|||
/* $NetBSD: cerror.c,v 1.3 2008/07/21 14:33:31 lukem 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.3 2008/07/21 14:33:31 lukem Exp $");
|
||||
__COPYRIGHT("@(#) Copyright (c) 2003\
|
||||
Christopher G. Demetriou. All rights reserved.");
|
||||
#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);
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
# $NetBSD: Makefile,v 1.3 2002/09/18 05:41:42 lukem Exp $
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
PROG= ioctl
|
||||
WARNS= 2
|
||||
LDADD+= -lutil
|
||||
DPADD+= ${LIBUTIL}
|
||||
|
||||
regress: ${PROG}
|
||||
@if ./ioctl > /dev/null; then \
|
||||
echo "PASSED"; \
|
||||
else \
|
||||
echo "FAILED"; \
|
||||
fi
|
||||
|
||||
.include <bsd.prog.mk>
|
|
@ -1,147 +0,0 @@
|
|||
/* $NetBSD: ioctl.c,v 1.3 2008/04/28 20:23:05 martin Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Andrew Brown.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``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 FOUNDATION OR CONTRIBUTORS
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: ioctl.c,v 1.3 2008/04/28 20:23:05 martin Exp $");
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <termios.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <err.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#include <util.h>
|
||||
#elif defined(__bsdi__)
|
||||
int openpty(int *, int *, char *, struct termios *, struct winsize *);
|
||||
#elif defined(__FreeBSD__)
|
||||
#include <libutil.h>
|
||||
#else
|
||||
#error where openpty?
|
||||
#endif
|
||||
|
||||
/* ARGSUSED */
|
||||
static void
|
||||
sigchld(int nsig)
|
||||
{
|
||||
if (wait(NULL) == -1)
|
||||
err(1, "wait");
|
||||
}
|
||||
|
||||
/* ARGSUSED */
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
int m, s, rc;
|
||||
char name[128], buf[128];
|
||||
struct termios term;
|
||||
struct sigaction sa;
|
||||
|
||||
/* unbuffer stdout */
|
||||
setbuf(stdout, NULL);
|
||||
|
||||
/* get terminal settings for later use */
|
||||
if (tcgetattr(STDIN_FILENO, &term) == -1)
|
||||
err(1, "tcgetattr");
|
||||
|
||||
/* get a tty */
|
||||
if (openpty(&m, &s, name, &term, NULL) == -1)
|
||||
err(1, "openpty");
|
||||
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
err(1, "fork");
|
||||
/* NOTREACHED */
|
||||
case 0:
|
||||
/* wait for parent to get set up */
|
||||
(void) sleep(1);
|
||||
(void) printf("child1: exiting\n");
|
||||
exit(0);
|
||||
/* NOTREACHED */
|
||||
default:
|
||||
(void) printf("parent: spawned child1\n");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (fork()) {
|
||||
case -1:
|
||||
err(1, "fork");
|
||||
/* NOTREACHED */
|
||||
case 0:
|
||||
/* wait for parent to get upset */
|
||||
(void) sleep(2);
|
||||
/* drain the tty q */
|
||||
if (read(m, buf, sizeof(buf)) == -1)
|
||||
err(1, "read");
|
||||
(void) printf("child2: exiting\n");
|
||||
exit(0);
|
||||
/* NOTREACHED */
|
||||
default:
|
||||
(void) printf("parent: spawned child2\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* set up a restarting signal handler */
|
||||
(void) sigemptyset(&sa.sa_mask);
|
||||
sa.sa_handler = sigchld;
|
||||
sa.sa_flags = SA_RESTART;
|
||||
if (sigaction(SIGCHLD, &sa, NULL) == -1)
|
||||
err(1, "sigaction");
|
||||
|
||||
/* put something in the output q */
|
||||
if (write(s, "Hello world\n", 12) == -1)
|
||||
err(1, "write");
|
||||
|
||||
/* ask for output to drain but don't drain it */
|
||||
rc = 0;
|
||||
if (tcsetattr(s, TCSADRAIN, &term) == -1) {
|
||||
(void) printf("parent: tcsetattr: %s\n", strerror(errno));
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
/* wait for last child */
|
||||
sa.sa_handler = SIG_DFL;
|
||||
if (sigaction(SIGCHLD, &sa, NULL) == -1)
|
||||
err(1, "sigaction");
|
||||
(void) wait(NULL);
|
||||
|
||||
exit(rc);
|
||||
/* NOTREACHED */
|
||||
exit(rc);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue