mirror of
https://github.com/golang/sys.git
synced 2026-02-08 03:36:03 +03:00
unix: in TestSelect, only error for an early wakeup on Linux
On Linux, 'man 2 select' explicitly lists the conditions under which select may return before the timeout interval. Most other platforms make no such guarantee, so do not test for it on those platforms. Fixes golang/go#36409 Change-Id: I194a34af3132a7db7fc186dec9de67fa6dd0bfae Reviewed-on: https://go-review.googlesource.com/c/sys/+/363455 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
@@ -562,10 +562,17 @@ func TestSelect(t *testing.T) {
|
||||
break
|
||||
}
|
||||
|
||||
// On some BSDs the actual timeout might also be slightly less than the requested.
|
||||
// Add an acceptable margin to avoid flaky tests.
|
||||
if took < dur*2/3 {
|
||||
t.Errorf("Select: got %v timeout, expected at least %v", took, dur)
|
||||
// On some platforms (e.g. NetBSD) the actual timeout might be arbitrarily
|
||||
// less than requested. However, Linux in particular promises to only return
|
||||
// early if a file descriptor becomes ready (not applicable here), or the call
|
||||
// is interrupted by a signal handler (explicitly retried in the loop above),
|
||||
// or the timeout expires.
|
||||
if took < dur {
|
||||
if runtime.GOOS == "linux" {
|
||||
t.Errorf("Select: slept for %v, expected %v", took, dur)
|
||||
} else {
|
||||
t.Logf("Select: slept for %v, requested %v", took, dur)
|
||||
}
|
||||
}
|
||||
|
||||
rr, ww, err := os.Pipe()
|
||||
|
||||
Reference in New Issue
Block a user