diff options
Diffstat (limited to 'libgo/go/time/sleep_test.go')
-rw-r--r-- | libgo/go/time/sleep_test.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libgo/go/time/sleep_test.go b/libgo/go/time/sleep_test.go index 86b634c92e4..fb66e70c5fa 100644 --- a/libgo/go/time/sleep_test.go +++ b/libgo/go/time/sleep_test.go @@ -512,6 +512,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 |