Skip to content

Commit

Permalink
os/signal: test with a significantly longer fatal timeout
Browse files Browse the repository at this point in the history
We've observed some occasional os-arch specific timeouts
in signal.TestSignalTrace(). While the main purpose of a
short timeout is to ensure the passing tests complete
quickly, the unexpected failure path can tolerate waiting
longer (the test is not intended to test how slow or
overloaded the OS is at the time it is run).

Fixes #46736
Change-Id: Ib392fc6ce485a919612784ca88ed76c30f4898e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/329502
Run-TryBot: Ian Lance Taylor <[email protected]>
TryBot-Result: Go Bot <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Reviewed-by: Emmanuel Odeke <[email protected]>
Trust: Emmanuel Odeke <[email protected]>
  • Loading branch information
AndrewGMorgan authored and odeke-em committed Jun 20, 2021
1 parent b73cc4b commit 460900a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/os/signal/signal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ import (
// The current value is set based on flakes observed in the Go builders.
var settleTime = 100 * time.Millisecond

// fatalWaitingTime is an absurdly long time to wait for signals to be
// delivered but, using it, we (hopefully) eliminate test flakes on the
// build servers. See #46736 for discussion.
var fatalWaitingTime = 30 * time.Second

func init() {
if testenv.Builder() == "solaris-amd64-oraclerel" {
// The solaris-amd64-oraclerel builder has been observed to time out in
Expand Down Expand Up @@ -84,7 +89,7 @@ func waitSig1(t *testing.T, c <-chan os.Signal, sig os.Signal, all bool) {
// General user code should filter out all unexpected signals instead of just
// SIGURG, but since os/signal is tightly coupled to the runtime it seems
// appropriate to be stricter here.
for time.Since(start) < settleTime {
for time.Since(start) < fatalWaitingTime {
select {
case s := <-c:
if s == sig {
Expand All @@ -97,7 +102,7 @@ func waitSig1(t *testing.T, c <-chan os.Signal, sig os.Signal, all bool) {
timer.Reset(settleTime / 10)
}
}
t.Fatalf("timeout after %v waiting for %v", settleTime, sig)
t.Fatalf("timeout after %v waiting for %v", fatalWaitingTime, sig)
}

// quiesce waits until we can be reasonably confident that all pending signals
Expand Down

0 comments on commit 460900a

Please sign in to comment.