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>
diff --git a/unix/syscall_unix_test.go b/unix/syscall_unix_test.go
index 259098b..81db934 100644
--- a/unix/syscall_unix_test.go
+++ b/unix/syscall_unix_test.go
@@ -522,20 +522,25 @@
t.Errorf("Poll: wrong number of events: got %v, expected %v", n, 0)
// Identify which event(s) caused Poll to return.
- for _, ev := range []struct {
- name string
- bits int16
- }{
- {"POLLIN", unix.POLLIN},
- {"POLLPRI", unix.POLLPRI},
- {"POLLOUT", unix.POLLOUT},
- {"POLLERR", unix.POLLERR},
- {"POLLHUP", unix.POLLHUP},
- {"POLLNVAL", unix.POLLNVAL},
- } {
- if fds[0].Revents&ev.bits != 0 {
- t.Logf("Poll: found event %s", ev.name)
- }
+ // We can't trivially use a table here because Revents
+ // isn't the same type on all systems.
+ if fds[0].Revents&unix.POLLIN != 0 {
+ t.Log("found POLLIN event")
+ }
+ if fds[0].Revents&unix.POLLPRI != 0 {
+ t.Log("found POLLPRI event")
+ }
+ if fds[0].Revents&unix.POLLOUT != 0 {
+ t.Log("found POLLOUT event")
+ }
+ if fds[0].Revents&unix.POLLERR != 0 {
+ 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