Commit b1cc5501 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Check the baton waits in the ScopedEventBaseThread tests

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
parent e3f67e10
...@@ -31,7 +31,7 @@ TEST_F(ScopedEventBaseThreadTest, example) { ...@@ -31,7 +31,7 @@ TEST_F(ScopedEventBaseThreadTest, example) {
Baton<> done; Baton<> done;
sebt.getEventBase()->runInEventBaseThread([&] { done.post(); }); 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) { TEST_F(ScopedEventBaseThreadTest, start_stop) {
...@@ -44,7 +44,7 @@ TEST_F(ScopedEventBaseThreadTest, start_stop) { ...@@ -44,7 +44,7 @@ TEST_F(ScopedEventBaseThreadTest, start_stop) {
Baton<> done; Baton<> done;
sebt.getEventBase()->runInEventBaseThread([&] { done.post(); }); 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()); EXPECT_NE(nullptr, sebt.getEventBase());
sebt.stop(); sebt.stop();
...@@ -63,7 +63,7 @@ TEST_F(ScopedEventBaseThreadTest, move) { ...@@ -63,7 +63,7 @@ TEST_F(ScopedEventBaseThreadTest, move) {
Baton<> done; Baton<> done;
sebt2.getEventBase()->runInEventBaseThread([&] { done.post(); }); 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) { TEST_F(ScopedEventBaseThreadTest, self_move) {
...@@ -74,7 +74,7 @@ TEST_F(ScopedEventBaseThreadTest, self_move) { ...@@ -74,7 +74,7 @@ TEST_F(ScopedEventBaseThreadTest, self_move) {
Baton<> done; Baton<> done;
sebt.getEventBase()->runInEventBaseThread([&] { done.post(); }); sebt.getEventBase()->runInEventBaseThread([&] { done.post(); });
done.timed_wait(steady_clock::now() + milliseconds(100)); ASSERT_TRUE(done.timed_wait(seconds(1)));
} }
TEST_F(ScopedEventBaseThreadTest, manager) { TEST_F(ScopedEventBaseThreadTest, manager) {
......
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