mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-05 16:47:27 -04:00
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>
This commit is contained in:
committed by
Michael Knyszek
parent
7580c6e521
commit
faf0a1b62c
@@ -520,6 +520,23 @@ func TestPoll(t *testing.T) {
|
|||||||
}
|
}
|
||||||
if n != 0 {
|
if n != 0 {
|
||||||
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.
|
||||||
|
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
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user