]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: adjust expected error threshold in TestSelectFairness
authorGiovanni Bajo <rasky@develer.com>
Sat, 12 Oct 2019 10:05:58 +0000 (12:05 +0200)
committerGiovanni Bajo <rasky@develer.com>
Sat, 12 Oct 2019 16:38:27 +0000 (16:38 +0000)
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 <rasky@develer.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/runtime/chan_test.go

index f5a7a57ed895527bb9b52d2731a60789a861c699..d4752dd344ad70fe490c19b70b0cee631c4ded44 100644 (file)
@@ -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)