unix: identify unexpected events that fired in TestPoll
Currently if TestPoll fails because an unexpected event fired, we just
print that it happened, not which one fired. #49380 has been difficult
to reproduce, so printing more information for this case would be
helpful.
Updates #49380.
Change-Id: I820c4b634536565487ee1474f8afe092a8a4443b
Reviewed-on: https://go-review.googlesource.com/c/sys/+/363714
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
diff --git a/unix/syscall_unix_test.go b/unix/syscall_unix_test.go
index cfcdd0e..259098b 100644
--- a/unix/syscall_unix_test.go
+++ b/unix/syscall_unix_test.go
@@ -520,6 +520,23 @@
}
if n != 0 {
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)
+ }
+ }
}
break
}