]> Cypherpunks repositories - gostls13.git/commitdiff
os/signal: test with a significantly longer fatal timeout
authorAndrew G. Morgan <agm@google.com>
Sat, 19 Jun 2021 16:46:52 +0000 (09:46 -0700)
committerEmmanuel Odeke <emmanuel@orijtech.com>
Sun, 20 Jun 2021 11:17:27 +0000 (11:17 +0000)
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 <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

src/os/signal/signal_test.go

index cea68742d264b9889a9e18a31cec2ff0d0fe0fd0..649854b746c149e0dc2a9002f299b3b962a44e99 100644 (file)
@@ -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
@@ -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 {
@@ -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