Update for valgrind failure.
[awesomized/libmemcached] / libtest / server.cc
index 182e6f3ec2dad99b40b9e5a2fd505ec932640a0a..34d367ef41ad209fc0fe89ada478fbe8d61b258c 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <cassert>
@@ -138,6 +139,19 @@ bool Server::start()
   }
 
   Application app(executable(), is_libtool());
+
+  if (is_debug())
+  {
+    app.use_gdb();
+  }
+  else if (getenv("TESTS_ENVIRONMENT"))
+  {
+    if (strstr(getenv("TESTS_ENVIRONMENT"), "gdb"))
+    {
+      app.use_gdb();
+    }
+  }
+
   if (args(app) == false)
   {
     Error << "Could not build command()";
@@ -154,7 +168,7 @@ bool Server::start()
 
   if (Application::SUCCESS !=  (ret= app.wait()))
   {
-    Error << "Application::wait() " << app.print() << " " << ret;
+    Error << "Application::wait() " << _running << " " << ret;
     return false;
   }
 
@@ -167,9 +181,11 @@ bool Server::start()
   {
     Wait wait(pid_file(), 8);
 
-    if (not wait.successful())
+    if (wait.successful() == false)
     {
-      Error << "Unable to open pidfile for: " << _running;
+      libtest::fatal(LIBYATL_DEFAULT_PARAM,
+                     "Unable to open pidfile for: %s",
+                     _running.c_str());
     }
   }
 
@@ -186,10 +202,16 @@ bool Server::start()
     // If we happen to have a pid file, lets try to kill it
     if (pid_file().empty() == false)
     {
-      Error << "We are going to kill it off";
-      kill_file(pid_file());
+      if (kill_file(pid_file()) == false)
+      {
+        fatal_message("Failed to kill off server after startup occurred, when pinging failed");
+      }
+      Error << "Failed to ping() server started, having pid_file. exec:" << _running;
+    }
+    else
+    {
+      Error << "Failed to ping() server started. exec:" << _running;
     }
-    Error << "Failed to ping() server started with:" << _running;
     _running.clear();
     return false;
   }
@@ -287,8 +309,7 @@ bool Server::set_log_file()
   int fd;
   if ((fd= mkstemp(file_buffer)) == -1)
   {
-    perror(file_buffer);
-    return false;
+    libtest::fatal(LIBYATL_DEFAULT_PARAM, "mkstemp() failed on %s with %s", file_buffer, strerror(errno));
   }
   close(fd);
 
@@ -301,13 +322,9 @@ bool Server::args(Application& app)
 {
 
   // Set a log file if it was requested (and we can)
-  if (getenv("LIBTEST_LOG") and has_log_file_option())
+  if (has_log_file_option())
   {
-    if (not set_log_file())
-    {
-      return false;
-    }
-
+    set_log_file();
     log_file_option(app, _log_file);
   }
 
@@ -334,7 +351,6 @@ bool Server::args(Application& app)
 
   if (has_socket_file_option())
   {
-    Error << "adding socket option ";
     if (set_socket_file() == false)
     {
       return false;