mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: test Goexit/defer iteraction.
Make sure Goexit runs defers. Make sure recover() during a Goexit defer returns nil. LGTM=dvyukov, bradfitz R=golang-codereviews, dvyukov, bradfitz, khr CC=golang-codereviews https://golang.org/cl/140650043
This commit is contained in:
parent
1e4f86e485
commit
7e62316b84
1 changed files with 16 additions and 0 deletions
|
|
@ -159,6 +159,22 @@ func TestGoexitCrash(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGoexitDefer(t *testing.T) {
|
||||||
|
c := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
defer func() {
|
||||||
|
r := recover()
|
||||||
|
if r != nil {
|
||||||
|
t.Errorf("non-nil recover during Goexit")
|
||||||
|
}
|
||||||
|
c <- struct{}{}
|
||||||
|
}()
|
||||||
|
runtime.Goexit()
|
||||||
|
}()
|
||||||
|
// Note: if the defer fails to run, we will get a deadlock here
|
||||||
|
<-c
|
||||||
|
}
|
||||||
|
|
||||||
func TestGoNil(t *testing.T) {
|
func TestGoNil(t *testing.T) {
|
||||||
output := executeTest(t, goNilSource, nil)
|
output := executeTest(t, goNilSource, nil)
|
||||||
want := "go of nil func value"
|
want := "go of nil func value"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue