summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
authoranton <anton@cvs.openbsd.org>2019-03-04 19:35:29 +0000
committeranton <anton@cvs.openbsd.org>2019-03-04 19:35:29 +0000
commit0b7ccf24ee4b6e86ac36eaadf627299c5fa99694 (patch)
treed5ce65faabdb0132254ecc43d09217bf5df06c8e /regress
parentc278d24df638bdf8027a10ff1263e3ce8c597c8d (diff)
add kqueue pty close slave test
Diffstat (limited to 'regress')
-rw-r--r--regress/sys/kern/kqueue/Makefile5
-rw-r--r--regress/sys/kern/kqueue/kqueue-pty.c34
2 files changed, 37 insertions, 2 deletions
diff --git a/regress/sys/kern/kqueue/Makefile b/regress/sys/kern/kqueue/Makefile
index 18fdc010a23..e991a431123 100644
--- a/regress/sys/kern/kqueue/Makefile
+++ b/regress/sys/kern/kqueue/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.25 2019/03/04 19:33:41 anton Exp $
+# $OpenBSD: Makefile,v 1.26 2019/03/04 19:35:28 anton Exp $
PROG= kqueue-test
CFLAGS+=-Wall
@@ -24,6 +24,8 @@ kq-tun: ${PROG}
@-${SUDO} rm -f /dev/tun98 /dev/tun99
kq-pty-1: ${PROG}
${SUDO} ./${PROG} -T1
+kq-pty-2: ${PROG}
+ ${SUDO} ./${PROG} -T2
kq-signal: ${PROG}
./${PROG} -s
kq-fdpass: ${PROG}
@@ -48,6 +50,7 @@ TESTS+= kq-invalid-timer
TESTS+= kq-pipe
TESTS+= kq-process
TESTS+= kq-pty-1
+TESTS+= kq-pty-2
TESTS+= kq-random
TESTS+= kq-regress-1
TESTS+= kq-regress-2
diff --git a/regress/sys/kern/kqueue/kqueue-pty.c b/regress/sys/kern/kqueue/kqueue-pty.c
index 7a2d7b7cb18..068eaabdaae 100644
--- a/regress/sys/kern/kqueue/kqueue-pty.c
+++ b/regress/sys/kern/kqueue/kqueue-pty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kqueue-pty.c,v 1.9 2019/03/04 19:33:41 anton Exp $ */
+/* $OpenBSD: kqueue-pty.c,v 1.10 2019/03/04 19:35:28 anton Exp $ */
/* Written by Michael Shalayeff, 2003, Public Domain */
@@ -116,12 +116,44 @@ pty_rdrw(void)
return (0);
}
+static int
+pty_close(void)
+{
+ struct kevent ev[1];
+ struct timespec ts;
+ int kq, massa, n, slave;
+
+ if (openpty(&massa, &slave, NULL, NULL, NULL) == -1)
+ err(1, "openpty");
+
+ kq = kqueue();
+ if (kq == -1)
+ err(1, "kqueue");
+
+ EV_SET(&ev[0], massa, EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, NULL);
+ if (kevent(kq, ev, 1, NULL, 0, NULL) == -1)
+ err(1, "kevent: add");
+
+ close(slave);
+
+ ts.tv_sec = 5;
+ ts.tv_nsec = 0;
+ n = kevent(kq, NULL, 0, ev, 1, &ts);
+ ASSX(n == 1);
+ ASSX(ev[0].filter == EVFILT_READ);
+ ASSX(ev[0].flags & EV_EOF);
+
+ return 0;
+}
+
int
do_pty(int n)
{
switch (n) {
case 1:
return pty_rdrw();
+ case 2:
+ return pty_close();
default:
errx(1, "unknown pty test number %d", n);
}