mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: reset GOMAXPROCS during tests
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
This commit is contained in:
parent
f18a4e9609
commit
91cc1e6b77
1 changed files with 6 additions and 3 deletions
|
|
@ -24,20 +24,23 @@ func TestStopTheWorldDeadlock(t *testing.T) {
|
||||||
t.Logf("skipping during short test")
|
t.Logf("skipping during short test")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
runtime.GOMAXPROCS(3)
|
maxprocs := runtime.GOMAXPROCS(3)
|
||||||
compl := make(chan int, 1)
|
compl := make(chan bool, 2)
|
||||||
go func() {
|
go func() {
|
||||||
for i := 0; i != 1000; i += 1 {
|
for i := 0; i != 1000; i += 1 {
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
}
|
}
|
||||||
compl <- 0
|
compl <- true
|
||||||
}()
|
}()
|
||||||
go func() {
|
go func() {
|
||||||
for i := 0; i != 1000; i += 1 {
|
for i := 0; i != 1000; i += 1 {
|
||||||
runtime.GOMAXPROCS(3)
|
runtime.GOMAXPROCS(3)
|
||||||
}
|
}
|
||||||
|
compl <- true
|
||||||
}()
|
}()
|
||||||
go perpetuumMobile()
|
go perpetuumMobile()
|
||||||
<-compl
|
<-compl
|
||||||
|
<-compl
|
||||||
stop <- true
|
stop <- true
|
||||||
|
runtime.GOMAXPROCS(maxprocs)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue