From b1cc55016a1f3863ff9232dd4dc83575d986e0bf Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Thu, 15 Dec 2016 01:37:21 -0800 Subject: [PATCH] Check the baton waits in the ScopedEventBaseThread tests Summary: [Folly] Check the baton waits in the `ScopedEventBaseThread` tests. Also: * `Baton::timed_wait` can take a `duration`, not just a `time_point`. * Allow a bit more time for waiting, just in case the machine running the tests is under load. Reviewed By: andriigrynenko Differential Revision: D4330126 fbshipit-source-id: 55878577b1deeb260686647e5f22a81d6fb9e06d --- folly/io/async/test/ScopedEventBaseThreadTest.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/folly/io/async/test/ScopedEventBaseThreadTest.cpp b/folly/io/async/test/ScopedEventBaseThreadTest.cpp index 9d92ea83..6832f347 100644 --- a/folly/io/async/test/ScopedEventBaseThreadTest.cpp +++ b/folly/io/async/test/ScopedEventBaseThreadTest.cpp @@ -31,7 +31,7 @@ TEST_F(ScopedEventBaseThreadTest, example) { Baton<> done; sebt.getEventBase()->runInEventBaseThread([&] { done.post(); }); - done.timed_wait(steady_clock::now() + milliseconds(100)); + ASSERT_TRUE(done.timed_wait(seconds(1))); } TEST_F(ScopedEventBaseThreadTest, start_stop) { @@ -44,7 +44,7 @@ TEST_F(ScopedEventBaseThreadTest, start_stop) { Baton<> done; sebt.getEventBase()->runInEventBaseThread([&] { done.post(); }); - done.timed_wait(steady_clock::now() + milliseconds(100)); + ASSERT_TRUE(done.timed_wait(seconds(1))); EXPECT_NE(nullptr, sebt.getEventBase()); sebt.stop(); @@ -63,7 +63,7 @@ TEST_F(ScopedEventBaseThreadTest, move) { Baton<> done; sebt2.getEventBase()->runInEventBaseThread([&] { done.post(); }); - done.timed_wait(steady_clock::now() + milliseconds(100)); + ASSERT_TRUE(done.timed_wait(seconds(1))); } TEST_F(ScopedEventBaseThreadTest, self_move) { @@ -74,7 +74,7 @@ TEST_F(ScopedEventBaseThreadTest, self_move) { Baton<> done; sebt.getEventBase()->runInEventBaseThread([&] { done.post(); }); - done.timed_wait(steady_clock::now() + milliseconds(100)); + ASSERT_TRUE(done.timed_wait(seconds(1))); } TEST_F(ScopedEventBaseThreadTest, manager) { -- 2.34.1