unix: avoid depending on consistent Revents type in TestPoll

For golang/go#49380

Change-Id: Ie1d370681962d9f69ef54b33ddf38e4c74a2e298
Reviewed-on: https://go-review.googlesource.com/c/sys/+/363660
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Ian Lance Taylor
2021-11-13 00:15:01 +00:00
parent faf0a1b62c
commit 0c823b97ae
+19 -14
View File
@@ -522,20 +522,25 @@ func TestPoll(t *testing.T) {
t.Errorf("Poll: wrong number of events: got %v, expected %v", n, 0) t.Errorf("Poll: wrong number of events: got %v, expected %v", n, 0)
// Identify which event(s) caused Poll to return. // Identify which event(s) caused Poll to return.
for _, ev := range []struct { // We can't trivially use a table here because Revents
name string // isn't the same type on all systems.
bits int16 if fds[0].Revents&unix.POLLIN != 0 {
}{ t.Log("found POLLIN event")
{"POLLIN", unix.POLLIN}, }
{"POLLPRI", unix.POLLPRI}, if fds[0].Revents&unix.POLLPRI != 0 {
{"POLLOUT", unix.POLLOUT}, t.Log("found POLLPRI event")
{"POLLERR", unix.POLLERR}, }
{"POLLHUP", unix.POLLHUP}, if fds[0].Revents&unix.POLLOUT != 0 {
{"POLLNVAL", unix.POLLNVAL}, t.Log("found POLLOUT event")
} { }
if fds[0].Revents&ev.bits != 0 { if fds[0].Revents&unix.POLLERR != 0 {
t.Logf("Poll: found event %s", ev.name) t.Log("found POLLERR event")
} }
if fds[0].Revents&unix.POLLHUP != 0 {
t.Log("found POLLHUP event")
}
if fds[0].Revents&unix.POLLNVAL != 0 {
t.Log("found POLLNVAL event")
} }
} }
break break