From: Brian Aker Date: Fri, 25 May 2012 00:57:33 +0000 (-0400) Subject: Fix for test cases to make sure memcached is around. X-Git-Tag: 1.0.9~34^2~5 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=ab130c459a975d24628169901addb191ef2cdf87;p=awesomized%2Flibmemcached Fix for test cases to make sure memcached is around. --- diff --git a/libtest/binaries.cc b/libtest/binaries.cc index c3e2e5b7..d5e0cc72 100644 --- a/libtest/binaries.cc +++ b/libtest/binaries.cc @@ -35,65 +35,7 @@ */ #include -#include namespace libtest { -bool has_gearmand_binary() -{ -#if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY - std::stringstream arg_buffer; - - if (getenv("PWD")) - { - arg_buffer << getenv("PWD"); - arg_buffer << "/"; - } - arg_buffer << GEARMAND_BINARY; - - if (access(arg_buffer.str().c_str() ,R_OK|X_OK) == 0) - { - return true; - } -#endif - - return false; -} - -bool has_drizzled_binary() -{ -#if defined(HAVE_DRIZZLED_BINARY) && HAVE_DRIZZLED_BINARY - if (access(DRIZZLED_BINARY, R_OK|X_OK) == 0) - { - return true; - } -#endif - - return false; -} - -bool has_memcached_binary() -{ -#if defined(HAVE_MEMCACHED_BINARY) && HAVE_MEMCACHED_BINARY - if (access(MEMCACHED_BINARY, R_OK|X_OK) == 0) - { - return true; - } -#endif - - return false; -} - -bool has_memcached_sasl_binary() -{ -#if defined(HAVE_MEMCACHED_SASL_BINARY) && HAVE_MEMCACHED_SASL_BINARY - if (access(MEMCACHED_SASL_BINARY, R_OK|X_OK) == 0) - { - return true; - } -#endif - - return false; -} - } diff --git a/libtest/binaries.h b/libtest/binaries.h index 4ec663e6..7829f3f0 100644 --- a/libtest/binaries.h +++ b/libtest/binaries.h @@ -38,17 +38,4 @@ namespace libtest { -LIBTEST_API -bool has_memcached_binary(); - -LIBTEST_API -bool has_memcached_sasl_binary(); - -LIBTEST_API -bool has_gearmand_binary(); - -LIBTEST_API -bool has_drizzled_binary(); - } // namespace libtest - diff --git a/libtest/has.cc b/libtest/has.cc index 1c7b0493..699a1326 100644 --- a/libtest/has.cc +++ b/libtest/has.cc @@ -35,13 +35,16 @@ */ #include -#include +#include #include +#include + +namespace libtest { bool has_memcached_support(void) { - if (HAVE_LIBMEMCACHED and HAVE_MEMCACHED_BINARY) + if (HAVE_LIBMEMCACHED) { return true; } @@ -49,9 +52,9 @@ bool has_memcached_support(void) return false; } -bool has_drizzle_support(void) +bool has_libdrizzle(void) { - if (HAVE_LIBDRIZZLE and HAVE_DRIZZLED_BINARY) + if (HAVE_LIBDRIZZLE) { return true; } @@ -63,7 +66,6 @@ bool has_postgres_support(void) { if (getenv("POSTGES_IS_RUNNING_AND_SETUP")) { - if (HAVE_LIBPQ) { return true; @@ -72,3 +74,67 @@ bool has_postgres_support(void) return false; } + + +bool has_gearmand() +{ + if (HAVE_GEARMAND_BINARY) + { + std::stringstream arg_buffer; + + if (getenv("PWD")) + { + arg_buffer << getenv("PWD"); + arg_buffer << "/"; + } + arg_buffer << GEARMAND_BINARY; + + if (access(arg_buffer.str().c_str(), X_OK) == 0) + { + return true; + } + } + + return false; +} + +bool has_drizzled() +{ + if (HAVE_DRIZZLED_BINARY) + { + if (access(DRIZZLED_BINARY, X_OK) == 0) + { + return true; + } + } + + return false; +} + +bool has_memcached() +{ + if (HAVE_MEMCACHED_BINARY) + { + if (access(MEMCACHED_BINARY, X_OK) == 0) + { + return true; + } + } + + return false; +} + +bool has_memcached_sasl() +{ + if (HAVE_MEMCACHED_SASL_BINARY) + { + if (access(MEMCACHED_SASL_BINARY, X_OK) == 0) + { + return true; + } + } + + return false; +} + +} // namespace libtest diff --git a/libtest/has.hpp b/libtest/has.hpp index 176bf9fd..68593d74 100644 --- a/libtest/has.hpp +++ b/libtest/has.hpp @@ -36,8 +36,27 @@ #pragma once -bool has_memcached_support(void); +namespace libtest { -bool has_drizzle_support(void); +LIBTEST_API +bool has_libmemcached(); -bool has_postgres_support(void); +LIBTEST_API +bool has_libdrizzle(); + +LIBTEST_API +bool has_postgres_support(); + +LIBTEST_API +bool has_memcached(); + +LIBTEST_API +bool has_memcached_sasl(); + +LIBTEST_API +bool has_gearmand(); + +LIBTEST_API +bool has_drizzled(); + +} // namespace libtest diff --git a/libtest/unittest.cc b/libtest/unittest.cc index c27f366a..56df76ba 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -265,10 +265,10 @@ static test_return_t drizzled_cycle_test(void *object) test_true(servers and servers->validate()); #if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY - test_true(has_drizzled_binary()); + test_true(has_drizzled()); #endif - test_skip(true, has_drizzled_binary()); + test_skip(true, has_drizzled()); test_true(server_startup(*servers, "drizzled", get_free_port(), 0, NULL)); @@ -281,10 +281,10 @@ static test_return_t gearmand_cycle_test(void *object) test_true(servers and servers->validate()); #if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY - test_true(has_gearmand_binary()); + test_true(has_gearmand()); #endif - test_skip(true, has_gearmand_binary()); + test_skip(true, has_gearmand()); test_true(server_startup(*servers, "gearmand", get_free_port(), 0, NULL)); @@ -333,7 +333,7 @@ static test_return_t memcached_cycle_test(void *object) if (MEMCACHED_BINARY and HAVE_LIBMEMCACHED) { - test_true(has_memcached_binary()); + test_true(has_memcached()); test_true(server_startup(*servers, "memcached", get_free_port(), 0, NULL)); return TEST_SUCCESS; @@ -351,7 +351,7 @@ static test_return_t memcached_socket_cycle_test(void *object) { if (HAVE_LIBMEMCACHED) { - test_true(has_memcached_binary()); + test_true(has_memcached()); test_true(servers->start_socket_server("memcached", get_free_port(), 0, NULL)); return TEST_SUCCESS; @@ -372,7 +372,7 @@ static test_return_t memcached_sasl_test(void *object) { if (HAVE_LIBMEMCACHED) { - test_true(has_memcached_sasl_binary()); + test_true(has_memcached_sasl()); test_true(server_startup(*servers, "memcached-sasl", get_free_port(), 0, NULL)); return TEST_SUCCESS; @@ -757,14 +757,14 @@ static test_return_t default_port_TEST(void *) static test_return_t check_for_gearman(void *) { test_skip(true, HAVE_LIBGEARMAN); - test_skip(true, has_gearmand_binary()); + test_skip(true, has_gearmand()); return TEST_SUCCESS; } static test_return_t check_for_drizzle(void *) { test_skip(true, HAVE_LIBDRIZZLE); - test_skip(true, has_drizzled_binary()); + test_skip(true, has_drizzled()); return TEST_SUCCESS; } @@ -786,7 +786,7 @@ test_st gearmand_tests[] ={ static test_return_t check_for_libmemcached(void *) { test_skip(true, HAVE_LIBMEMCACHED); - test_skip(true, has_memcached_binary()); + test_skip(true, has_memcached()); return TEST_SUCCESS; } diff --git a/tests/cycle.cc b/tests/cycle.cc index fe4ca1b3..679473ea 100644 --- a/tests/cycle.cc +++ b/tests/cycle.cc @@ -116,8 +116,14 @@ collection_st collection[] ={ {0, 0, 0, 0} }; -static void *world_create(server_startup_st& servers, test_return_t& ) +static void *world_create(server_startup_st& servers, test_return_t& error) { + if (libtest::has_memcached() == false) + { + error= TEST_SKIPPED; + return NULL; + } + return &servers; } diff --git a/tests/libmemcached_world.h b/tests/libmemcached_world.h index 88329db4..8bc48a71 100644 --- a/tests/libmemcached_world.h +++ b/tests/libmemcached_world.h @@ -43,7 +43,7 @@ static void *world_create(libtest::server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; diff --git a/tests/libmemcached_world_socket.h b/tests/libmemcached_world_socket.h index 9ea175e3..fbfb5a9c 100644 --- a/tests/libmemcached_world_socket.h +++ b/tests/libmemcached_world_socket.h @@ -45,7 +45,7 @@ static void *world_create(libtest::server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; diff --git a/tests/memcapable.cc b/tests/memcapable.cc index d0392d01..2723e7f6 100644 --- a/tests/memcapable.cc +++ b/tests/memcapable.cc @@ -107,7 +107,7 @@ collection_st collection[] ={ static void *world_create(server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; diff --git a/tests/memcat.cc b/tests/memcat.cc index 32e3f2c3..f70da3be 100644 --- a/tests/memcat.cc +++ b/tests/memcat.cc @@ -126,7 +126,7 @@ collection_st collection[] ={ static void *world_create(server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; diff --git a/tests/memcp.cc b/tests/memcp.cc index 8aba6088..590f1af3 100644 --- a/tests/memcp.cc +++ b/tests/memcp.cc @@ -85,7 +85,7 @@ collection_st collection[] ={ static void *world_create(server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; diff --git a/tests/memdump.cc b/tests/memdump.cc index a8720e5b..ac1619c3 100644 --- a/tests/memdump.cc +++ b/tests/memdump.cc @@ -112,7 +112,7 @@ collection_st collection[] ={ static void *world_create(server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; diff --git a/tests/memerror.cc b/tests/memerror.cc index dd7610ef..1c893e11 100644 --- a/tests/memerror.cc +++ b/tests/memerror.cc @@ -111,8 +111,14 @@ collection_st collection[] ={ {0, 0, 0, 0} }; -static void *world_create(server_startup_st&, test_return_t&) +static void *world_create(server_startup_st&, test_return_t& error) { + if (libtest::has_memcached() == false) + { + error= TEST_SKIPPED; + return NULL; + } + return NULL; } diff --git a/tests/memexist.cc b/tests/memexist.cc index fb69354d..a9430a33 100644 --- a/tests/memexist.cc +++ b/tests/memexist.cc @@ -143,7 +143,7 @@ collection_st collection[] ={ static void *world_create(server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; diff --git a/tests/memflush.cc b/tests/memflush.cc index 80a42453..d8e0b5f8 100644 --- a/tests/memflush.cc +++ b/tests/memflush.cc @@ -95,7 +95,7 @@ collection_st collection[] ={ static void *world_create(server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; diff --git a/tests/memrm.cc b/tests/memrm.cc index 29c66337..5c3b6d52 100644 --- a/tests/memrm.cc +++ b/tests/memrm.cc @@ -146,7 +146,7 @@ collection_st collection[] ={ static void *world_create(server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; diff --git a/tests/memslap.cc b/tests/memslap.cc index 3c5ea250..57b7c355 100644 --- a/tests/memslap.cc +++ b/tests/memslap.cc @@ -167,7 +167,7 @@ collection_st collection[] ={ static void *world_create(server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; diff --git a/tests/memstat.cc b/tests/memstat.cc index 9b61697d..b6053aeb 100644 --- a/tests/memstat.cc +++ b/tests/memstat.cc @@ -107,7 +107,7 @@ collection_st collection[] ={ static void *world_create(server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; diff --git a/tests/memtouch.cc b/tests/memtouch.cc index c44e6a08..647485e4 100644 --- a/tests/memtouch.cc +++ b/tests/memtouch.cc @@ -139,7 +139,7 @@ collection_st collection[] ={ static void *world_create(server_startup_st& servers, test_return_t& error) { - if (HAVE_MEMCACHED_BINARY == 0) + if (libtest::has_memcached() == false) { error= TEST_SKIPPED; return NULL; @@ -160,4 +160,3 @@ void get_world(Framework *world) world->collections(collection); world->create(world_create); } -