From: Dmitriy Vyukov Date: Thu, 1 Aug 2013 14:25:36 +0000 (+0400) Subject: runtime: make new tests shorter in short mode X-Git-Tag: go1.2rc2~837 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d8bbbd2537551c0f6145c27747c7675b21a58f9f;p=gostls13.git runtime: make new tests shorter in short mode We see timeouts in these tests on some platforms, but not on the others. The hypothesis is that the problematic platforms are slow uniprocessors. Stack traces do not suggest that the process is completely hang, and it is able to schedule the alarm goroutine. And if it actually hangs, we still will be able to detect that. R=golang-dev, r CC=golang-dev https://golang.org/cl/12253043 --- diff --git a/src/pkg/runtime/proc_test.go b/src/pkg/runtime/proc_test.go index 8f47553fb4..dd70ed97d7 100644 --- a/src/pkg/runtime/proc_test.go +++ b/src/pkg/runtime/proc_test.go @@ -94,9 +94,14 @@ func TestYieldLocked(t *testing.T) { } func TestGoroutineParallelism(t *testing.T) { - const P = 4 + P := 4 + N := 10 + if testing.Short() { + P = 3 + N = 3 + } defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(P)) - for try := 0; try < 10; try++ { + for try := 0; try < N; try++ { done := make(chan bool) x := uint32(0) for p := 0; p < P; p++ { @@ -194,7 +199,10 @@ var preempt = func() int { func TestPreemption(t *testing.T) { // Test that goroutines are preempted at function calls. - const N = 5 + N := 5 + if testing.Short() { + N = 2 + } c := make(chan bool) var x uint32 for g := 0; g < 2; g++ { @@ -214,7 +222,12 @@ func TestPreemption(t *testing.T) { func TestPreemptionGC(t *testing.T) { // Test that pending GC preempts running goroutines. - const P = 5 + P := 5 + N := 10 + if testing.Short() { + P = 3 + N = 2 + } defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(P + 1)) var stop uint32 for i := 0; i < P; i++ { @@ -224,7 +237,7 @@ func TestPreemptionGC(t *testing.T) { } }() } - for i := 0; i < 10; i++ { + for i := 0; i < N; i++ { runtime.Gosched() runtime.GC() }