Commit 24e91815 authored by Dave Watson's avatar Dave Watson Committed by Facebook Github Bot 0

More tests

Summary:
Test timers where we need to reschedule the wheel timer next tick.

This wasn't tested before, since we were always ticking, and never needed to reschedule.

Differential Revision: D3637103

fbshipit-source-id: cb80e7b790bb6aac68bdb5f60f8aa00caa2e5b69
parent acd8ed50
......@@ -390,6 +390,36 @@ TEST_F(HHWheelTimerTest, SlowLoop) {
T_CHECK_TIMEOUT(start2, end2, milliseconds(10), milliseconds(1));
}
/*
* Test an event scheduled before the last event fires on time
*/
TEST_F(HHWheelTimerTest, SlowFast) {
HHWheelTimer& t = eventBase.timer();
TestTimeout t1;
TestTimeout t2;
ASSERT_EQ(t.count(), 0);
t.scheduleTimeout(&t1, milliseconds(10));
t.scheduleTimeout(&t2, milliseconds(5));
ASSERT_EQ(t.count(), 2);
TimePoint start;
eventBase.loop();
TimePoint end;
ASSERT_EQ(t1.timestamps.size(), 1);
ASSERT_EQ(t2.timestamps.size(), 1);
ASSERT_EQ(t.count(), 0);
// Check that the timeout was delayed by sleep
T_CHECK_TIMEOUT(start, t1.timestamps[0], milliseconds(10), milliseconds(1));
T_CHECK_TIMEOUT(start, t2.timestamps[0], milliseconds(5), milliseconds(1));
}
/*
* Test scheduling a mix of timers with default timeout and variable timeout.
*/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment