Commit d76f28fc authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

runtime: add concurrent map read test

Currently crashes, so disabled.

Update #5179

R=golang-dev, khr
CC=golang-dev
https://golang.org/cl/8222044
parent 79a0c170
......@@ -7,8 +7,10 @@ package runtime_test
import (
"fmt"
"math"
"os"
"runtime"
"sort"
"sync"
"testing"
)
......@@ -231,6 +233,43 @@ func TestIterGrowWithGC(t *testing.T) {
}
}
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++ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment