Codebase list golang-golang-x-sys / faf0a1b
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> Michael Anthony Knyszek authored 2 years ago Michael Knyszek committed 2 years ago
1 changed file(s) with 17 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
519519 }
520520 if n != 0 {
521521 t.Errorf("Poll: wrong number of events: got %v, expected %v", n, 0)
522
523 // Identify which event(s) caused Poll to return.
524 for _, ev := range []struct {
525 name string
526 bits int16
527 }{
528 {"POLLIN", unix.POLLIN},
529 {"POLLPRI", unix.POLLPRI},
530 {"POLLOUT", unix.POLLOUT},
531 {"POLLERR", unix.POLLERR},
532 {"POLLHUP", unix.POLLHUP},
533 {"POLLNVAL", unix.POLLNVAL},
534 } {
535 if fds[0].Revents&ev.bits != 0 {
536 t.Logf("Poll: found event %s", ev.name)
537 }
538 }
522539 }
523540 break
524541 }