mirror of
https://github.com/octoleo/syncthing.git
synced 2024-09-19 21:29:01 +00:00
lib/events: Overflow test should calculate average log time
This commit is contained in:
parent
5a1ee7f0b0
commit
dfd2c464b6
@ -12,7 +12,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const timeout = 5 * time.Second
|
const timeout = time.Second
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
runningTests = true
|
runningTests = true
|
||||||
@ -102,11 +102,12 @@ func TestBufferOverflow(t *testing.T) {
|
|||||||
defer l.Unsubscribe(s)
|
defer l.Unsubscribe(s)
|
||||||
|
|
||||||
t0 := time.Now()
|
t0 := time.Now()
|
||||||
for i := 0; i < BufferSize*2; i++ {
|
const nEvents = BufferSize * 2
|
||||||
|
for i := 0; i < nEvents; i++ {
|
||||||
l.Log(DeviceConnected, "foo")
|
l.Log(DeviceConnected, "foo")
|
||||||
}
|
}
|
||||||
if time.Since(t0) > timeout {
|
if d := time.Since(t0); d > nEvents*eventLogTimeout {
|
||||||
t.Fatalf("Logging took too long")
|
t.Fatal("Logging took too long,", d, "avg", d/nEvents, "expected <", eventLogTimeout)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user