Browse Source

Fix ServerTest.ClientStop test case (#1542)

Jiwoo Park 2 years ago
parent
commit
3956a2b790
1 changed files with 7 additions and 2 deletions
  1. 7 2
      test/test.cc

+ 7 - 2
test/test.cc

@@ -2867,11 +2867,16 @@ TEST_F(ServerTest, GetStreamedEndless) {
 }
 
 TEST_F(ServerTest, ClientStop) {
+  std::atomic_size_t count{4};
   std::vector<std::thread> threads;
-  for (auto i = 0; i < 3; i++) {
+
+  for (auto i = count.load(); i != 0; --i) {
     threads.emplace_back([&]() {
       auto res = cli_.Get("/streamed-cancel",
                           [&](const char *, uint64_t) { return true; });
+
+      --count;
+
       ASSERT_TRUE(!res);
       EXPECT_TRUE(res.error() == Error::Canceled ||
                   res.error() == Error::Read || res.error() == Error::Write);
@@ -2879,7 +2884,7 @@ TEST_F(ServerTest, ClientStop) {
   }
 
   std::this_thread::sleep_for(std::chrono::seconds(2));
-  while (cli_.is_socket_open()) {
+  while (count != 0) {
     cli_.stop();
     std::this_thread::sleep_for(std::chrono::milliseconds(10));
   }