From: Brian Aker Date: Fri, 22 Jul 2011 06:43:27 +0000 (-0700) Subject: Merge in version update (0.51) X-Git-Tag: 0.51 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=a6253e0a9ee914db2e55680a83cd03fdd5a2bc40;hp=04b8554c3724eae57fbd75dc6b3e69dca8b58187;p=awesomized%2Flibmemcached Merge in version update (0.51) --- diff --git a/ChangeLog b/ChangeLog index f522e4ce..8afdf7db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ -0.51 - +0.51 Thu Jul 21 11:08:58 PDT 2011 * memcached_callback_set() now takes its data argument as const - + * Update to tests. + * Fix in parser for port number. 0.50 Mon Jun 20 10:36:57 PDT 2011 * Updates to C++ interface diff --git a/configure.ac b/configure.ac index e0558a52..bb512954 100644 --- a/configure.ac +++ b/configure.ac @@ -18,9 +18,9 @@ AC_CHECK_PROGS([YACC], ['bison'], [:]) AC_CHECK_PROGS([LEX], ['flex'], [:]) #shared library versioning -MEMCACHED_UTIL_LIBRARY_VERSION=2:1:1 +MEMCACHED_UTIL_LIBRARY_VERSION=2:0:0 MEMCACHED_PROTOCAL_LIBRARY_VERSION=0:0:0 -MEMCACHED_LIBRARY_VERSION=8:1:1 +MEMCACHED_LIBRARY_VERSION=8:0:0 # | | | # +------+ | +---+ # | | | diff --git a/docs/conf.py.in b/docs/conf.py.in index 84d6eccb..c27cd5c2 100644 --- a/docs/conf.py.in +++ b/docs/conf.py.in @@ -239,7 +239,6 @@ man_pages = [ ('libmemcached_configuration', 'memcached', u'libmemcached Documentation', [u'Brian Aker'], 3), ('libmemcached_examples', 'libmemcached_examples', u'libmemcached Documentation', [u'Brian Aker'], 3), ('libmemcachedutil', 'libmemcachedutil', u'libmemcached Documentation', [u'Brian Aker'], 3), - ('memaslap', 'memaslap', u'libmemcached Documentation', [u'Brian Aker'], 1), ('memcached_analyze', 'memcached_analyze', u'libmemcached Documentation', [u'Brian Aker'], 3), ('memcached_append', 'memcached_append', u'Appending to or Prepending to data on the server', [u'Brian Aker'], 3), ('memcached_append', 'memcached_append_by_key', u'Appending to or Prepending to data on the server', [u'Brian Aker'], 3), @@ -269,7 +268,7 @@ man_pages = [ ('memcached_flush_buffers', 'memcached_flush_buffers', u'libmemcached Documentation', [u'Brian Aker'], 3), ('memcached_generate_hash_value', 'memcached_generate_hash', u'Generating hash values directly', [u'Brian Aker'], 3), ('memcached_generate_hash_value', 'memcached_generate_hash_value', u'Generating hash values directly', [u'Brian Aker'], 3), - ('memcached_get', 'memcached_fetch', u'Retrieving data from the server', [u'Brian Aker'], 3), + ('libmemcached/memcached_fetch', 'memcached_fetch', u'Retrieving data from the server', [u'Brian Aker'], 3), ('memcached_get', 'memcached_fetch_execute', u'Retrieving data from the server', [u'Brian Aker'], 3), ('memcached_get', 'memcached_fetch_result', u'Retrieving data from the server', [u'Brian Aker'], 3), ('memcached_get', 'memcached_get', u'Retrieving data from the server', [u'Brian Aker'], 3), @@ -301,6 +300,7 @@ man_pages = [ ('memcached_result_st', 'memcached_result_length', u'Working with result sets', [u'Brian Aker'], 3), ('memcached_result_st', 'memcached_result_st', u'Working with result sets', [u'Brian Aker'], 3), ('memcached_result_st', 'memcached_result_value', u'Working with result sets', [u'Brian Aker'], 3), + ('libmemcached/memcached_return_t', 'memcached_return_t', u'Return type values ', [u'Brian Aker'], 3), ('memcached_sasl', 'memcached_destroy_sasl_auth_data', u'libmemcached Documentation', [u'Brian Aker'], 3), ('memcached_sasl', 'memcached_get_sasl_callbacks', u'libmemcached Documentation', [u'Brian Aker'], 3), ('memcached_sasl', 'memcached_sasl', u'libmemcached Documentation', [u'Brian Aker'], 3), @@ -337,18 +337,14 @@ man_pages = [ ('memcached_verbosity', 'memcached_verbosity', u'libmemcached Documentation', [u'Brian Aker'], 3), ('memcached_version', 'memcached_lib_version', u'libmemcached Documentation', [u'Brian Aker'], 3), ('memcached_version', 'memcached_version', u'libmemcached Documentation', [u'Brian Aker'], 3), - ('memcapable', 'memcapable', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memcapable', 'memcapable', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memcat', 'memcat', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memcat', 'memcat', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memcp', 'memcp', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memcp', 'memcp', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memdump', 'memdump', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memdump', 'memdump', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memerror', 'memerror', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memerror', 'memerror', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memflush', 'memflush', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memrm', 'memrm', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memslap', 'memslap', u'libmemcached Documentation', [u'Brian Aker'], 1), - ('memstat', 'memstat', u'libmemcached Documentation', [u'Brian Aker'], 1), + ('bin/memcapable', 'memcapable', u'libmemcached Documentation', [u'Brian Aker'], 1), + ('bin/memcat', 'memcat', u'libmemcached Documentation', [u'Brian Aker'], 1), + ('bin/memcp', 'memcp', u'libmemcached Documentation', [u'Brian Aker'], 1), + ('bin/memdump', 'memdump', u'libmemcached Documentation', [u'Brian Aker'], 1), + ('bin/memerror', 'memerror', u'libmemcached Documentation', [u'Brian Aker'], 1), + ('bin/memflush', 'memflush', u'libmemcached Documentation', [u'Brian Aker'], 1), + ('bin/memrm', 'memrm', u'libmemcached Documentation', [u'Brian Aker'], 1), + ('bin/memaslap', 'memaslap', u'libmemcached Documentation', [u'Brian Aker'], 1), + ('bin/memslap', 'memslap', u'libmemcached Documentation', [u'Brian Aker'], 1), + ('bin/memstat', 'memstat', u'libmemcached Documentation', [u'Brian Aker'], 1), ] diff --git a/libmemcached/behavior.cc b/libmemcached/behavior.cc index 0c182ec2..a6988a22 100644 --- a/libmemcached/behavior.cc +++ b/libmemcached/behavior.cc @@ -239,7 +239,7 @@ memcached_return_t memcached_behavior_set(memcached_st *ptr, case MEMCACHED_BEHAVIOR_MAX: default: /* Shouldn't get here */ - WATCHPOINT_ASSERT(0); + assert_msg(0, "Invalid behavior passed to memcached_behavior_set()"); return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid behavior passed to memcached_behavior_set()")); } @@ -441,7 +441,7 @@ uint64_t memcached_behavior_get(memcached_st *ptr, case MEMCACHED_BEHAVIOR_MAX: default: - WATCHPOINT_ASSERT(0); /* Programming mistake if it gets this far */ + assert_msg(0, "Invalid behavior passed to memcached_behavior_set()"); return 0; } diff --git a/libmemcached/callback.cc b/libmemcached/callback.cc index 47397863..bb13a87b 100644 --- a/libmemcached/callback.cc +++ b/libmemcached/callback.cc @@ -90,8 +90,10 @@ void *memcached_callback_get(memcached_st *ptr, { memcached_return_t local_error; - if (!error) + if (error == NULL) + { error = &local_error; + } switch (flag) { @@ -152,7 +154,7 @@ void *memcached_callback_get(memcached_st *ptr, } case MEMCACHED_CALLBACK_MAX: default: - WATCHPOINT_ASSERT(0); + assert_msg(0, "Invalid behavior passed to memcached_behavior_set()"); *error= MEMCACHED_FAILURE; return NULL; } diff --git a/libmemcached/connect.cc b/libmemcached/connect.cc index 8efbb119..ecff6386 100644 --- a/libmemcached/connect.cc +++ b/libmemcached/connect.cc @@ -78,7 +78,6 @@ static memcached_return_t connect_poll(memcached_server_st *ptr) } default: // A real error occurred and we need to completely bail - WATCHPOINT_ERRNO(get_socket_errno()); switch (get_socket_errno()) { #ifdef TARGET_OS_LINUX @@ -107,7 +106,7 @@ static memcached_return_t connect_poll(memcached_server_st *ptr) memcached_set_errno(*ptr, get_socket_errno(), MEMCACHED_AT); } - WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET); + assert_msg(ptr->fd != INVALID_SOCKET, "poll() was passed an invalid file descriptor"); (void)closesocket(ptr->fd); ptr->fd= INVALID_SOCKET; ptr->state= MEMCACHED_SERVER_STATE_NEW; @@ -123,7 +122,6 @@ static memcached_return_t connect_poll(memcached_server_st *ptr) static memcached_return_t set_hostinfo(memcached_server_st *server) { - WATCHPOINT_ASSERT(not server->address_info); // We cover the case where a programming mistake has been made. if (server->address_info) { freeaddrinfo(server->address_info); @@ -175,8 +173,6 @@ static memcached_return_t set_hostinfo(memcached_server_st *server) default: { - WATCHPOINT_STRING(server->hostname); - WATCHPOINT_STRING(gai_strerror(errcode)); return memcached_set_error(*server, MEMCACHED_HOST_LOOKUP_FAILURE, MEMCACHED_AT, memcached_string_make_from_cstr(gai_strerror(errcode))); } } @@ -225,10 +221,12 @@ static inline void set_socket_nonblocking(memcached_server_st *ptr) static void set_socket_options(memcached_server_st *ptr) { - WATCHPOINT_ASSERT(ptr->fd != -1); + assert_msg(ptr->fd != -1, "invalid socket was passed to set_socket_options()"); if (ptr->type == MEMCACHED_CONNECTION_UDP) + { return; + } #ifdef HAVE_SNDTIMEO if (ptr->root->snd_timeout) @@ -407,7 +405,9 @@ static memcached_return_t network_connect(memcached_server_st *ptr) while (--counter) { if ((rc= set_hostinfo(ptr)) != MEMCACHED_TIMEOUT) + { break; + } #ifndef WIN32 struct timespec dream, rem; @@ -529,11 +529,6 @@ void set_last_disconnected_host(memcached_server_write_instance_st self) // const_cast memcached_st *root= (memcached_st *)self->root; -#if 0 - WATCHPOINT_STRING(self->hostname); - WATCHPOINT_NUMBER(self->port); - WATCHPOINT_ERRNO(self->cached_errno); -#endif memcached_server_free(root->last_disconnected_server); root->last_disconnected_server= memcached_server_clone(NULL, self); } diff --git a/libmemcached/get.cc b/libmemcached/get.cc index 794d3d15..8c98d4ca 100644 --- a/libmemcached/get.cc +++ b/libmemcached/get.cc @@ -168,8 +168,8 @@ char *memcached_get_by_key(memcached_st *ptr, char *dummy_value= memcached_fetch(ptr, NULL, NULL, &dummy_length, &dummy_flags, &dummy_error); - WATCHPOINT_ASSERT(dummy_length == 0); - WATCHPOINT_ASSERT(dummy_value == 0); + assert_msg(dummy_value == 0, "memcached_fetch() returned additional values beyond the single get it expected"); + assert_msg(dummy_length == 0, "memcached_fetch() returned additional values beyond the single get it expected"); assert_msg(ptr->query_id == query_id +1, "Programmer error, the query_id was not incremented."); return value; diff --git a/libmemcached/hosts.cc b/libmemcached/hosts.cc index 89896e85..1bcaaa7a 100644 --- a/libmemcached/hosts.cc +++ b/libmemcached/hosts.cc @@ -80,7 +80,9 @@ static void sort_hosts(memcached_st *ptr) memcached_return_t run_distribution(memcached_st *ptr) { if (ptr->flags.use_sort_hosts) + { sort_hosts(ptr); + } switch (ptr->distribution) { @@ -89,15 +91,18 @@ memcached_return_t run_distribution(memcached_st *ptr) case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: return update_continuum(ptr); + case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: case MEMCACHED_DISTRIBUTION_MODULA: break; + case MEMCACHED_DISTRIBUTION_RANDOM: srandom((uint32_t) time(NULL)); break; + case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: default: - WATCHPOINT_ASSERT(0); /* We have added a distribution without extending the logic */ + assert_msg(0, "Invalid distribution type passed to run_distribution()"); } return MEMCACHED_SUCCESS; @@ -252,9 +257,6 @@ static memcached_return_t update_continuum(memcached_st *ptr) #ifdef DEBUG printf("update_continuum: key is %s\n", sort_host); #endif - - WATCHPOINT_ASSERT(sort_host_length); - if (is_ketama_weighted) { for (uint32_t x= 0; x < pointer_per_hash; x++) @@ -303,8 +305,6 @@ static memcached_return_t update_continuum(memcached_st *ptr) memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)")); } - WATCHPOINT_ASSERT(sort_host_length); - if (is_ketama_weighted) { for (uint32_t x = 0; x < pointer_per_hash; x++) diff --git a/libmemcached/server.cc b/libmemcached/server.cc index 4187a0ab..98b16eef 100644 --- a/libmemcached/server.cc +++ b/libmemcached/server.cc @@ -140,6 +140,7 @@ void __server_free(memcached_server_st *self) if (self->address_info) { freeaddrinfo(self->address_info); + self->address_info= NULL; } memcached_error_free(*self); @@ -280,7 +281,9 @@ void memcached_server_error_reset(memcached_server_st *self) { WATCHPOINT_ASSERT(self); if (not self) + { return; + } memcached_error_free(*self); } diff --git a/libmemcached/watchpoint.h b/libmemcached/watchpoint.h index 58875e09..822101e9 100644 --- a/libmemcached/watchpoint.h +++ b/libmemcached/watchpoint.h @@ -37,63 +37,6 @@ #pragma once -/* Some personal debugging functions */ -#if defined(DEBUG) - -#ifdef TARGET_OS_LINUX -static inline void libmemcached_stack_dump(void) -{ - void *array[10]; - int size; - char **strings; - - size= backtrace(array, 10); - strings= backtrace_symbols(array, size); - - fprintf(stderr, "Found %d stack frames.\n", size); - - for (int x= 0; x < size; x++) - fprintf(stderr, "%s\n", strings[x]); - - free (strings); - - fflush(stderr); -} - -#elif defined(__sun) -#include - -static inline void libmemcached_stack_dump(void) -{ - fflush(stderr); - printstack(fileno(stderr)); -} - -#else - -static inline void libmemcached_stack_dump(void) -{ } - -#endif // libmemcached_stack_dump() - -#include - -#define WATCHPOINT do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s)\n", __FILE__, __LINE__,__func__);fflush(stdout); } while (0) -#define WATCHPOINT_ERROR(A) do {fprintf(stderr, "\nWATCHPOINT %s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, A));fflush(stdout); } while (0) -#define WATCHPOINT_IFERROR(A) do { if(A != MEMCACHED_SUCCESS)fprintf(stderr, "\nWATCHPOINT %s:%d %s\n", __FILE__, __LINE__, memcached_strerror(NULL, A));fflush(stdout); } while (0) -#define WATCHPOINT_STRING(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__,A);fflush(stdout); } while (0) -#define WATCHPOINT_STRING_LENGTH(A,B) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %.*s\n", __FILE__, __LINE__,__func__,(int)B,A);fflush(stdout); } while (0) -#define WATCHPOINT_NUMBER(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %lu\n", __FILE__, __LINE__,__func__,(unsigned long)(A));fflush(stdout); } while (0) -#define WATCHPOINT_LABELED_NUMBER(A,B) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s:%lu\n", __FILE__, __LINE__,__func__,(A),(unsigned long)(B));fflush(stdout); } while (0) -#define WATCHPOINT_IF_LABELED_NUMBER(A,B,C) do { if(A) {fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s:%lu\n", __FILE__, __LINE__,__func__,(B),(unsigned long)(C));fflush(stdout);} } while (0) -#define WATCHPOINT_ERRNO(A) do { fprintf(stderr, "\nWATCHPOINT %s:%d (%s) %s\n", __FILE__, __LINE__,__func__, strerror(A));fflush(stdout); } while (0) -#define WATCHPOINT_ASSERT_PRINT(A,B,C) do { if(!(A)){fprintf(stderr, "\nWATCHPOINT ASSERT %s:%d (%s) ", __FILE__, __LINE__,__func__);fprintf(stderr, (B),(C));fprintf(stderr,"\n");fflush(stdout); libmemcached_stack_dump(); } assert((A)); } while (0) -#define WATCHPOINT_ASSERT(A) do { if (! (A)) {libmemcached_stack_dump();} assert((A)); } while (0) -#define WATCHPOINT_ASSERT_INITIALIZED(A) do { if (! (A)) { libmemcached_stack_dump(); } assert(memcached_is_initialized((A))); } while (0); -#define WATCHPOINT_SET(A) do { A; } while(0); - -#else - #define WATCHPOINT #define WATCHPOINT_ERROR(A) #define WATCHPOINT_IFERROR(__memcached_return_t) (void)(__memcached_return_t) @@ -106,5 +49,3 @@ static inline void libmemcached_stack_dump(void) #define WATCHPOINT_ASSERT(A) (void)(A) #define WATCHPOINT_ASSERT_INITIALIZED(A) #define WATCHPOINT_SET(A) - -#endif /* DEBUG */ diff --git a/libtest/framework.cc b/libtest/framework.cc index baff4b8a..deb9045d 100644 --- a/libtest/framework.cc +++ b/libtest/framework.cc @@ -57,6 +57,7 @@ Framework::Framework() : collection_shutdown(_default_callback), _on_error(NULL), _runner(NULL), + _socket(false), _creators_ptr(NULL) { } diff --git a/libtest/framework.h b/libtest/framework.h index b504c5c1..087268cc 100644 --- a/libtest/framework.h +++ b/libtest/framework.h @@ -153,6 +153,11 @@ public: test_return_t on_error(const enum test_return_t, void *); + void set_socket() + { + _servers.set_socket(); + } + /** Runner represents the callers for the tests. If not implemented we will use a set of default implementations. @@ -176,5 +181,6 @@ public: private: Framework& operator=(const Framework&); libtest::server_startup_st _servers; + bool _socket; void *_creators_ptr; }; diff --git a/libtest/server.h b/libtest/server.h index c09469ec..d987a0b7 100644 --- a/libtest/server.h +++ b/libtest/server.h @@ -171,6 +171,7 @@ class server_startup_st { private: std::string server_list; + bool _socket; public: @@ -178,6 +179,7 @@ public: std::vector servers; server_startup_st() : + _socket(false), udp(0) { } @@ -194,6 +196,17 @@ public: bool is_helgrind() const; bool is_valgrind() const; + bool socket() + { + return _socket; + } + + void set_socket() + { + _socket= true; + } + + void shutdown(bool remove= false); void push_server(Server *); Server *pop_server(); diff --git a/support/libmemcached.spec.in b/support/libmemcached.spec.in index ccfd9a7e..1ee25d76 100644 --- a/support/libmemcached.spec.in +++ b/support/libmemcached.spec.in @@ -111,6 +111,8 @@ you will need to install %{name}-devel. %{_includedir}/libhashkit/digest.h %{_includedir}/libhashkit/function.h %{_includedir}/libhashkit/hashkit.h +%{_includedir}/libhashkit/hashkit.hpp +%{_includedir}/libhashkit/str_algorithm.h %{_includedir}/libhashkit/strerror.h %{_includedir}/libhashkit/types.h %{_includedir}/libhashkit/visibility.h @@ -125,8 +127,6 @@ you will need to install %{name}-devel. %{_includedir}/libmemcached/callback.h %{_includedir}/libmemcached/configure.h %{_includedir}/libmemcached/constants.h -%{_includedir}/libhashkit/str_algorithm.h -%{_includedir}/libmemcached/memcached/vbucket.h %{_includedir}/libmemcached/delete.h %{_includedir}/libmemcached/dump.h %{_includedir}/libmemcached/error.h @@ -139,11 +139,12 @@ you will need to install %{name}-devel. %{_includedir}/libmemcached/memcached.h %{_includedir}/libmemcached/memcached.hpp %{_includedir}/libmemcached/memcached/protocol_binary.h +%{_includedir}/libmemcached/memcached/vbucket.h %{_includedir}/libmemcached/memcached_util.h +%{_includedir}/libmemcached/namespace.h %{_includedir}/libmemcached/options.h %{_includedir}/libmemcached/parse.h %{_includedir}/libmemcached/platform.h -%{_includedir}/libmemcached/prefix_key.h %{_includedir}/libmemcached/protocol/cache.h %{_includedir}/libmemcached/protocol/callback.h %{_includedir}/libmemcached/protocol_handler.h @@ -160,6 +161,7 @@ you will need to install %{name}-devel. %{_includedir}/libmemcached/types.h %{_includedir}/libmemcached/util.h %{_includedir}/libmemcached/util/flush.h +%{_includedir}/libmemcached/util/pid.h %{_includedir}/libmemcached/util/ping.h %{_includedir}/libmemcached/util/pool.h %{_includedir}/libmemcached/util/version.h diff --git a/tests/atomsmasher.cc b/tests/atomsmasher.cc index 60f201eb..573e7f53 100644 --- a/tests/atomsmasher.cc +++ b/tests/atomsmasher.cc @@ -33,6 +33,8 @@ #include +#include + using namespace libtest; /* Number of items generated for tests */ @@ -46,17 +48,15 @@ static pairs_st *global_pairs; static char *global_keys[GLOBAL_COUNT]; static size_t global_keys_length[GLOBAL_COUNT]; -static test_return_t cleanup_pairs(memcached_st *memc) +static test_return_t cleanup_pairs(memcached_st *) { - (void)memc; pairs_free(global_pairs); return TEST_SUCCESS; } -static test_return_t generate_pairs(memcached_st *memc) +static test_return_t generate_pairs(memcached_st *) { - (void)memc; global_pairs= pairs_generate(GLOBAL_COUNT, 400); global_count= GLOBAL_COUNT; @@ -71,14 +71,14 @@ static test_return_t generate_pairs(memcached_st *memc) static test_return_t drizzle(memcached_st *memc) { - memcached_return_t rc; - char *return_value; - size_t return_value_length; - uint32_t flags; - infinite: for (size_t x= 0; x < TEST_COUNTER; x++) { + memcached_return_t rc; + char *return_value; + size_t return_value_length; + uint32_t flags; + uint32_t test_bit; uint8_t which; @@ -119,7 +119,9 @@ infinite: } if (getenv("MEMCACHED_ATOM_BURIN_IN")) + { goto infinite; + } return TEST_SUCCESS; } @@ -137,13 +139,10 @@ static test_return_t pre_nonblock(memcached_st *memc) */ static test_return_t add_test(memcached_st *memc) { - memcached_return_t rc; const char *key= "foo"; const char *value= "when we sanitize"; - unsigned long long setting_value; - - setting_value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NO_BLOCK); + memcached_return_t rc; rc= memcached_set(memc, key, strlen(key), value, strlen(value), (time_t)0, (uint32_t)0); @@ -153,8 +152,13 @@ static test_return_t add_test(memcached_st *memc) value, strlen(value), (time_t)0, (uint32_t)0); + if (rc == MEMCACHED_CONNECTION_FAILURE) + { + print_servers(memc); + } + /* Too many broken OS'es have broken loopback in async, so we can't be sure of the result */ - if (setting_value) + if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NO_BLOCK)) { test_true(rc == MEMCACHED_NOTSTORED or rc == MEMCACHED_STORED); } @@ -172,18 +176,19 @@ static test_return_t add_test(memcached_st *memc) */ static test_return_t many_adds(memcached_st *memc) { + test_true(memc); for (size_t x= 0; x < TEST_COUNTER; x++) { - add_test(memc); + test_compare_got(TEST_SUCCESS, add_test(memc), x); } return TEST_SUCCESS; } test_st smash_tests[] ={ - {"generate_pairs", 1, (test_callback_fn*)generate_pairs }, - {"drizzle", 1, (test_callback_fn*)drizzle }, - {"cleanup", 1, (test_callback_fn*)cleanup_pairs }, - {"many_adds", 1, (test_callback_fn*)many_adds }, + {"generate_pairs", true, (test_callback_fn*)generate_pairs }, + {"drizzle", true, (test_callback_fn*)drizzle }, + {"cleanup", true, (test_callback_fn*)cleanup_pairs }, + {"many_adds", true, (test_callback_fn*)many_adds }, {0, 0, 0} }; @@ -197,9 +202,8 @@ struct benchmark_state_st memcached_st *clone; } benchmark_state; -static test_return_t memcached_create_benchmark(memcached_st *memc) +static test_return_t memcached_create_benchmark(memcached_st *) { - (void)memc; benchmark_state.create_init= true; for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++) @@ -228,9 +232,8 @@ static test_return_t memcached_clone_benchmark(memcached_st *memc) return TEST_SUCCESS; } -static test_return_t pre_allocate(memcached_st *memc) +static test_return_t pre_allocate(memcached_st *) { - (void)memc; memset(&benchmark_state, 0, sizeof(benchmark_state)); benchmark_state.create= (memcached_st *)calloc(BENCHMARK_TEST_LOOP, sizeof(memcached_st)); @@ -241,16 +244,19 @@ static test_return_t pre_allocate(memcached_st *memc) return TEST_SUCCESS; } -static test_return_t post_allocate(memcached_st *memc) +static test_return_t post_allocate(memcached_st *) { - (void)memc; for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++) { if (benchmark_state.create_init) + { memcached_free(&benchmark_state.create[x]); + } if (benchmark_state.clone_init) + { memcached_free(&benchmark_state.clone[x]); + } } free(benchmark_state.create); diff --git a/tests/debug.cc b/tests/debug.cc index 4ba46eae..0b091a8d 100644 --- a/tests/debug.cc +++ b/tests/debug.cc @@ -44,6 +44,7 @@ using namespace libtest; #include #include +#include /* Dump each server's keys */ static memcached_return_t print_keys_callback(const memcached_st *, @@ -179,3 +180,10 @@ size_t confirm_key_count(memcached_st *memc) memcached_free(clone); return count; } + +void print_servers(memcached_st *memc) +{ + memcached_server_fn callbacks[1]; + callbacks[0]= server_print_callback; + memcached_server_cursor(memc, callbacks, NULL, 1); +} diff --git a/tests/debug.h b/tests/debug.h index 3d5a2288..ad20b562 100644 --- a/tests/debug.h +++ b/tests/debug.h @@ -44,3 +44,5 @@ test_return_t confirm_keys_dont_exist(memcached_st *memc, const char * const *ke test_return_t print_keys_by_server(memcached_st *memc); size_t confirm_key_count(memcached_st *memc); + +void print_servers(memcached_st *); diff --git a/tests/include.am b/tests/include.am index ac0dd92b..93f26bed 100644 --- a/tests/include.am +++ b/tests/include.am @@ -96,6 +96,8 @@ check_PROGRAMS+= tests/testplus tests_atomsmasher_SOURCES= \ tests/atomsmasher.cc \ + tests/debug.cc \ + tests/print.cc \ clients/generator.cc \ clients/execute.cc tests_atomsmasher_DEPENDENCIES= $(TESTS_LDADDS) @@ -236,46 +238,26 @@ valgrind-memerror: clients/memerror @echo "Testing memerror" @$(VALGRIND_COMMAND) clients/memerror 0 > /dev/null - - - - -MEMSLAP_COMMAND= clients/memslap - -MEM_COMMAND= tests/testapp - -TESTPLUS_COMMAND= tests/testplus - -HASHPLUS_COMMAND= tests/hashplus - -CYCLE_COMMAND= tests/cycle - -ATOM_COMMAND= tests/atomsmasher - -UDP_COMMAND= tests/testudp - -HASH_COMMAND= tests/testhashkit - test-mem: tests/var tests/testapp @tests/testapp test-udp: tests/var tests/testudp - $(UDP_COMMAND) + @tests/testudp test-atom: tests/var tests/atomsmasher - $(ATOM_COMMAND) + @tests/atomsmasher test-plus: tests/var tests/testplus - $(TESTPLUS_COMMAND) + @tests/testplus test-hash: tests/var tests/testhashkit - $(HASH_COMMAND) + @tests/testhashkit -test-hashplus: tests/var tests/hashplus - $(HASHPLUS_COMMAND) +test-hashplus: tests/var tests/hash_plus + @tests/hash_plus test-cycle: tests/var tests/cycle - $(CYCLE_COMMAND) + @tests/cycle pahole-mem: tests/testapp @$(PAHOLE_COMMAND) tests/testapp @@ -284,73 +266,73 @@ gdb-mem: tests/testapp @$(DEBUG_COMMAND) tests/testapp gdb-atom: tests/atomsmasher - $(DEBUG_COMMAND) $(UDP_COMMAND) + @$(DEBUG_COMMAND) tests/testudp gdb-udp: tests/testudp - $(DEBUG_COMMAND) $(ATOM_COMMAND) + @$(DEBUG_COMMAND) tests/atomsmasher gdb-plus: tests/testplus - $(DEBUG_COMMAND) $(TESTPLUS_COMMAND) + $(DEBUG_COMMAND) tests/testplus gdb-hash: tests/testhashkit - $(DEBUG_COMMAND) $(HASH_COMMAND) + @$(DEBUG_COMMAND) tests/testhashkit -gdb-hashplus: tests/hashplus - $(DEBUG_COMMAND) $(HASHPLUS_COMMAND) +gdb-hashplus: tests/hash_plus + @$(DEBUG_COMMAND) tests/hash_plus gdb-cycle: tests/cycle - $(DEBUG_COMMAND) $(CYCLE_COMMAND) + @$(DEBUG_COMMAND) tests/cycle gdb-memslap: clients/memslap - $(DEBUG_COMMAND) $(MEMSLAP_COMMAND) + @$(DEBUG_COMMAND) clients/memslap valgrind-cycle: tests/cycle - $(VALGRIND_COMMAND) $(CYCLE_COMMAND) + $(VALGRIND_COMMAND) tests/cycle valgrind-mem: tests/testapp @$(VALGRIND_COMMAND) tests/testapp valgrind-atom: tests/atomsmasher - $(VALGRIND_COMMAND) $(ATOM_COMMAND) + $(VALGRIND_COMMAND) tests/atomsmasher valgrind-udp: tests/testudp - $(VALGRIND_COMMAND) $(UDP_COMMAND) + $(VALGRIND_COMMAND) tests/testudp valgrind-plus: tests/testplus - $(VALGRIND_COMMAND) $(TESTPLUS_COMMAND) + @$(VALGRIND_COMMAND) tests/testplus valgrind-hash: tests/testhashkit - $(VALGRIND_COMMAND) $(HASH_COMMAND) + @$(VALGRIND_COMMAND) tests/testhashkit -valgrind-hashplus: tests/hashplus - $(VALGRIND_COMMAND) $(HASHPLUS_COMMAND) +valgrind-hashplus: tests/hash_plus + @$(VALGRIND_COMMAND) tests/hash_plus PHONY += valgrind -valgrind: valgrind-cycle valgrind-mem valgrind-atom valgrind-udp valgrind-plus valgrind-hash valgrind-hashplus +valgrind: valgrind-cycle valgrind-mem valgrind-udp valgrind-plus valgrind-hash valgrind-hashplus helgrind-cycle: tests/cycle - $(HELGRIND_COMMAND) $(CYCLE_COMMAND) + @$(HELGRIND_COMMAND) tests/cycle helgrind-mem: tests/testapp @$(HELGRIND_COMMAND) tests/testapp helgrind-atom: tests/atomsmasher - $(HELGRIND_COMMAND) $(ATOM_COMMAND) + @$(HELGRIND_COMMAND) tests/atomsmasher helgrind-udp: tests/testudp - $(HELGRIND_COMMAND) $(UDP_COMMAND) + @$(HELGRIND_COMMAND) tests/testudp helgrind-plus: tests/testplus - $(HELGRIND_COMMAND) $(TESTPLUS_COMMAND) + @$(HELGRIND_COMMAND) tests/testplus helgrind-hash: tests/testhashkit - $(HELGRIND_COMMAND) $(HASH_COMMAND) + @$(HELGRIND_COMMAND) tests/testhashkit -helgrind-hashplus: tests/hashplus - $(HELGRIND_COMMAND) $(HASHPLUS_COMMAND) +helgrind-hashplus: tests/hash_plus + @$(HELGRIND_COMMAND) tests/hash_plus .PHONY += helgrind -helgrind: helgrind-cycle helgrind-mem helgrind-atom helgrind-udp helgrind-plus helgrind-hash helgrind-hashplus +helgrind: helgrind-cycle helgrind-mem helgrind-udp helgrind-plus helgrind-hash helgrind-hashplus PHONY += cachegrind CLEANFILES += tests/cachegrind.out @@ -369,4 +351,4 @@ callgrind: test-no-outputdiff: test hudson-valgrind: tests/testapp - $(VALGRIND_COMMAND) --log-file=tests/valgrind.out $(MEM_COMMAND) + $(VALGRIND_COMMAND) --log-file=tests/valgrind.out tests/testapp diff --git a/tests/libmemcached_world.h b/tests/libmemcached_world.h index c6eebea7..968c235e 100644 --- a/tests/libmemcached_world.h +++ b/tests/libmemcached_world.h @@ -59,11 +59,14 @@ static void *world_create(server_startup_st& servers, test_return_t& error) } } - const char *argv[1]= { "memcached" }; - if (not servers.start_socket_server("memcached", max_port +1, 1, argv)) + if (servers.socket()) { - error= TEST_FAILURE; - return NULL; + const char *argv[1]= { "memcached" }; + if (not servers.start_socket_server("memcached", max_port +1, 1, argv)) + { + error= TEST_FAILURE; + return NULL; + } } diff --git a/tests/mem_functions.cc b/tests/mem_functions.cc index 2dcb3f44..bf2f3ee0 100644 --- a/tests/mem_functions.cc +++ b/tests/mem_functions.cc @@ -3616,24 +3616,24 @@ static test_return_t pre_cork_and_nonblock(memcached_st *memc) static test_return_t pre_nonblock_binary(memcached_st *memc) { - memcached_return_t rc= MEMCACHED_FAILURE; - memcached_st *memc_clone; - - memc_clone= memcached_clone(NULL, memc); + memcached_st *memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); + // The memcached_version needs to be done on a clone, because the server // will not toggle protocol on an connection. memcached_version(memc_clone); + memcached_return_t rc= MEMCACHED_FAILURE; if (libmemcached_util_version_check(memc_clone, 1, 4, 4)) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); - rc = memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1); - test_compare(MEMCACHED_SUCCESS, rc); - test_true(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == 1); + test_compare(MEMCACHED_SUCCESS, + memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)); + test_compare(1UL, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL)); } else { + memcached_free(memc_clone); return TEST_SKIPPED; } @@ -6540,4 +6540,6 @@ void get_world(Framework *world) world->collection_shutdown= (test_callback_fn*)world_container_shutdown; world->set_runner(&defualt_libmemcached_runner); + + world->set_socket(); }