Skip to content

Commit

Permalink
unix: don't fail TestPpoll on EINTR
Browse files Browse the repository at this point in the history
TestPpoll sometimes fails builders due to Ppoll getting interrupted and
returning EINTR:

--- FAIL: TestPpoll (0.00s)
    syscall_linux_test.go:299: Ppoll: unexpected error: interrupted system call

Fix this by retrying Ppoll in case of EINTR, same as CL 298189 in
TestPoll.

Fixes golang/go#66324

Change-Id: I8ce4e2c00fe3b7a078cd75b4b15bb076d3a87fb2
Reviewed-on: https://go-review.googlesource.com/c/sys/+/627395
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
  • Loading branch information
tklauser authored and gopherbot committed Nov 13, 2024
1 parent d2cea70 commit 3cf1e67
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions unix/syscall_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,15 +337,21 @@ func TestPpoll(t *testing.T) {

fds := []unix.PollFd{{Fd: int32(f.Fd()), Events: unix.POLLIN}}
timeoutTs := unix.NsecToTimespec(int64(timeout))
n, err := unix.Ppoll(fds, &timeoutTs, nil)
ok <- true
if err != nil {
t.Errorf("Ppoll: unexpected error: %v", err)
return
}
if n != 0 {
t.Errorf("Ppoll: wrong number of events: got %v, expected %v", n, 0)
return
for {
n, err := unix.Ppoll(fds, &timeoutTs, nil)
ok <- true
if err == unix.EINTR {
t.Log("Ppoll interrupted")
continue
} else if err != nil {
t.Errorf("Ppoll: unexpected error: %v", err)
return
}
if n != 0 {
t.Errorf("Ppoll: wrong number of events: got %v, expected %v", n, 0)
return
}
break
}
}

Expand Down

0 comments on commit 3cf1e67

Please sign in to comment.