aboutsummaryrefslogtreecommitdiff
path: root/src/time/sleep_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/time/sleep_test.go')
-rw-r--r--src/time/sleep_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/time/sleep_test.go b/src/time/sleep_test.go
index 084ac33f51..6ee0631a85 100644
--- a/src/time/sleep_test.go
+++ b/src/time/sleep_test.go
@@ -511,6 +511,22 @@ func TestZeroTimerStopPanics(t *testing.T) {
tr.Stop()
}
+// Test that zero duration timers aren't missed by the scheduler. Regression test for issue 44868.
+func TestZeroTimer(t *testing.T) {
+ if testing.Short() {
+ t.Skip("-short")
+ }
+
+ for i := 0; i < 1000000; i++ {
+ s := Now()
+ ti := NewTimer(0)
+ <-ti.C
+ if diff := Since(s); diff > 2*Second {
+ t.Errorf("Expected time to get value from Timer channel in less than 2 sec, took %v", diff)
+ }
+ }
+}
+
// Benchmark timer latency when the thread that creates the timer is busy with
// other work and the timers must be serviced by other threads.
// https://golang.org/issue/38860