tests: fix udp tests
[awesomized/libmemcached] / libtest / memcached.cc
index b59dc22fa03c7efed4658828aad5a1dc410b5b96..e35166205599cf830d35780e44aa072fddf11869 100644 (file)
  *
  */
 
-#include "mem_config.h"
+#include "libtest/yatlcon.h"
 
-#include <libtest/common.h>
-
-#include <libmemcached-1.0/memcached.h>
-#include <libmemcachedutil-1.0/util.h>
+#include "libtest/common.h"
 
 #include <cassert>
 #include <cerrno>
@@ -75,14 +72,14 @@ public:
             const std::string& username_arg,
             const std::string& password_arg) :
     libtest::Server(host_arg, port_arg, 
-                    MEMCACHED_BINARY, false, is_socket_arg),
+                    memcached_binary(), false, is_socket_arg),
     _username(username_arg),
     _password(password_arg)
   { }
 
   Memcached(const std::string& host_arg, const in_port_t port_arg, const bool is_socket_arg) :
     libtest::Server(host_arg, port_arg,
-                    MEMCACHED_BINARY, false, is_socket_arg)
+                    memcached_binary(), false, is_socket_arg)
   {
     set_pid_file();
   }
@@ -134,7 +131,7 @@ public:
 
   const char *executable()
   {
-    return MEMCACHED_BINARY;
+    return memcached_binary();
   }
 
   bool is_libtool()
@@ -159,7 +156,8 @@ public:
   {
     char buffer[30];
     snprintf(buffer, sizeof(buffer), "%d", int(arg));
-    app.add_option("-p", buffer); 
+    app.add_option("-p", buffer);
+    app.add_option("-U", buffer);
   }
 
   bool has_port_option() const
@@ -191,13 +189,13 @@ public:
     return true;
   }
 
-  bool build(size_t argc, const char *argv[]);
+  bool build();
 };
 
 
 #include <sstream>
 
-bool Memcached::build(size_t argc, const char *argv[])
+bool Memcached::build()
 {
   if (getuid() == 0 or geteuid() == 0)
   {
@@ -205,7 +203,8 @@ bool Memcached::build(size_t argc, const char *argv[])
   }
 
   add_option("-l", "localhost");
-#ifndef TARGET_OS_OSX
+#ifdef __APPLE__
+#else
   add_option("-m", "128");
   add_option("-M");
 #endif
@@ -215,33 +214,27 @@ bool Memcached::build(size_t argc, const char *argv[])
     add_option(sasl());
   }
 
-  for (size_t x= 0 ; x < argc ; x++)
-  {
-    add_option(argv[x]);
-  }
-
   return true;
 }
 
 libtest::Server *build_memcached(const std::string& hostname, const in_port_t try_port)
 {
-  return new Memcached(hostname, try_port, false);
-}
+  if (has_memcached())
+  {
+    return new Memcached(hostname, try_port, false);
+  }
 
-libtest::Server *build_memcached_socket(const std::string& socket_file, const in_port_t try_port)
-{
-  return new Memcached(socket_file, try_port, true);
+  return NULL;
 }
 
-libtest::Server *build_memcached_sasl(const std::string& hostname, const in_port_t try_port, const std::string& username, const std::string &password)
+libtest::Server *build_memcached_socket(const std::string& socket_file, const in_port_t try_port)
 {
-  if (username.empty())
+  if (has_memcached())
   {
-    return new Memcached(hostname, try_port, false,  "memcached", "memcached");
+    return new Memcached(socket_file, try_port, true);
   }
 
-  return new Memcached(hostname, try_port, false,  username, password);
+  return NULL;
 }
 
 } // namespace libtest
-