Second pass on update of yatl.
[awesomized/libmemcached] / libtest / server_container.cc
index 13b8957339d02e71cb48fc0108cbb944006216f5..e9b2f4e094b5572a47308535873bd9d558b335d5 100644 (file)
@@ -34,8 +34,9 @@
  *
  */
 
-#include <config.h>
-#include <libtest/common.h>
+#include "libtest/yatlcon.h"
+
+#include "libtest/common.h"
 
 #include <cassert>
 #include <cerrno>
@@ -75,13 +76,14 @@ void server_startup_st::push_server(Server *arg)
   }
   else
   {
-    char port_str[NI_MAXSERV]= { 0 };
-    snprintf(port_str, sizeof(port_str), "%u", int(arg->port()));
+    libtest::vchar_t port_str;
+    port_str.resize(NI_MAXSERV);
+    snprintf(&port_str[0], port_str.size(), "%u", int(arg->port()));
 
     server_config_string+= "--server=";
     server_config_string+= arg->hostname();
     server_config_string+= ":";
-    server_config_string+= port_str;
+    server_config_string+= &port_str[0];
     server_config_string+= " ";
   }
 
@@ -200,20 +202,14 @@ bool server_startup_st::start_server(const std::string& server_type, in_port_t t
     {
       if (GEARMAND_BINARY)
       {
-        if (HAVE_LIBGEARMAN)
-        {
-          server= build_gearmand("localhost", try_port);
-        }
+        server= build_gearmand("localhost", try_port);
       }
     }
     else if (server_type.compare("hostile-gearmand") == 0)
     {
       if (GEARMAND_BINARY)
       {
-        if (HAVE_LIBGEARMAN)
-        {
-          server= build_gearmand("localhost", try_port, "gearmand/hostile_gearmand");
-        }
+        server= build_gearmand("localhost", try_port, "gearmand/hostile_gearmand");
       }
     }
     else if (server_type.compare("drizzled") == 0)
@@ -239,34 +235,11 @@ bool server_startup_st::start_server(const std::string& server_type, in_port_t t
         }
       }
     }
-    else if (server_type.compare("memcached-sasl") == 0)
-    {
-      if (MEMCACHED_SASL_BINARY)
-      {
-        if (HAVE_LIBMEMCACHED)
-        {
-          server= build_memcached_sasl("localhost", try_port, username(), password());
-        }
-      }
-    }
     else if (server_type.compare("memcached") == 0)
     {
       if (HAVE_MEMCACHED_BINARY)
       {
-        if (HAVE_LIBMEMCACHED)
-        {
-          server= build_memcached("localhost", try_port);
-        }
-      }
-    }
-    else if (server_type.compare("memcached-light") == 0)
-    {
-      if (MEMCACHED_LIGHT_BINARY)
-      {
-        if (HAVE_LIBMEMCACHED)
-        {
-          server= build_memcached_light("localhost", try_port);
-        }
+        server= build_memcached("localhost", try_port);
       }
     }
 
@@ -274,7 +247,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.
     */
@@ -296,26 +275,35 @@ bool server_startup_st::start_server(const std::string& server_type, in_port_t t
     }
     else
 #endif
+
       if (server->start() == false)
-    {
-      delete server;
-      return false;
-    }
-    else
-    {
-      if (opt_startup_message)
       {
-        Outn();
-        Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
-        Outn();
+        delete server;
+        return false;
+      }
+      else
+      {
+        if (opt_startup_message)
+        {
+#if defined(DEBUG)
+          if (DEBUG)
+          {
+            Outn();
+            Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
+            Outn();
+          }
+#endif
+        }
       }
-    }
   }
-  catch (libtest::disconnected err)
+  catch (libtest::disconnected& err)
   {
-    stream::cerr(err.file(), err.line(), err.func()) << err.what();
-    delete server;
-    return false;
+    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 (...)
   {
@@ -343,36 +331,11 @@ bool server_startup_st::start_socket_server(const std::string& server_type, cons
     {
       Error << "Socket files are not supported for gearmand yet";
     }
-    else if (server_type.compare("memcached-sasl") == 0)
-    {
-      if (MEMCACHED_SASL_BINARY)
-      {
-        if (HAVE_LIBMEMCACHED)
-        {
-          server= build_memcached_sasl_socket("localhost", try_port, username(), password());
-        }
-        else
-        {
-          Error << "Libmemcached was not found";
-        }
-      }
-      else
-      {
-        Error << "No memcached binary is available";
-      }
-    }
     else if (server_type.compare("memcached") == 0)
     {
-      if (MEMCACHED_BINARY)
+      if (HAVE_MEMCACHED_BINARY)
       {
-        if (HAVE_LIBMEMCACHED)
-        {
           server= build_memcached_socket("localhost", try_port);
-        }
-        else
-        {
-          Error << "Libmemcached was not found";
-        }
       }
       else
       {
@@ -423,9 +386,14 @@ bool server_startup_st::start_socket_server(const std::string& server_type, cons
     {
       if (opt_startup_message)
       {
-        Outn();
-        Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
-        Outn();
+#if defined(DEBUG)
+        if (DEBUG)
+        {
+          Outn();
+          Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
+          Outn();
+        }
+#endif
       }
     }
   }