gcc/libgo/go/runtime/proc_test.go
Ian Lance Taylor 9ff56c9570 Update to current version of Go library.
From-SVN: r173931
2011-05-20 00:18:15 +00:00

44 lines
718 B
Go

// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package runtime_test
import (
"runtime"
"testing"
)
var stop = make(chan bool, 1)
func perpetuumMobile() {
select {
case <-stop:
default:
go perpetuumMobile()
}
}
func TestStopTheWorldDeadlock(t *testing.T) {
if testing.Short() {
t.Logf("skipping during short test")
return
}
runtime.GOMAXPROCS(3)
compl := make(chan int, 1)
go func() {
for i := 0; i != 1000; i += 1 {
runtime.GC()
}
compl <- 0
}()
go func() {
for i := 0; i != 1000; i += 1 {
runtime.GOMAXPROCS(3)
}
}()
go perpetuumMobile()
<-compl
stop <- true
}