fifofs now respects the flags a descriptor was opened with.
authormillert <millert@openbsd.org>
Tue, 5 May 2015 20:16:44 +0000 (20:16 +0000)
committermillert <millert@openbsd.org>
Tue, 5 May 2015 20:16:44 +0000 (20:16 +0000)
Also add tests for when no FD events are specified.
A few tests still don't pass which will be addressed shortly.

regress/sys/fifofs/fifotest.c
regress/sys/fifofs/fifotest.out

index cd17244..87c1332 100644 (file)
@@ -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);
index c0acced..02f9081 100644 (file)
@@ -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