From 88b6017d06564827ae436c619d52116f470a3611 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 8 Mar 2021 17:15:44 +0100 Subject: [PATCH] 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 Trust: Matt Layher Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Matt Layher --- unix/syscall_unix_test.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/unix/syscall_unix_test.go b/unix/syscall_unix_test.go index fd67d8b0..5d31524d 100644 --- a/unix/syscall_unix_test.go +++ b/unix/syscall_unix_test.go @@ -509,16 +509,21 @@ func TestPoll(t *testing.T) { } }() - 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 } }