*
* Data Differential YATL (i.e. libtest) library
*
- * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2012-2013 Data Differential, http://datadifferential.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
}
else if (waited_pid == -1)
{
+ std::string error_string
+ if (stdout_result_length())
+ {
+ error_string+= " stdout: ";
+ error_string+= stdout_c_str();
+ }
+
+ if (stderr_result_length())
+ {
+ error_string+= " stderr: ";
+ error_string+= stderr_c_str();
+ }
+ Error << "waitpid() returned errno:" << strerror(errno) << " " << error_string;
_app_exit_state= Application::UNKNOWN;
- Error << "waitpid() returned errno:" << strerror(errno);
}
else
{
return int(app.join());
}
-const char *gearmand_binary()
-{
- return GEARMAND_BINARY;
-}
-
-const char *drizzled_binary()
-{
- return DRIZZLED_BINARY;
-}
-
} // namespace exec_cmdline
int exec_cmdline(const std::string& executable, const char *args[], bool use_libtool= false);
-const char *gearmand_binary();
-const char *drizzled_binary();
-
}
*
* Data Differential YATL (i.e. libtest) library
*
- * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2012-2013 Data Differential, http://datadifferential.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
#include "libtest/yatlcon.h"
#include <libtest/common.h>
+#include <cstdio>
#include <cstdlib>
#include <unistd.h>
return false;
}
-bool has_memcached()
+static char memcached_binary_path[FILENAME_MAX];
+
+static void initialize_curl_startup()
{
+ memcached_binary_path[0]= NULL;
+
#if defined(HAVE_MEMCACHED_BINARY) && HAVE_MEMCACHED_BINARY
if (HAVE_MEMCACHED_BINARY)
{
std::stringstream arg_buffer;
-
char *getenv_ptr;
if (bool((getenv_ptr= getenv("PWD"))) and strcmp(MEMCACHED_BINARY, "memcached/memcached") == 0)
{
if (access(arg_buffer.str().c_str(), X_OK) == 0)
{
- return true;
+ strncpy(memcached_binary_path, arg_buffer.str().c_str(), FILENAME_MAX);
}
}
#endif
+}
+
+static pthread_once_t memcached_binary_once= PTHREAD_ONCE_INIT;
+static void initialize_memcached_binary(void)
+{
+ int ret;
+ if ((ret= pthread_once(&memcached_binary_once, initialize_curl_startup)) != 0)
+ {
+ FATAL(strerror(ret));
+ }
+}
+
+bool has_memcached()
+{
+ initialize_memcached_binary();
+
+ if (memcached_binary_path[0])
+ {
+ return true;
+ }
return false;
}
+const char* memcached_binary()
+{
+ initialize_memcached_binary();
+
+ if (memcached_binary_path[0])
+ {
+ return memcached_binary_path;
+ }
+
+ return NULL;
+}
+
bool has_memcached_sasl()
{
#if defined(HAVE_MEMCACHED_SASL_BINARY) && HAVE_MEMCACHED_SASL_BINARY
return false;
}
+const char *gearmand_binary()
+{
+ return GEARMAND_BINARY;
+}
+
+const char *drizzled_binary()
+{
+ return DRIZZLED_BINARY;
+}
+
} // namespace libtest
*
* Data Differential YATL (i.e. libtest) library
*
- * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2012-2013 Data Differential, http://datadifferential.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
LIBTEST_API
bool has_mysqld();
+LIBTEST_API
+const char* memcached_binary();
+
+LIBTEST_API
+const char *gearmand_binary();
+
+LIBTEST_API
+const char *drizzled_binary();
} // namespace libtest
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();
}
const char *executable()
{
- return MEMCACHED_BINARY;
+ return memcached_binary();
}
bool is_libtool()
libtest::Server *build_memcached(const std::string& hostname, const in_port_t try_port)
{
- if (HAVE_MEMCACHED_BINARY)
+ 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)
{
- if (HAVE_MEMCACHED_BINARY)
+ if (has_memcached())
{
return new Memcached(socket_file, try_port, true);
}