Commit d904cfb9 authored by Andrei Bajenov's avatar Andrei Bajenov Committed by Dave Watson

Readd unit test

Summary:
Description:
Last time a merge error broke stuff, fixing and readding

Test Plan:
Ran unit test

This reverts commit 1075ab9d6f62cad36a228bd3fc7203a75fdf5baf.

Reviewed By: davejwatson@fb.com

Subscribers: njormrod, folly-diffs@, wstefancik

FB internal diff: D1695920

Signature: t1:1695920:1416529609:3f726ac5df4e33f254075738ea6655a6fc01bb7f
parent 78b2965a
...@@ -96,6 +96,32 @@ TEST(HHWheelTimerTest, FireOnce) { ...@@ -96,6 +96,32 @@ TEST(HHWheelTimerTest, FireOnce) {
T_CHECK_TIMEOUT(start, end, milliseconds(10)); T_CHECK_TIMEOUT(start, end, milliseconds(10));
} }
/*
* Test scheduling a timeout from another timeout callback.
*/
TEST(HHWheelTimerTest, TestSchedulingWithinCallback) {
EventBase eventBase;
StackWheelTimer t(&eventBase, milliseconds(10));
const HHWheelTimer::Callback* nullCallback = nullptr;
TestTimeout t1;
// Delayed to simulate the steady_clock counter lagging
TestTimeoutDelayed t2;
t.scheduleTimeout(&t1, milliseconds(500));
t1.fn = [&] { t.scheduleTimeout(&t2, milliseconds(1)); };
// If t is in an inconsistent state, detachEventBase should fail.
t2.fn = [&] { t.detachEventBase(); };
ASSERT_EQ(t.count(), 1);
eventBase.loop();
ASSERT_EQ(t.count(), 0);
ASSERT_EQ(t1.timestamps.size(), 1);
ASSERT_EQ(t2.timestamps.size(), 1);
}
/* /*
* Test cancelling a timeout when it is scheduled to be fired right away. * Test cancelling a timeout when it is scheduled to be fired right away.
*/ */
......
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