]> Cypherpunks repositories - gostls13.git/commit
os/signal: rework test timeouts and concurrency
authorBryan C. Mills <bcmills@google.com>
Fri, 27 Mar 2020 19:04:09 +0000 (15:04 -0400)
committerBryan C. Mills <bcmills@google.com>
Mon, 30 Mar 2020 17:35:19 +0000 (17:35 +0000)
commit3ee782b11da3fb0313603ad0e3be8ab6755802a9
treeac4005499d5792ba937db88e770e0b1b34fb106a
parent33b648c0e9428c8775043db75fdff5864a64219a
os/signal: rework test timeouts and concurrency

Use a uniform function (named “quiesce”) to wait for possible signals
in a way that gives the kernel many opportunities to deliver them.

Simplify channel usage and concurrency in stress tests.

Use (*testing.T).Deadline instead of parsing the deadline in TestMain.

In TestStop, sleep forever in a loop if we expect the test to die from
a signal. That should reduce the flakiness of TestNohup, since
TestStop will no longer spuriously pass when run as a subprocess of
TestNohup.

Since independent signals should not interfere, run the different
signals in TestStop in parallel when testing in short mode.

Since TestNohup runs TestStop as a subprocess, and TestStop needs to
wait many times for signals to quiesce, run its test subprocesses
concurrently and in short mode — reducing the latency of that test by
more than a factor of 2.

The above two changes reduce the running time of TestNohup on my
workstation to ~345ms, making it possible to run much larger counts of
the test in the same amount of wall time. If the test remains flaky
after this CL, we can spend all or part of that latency improvement on
a longer settle time.

Updates #33174

Change-Id: I09206f213d8c1888b50bf974f965221a5d482419
Reviewed-on: https://go-review.googlesource.com/c/go/+/226138
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/os/signal/signal_test.go