mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user