case MEMCACHED_CONNECTION_TCP:
rc= network_connect(server);
-#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
+#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT)
if (LIBMEMCACHED_WITH_SASL_SUPPORT)
{
if (server->fd != INVALID_SOCKET and server->root->sasl.callbacks)
in_port_t port,
uint32_t weight)
{
- char buffer[MEMCACHED_NI_MAXHOST];
+ char buffer[MEMCACHED_NI_MAXHOST]= { 0 };
memcpy(buffer, hostname, hostname_length);
buffer[hostname_length]= 0;
namespace libtest {
+bool has_libmemcached_sasl(void)
+{
+#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
+ if (LIBMEMCACHED_WITH_SASL_SUPPORT)
+ {
+ return true;
+ }
+#endif
+
+ return false;
+}
+
bool has_libmemcached(void)
{
#if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED
bool has_gearmand()
{
-#if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
+#if defined(GEARMAND_BINARY) && defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
if (HAVE_GEARMAND_BINARY)
{
std::stringstream arg_buffer;
bool has_drizzled()
{
-#if defined(HAVE_DRIZZLED_BINARY) && HAVE_DRIZZLED_BINARY
+#if defined(DRIZZLED_BINARY) && defined(HAVE_DRIZZLED_BINARY) && HAVE_DRIZZLED_BINARY
if (HAVE_DRIZZLED_BINARY)
{
if (access(DRIZZLED_BINARY, X_OK) == 0)
bool has_mysqld()
{
-#if defined(HAVE_MYSQLD_BUILD) && HAVE_MYSQLD_BUILD
+#if defined(MYSQLD_BINARY) && defined(HAVE_MYSQLD_BUILD) && HAVE_MYSQLD_BUILD
if (HAVE_MYSQLD_BUILD)
{
if (access(MYSQLD_BINARY, X_OK) == 0)
static char memcached_binary_path[FILENAME_MAX];
-static void initialize_curl_startup()
+static void initialize_memcached_binary_path()
{
memcached_binary_path[0]= 0;
-#if defined(HAVE_MEMCACHED_BINARY) && HAVE_MEMCACHED_BINARY
+#if defined(MEMCACHED_BINARY) && defined(HAVE_MEMCACHED_BINARY) && HAVE_MEMCACHED_BINARY
if (HAVE_MEMCACHED_BINARY)
{
std::stringstream arg_buffer;
static void initialize_memcached_binary(void)
{
int ret;
- if ((ret= pthread_once(&memcached_binary_once, initialize_curl_startup)) != 0)
+ if ((ret= pthread_once(&memcached_binary_once, initialize_memcached_binary_path)) != 0)
{
FATAL(strerror(ret));
}
initialize_memcached_binary();
if (memcached_binary_path[0])
+ if (memcached_binary_path[0] and (strlen(memcached_binary_path) > 0))
{
return true;
}
return NULL;
}
-bool has_memcached_sasl()
+static char memcached_sasl_binary_path[FILENAME_MAX];
+
+static void initialize_has_memcached_sasl()
{
-#if defined(HAVE_MEMCACHED_SASL_BINARY) && HAVE_MEMCACHED_SASL_BINARY
- if (HAVE_MEMCACHED_SASL_BINARY)
+ memcached_sasl_binary_path[0]= 0;
+
+#if defined(MEMCACHED_BINARY) && defined(HAVE_MEMCACHED_BINARY) && HAVE_MEMCACHED_BINARY
+ if (HAVE_MEMCACHED_BINARY)
{
- if (access(MEMCACHED_SASL_BINARY, X_OK) == 0)
+ std::stringstream arg_buffer;
+
+ char *getenv_ptr;
+ if (bool((getenv_ptr= getenv("PWD"))) and strcmp(MEMCACHED_BINARY, "memcached/memcached") == 0)
{
- return true;
+ arg_buffer << getenv_ptr;
+ arg_buffer << "/";
+ }
+ arg_buffer << MEMCACHED_BINARY;
+
+ if (access(arg_buffer.str().c_str(), X_OK) == 0)
+ {
+ strncpy(memcached_sasl_binary_path, arg_buffer.str().c_str(), FILENAME_MAX);
}
}
#endif
+}
+
+bool has_memcached_sasl()
+{
+ initialize_has_memcached_sasl();
+
+ if (memcached_sasl_binary_path[0] and (strlen(memcached_sasl_binary_path) > 0))
+ {
+ return true;
+ }
return false;
}
const char *gearmand_binary()
{
+#if defined(GEARMAND_BINARY)
return GEARMAND_BINARY;
+#else
+ return NULL;
+#endif
}
const char *drizzled_binary()
{
+#if defined(DRIZZLED_BINARY)
return DRIZZLED_BINARY;
+#else
+ return NULL;
+#endif
}
} // namespace libtest
namespace libtest {
+LIBTEST_API
+bool has_libmemcached_sasl(void);
+
LIBTEST_API
bool has_libmemcached();
(void)http_get_result_callback;
(void)curl;
(void)url;
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
if (HAVE_LIBCURL)
{
-#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
assert(curl);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_USERAGENT, YATL_USERAGENT);
-#endif
}
+#endif
}
HTTP::HTTP(const std::string& url_arg) :
{
(void)init;
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
if (HAVE_LIBCURL)
{
-#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
CURL *curl= curl_easy_init();
init(curl, url());
curl_easy_cleanup(curl);
return bool(retref == CURLE_OK);
-#endif
}
+#endif
return false;
}
bool POST::execute()
{
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
if (HAVE_LIBCURL)
{
-#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
CURL *curl= curl_easy_init();;
init(curl, url());
curl_easy_cleanup(curl);
return bool(retref == CURLE_OK);
-#endif
}
+#endif
return false;
}
bool TRACE::execute()
{
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
if (HAVE_LIBCURL)
{
-#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
CURL *curl= curl_easy_init();;
init(curl, url());
curl_easy_cleanup(curl);
return retref == CURLE_OK;
-#endif
}
+#endif
return false;
}
bool HEAD::execute()
{
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
if (HAVE_LIBCURL)
{
-#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
CURL *curl= curl_easy_init();;
init(curl, url());
curl_easy_cleanup(curl);
return retref == CURLE_OK;
-#endif
}
+#endif
return false;
}
} \
} while (0)
+#define SKIP_UNLESS(__expression) \
+do \
+{ \
+ if (! (__expression)) { \
+ if (YATL_FULL) { \
+ SKIP(#__expression); \
+ } \
+ fprintf(stdout, "\n%s:%d: %s SKIP '(%s)'\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #__expression); \
+ exit(EXIT_SKIP); \
+ } \
+} while (0)
+
+#define SKIP_UNLESS_(__expression, ...) \
+do \
+{ \
+ if (! (__expression)) { \
+ size_t ask= snprintf(0, 0, __VA_ARGS__); \
+ ask++; \
+ char *buffer= (char*)alloca(sizeof(char) * ask); \
+ snprintf(buffer, ask, __VA_ARGS__); \
+ if (YATL_FULL) { \
+ SKIP(#__expression, buffer); \
+ } \
+ fprintf(stdout, "\n%s:%d: %s SKIP '%s' [ %s ]\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #__expression, buffer); \
+ exit(EXIT_SKIP); \
+ } \
+} while (0)
+
#define ASSERT_TRUE(__expression) \
do \
{ \
return TEST_FAILURE;
}
+static test_return_t test_throw_skip_unless_macro_TEST(void *)
+{
+ try {
+ SKIP_UNLESS(false);
+ }
+ catch (const libtest::__skipped&)
+ {
+ return TEST_SUCCESS;
+ }
+ catch (...)
+ {
+ FAIL("SLIP_UNLESS() failed to throw libtest::_skipped");
+ }
+
+ FAIL("SLIP_UNLESS() failed to throw");
+
+ return TEST_FAILURE;
+}
+
static test_return_t test_throw_skip_TEST(void *)
{
try {
{"SUCCESS", false, test_throw_success_TEST },
{"libtest::__skipped", false, test_throw_skip_TEST },
{"SKIP_IF", false, test_throw_skip_macro_TEST },
+ {"SKIP_UNLESS", false, test_throw_skip_unless_macro_TEST },
{"FAIL", false, test_throw_fail_TEST },
{"ASSERT_FALSE_", false, ASSERT_FALSE__TEST },
{"ASSERT_FALSE", false, ASSERT_FALSE_TEST },
static void *world_create(libtest::server_startup_st& servers, test_return_t& error)
{
- if (libtest::has_memcached() == false)
- {
- error= TEST_SKIPPED;
- return NULL;
- }
+ SKIP_UNLESS(libtest::has_libmemcached());
if (servers.sasl())
{
- if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
- {
- error= TEST_SKIPPED;
- return NULL;
- }
+ SKIP_UNLESS(libtest::has_libmemcached_sasl());
- if (HAVE_MEMCACHED_SASL_BINARY == 0)
- {
- error= TEST_SKIPPED;
- return NULL;
- }
-
// Assume we are running under valgrind, and bail
if (getenv("TESTS_ENVIRONMENT"))
{