From e49ecaaa0a1d6f6356b4db16ac170123e11f9e62 Mon Sep 17 00:00:00 2001 From: Giovanni Bajo Date: Sat, 12 Oct 2019 12:05:58 +0200 Subject: [PATCH] runtime: adjust expected error threshold in TestSelectFairness Make it a bit more relaxed on the expected fairness, as fastrand() isn't a truly perfect random number generator. Fixes #34808 Change-Id: Ib55b2bbe3c1bf63fb4f446fd1291eb1236efc33b Reviewed-on: https://go-review.googlesource.com/c/go/+/200857 Run-TryBot: Giovanni Bajo TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/runtime/chan_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/runtime/chan_test.go b/src/runtime/chan_test.go index f5a7a57ed8..d4752dd344 100644 --- a/src/runtime/chan_test.go +++ b/src/runtime/chan_test.go @@ -480,11 +480,11 @@ func TestSelectFairness(t *testing.T) { // If the select in the goroutine is fair, // cnt1 and cnt2 should be about the same value. // With 10,000 trials, the expected margin of error at - // a confidence level of five nines is 4.4172 / (2 * Sqrt(10000)). + // a confidence level of six nines is 4.891676 / (2 * Sqrt(10000)). r := float64(cnt1) / trials e := math.Abs(r - 0.5) t.Log(cnt1, cnt2, r, e) - if e > 4.4172/(2*math.Sqrt(trials)) { + if e > 4.891676/(2*math.Sqrt(trials)) { t.Errorf("unfair select: in %d trials, results were %d, %d", trials, cnt1, cnt2) } close(done) -- 2.50.0