diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2017-02-21 15:46:26 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2017-02-21 15:46:26 +0000 |
commit | 31abf7d17b9116cc88cc3216c9461528b585c623 (patch) | |
tree | af49982698de5b09ddb14587abaf11aaf54d9603 /regress/sys | |
parent | 1c91db5d4ec764ce6d58dbaf08cb9e96cb851fc0 (diff) |
Make test_request_tty() also pass in environments without tty by opening a
pseudo-tty and testing on the slave instead of stderr.
nicm confirms that this approach is fine
bluhm tested in his environment and the tests now pass
from semarie
Diffstat (limited to 'regress/sys')
-rw-r--r-- | regress/sys/kern/pledge/generic/Makefile | 3 | ||||
-rw-r--r-- | regress/sys/kern/pledge/generic/test_tty.c | 10 |
2 files changed, 9 insertions, 4 deletions
diff --git a/regress/sys/kern/pledge/generic/Makefile b/regress/sys/kern/pledge/generic/Makefile index 2d71c81644d..51e4103e910 100644 --- a/regress/sys/kern/pledge/generic/Makefile +++ b/regress/sys/kern/pledge/generic/Makefile @@ -1,8 +1,9 @@ -# $OpenBSD: Makefile,v 1.7 2016/04/25 19:30:10 tedu Exp $ +# $OpenBSD: Makefile,v 1.8 2017/02/21 15:46:25 tb Exp $ PROG= generic SRCS+= main.c manager.c test_stdio.c test_tty.c NOMAN= yes +LDADD+= -lutil CFLAGS+= -Wall -Werror REGRESS_TARGETS+= test_normal diff --git a/regress/sys/kern/pledge/generic/test_tty.c b/regress/sys/kern/pledge/generic/test_tty.c index 695c1e25df6..9c15a97782b 100644 --- a/regress/sys/kern/pledge/generic/test_tty.c +++ b/regress/sys/kern/pledge/generic/test_tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: test_tty.c,v 1.4 2015/10/30 07:24:20 semarie Exp $ */ +/* $OpenBSD: test_tty.c,v 1.5 2017/02/21 15:46:25 tb Exp $ */ /* * Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org> * @@ -24,16 +24,20 @@ #include <unistd.h> #include <stdio.h> #include <stdlib.h> +#include <util.h> void test_request_tty() { - int fd = STDERR_FILENO; + int amaster, fd; struct termios ts; /* sys/termios.h */ struct winsize ws; /* sys/ttycom.h */ - /* TODO: get a tty */ + /* get a tty */ + if (openpty(&amaster, &fd, NULL, NULL, NULL) == -1) + _exit(errno); + close(amaster); /* tests that need tty+proc (stdio for pledge(2) */ if (pledge("stdio tty proc", NULL) == -1) |