Commit 84890c72 authored by Austin Clements's avatar Austin Clements

runtime: more diagnostics for TestStackGrowth

This adds diagnostics so we can tell if the finalizer has started, in
addition to whether or not it has finished.

Updates #19381.

Change-Id: Icb7b1b0380c9ad1128b17074828945511a6cca5d
Reviewed-on: https://go-review.googlesource.com/45138
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 829adf50
...@@ -8,6 +8,7 @@ import ( ...@@ -8,6 +8,7 @@ import (
. "runtime" . "runtime"
"strings" "strings"
"sync" "sync"
"sync/atomic"
"testing" "testing"
"time" "time"
) )
...@@ -97,9 +98,11 @@ func TestStackGrowth(t *testing.T) { ...@@ -97,9 +98,11 @@ func TestStackGrowth(t *testing.T) {
go func() { go func() {
defer wg.Done() defer wg.Done()
done := make(chan bool) done := make(chan bool)
var started uint32
go func() { go func() {
s := new(string) s := new(string)
SetFinalizer(s, func(ss *string) { SetFinalizer(s, func(ss *string) {
atomic.StoreUint32(&started, 1)
growStack() growStack()
done <- true done <- true
}) })
...@@ -111,6 +114,9 @@ func TestStackGrowth(t *testing.T) { ...@@ -111,6 +114,9 @@ func TestStackGrowth(t *testing.T) {
select { select {
case <-done: case <-done:
case <-time.After(20 * time.Second): case <-time.After(20 * time.Second):
if atomic.LoadUint32(&started) == 0 {
t.Log("finalizer did not start")
}
t.Error("finalizer did not run") t.Error("finalizer did not run")
return return
} }
......
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