summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrei Vagin <avagin@google.com>2020-03-18 17:41:06 -0700
committergVisor bot <gvisor-bot@google.com>2020-03-18 17:42:29 -0700
commitc3cee7f5a433708a394cee4e89c223f80036f5d9 (patch)
tree8ec5afb315d9920fc1b59d1d972b96d8e8f93dc0
parenta0fed7ea459833c93980dd6937a140db9bdcee8c (diff)
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
-rw-r--r--pkg/gate/gate_test.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/pkg/gate/gate_test.go b/pkg/gate/gate_test.go
index 850693df8..316015e06 100644
--- a/pkg/gate/gate_test.go
+++ b/pkg/gate/gate_test.go
@@ -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()