Let tests pass for the moment.
[awesomized/libmemcached] / libtest / server.cc
index 99991209dc2703297ec5c38838bfcb5351a511ad..6542fd3fc6c474798e5a122df6dbd4df48d79128 100644 (file)
@@ -99,7 +99,8 @@ Server::Server(const std::string& host_arg, const in_port_t port_arg,
   _is_socket(is_socket_arg),
   _port(port_arg),
   _hostname(host_arg),
-  _app(executable, _is_libtool)
+  _app(executable, _is_libtool),
+  out_of_ban_killed_(false)
 {
 }
 
@@ -111,7 +112,6 @@ bool Server::check()
 {
   _app.slurp();
   _app.check();
-
   return true;
 }
 
@@ -178,6 +178,12 @@ bool Server::start()
   }
 #endif
 
+  if (port() == LIBTEST_FAIL_PORT)
+  {
+    throw libtest::start(LIBYATL_DEFAULT_PARAM,
+                         hostname(), port(), "Called failure");
+  }
+
   if (getenv("YATL_PTRCHECK_SERVER"))
   {
     _app.use_ptrcheck();
@@ -189,15 +195,16 @@ bool Server::start()
 
   if (args(_app) == false)
   {
-    Error << "Could not build command()";
-    return false;
+    throw libtest::start(LIBYATL_DEFAULT_PARAM,
+                         hostname(), port(), "Could not build command()");
   }
 
   libtest::release_port(_port);
   Application::error_t ret;
   if (Application::SUCCESS !=  (ret= _app.run()))
   {
-    Error << "Application::run() " << ret;
+    throw libtest::start(LIBYATL_DEFAULT_PARAM,
+                         hostname(), port(), "Application::run() %s", libtest::Application::toString(ret));
     return false;
   }
   _running= _app.print();
@@ -225,11 +232,12 @@ bool Server::start()
 
         char buf[PATH_MAX];
         char *getcwd_buf= getcwd(buf, sizeof(buf));
-        throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
-                             "Unable to open pidfile in %s for: %s stderr:%s",
-                             getcwd_buf ? getcwd_buf : "",
-                             _running.c_str(),
-                             _app.stderr_c_str());
+        throw libtest::start(LIBYATL_DEFAULT_PARAM,
+                                    hostname(), port(),
+                                    "Unable to open pidfile in %s for: %s stderr:%s",
+                                    getcwd_buf ? getcwd_buf : "",
+                                    _running.c_str(),
+                                    _app.stderr_c_str());
       }
     }
   }
@@ -241,7 +249,7 @@ bool Server::start()
     uint32_t waited;
     uint32_t retry;
 
-    for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
+    for (waited= 0, retry= 4; ; retry++, waited+= this_wait)
     {
       if ((pinged= ping()) == true)
       {
@@ -265,40 +273,38 @@ bool Server::start()
       _app.slurp();
       if (kill_file(pid_file()) == false)
       {
-        libtest::fatal err(LIBYATL_DEFAULT_PARAM,
-                           "Failed to kill off server, waited: %u after startup occurred, when pinging failed: %.*s stderr:%.*s",
-                           this_wait,
-                           int(_running.size()), _running.c_str(),
-                           int(_app.stderr_result_length()), _app.stderr_c_str());
-
-        stream::cerr(err.file(), err.line(), err.func()) << err.what();
+        throw libtest::start(LIBYATL_DEFAULT_PARAM,
+                             hostname(), port(),
+                             "Failed to kill off server, waited: %u after startup occurred, when pinging failed: %.*s stderr:%.*s",
+                             this_wait,
+                             int(_running.size()), _running.c_str(),
+                             int(_app.stderr_result_length()), _app.stderr_c_str());
       }
       else
       {
-        libtest::fatal err(LIBYATL_DEFAULT_PARAM, 
-                           "Failed native ping(), pid: %d was alive: %s waited: %u server started, having pid_file. exec: %.*s stderr:%.*s",
+        throw libtest::start(LIBYATL_DEFAULT_PARAM, 
+                             hostname(), port(),
+                             "Failed native ping(), pid: %d was alive: %s waited: %u server started, having pid_file. exec: %.*s stderr:%.*s",
+                             int(_app.pid()),
+                             _app.check() ? "true" : "false",
+                             this_wait,
+                             int(_running.size()), _running.c_str(),
+                             int(_app.stderr_result_length()), _app.stderr_c_str());
+      }
+    }
+    else
+    {
+      throw libtest::start(LIBYATL_DEFAULT_PARAM,
+                           hostname(), port(),
+                           "Failed native ping(), pid: %d is alive: %s waited: %u server started. exec: %.*s stderr:%.*s",
                            int(_app.pid()),
                            _app.check() ? "true" : "false",
                            this_wait,
                            int(_running.size()), _running.c_str(),
                            int(_app.stderr_result_length()), _app.stderr_c_str());
-
-        stream::cerr(err.file(), err.line(), err.func()) << err.what();
-      }
-    }
-    else
-    {
-      libtest::fatal err(LIBYATL_DEFAULT_PARAM,
-                         "Failed native ping(), pid: %d is alive: %s waited: %u server started. exec: %.*s stderr:%.*s",
-                         int(_app.pid()),
-                         _app.check() ? "true" : "false",
-                         this_wait,
-                         int(_running.size()), _running.c_str(),
-                         int(_app.stderr_result_length()), _app.stderr_c_str());
-
-      stream::cerr(err.file(), err.line(), err.func()) << err.what();
     }
     _running.clear();
+
     return false;
   }
 
@@ -401,6 +407,7 @@ bool Server::set_log_file()
 
 bool Server::args(Application& app)
 {
+
   // Set a log file if it was requested (and we can)
   if (has_log_file_option())
   {