tests: Making Scheduler and TCP test cases more resilient to time
These two tests were frequently falsely failing on overloaded build bots
Change-Id: I4e6dc09a647317514a7318e09bb095c7d7e6045a
diff --git a/tests/core/scheduler.cpp b/tests/core/scheduler.cpp
index 9e673a0..77ca1e9 100644
--- a/tests/core/scheduler.cpp
+++ b/tests/core/scheduler.cpp
@@ -59,25 +59,25 @@
boost::asio::io_service io;
Scheduler scheduler(io);
- scheduler.scheduleEvent(time::seconds(0.1), bind(&SchedulerFixture::event1, this));
+ scheduler.scheduleEvent(time::seconds(0.5), bind(&SchedulerFixture::event1, this));
- EventId i = scheduler.scheduleEvent(time::seconds(0.2), bind(&SchedulerFixture::event2, this));
+ EventId i = scheduler.scheduleEvent(time::seconds(1.0), bind(&SchedulerFixture::event2, this));
scheduler.cancelEvent(i);
- scheduler.scheduleEvent(time::seconds(0.05), bind(&SchedulerFixture::event3, this));
+ scheduler.scheduleEvent(time::seconds(0.25), bind(&SchedulerFixture::event3, this));
- i = scheduler.scheduleEvent(time::seconds(0.01), bind(&SchedulerFixture::event2, this));
+ i = scheduler.scheduleEvent(time::seconds(0.05), bind(&SchedulerFixture::event2, this));
scheduler.cancelEvent(i);
i = scheduler.schedulePeriodicEvent(time::seconds(0.3), time::seconds(0.1), bind(&SchedulerFixture::event4, this));
- scheduler.scheduleEvent(time::seconds(0.69), bind(&Scheduler::cancelEvent, &scheduler, i));
+ scheduler.scheduleEvent(time::seconds(1), bind(&Scheduler::cancelEvent, &scheduler, i));
io.run();
BOOST_CHECK_EQUAL(count1, 1);
BOOST_CHECK_EQUAL(count2, 0);
BOOST_CHECK_EQUAL(count3, 1);
- BOOST_CHECK_EQUAL(count4, 4);
+ BOOST_CHECK_GT(count4, 1);
}
BOOST_AUTO_TEST_CASE(CancelEmptyEvent)