Browse Source

Made unit tests stable

yhirose 6 years ago
parent
commit
e8799383f3
1 changed files with 3 additions and 0 deletions
  1. 3 0
      test/test.cc

+ 3 - 0
test/test.cc

@@ -1466,6 +1466,7 @@ TEST(SSLClientServerTest, ClientCertPresent) {
   });
   });
 
 
   thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); });
   thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); });
+  msleep(1);
 
 
   httplib::SSLClient cli(HOST, PORT, 30, CLIENT_CERT_FILE,
   httplib::SSLClient cli(HOST, PORT, 30, CLIENT_CERT_FILE,
                          CLIENT_PRIVATE_KEY_FILE);
                          CLIENT_PRIVATE_KEY_FILE);
@@ -1484,6 +1485,7 @@ TEST(SSLClientServerTest, ClientCertMissing) {
   svr.Get("/test", [&](const Request &, Response &) { ASSERT_TRUE(false); });
   svr.Get("/test", [&](const Request &, Response &) { ASSERT_TRUE(false); });
 
 
   thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); });
   thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); });
+  msleep(1);
 
 
   httplib::SSLClient cli(HOST, PORT, 30);
   httplib::SSLClient cli(HOST, PORT, 30);
   auto res = cli.Get("/test");
   auto res = cli.Get("/test");
@@ -1504,6 +1506,7 @@ TEST(SSLClientServerTest, TrustDirOptional) {
   });
   });
 
 
   thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); });
   thread t = thread([&]() { ASSERT_TRUE(svr.listen(HOST, PORT)); });
+  msleep(1);
 
 
   httplib::SSLClient cli(HOST, PORT, 30, CLIENT_CERT_FILE,
   httplib::SSLClient cli(HOST, PORT, 30, CLIENT_CERT_FILE,
                          CLIENT_PRIVATE_KEY_FILE);
                          CLIENT_PRIVATE_KEY_FILE);