Commit 86346823 authored by Adam Simpkins's avatar Adam Simpkins Committed by Facebook Github Bot

fix a bug in the EventBase tests

Summary:
This test was accidentally updating `timestamp1` twice rather than updating
`timestamp0`.

The existing check for `timestamp0` only succeeded because `timestamp0` was
never actually updated.  With the current EventBase behavior, even though we
asked the function to be scheduled immediately, it actually ends up waiting
for a full HHWheelTimer tick interval (10ms by default) before it runs.
Update the check to take this into account.

Reviewed By: yfeldblum

Differential Revision: D15462318

fbshipit-source-id: e1851c9c4f2e082ad73debf85343d99bbf244b23
parent 83989dbc
......@@ -1104,7 +1104,7 @@ TEST(EventBaseTest, ScheduledFnAt) {
TimePoint timestamp2(false);
TimePoint timestamp3(false);
eb.scheduleAt(
std::bind(&TimePoint::reset, &timestamp1), eb.now() - milliseconds(5));
std::bind(&TimePoint::reset, &timestamp0), eb.now() - milliseconds(5));
eb.scheduleAt(
std::bind(&TimePoint::reset, &timestamp1), eb.now() + milliseconds(9));
eb.scheduleAt(
......@@ -1116,7 +1116,11 @@ TEST(EventBaseTest, ScheduledFnAt) {
eb.loop();
TimePoint end;
T_CHECK_TIME_LT(start, timestamp0, milliseconds(0));
// Even though we asked to schedule the first function in the past,
// in practice it doesn't run until after 1 iteration of the HHWheelTimer tick
// interval.
T_CHECK_TIMEOUT(start, timestamp0, eb.timer().getTickInterval());
T_CHECK_TIMEOUT(start, timestamp1, milliseconds(9));
T_CHECK_TIMEOUT(start, timestamp2, milliseconds(19));
T_CHECK_TIMEOUT(start, timestamp3, milliseconds(39));
......
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