lichao
2021-05-18 3788226ee9332945e90066b58f2b85026c2a0460
utest/robust_test.cpp
@@ -16,6 +16,35 @@
/////////////////////////////////////////////////////////////////////////////////////////
BOOST_AUTO_TEST_CASE(InitTest)
{
   AtomicReqRep rr;
   auto client = [&]() {
      for (int i = 0; i < 20; ++i) {
         int64_t reply = 0;
         bool r = rr.ClientRequest(i, reply);
         printf("init request %d, %s, reply %d\n", i, (r ? "ok" : "failed"), reply);
      }
   };
   bool run = true;
   auto server = [&]() {
      auto onReq = [](int64_t req) { return req + 100; };
      while (run) {
         rr.ServerProcess(onReq);
      }
   };
   ThreadManager clients, servers;
   servers.Launch(server);
   for (int i = 0; i < 2; ++i) {
      clients.Launch(client);
   }
   clients.WaitAll();
   run = false;
   servers.WaitAll();
}
BOOST_AUTO_TEST_CASE(QueueTest)
{
   const int nthread = 100;