Commit 9d81ade2 authored by Russ Cox's avatar Russ Cox

runtime: make stack growth test shorter

It runs too long in -short mode.

Disable the one in init, because it doesn't respect -short.

Make the part that claims to test execution in a finalizer
actually execute the test in the finalizer.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=aram.h, golang-codereviews, iant, khr
https://golang.org/cl/86550045
parent a30eaa12
...@@ -132,6 +132,7 @@ func TestStackGrowth(t *testing.T) { ...@@ -132,6 +132,7 @@ func TestStackGrowth(t *testing.T) {
defer wg.Done() defer wg.Done()
growStack() growStack()
}() }()
wg.Wait()
// in locked goroutine // in locked goroutine
wg.Add(1) wg.Add(1)
...@@ -141,6 +142,7 @@ func TestStackGrowth(t *testing.T) { ...@@ -141,6 +142,7 @@ func TestStackGrowth(t *testing.T) {
growStack() growStack()
UnlockOSThread() UnlockOSThread()
}() }()
wg.Wait()
// in finalizer // in finalizer
wg.Add(1) wg.Add(1)
...@@ -150,6 +152,7 @@ func TestStackGrowth(t *testing.T) { ...@@ -150,6 +152,7 @@ func TestStackGrowth(t *testing.T) {
go func() { go func() {
s := new(string) s := new(string)
SetFinalizer(s, func(ss *string) { SetFinalizer(s, func(ss *string) {
growStack()
done <- true done <- true
}) })
s = nil s = nil
...@@ -163,17 +166,20 @@ func TestStackGrowth(t *testing.T) { ...@@ -163,17 +166,20 @@ func TestStackGrowth(t *testing.T) {
t.Fatal("finalizer did not run") t.Fatal("finalizer did not run")
} }
}() }()
wg.Wait() wg.Wait()
} }
// ... and in init // ... and in init
func init() { //func init() {
growStack() // growStack()
} //}
func growStack() { func growStack() {
for i := 0; i < 1<<10; i++ { n := 1 << 10
if testing.Short() {
n = 1 << 8
}
for i := 0; i < n; i++ {
x := 0 x := 0
growStackIter(&x, i) growStackIter(&x, i)
if x != i+1 { if x != i+1 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment