Commit 7f9d0e89 authored by gejun's avatar gejun

loose assertions on running time in test/bthread_timer_thread_unittest.cpp

parent 16698226
...@@ -68,8 +68,7 @@ public: ...@@ -68,8 +68,7 @@ public:
{ {
ASSERT_TRUE(!_run_times.empty()); ASSERT_TRUE(!_run_times.empty());
long diff = timespec_diff_us(_run_times[0], expect_run_time); long diff = timespec_diff_us(_run_times[0], expect_run_time);
EXPECT_GE(diff, 0); EXPECT_LE(labs(diff), 10000);
EXPECT_LE(diff, kEpsilonUs);
} }
void expect_not_run() { void expect_not_run() {
...@@ -89,9 +88,7 @@ private: ...@@ -89,9 +88,7 @@ private:
const char* _name; const char* _name;
int _sleep_ms; int _sleep_ms;
std::vector<timespec> _run_times; std::vector<timespec> _run_times;
static const long kEpsilonUs;
}; };
const long TimeKeeper::kEpsilonUs = 50000; // 50,000 us, 1/20 second.
TEST(TimerThreadTest, RunTasks) { TEST(TimerThreadTest, RunTasks) {
bthread::TimerThread timer_thread; bthread::TimerThread timer_thread;
......
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