]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: reset GOMAXPROCS during tests
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 31 May 2011 14:38:51 +0000 (10:38 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 31 May 2011 14:38:51 +0000 (10:38 -0400)
Fix the fact that the test leaves GOMAXPROCS=3
and a running goroutine behind.

R=golang-dev, rsc
CC=dvyukov, golang-dev
https://golang.org/cl/4517121

src/pkg/runtime/proc_test.go

index a15b2d80a4e34c5660f24ff26f828281d9e085b2..cac4f9eeac87c5e5d36fd4be051eb7b7fbba387e 100644 (file)
@@ -24,20 +24,23 @@ func TestStopTheWorldDeadlock(t *testing.T) {
                t.Logf("skipping during short test")
                return
        }
-       runtime.GOMAXPROCS(3)
-       compl := make(chan int, 1)
+       maxprocs := runtime.GOMAXPROCS(3)
+       compl := make(chan bool, 2)
        go func() {
                for i := 0; i != 1000; i += 1 {
                        runtime.GC()
                }
-               compl <- 0
+               compl <- true
        }()
        go func() {
                for i := 0; i != 1000; i += 1 {
                        runtime.GOMAXPROCS(3)
                }
+               compl <- true
        }()
        go perpetuumMobile()
        <-compl
+       <-compl
        stop <- true
+       runtime.GOMAXPROCS(maxprocs)
 }