Check the baton waits in the ScopedEventBaseThread tests
authorYedidya Feldblum <yfeldblum@fb.com>
Thu, 15 Dec 2016 09:37:21 +0000 (01:37 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 15 Dec 2016 09:48:00 +0000 (01:48 -0800)
Summary:
[Folly] Check the baton waits in the `ScopedEventBaseThread` tests.

Also:
* `Baton<T>::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

index 9d92ea838a25443f4314c030a1f484be85b28a30..6832f347afed182b3fe9b900d4872b9775abcd2a 100644 (file)
@@ -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) {