File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,10 @@ package runtime_test
7
7
import (
8
8
"fmt"
9
9
"math"
10
+ "os"
10
11
"runtime"
11
12
"sort"
13
+ "sync"
12
14
"testing"
13
15
)
14
16
@@ -231,6 +233,43 @@ func TestIterGrowWithGC(t *testing.T) {
231
233
}
232
234
}
233
235
236
+ func TestConcurrentReadsAfterGrowth (t * testing.T ) {
237
+ // TODO(khr): fix and enable this test.
238
+ t .Skip ("Known currently broken; golang.org/issue/5179" )
239
+
240
+ if os .Getenv ("GOMAXPROCS" ) == "" {
241
+ defer runtime .GOMAXPROCS (runtime .GOMAXPROCS (16 ))
242
+ }
243
+ numLoop := 10
244
+ numGrowStep := 250
245
+ numReader := 16
246
+ if testing .Short () {
247
+ numLoop , numGrowStep = 2 , 500
248
+ }
249
+ for i := 0 ; i < numLoop ; i ++ {
250
+ m := make (map [int ]int , 0 )
251
+ for gs := 0 ; gs < numGrowStep ; gs ++ {
252
+ m [gs ] = gs
253
+ var wg sync.WaitGroup
254
+ wg .Add (numReader * 2 )
255
+ for nr := 0 ; nr < numReader ; nr ++ {
256
+ go func () {
257
+ defer wg .Done ()
258
+ for _ = range m {
259
+ }
260
+ }()
261
+ go func () {
262
+ defer wg .Done ()
263
+ for key := 0 ; key < gs ; key ++ {
264
+ _ = m [key ]
265
+ }
266
+ }()
267
+ }
268
+ wg .Wait ()
269
+ }
270
+ }
271
+ }
272
+
234
273
func TestBigItems (t * testing.T ) {
235
274
var key [256 ]string
236
275
for i := 0 ; i < 256 ; i ++ {
You can’t perform that action at this time.
0 commit comments