mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-31 02:48:27 +00:00
lib/events: Make test even less timing dependent
This commit is contained in:
parent
dfd2c464b6
commit
9fda9642d3
@ -101,12 +101,19 @@ func TestBufferOverflow(t *testing.T) {
|
||||
s := l.Subscribe(AllEvents)
|
||||
defer l.Unsubscribe(s)
|
||||
|
||||
// The first BufferSize events will be logged pretty much
|
||||
// instantaneously. The next BufferSize events will each block for up to
|
||||
// 15ms, plus overhead from race detector and thread scheduling latency
|
||||
// etc. This latency can sometimes be significant and is incurred for
|
||||
// each call. We just verify that the whole test completes in a
|
||||
// reasonable time, taking no more than 15 seconds in total.
|
||||
|
||||
t0 := time.Now()
|
||||
const nEvents = BufferSize * 2
|
||||
for i := 0; i < nEvents; i++ {
|
||||
l.Log(DeviceConnected, "foo")
|
||||
}
|
||||
if d := time.Since(t0); d > nEvents*eventLogTimeout {
|
||||
if d := time.Since(t0); d > 15*time.Second {
|
||||
t.Fatal("Logging took too long,", d, "avg", d/nEvents, "expected <", eventLogTimeout)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user