aboutsummaryrefslogtreecommitdiff
path: root/src/time/sleep_test.go
diff options
context:
space:
mode:
authorKatie Hockman <katie@golang.org>2021-05-07 10:36:42 -0400
committerKatie Hockman <katie@golang.org>2021-05-07 10:36:42 -0400
commit03a15201e7e0f11c8f4021a181071040a04dc375 (patch)
treebef4ddc5af5c0d370fb4ae356cb9bb1ded361043 /src/time/sleep_test.go
parentbe25192f119eb66e29a59d8c66622080852cbb58 (diff)
parent07d8cba9e15f5c5a3b0462a9215dbeac0cebf027 (diff)
downloadgo-03a15201e7e0f11c8f4021a181071040a04dc375.tar.gz
go-03a15201e7e0f11c8f4021a181071040a04dc375.zip
[dev.boringcrypto.go1.15] all: merge go1.15.12 into dev.boringcrypto.go1.15
Change-Id: I32e96d4675ba1c6a87b193f41700f6aa83b85bd1
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 f5678020b9a..ea253f87099 100644
--- a/src/time/sleep_test.go
+++ b/src/time/sleep_test.go
@@ -501,3 +501,19 @@ func TestZeroTimerStopPanics(t *testing.T) {
var tr Timer
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)
+ }
+ }
+}