mirror of
https://github.com/golang/go
synced 2024-11-26 16:16:57 -07:00
runtime: add concurrent map read test
Currently crashes, so disabled. Update #5179 R=golang-dev, khr CC=golang-dev https://golang.org/cl/8222044
This commit is contained in:
parent
79a0c17012
commit
d76f28fc39
@ -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++ {
|
||||
|
Loading…
Reference in New Issue
Block a user