Commit 23a59ba1 authored by Ian Lance Taylor's avatar Ian Lance Taylor

runtime: deflake TestSignalExitStatus

The signal might get delivered to a different thread, and that thread
might not run again before the currently running thread returns and
exits. Sleep to give the other thread time to pick up the signal and
crash.

Not tested for all cases, but, optimistically:
Fixes #14063.

Change-Id: Iff58669ac6185ad91cce85e0e86f17497a3659fd
Reviewed-on: https://go-review.googlesource.com/23203
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarMikio Hara <mikioh.mikioh@gmail.com>
parent ac66bb34
...@@ -149,10 +149,6 @@ func loop(i int, c chan bool) { ...@@ -149,10 +149,6 @@ func loop(i int, c chan bool) {
func TestSignalExitStatus(t *testing.T) { func TestSignalExitStatus(t *testing.T) {
testenv.MustHaveGoBuild(t) testenv.MustHaveGoBuild(t)
switch runtime.GOOS {
case "netbsd", "solaris":
t.Skipf("skipping on %s; see https://golang.org/issue/14063", runtime.GOOS)
}
exe, err := buildTestProg(t, "testprog") exe, err := buildTestProg(t, "testprog")
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
......
...@@ -6,7 +6,10 @@ ...@@ -6,7 +6,10 @@
package main package main
import "syscall" import (
"syscall"
"time"
)
func init() { func init() {
register("SignalExitStatus", SignalExitStatus) register("SignalExitStatus", SignalExitStatus)
...@@ -14,4 +17,13 @@ func init() { ...@@ -14,4 +17,13 @@ func init() {
func SignalExitStatus() { func SignalExitStatus() {
syscall.Kill(syscall.Getpid(), syscall.SIGTERM) syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
// Should die immediately, but we've seen flakiness on various
// systems (see issue 14063). It's possible that the signal is
// being delivered to a different thread and we are returning
// and exiting before that thread runs again. Give the program
// a little while to die to make sure we pick up the signal
// before we return and exit the program. The time here
// shouldn't matter--we'll never really sleep this long.
time.Sleep(time.Second)
} }
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