unix: don't fail TestPoll on EINTR from Poll
Occassionaly TestPoll fails on some builders due to Poll getting
interrupted:
--- FAIL: TestPoll (0.00s)
syscall_unix_test.go:516: Poll: unexpected error: interrupted system call
FAIL
FAIL golang.org/x/sys/unix 0.956s
Fix this by retrying Poll in case of EINTR, same as CL 207861 did in
TestSelect.
Change-Id: I78ada14d7409e6cde852d76abd5a9a1b1bb645d2
Reviewed-on: https://go-review.googlesource.com/c/sys/+/298189
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
diff --git a/unix/syscall_unix_test.go b/unix/syscall_unix_test.go
index fd67d8b..5d31524 100644
--- a/unix/syscall_unix_test.go
+++ b/unix/syscall_unix_test.go
@@ -509,16 +509,21 @@
}
}()
- 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
+ for {
+ fds := []unix.PollFd{{Fd: int32(f.Fd()), Events: unix.POLLIN}}
+ n, err := unix.Poll(fds, timeout)
+ ok <- true
+ if err == unix.EINTR {
+ t.Logf("Poll interrupted")
+ continue
+ } else 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)
+ }
+ break
}
}