diff options
author | yang-g <yangg@google.com> | 2016-07-11 15:48:01 -0700 |
---|---|---|
committer | yang-g <yangg@google.com> | 2016-07-13 22:23:19 -0700 |
commit | 05573f1692647ca30a10839b61731486700587ac (patch) | |
tree | f5873f430970911aaf6637fb9dfe63ee092b083d /test/cpp/end2end | |
parent | a5293000534deca9e4d67a323c3b369055615022 (diff) |
Make Server::Wait work for async only server.
Diffstat (limited to 'test/cpp/end2end')
-rw-r--r-- | test/cpp/end2end/async_end2end_test.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 6c7eae53a4..01ba8962d7 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -345,6 +345,24 @@ TEST_P(AsyncEnd2endTest, SequentialRpcs) { SendRpc(10); } +// We do not need to protect notify because the use is synchronized. +void ServerWait(Server* server, int* notify) { + server->Wait(); + *notify = 1; +} +TEST_P(AsyncEnd2endTest, WaitAndShutdownTest) { + int notify = 0; + std::thread* wait_thread = + new std::thread(&ServerWait, server_.get(), ¬ify); + ResetStub(); + SendRpc(1); + EXPECT_EQ(0, notify); + server_->Shutdown(); + wait_thread->join(); + EXPECT_EQ(1, notify); + delete wait_thread; +} + // Test a simple RPC using the async version of Next TEST_P(AsyncEnd2endTest, AsyncNextRpc) { ResetStub(); |