diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2015-05-05 20:16:45 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2015-05-05 20:16:45 +0000 |
commit | 7c0d29c2642e55e0b7b8c0af53bb0d20e9d2e06e (patch) | |
tree | 66e9ac5bae37384a00e89e7a63680245cbad5572 /regress | |
parent | 201a10356f5cfc622b5d4c4a3547f9505cdf0b50 (diff) |
fifofs now respects the flags a descriptor was opened with.
Also add tests for when no FD events are specified.
A few tests still don't pass which will be addressed shortly.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/sys/fifofs/fifotest.c | 22 | ||||
-rw-r--r-- | regress/sys/fifofs/fifotest.out | 70 |
2 files changed, 80 insertions, 12 deletions
diff --git a/regress/sys/fifofs/fifotest.c b/regress/sys/fifofs/fifotest.c index cd17244cdae..87c1332dc27 100644 --- a/regress/sys/fifofs/fifotest.c +++ b/regress/sys/fifofs/fifotest.c @@ -100,9 +100,11 @@ runtest(char *fifo, int flags, int timeout) dopoll(fd, POLLIN|POLLOUT, "POLLIN|POLLOUT", timeout); dopoll(fd, POLLIN, "POLLIN", timeout); dopoll(fd, POLLOUT, "POLLOUT", timeout); + dopoll(fd, 0, "(none)", timeout); doselect(fd, fd, timeout); doselect(fd, -1, timeout); doselect(-1, fd, timeout); + doselect(-1, -1, timeout); if (write(fd, "test", 4) != 4) { printf("write error: %s\n", strerror(errno)); @@ -113,9 +115,11 @@ runtest(char *fifo, int flags, int timeout) dopoll(fd, POLLIN|POLLOUT, "POLLIN|POLLOUT", timeout); dopoll(fd, POLLIN, "POLLIN", timeout); dopoll(fd, POLLOUT, "POLLOUT", timeout); + dopoll(fd, 0, "(none)", timeout); doselect(fd, fd, timeout); doselect(fd, -1, timeout); doselect(-1, fd, timeout); + doselect(-1, -1, timeout); if ((nread = read(fd, buf, sizeof(buf))) <= 0) { printf("read error: %s\n", (nread == 0) ? "EOF" : strerror(errno)); @@ -175,7 +179,7 @@ eoftest(char *fifo, int flags, int timeout) /* * Test all combinations of select and poll. */ - for (pass = 0; pass < 12; pass++) { + for (pass = 0; pass < 16; pass++) { /* * We run each test twice, once with a fresh fifo, * and once with a reused one. @@ -226,16 +230,24 @@ eoftest(char *fifo, int flags, int timeout) break; case 6: case 7: - doselect(fd, fd, timeout); + dopoll(fd, 0, "(none)", timeout); break; case 8: case 9: - doselect(fd, -1, timeout); + doselect(fd, fd, timeout); break; case 10: case 11: + doselect(fd, -1, timeout); + break; + case 12: + case 13: doselect(-1, fd, timeout); break; + case 14: + case 15: + doselect(-1, -1, timeout); + break; } wait(&status); if ((nread = read(fd, buf, sizeof(buf))) < 0) { @@ -315,8 +327,8 @@ doselect(int rfd, int wfd, int timeout) FD_SET(wfd, wfds); } - printf("\tselect%s%s\n", rfds ? " read" : "", - wfds ? " write" : ""); + printf("\tselect%s%s, timeout=%d\n", rfds ? " read" : "", + wfds ? " write" : rfds ? "" : " (none)", timeout); alarm(2); nready = select(maxfd + 1, rfds, wfds, NULL, &tv); diff --git a/regress/sys/fifofs/fifotest.out b/regress/sys/fifofs/fifotest.out index c0accede612..02f90815878 100644 --- a/regress/sys/fifofs/fifotest.out +++ b/regress/sys/fifofs/fifotest.out @@ -8,12 +8,16 @@ Testing empty FIFO: 0 fd(s) ready poll POLLOUT, timeout=0 1 fd(s) ready, revents == POLLOUT + poll (none), timeout=0 + 0 fd(s) ready select read write 1 fd(s) ready, writeable select read 0 fd(s) ready select write 1 fd(s) ready, writeable + select + 0 fd(s) ready Testing full FIFO: poll POLLIN|POLLOUT, timeout=0 @@ -22,12 +26,16 @@ Testing full FIFO: 1 fd(s) ready, revents == POLLIN poll POLLOUT, timeout=0 1 fd(s) ready, revents == POLLOUT + poll (none), timeout=0 + 0 fd(s) ready select read write 2 fd(s) ready, readable, writeable select read 1 fd(s) ready, readable select write 1 fd(s) ready, writeable + select + 0 fd(s) ready received 'test' from FIFO Opened fifo fi.fo.fum @@ -39,12 +47,16 @@ Testing empty FIFO: poll: Interrupted system call poll POLLOUT, timeout=-1 1 fd(s) ready, revents == POLLOUT + poll (none), timeout=-1 +poll: Interrupted system call select read write 1 fd(s) ready, writeable select read 0 fd(s) ready select write 1 fd(s) ready, writeable + select + 0 fd(s) ready Testing full FIFO: poll POLLIN|POLLOUT, timeout=-1 @@ -53,12 +65,16 @@ Testing full FIFO: 1 fd(s) ready, revents == POLLIN poll POLLOUT, timeout=-1 1 fd(s) ready, revents == POLLOUT + poll (none), timeout=-1 +poll: Interrupted system call select read write 2 fd(s) ready, readable, writeable select read 1 fd(s) ready, readable select write 1 fd(s) ready, writeable + select + 0 fd(s) ready received 'test' from FIFO Opened fifo fi.fo.fum (nonblocking) @@ -70,12 +86,16 @@ Testing empty FIFO: 0 fd(s) ready poll POLLOUT, timeout=0 1 fd(s) ready, revents == POLLOUT + poll (none), timeout=0 + 0 fd(s) ready select read write 1 fd(s) ready, writeable select read 0 fd(s) ready select write 1 fd(s) ready, writeable + select + 0 fd(s) ready Testing full FIFO: poll POLLIN|POLLOUT, timeout=0 @@ -84,12 +104,16 @@ Testing full FIFO: 1 fd(s) ready, revents == POLLIN poll POLLOUT, timeout=0 1 fd(s) ready, revents == POLLOUT + poll (none), timeout=0 + 0 fd(s) ready select read write 2 fd(s) ready, readable, writeable select read 1 fd(s) ready, readable select write 1 fd(s) ready, writeable + select + 0 fd(s) ready received 'test' from FIFO Opened fifo fi.fo.fum (nonblocking) @@ -101,12 +125,16 @@ Testing empty FIFO: poll: Interrupted system call poll POLLOUT, timeout=-1 1 fd(s) ready, revents == POLLOUT + poll (none), timeout=-1 +poll: Interrupted system call select read write 1 fd(s) ready, writeable select read 0 fd(s) ready select write 1 fd(s) ready, writeable + select + 0 fd(s) ready Testing full FIFO: poll POLLIN|POLLOUT, timeout=-1 @@ -115,12 +143,16 @@ Testing full FIFO: 1 fd(s) ready, revents == POLLIN poll POLLOUT, timeout=-1 1 fd(s) ready, revents == POLLOUT + poll (none), timeout=-1 +poll: Interrupted system call select read write 2 fd(s) ready, readable, writeable select read 1 fd(s) ready, readable select write 1 fd(s) ready, writeable + select + 0 fd(s) ready received 'test' from FIFO Opened fifo for reading fi.fo.fum (nonblocking) @@ -132,7 +164,7 @@ Testing EOF FIFO behavior (pass 0): Testing EOF FIFO behavior (pass 1): poll POLLIN|POLLOUT, timeout=-1 - 1 fd(s) ready, revents == POLLOUT + 1 fd(s) ready, revents == POLLIN POLLHUP received EOF from FIFO Opened fifo for reading fi.fo.fum (nonblocking) @@ -162,35 +194,59 @@ Testing EOF FIFO behavior (pass 5): Opened fifo for reading fi.fo.fum (nonblocking) Testing EOF FIFO behavior (pass 6): + poll (none), timeout=-1 +poll: Interrupted system call + received EOF from FIFO + +Testing EOF FIFO behavior (pass 7): + poll (none), timeout=-1 +poll: Interrupted system call + received EOF from FIFO + +Opened fifo for reading fi.fo.fum (nonblocking) + +Testing EOF FIFO behavior (pass 8): select read write 1 fd(s) ready, writeable received EOF from FIFO -Testing EOF FIFO behavior (pass 7): +Testing EOF FIFO behavior (pass 9): select read write 1 fd(s) ready, writeable received EOF from FIFO Opened fifo for reading fi.fo.fum (nonblocking) -Testing EOF FIFO behavior (pass 8): +Testing EOF FIFO behavior (pass 10): select read 0 fd(s) ready received EOF from FIFO -Testing EOF FIFO behavior (pass 9): +Testing EOF FIFO behavior (pass 11): select read - 0 fd(s) ready + 1 fd(s) ready, readable received EOF from FIFO Opened fifo for reading fi.fo.fum (nonblocking) -Testing EOF FIFO behavior (pass 10): +Testing EOF FIFO behavior (pass 12): select write 1 fd(s) ready, writeable received EOF from FIFO -Testing EOF FIFO behavior (pass 11): +Testing EOF FIFO behavior (pass 13): select write 1 fd(s) ready, writeable received EOF from FIFO + +Opened fifo for reading fi.fo.fum (nonblocking) + +Testing EOF FIFO behavior (pass 14): + select + 0 fd(s) ready + received EOF from FIFO + +Testing EOF FIFO behavior (pass 15): + select + 0 fd(s) ready + received EOF from FIFO |