Further increase the timer test tolerance to account for the macOS builds.
This commit is contained in:
parent
9a580ccbf9
commit
7ea0e34a46
|
@ -27,20 +27,20 @@ void main()
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assert(dur > 200.msecs, (dur - 200.msecs).toString());
|
assert(dur > 1200.msecs, (dur - 1200.msecs).toString());
|
||||||
assert(dur < 260.msecs, (dur - 200.msecs).toString());
|
assert(dur < 1300.msecs, (dur - 1200.msecs).toString());
|
||||||
} catch (Exception e) assert(false, e.msg);
|
} catch (Exception e) assert(false, e.msg);
|
||||||
|
|
||||||
s_startTime += dur;
|
s_startTime += dur;
|
||||||
|
|
||||||
eventDriver.timers.set(tm, 100.msecs, 100.msecs);
|
eventDriver.timers.set(tm, 300.msecs, 300.msecs);
|
||||||
|
|
||||||
void secondTier(TimerID timer) nothrow @safe {
|
void secondTier(TimerID timer) nothrow @safe {
|
||||||
try {
|
try {
|
||||||
auto dur = Clock.currTime(UTC()) - s_startTime;
|
auto dur = Clock.currTime(UTC()) - s_startTime;
|
||||||
s_cnt++;
|
s_cnt++;
|
||||||
assert(dur > 100.msecs * s_cnt, (dur - 100.msecs * s_cnt).toString());
|
assert(dur > 300.msecs * s_cnt, (dur - 300.msecs * s_cnt).toString());
|
||||||
assert(dur < 100.msecs * s_cnt + 60.msecs, (dur - 100.msecs * s_cnt).toString());
|
assert(dur < 300.msecs * s_cnt + 100.msecs, (dur - 300.msecs * s_cnt).toString());
|
||||||
assert(s_cnt <= 3);
|
assert(s_cnt <= 3);
|
||||||
|
|
||||||
if (s_cnt == 3) {
|
if (s_cnt == 3) {
|
||||||
|
@ -55,7 +55,7 @@ void main()
|
||||||
eventDriver.timers.wait(tm, &secondTier);
|
eventDriver.timers.wait(tm, &secondTier);
|
||||||
});
|
});
|
||||||
|
|
||||||
eventDriver.timers.set(tm, 200.msecs, 0.msecs);
|
eventDriver.timers.set(tm, 1200.msecs, 0.msecs);
|
||||||
|
|
||||||
ExitReason er;
|
ExitReason er;
|
||||||
do er = eventDriver.core.processEvents(Duration.max);
|
do er = eventDriver.core.processEvents(Duration.max);
|
||||||
|
|
|
@ -26,30 +26,30 @@ void main()
|
||||||
writefln("First timer");
|
writefln("First timer");
|
||||||
auto dur = Clock.currTime(UTC()) - s_startTime;
|
auto dur = Clock.currTime(UTC()) - s_startTime;
|
||||||
|
|
||||||
assert(dur >= 200.msecs, (dur - 200.msecs).toString());
|
assert(dur >= 1200.msecs, (dur - 1200.msecs).toString());
|
||||||
assert(dur < 250.msecs, (dur - 200.msecs).toString());
|
assert(dur < 1300.msecs, (dur - 1200.msecs).toString());
|
||||||
|
|
||||||
timer1fired = true;
|
timer1fired = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
assert(false, e.msg);
|
assert(false, e.msg);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
eventDriver.timers.set(tm, 200.msecs, 0.msecs);
|
eventDriver.timers.set(tm, 1200.msecs, 0.msecs);
|
||||||
|
|
||||||
// second timer repeating 100ms, 3 times
|
// second timer repeating 300ms, 5 times
|
||||||
auto tm2 = eventDriver.timers.create();
|
auto tm2 = eventDriver.timers.create();
|
||||||
eventDriver.timers.set(tm2, 100.msecs, 100.msecs);
|
eventDriver.timers.set(tm2, 300.msecs, 300.msecs);
|
||||||
void periodicCallback(TimerID timer) nothrow @safe {
|
void periodicCallback(TimerID timer) nothrow @safe {
|
||||||
try {
|
try {
|
||||||
writefln("Second timer");
|
writefln("Second timer");
|
||||||
|
|
||||||
auto dur = Clock.currTime(UTC()) - s_startTime;
|
auto dur = Clock.currTime(UTC()) - s_startTime;
|
||||||
s_cnt++;
|
s_cnt++;
|
||||||
assert(dur > 100.msecs * s_cnt, (dur - 100.msecs * s_cnt).toString());
|
assert(dur > 300.msecs * s_cnt, (dur - 300.msecs * s_cnt).toString());
|
||||||
assert(dur < 100.msecs * s_cnt + 60.msecs, (dur - 100.msecs * s_cnt).toString());
|
assert(dur < 300.msecs * s_cnt + 100.msecs, (dur - 300.msecs * s_cnt).toString());
|
||||||
assert(s_cnt <= 3);
|
assert(s_cnt <= 5);
|
||||||
|
|
||||||
if (s_cnt == 3) {
|
if (s_cnt == 5) {
|
||||||
s_done = true;
|
s_done = true;
|
||||||
eventDriver.timers.stop(timer);
|
eventDriver.timers.stop(timer);
|
||||||
assert(timer1fired, "Timer 1 didn't fire within 300ms");
|
assert(timer1fired, "Timer 1 didn't fire within 300ms");
|
||||||
|
|
Loading…
Reference in a new issue