Update libtest.
[m6w6/libmemcached] / libtest / server_container.cc
index d8ef5d495364ad4c51e42722b3a70faeb20a67ac..f87a9fba126cde97070b3b1525bb19a007c63d52 100644 (file)
@@ -182,7 +182,7 @@ bool server_startup_st::validate()
 
 bool server_startup(server_startup_st& construct, const std::string& server_type, in_port_t try_port, int argc, const char *argv[], const bool opt_startup_message)
 {
-  construct.start_server(server_type, try_port, argc, argv, opt_startup_message);
+  return construct.start_server(server_type, try_port, argc, argv, opt_startup_message);
 }
 
 bool server_startup_st::start_server(const std::string& server_type, in_port_t try_port, int argc, const char *argv[], const bool opt_startup_message)
@@ -274,7 +274,13 @@ bool server_startup_st::start_server(const std::string& server_type, in_port_t t
     {
       throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "Launching of an unknown server was attempted: %s", server_type.c_str());
     }
+  }
+  catch (...)
+  {
+    throw;
+  }
 
+  try {
     /*
       We will now cycle the server we have created.
     */
@@ -287,29 +293,38 @@ bool server_startup_st::start_server(const std::string& server_type, in_port_t t
 
     server->build(argc, argv);
 
+#if 0
     if (false)
     {
       Out << "Pausing for startup, hit return when ready.";
       std::string gdb_command= server->base_command();
-      std::string options;
-#if 0
-      Out << "run " << server->args(options);
-#endif
       getchar();
     }
-    else if (server->start() == false)
-    {
-      delete server;
-      return false;
-    }
     else
-    {
-      if (opt_startup_message)
+#endif
+
+      if (server->start() == false)
       {
-        Outn();
-        Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
-        Outn();
+        delete server;
+        return false;
       }
+      else
+      {
+        if (opt_startup_message)
+        {
+          Outn();
+          Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
+          Outn();
+        }
+      }
+  }
+  catch (libtest::disconnected& err)
+  {
+    if (fatal::is_disabled() == false and try_port != LIBTEST_FAIL_PORT)
+    {
+      stream::cerr(err.file(), err.line(), err.func()) << err.what();
+      delete server;
+      return false;
     }
   }
   catch (...)
@@ -397,17 +412,18 @@ bool server_startup_st::start_socket_server(const std::string& server_type, cons
 
     server->build(argc, argv);
 
+#if 0
     if (false)
     {
       Out << "Pausing for startup, hit return when ready.";
       std::string gdb_command= server->base_command();
       std::string options;
-#if 0
       Out << "run " << server->args(options);
-#endif
       getchar();
     }
-    else if (server->start() == false)
+    else
+#endif
+      if (server->start() == false)
     {
       Error << "Failed to start " << *server;
       delete server;