summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/sys/unix/syscall_unix_test.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2017-11-13 09:09:58 -0800
committerGitHub <noreply@github.com>2017-11-13 09:09:58 -0800
commit1329aa51b605cb54ba9aae3a82a0a87b881fb7b3 (patch)
tree93cbf354ab894a560fc2cef8ef685d681b4ff889 /vendor/golang.org/x/sys/unix/syscall_unix_test.go
parent7304a61ef597970be3031b14e652fb3a4df44304 (diff)
downloadchat-1329aa51b605cb54ba9aae3a82a0a87b881fb7b3.tar.gz
chat-1329aa51b605cb54ba9aae3a82a0a87b881fb7b3.tar.bz2
chat-1329aa51b605cb54ba9aae3a82a0a87b881fb7b3.zip
Updating server dependancies. (#7816)
Diffstat (limited to 'vendor/golang.org/x/sys/unix/syscall_unix_test.go')
-rw-r--r--vendor/golang.org/x/sys/unix/syscall_unix_test.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/vendor/golang.org/x/sys/unix/syscall_unix_test.go b/vendor/golang.org/x/sys/unix/syscall_unix_test.go
index 394b3502e..d0a09ce88 100644
--- a/vendor/golang.org/x/sys/unix/syscall_unix_test.go
+++ b/vendor/golang.org/x/sys/unix/syscall_unix_test.go
@@ -138,6 +138,9 @@ func TestPassFD(t *testing.T) {
uc.Close()
})
_, oobn, _, _, err := uc.ReadMsgUnix(buf, oob)
+ if err != nil {
+ t.Fatalf("ReadMsgUnix: %v", err)
+ }
closeUnix.Stop()
scms, err := unix.ParseSocketControlMessage(oob[:oobn])
@@ -335,6 +338,9 @@ func TestDup(t *testing.T) {
t.Fatalf("Write to dup2 fd failed: %v", err)
}
_, err = unix.Seek(f, 0, 0)
+ if err != nil {
+ t.Fatalf("Seek failed: %v", err)
+ }
_, err = unix.Read(f, b2)
if err != nil {
t.Fatalf("Read back failed: %v", err)
@@ -343,3 +349,50 @@ func TestDup(t *testing.T) {
t.Errorf("Dup: stdout write not in file, expected %v, got %v", string(b1), string(b2))
}
}
+
+func TestPoll(t *testing.T) {
+ f, cleanup := mktmpfifo(t)
+ defer cleanup()
+
+ const timeout = 100
+
+ ok := make(chan bool, 1)
+ go func() {
+ select {
+ case <-time.After(10 * timeout * time.Millisecond):
+ t.Errorf("Poll: failed to timeout after %d milliseconds", 10*timeout)
+ case <-ok:
+ }
+ }()
+
+ fds := []unix.PollFd{{Fd: int32(f.Fd()), Events: unix.POLLIN}}
+ n, err := unix.Poll(fds, timeout)
+ ok <- true
+ if err != nil {
+ t.Errorf("Poll: unexpected error: %v", err)
+ return
+ }
+ if n != 0 {
+ t.Errorf("Poll: wrong number of events: got %v, expected %v", n, 0)
+ return
+ }
+}
+
+// mktmpfifo creates a temporary FIFO and provides a cleanup function.
+func mktmpfifo(t *testing.T) (*os.File, func()) {
+ err := unix.Mkfifo("fifo", 0666)
+ if err != nil {
+ t.Fatalf("mktmpfifo: failed to create FIFO: %v", err)
+ }
+
+ f, err := os.OpenFile("fifo", os.O_RDWR, 0666)
+ if err != nil {
+ os.Remove("fifo")
+ t.Fatalf("mktmpfifo: failed to open FIFO: %v", err)
+ }
+
+ return f, func() {
+ f.Close()
+ os.Remove("fifo")
+ }
+}