runtime: add concurrent map read test
Currently crashes, so disabled.
Update #5179
R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/8222044
diff --git a/src/pkg/runtime/map_test.go b/src/pkg/runtime/map_test.go
index 1bf6b60..cc8863b 100644
--- a/src/pkg/runtime/map_test.go
+++ b/src/pkg/runtime/map_test.go
@@ -7,8 +7,10 @@
import (
"fmt"
"math"
+ "os"
"runtime"
"sort"
+ "sync"
"testing"
)
@@ -231,6 +233,43 @@
}
}
+func TestConcurrentReadsAfterGrowth(t *testing.T) {
+ // TODO(khr): fix and enable this test.
+ t.Skip("Known currently broken; golang.org/issue/5179")
+
+ if os.Getenv("GOMAXPROCS") == "" {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(16))
+ }
+ numLoop := 10
+ numGrowStep := 250
+ numReader := 16
+ if testing.Short() {
+ numLoop, numGrowStep = 2, 500
+ }
+ for i := 0; i < numLoop; i++ {
+ m := make(map[int]int, 0)
+ for gs := 0; gs < numGrowStep; gs++ {
+ m[gs] = gs
+ var wg sync.WaitGroup
+ wg.Add(numReader * 2)
+ for nr := 0; nr < numReader; nr++ {
+ go func() {
+ defer wg.Done()
+ for _ = range m {
+ }
+ }()
+ go func() {
+ defer wg.Done()
+ for key := 0; key < gs; key++ {
+ _ = m[key]
+ }
+ }()
+ }
+ wg.Wait()
+ }
+ }
+}
+
func TestBigItems(t *testing.T) {
var key [256]string
for i := 0; i < 256; i++ {