diff -r fee0771aad22 tools/regression/poll/pipepoll.c --- a/tools/regression/poll/pipepoll.c Sun Jan 01 19:00:13 2012 +0100 +++ b/tools/regression/poll/pipepoll.c Fri Jan 13 00:14:57 2012 +0100 @@ -29,12 +29,24 @@ decode_events(int events) case POLLIN: result = "POLLIN"; break; + case POLLOUT: + result = "POLLOUT"; + break; case POLLHUP: result = "POLLHUP"; break; case POLLIN | POLLHUP: result = "POLLIN | POLLHUP"; break; + case POLLIN | POLLOUT: + result = "POLLIN | POLLOUT"; + break; + case POLLIN | POLLOUT | POLLHUP: + result = "POLLIN | POLLOUT | POLLHUP"; + break; + case POLLOUT | POLLHUP: + result = "POLLOUT | POLLHUP"; + break; default: asprintf(&ncresult, "%#x", events); result = ncresult; @@ -99,12 +111,11 @@ child(int fd, int num) err(1, "open for read"); } pfd.fd = fd; - pfd.events = POLLIN; - + pfd.events = POLLIN | POLLOUT; if (filetype == FT_FIFO) { if ((res = poll(&pfd, 1, 0)) < 0) err(1, "poll"); - report(num++, "0", 0, pfd.revents, res, 0); + report(num++, "0", POLLOUT, pfd.revents, res, 0); } kill(ppid, SIGUSR1); @@ -122,7 +133,7 @@ child(int fd, int num) } if ((res = poll(&pfd, 1, 0)) < 0) err(1, "poll"); - report(num++, "1", 0, pfd.revents, res, 0); + report(num++, "1", POLLOUT, pfd.revents, res, 0); kill(ppid, SIGUSR1); usleep(1); @@ -130,12 +141,12 @@ child(int fd, int num) ; if ((res = poll(&pfd, 1, 0)) < 0) err(1, "poll"); - report(num++, "2", POLLIN, pfd.revents, res, 1); + report(num++, "2", POLLIN | POLLOUT, pfd.revents, res, 1); if (read(fd, buf, sizeof buf) != 1) err(1, "read"); if ((res = poll(&pfd, 1, 0)) < 0) err(1, "poll"); - report(num++, "2a", 0, pfd.revents, res, 0); + report(num++, "2a", POLLOUT, pfd.revents, res, 0); kill(ppid, SIGUSR1); usleep(1); @@ -158,7 +169,7 @@ child(int fd, int num) state4: if ((res = poll(&pfd, 1, 0)) < 0) err(1, "poll"); - report(num++, "4", 0, pfd.revents, res, 0); + report(num++, "4", POLLOUT, pfd.revents, res, 0); kill(ppid, SIGUSR1); usleep(1); @@ -166,7 +177,7 @@ state4: ; if ((res = poll(&pfd, 1, 0)) < 0) err(1, "poll"); - report(num++, "5", POLLIN, pfd.revents, res, 1); + report(num++, "5", POLLIN | POLLOUT, pfd.revents, res, 1); kill(ppid, SIGUSR1); usleep(1); @@ -211,8 +222,16 @@ state4: err(1, "poll"); report(num++, "6d", POLLHUP, pfd.revents, res, 1); } - close(fd); kill(ppid, SIGUSR1); + if (filetype != FT_FIFO) + close (fd); + else { + usleep(1); + while (state != 7) + ; + close(fd); + kill(ppid, SIGUSR1); + } exit(0); } @@ -220,6 +239,9 @@ state4: static void parent(int fd) { + struct pollfd pfd; + int res; + usleep(1); while (state != 1) ; @@ -228,6 +250,12 @@ parent(int fd) if (fd < 0) err(1, "open for write"); } + pfd.fd = fd; + pfd.events = POLLIN | POLLOUT; + + if ((res = poll(&pfd, 1, 0)) < 0) + err(1, "poll"); + report(-1, "1p", POLLOUT, pfd.revents, res, 1); kill(cpid, SIGUSR1); usleep(1); @@ -271,6 +299,21 @@ parent(int fd) usleep(1); while (state != 7) ; + fd = open(FIFONAME, O_WRONLY | O_NONBLOCK); + if (fd < 0) + err(1, "open for write"); + pfd.fd = fd; + if ((res = poll(&pfd, 1, 0)) < 0) + err(1, "poll"); + report(-1, "7", POLLOUT, pfd.revents, res, 1); + kill(cpid, SIGUSR1); + + usleep(1); + while (state != 8) + ; + if ((res = poll(&pfd, 1, 0)) < 0) + err(1, "poll"); + report(-1, "8", POLLHUP, pfd.revents, res, 1); } int