diff options
-rw-r--r-- | regress/sys/kern/unfdpass/Makefile | 12 | ||||
-rw-r--r-- | regress/sys/kern/unfdpass/unfdpass.c | 20 |
2 files changed, 22 insertions, 10 deletions
diff --git a/regress/sys/kern/unfdpass/Makefile b/regress/sys/kern/unfdpass/Makefile index 6fa11cd7e8a..9eb5acd945c 100644 --- a/regress/sys/kern/unfdpass/Makefile +++ b/regress/sys/kern/unfdpass/Makefile @@ -1,10 +1,10 @@ -# $OpenBSD: Makefile,v 1.9 2010/06/21 16:55:52 phessler Exp $ +# $OpenBSD: Makefile,v 1.10 2011/07/06 19:48:10 matthew Exp $ # $NetBSD: Makefile,v 1.3 1998/03/02 21:57:38 cgd Exp $ PROG= unfdpass CLEANFILES+=file1 file2 file3 output test-sock -REGRESS_TARGETS=do-unfdpass1 do-unfdpass2 +REGRESS_TARGETS=do-unfdpass1 do-unfdpass2 do-unfdpass3 do-unfdpass4 do-unfdpass1: ${PROG} ./unfdpass > output @@ -14,4 +14,12 @@ do-unfdpass2: ${PROG} ./unfdpass -p > output cmp -s ${.CURDIR}/expected output +do-unfdpass3: ${PROG} + ./unfdpass -q > output + cmp -s ${.CURDIR}/expected output + +do-unfdpass4: ${PROG} + ./unfdpass -pq > output + cmp -s ${.CURDIR}/expected output + .include <bsd.regress.mk> diff --git a/regress/sys/kern/unfdpass/unfdpass.c b/regress/sys/kern/unfdpass/unfdpass.c index c5d8fe41649..fc0b13cfa31 100644 --- a/regress/sys/kern/unfdpass/unfdpass.c +++ b/regress/sys/kern/unfdpass/unfdpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: unfdpass.c,v 1.16 2008/06/26 05:42:06 ray Exp $ */ +/* $OpenBSD: unfdpass.c,v 1.17 2011/07/06 19:48:10 matthew Exp $ */ /* $NetBSD: unfdpass.c,v 1.3 1998/06/24 23:51:30 thorpej Exp $ */ /*- @@ -52,7 +52,7 @@ #define SOCK_NAME "test-sock" int main(int, char *[]); -void child(int); +void child(int, int); void catch_sigchld(int); /* ARGSUSED */ @@ -72,14 +72,18 @@ main(int argc, char *argv[]) char buf[CMSG_SPACE(sizeof(int) * 3)]; } cmsgbuf; int pflag; + int type = SOCK_STREAM; extern char *__progname; pflag = 0; - while ((i = getopt(argc, argv, "p")) != -1) { + while ((i = getopt(argc, argv, "pq")) != -1) { switch (i) { case 'p': pflag = 1; break; + case 'q': + type = SOCK_SEQPACKET; + break; default: fprintf(stderr, "usage: %s [-p]\n", __progname); exit(1); @@ -103,13 +107,13 @@ main(int argc, char *argv[]) /* * Create the socketpair */ - if (socketpair(PF_LOCAL, SOCK_STREAM, 0, pfd) == -1) + if (socketpair(PF_LOCAL, type, 0, pfd) == -1) err(1, "socketpair"); } else { /* * Create the listen socket. */ - if ((listensock = socket(PF_LOCAL, SOCK_STREAM, 0)) == -1) + if ((listensock = socket(PF_LOCAL, type, 0)) == -1) err(1, "socket"); (void) unlink(SOCK_NAME); @@ -139,7 +143,7 @@ main(int argc, char *argv[]) case 0: if (pfd[0] != -1) close(pfd[0]); - child(pfd[1]); + child(pfd[1], type); /* NOTREACHED */ } @@ -232,7 +236,7 @@ catch_sigchld(sig) } void -child(int sock) +child(int sock, int type) { struct msghdr msg; char fname[16]; @@ -249,7 +253,7 @@ child(int sock) * Create socket if needed and connect to the receiver. */ if (sock == -1) { - if ((sock = socket(PF_LOCAL, SOCK_STREAM, 0)) == -1) + if ((sock = socket(PF_LOCAL, type, 0)) == -1) err(1, "child socket"); (void) memset(&sun, 0, sizeof(sun)); |