From dfd2c464b66606a74e35da94f123ee8e07edd730 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Tue, 7 Feb 2017 08:47:53 +0100 Subject: [PATCH] lib/events: Overflow test should calculate average log time --- lib/events/events_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/events/events_test.go b/lib/events/events_test.go index 950fc50aa..aaa6816b2 100644 --- a/lib/events/events_test.go +++ b/lib/events/events_test.go @@ -12,7 +12,7 @@ import ( "time" ) -const timeout = 5 * time.Second +const timeout = time.Second func init() { runningTests = true @@ -102,11 +102,12 @@ func TestBufferOverflow(t *testing.T) { defer l.Unsubscribe(s) t0 := time.Now() - for i := 0; i < BufferSize*2; i++ { + const nEvents = BufferSize * 2 + for i := 0; i < nEvents; i++ { l.Log(DeviceConnected, "foo") } - if time.Since(t0) > timeout { - t.Fatalf("Logging took too long") + if d := time.Since(t0); d > nEvents*eventLogTimeout { + t.Fatal("Logging took too long,", d, "avg", d/nEvents, "expected <", eventLogTimeout) } }