Deflake third_party/gvisor/pkg/gate/gate_test

TestConcurrentAll executes 1000 goroutines which never sleep,
so they are not preempted by Go's runtime. In Go 1.14, async preemption
has been added, but the added runtime.Gosched() call will do nothing
wrong in this case too.

PiperOrigin-RevId: 301705712
This commit is contained in:
Andrei Vagin
2020-03-18 17:42:29 -07:00
committed by gVisor bot
parent a0fed7ea45
commit c3cee7f5a4
+3
View File
@@ -15,6 +15,7 @@
package gate_test
import (
"runtime"
"testing"
"time"
@@ -165,6 +166,8 @@ func worker(g *gate.Gate, done *sync.WaitGroup) {
if !g.Enter() {
break
}
// Golang before v1.14 doesn't preempt busyloops.
runtime.Gosched()
g.Leave()
}
done.Done()