]> Cypherpunks repositories - gostls13.git/commitdiff
sync/atomic: reduce test in short mode
authorDmitry Vyukov <dvyukov@google.com>
Fri, 26 Feb 2016 15:14:31 +0000 (16:14 +0100)
committerDmitry Vyukov <dvyukov@google.com>
Fri, 26 Feb 2016 16:41:12 +0000 (16:41 +0000)
In normal mode the test runs for 9+ seconds on my machine (48 cores).
But the real problem is race mode, in race mode it hits 10m test timeout.
Reduce test size in short mode. Now it runs for 100ms without race.

Change-Id: I9493a0e84f630b930af8f958e2920025df37c268
Reviewed-on: https://go-review.googlesource.com/19956
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/sync/atomic/value_test.go

index 382dc6854d1561af5af75952abcda4b5256f01b4..fd90451dd83f6afdce6da4ca95b79a38519de4e8 100644 (file)
@@ -86,6 +86,11 @@ func TestValueConcurrent(t *testing.T) {
                {complex(0, 0), complex(1, 2), complex(3, 4), complex(5, 6)},
        }
        p := 4 * runtime.GOMAXPROCS(0)
+       N := int(1e5)
+       if testing.Short() {
+               p /= 2
+               N = 1e3
+       }
        for _, test := range tests {
                var v Value
                done := make(chan bool)
@@ -93,7 +98,7 @@ func TestValueConcurrent(t *testing.T) {
                        go func() {
                                r := rand.New(rand.NewSource(rand.Int63()))
                        loop:
-                               for j := 0; j < 1e5; j++ {
+                               for j := 0; j < N; j++ {
                                        x := test[r.Intn(len(test))]
                                        v.Store(x)
                                        x = v.Load()