*.OTHER
*.THIS
*.exe
+*.gz
*.lo
*.orig
*.output
*.pop
+*.rej
*.rpm
+*.tar
*/*.l[oa]
*/*/*.l[oa]
*/*/.deps
TAGS
aclocal.m4
autom4te.cache
+autoscan.log
clients/memaslap
clients/memcapable
clients/memcat
config/plugin.ac
config/top.h
configure
+configure.scan
docs/*.[13]
docs/*.html
docs/changes
docs/text
example/memcached_light
libhashkit/configure.h
-libmemcached-*.tar.gz
-libmemcached-0.30-1.src.rpm
-libmemcached-0.30-1.x86_64.rpm
-libmemcached-0.31-1.src.rpm
-libmemcached-0.31-1.x86_64.rpm
-libmemcached-0.37-1.src.rpm
-libmemcached-0.37-1.x86_64.rpm
libmemcached-?.??/
libmemcached/configure.h
libmemcached/dtrace_probes.h
ltsugar.m4
ltversion.m4
lt~obsolete.m4
+m4/libtool.m4
+m4/ltoptions.m4
+m4/ltsugar.m4
+m4/ltversion.m4
+m4/lt~obsolete.m4
out
patch
patch2
tests/cycle
tests/hash_plus
tests/hashplus
+tests/internals
tests/memcapable
tests/memplus
tests/memslap
m4/po.m4 \
m4/progtest.m4
-include libtest/include.am
-include libmemcached/include.am
-include libmemcached/protocol/include.am
-include libmemcached/util/include.am
+libmemcached_libmemcached_la_LDFLAGS=
+
include clients/include.am
-include libhashkit/include.am
-include tests/include.am
+include docs/include.am
include example/include.am
-include support/include.am
+include libhashkit/include.am
+include libmemcached/include.am
+include libmemcached/util/include.am
+include libmemcached/protocol/include.am
+include libmemcachedinternal/include.am
+include libmemcachedinternal/util/include.am
+include libtest/include.am
include poll/include.am
+include support/include.am
+include tests/include.am
include util/include.am
include win32/include.am
-include docs/include.am
docs: html man
clients_memslap_SOURCES = clients/memslap.cc
clients_memslap_SOURCES+= clients/generator.cc clients/execute.cc
+clients_memslap_CXXFLAGS = ${PTHREAD_CFLAGS}
clients_memslap_LDADD = $(PTHREAD_LIBS) $(CLIENTS_LDADDS)
clients_memaslap_SOURCES= \
PANDORA_HAVE_SASL
WITH_LIBGEARMAN
+AC_CHECK_FUNCS([alarm])
+AC_CHECK_FUNCS([dup2])
+AC_CHECK_FUNCS([gettimeofday])
+AC_CHECK_FUNCS([memchr])
+AC_CHECK_FUNCS([memmove])
+AC_CHECK_FUNCS([memset])
+AC_CHECK_FUNCS([select])
+AC_CHECK_FUNCS([setenv])
+AC_CHECK_FUNCS([socket])
+AC_CHECK_FUNCS([sqrt])
+AC_CHECK_FUNCS([strcasecmp])
+AC_CHECK_FUNCS([strchr])
+AC_CHECK_FUNCS([strdup])
+AC_CHECK_FUNCS([strerror])
+AC_CHECK_FUNCS([strtol])
+AC_CHECK_FUNCS([strtoul])
+AC_CHECK_FUNCS([strtoull])
+AC_CHECK_HEADERS([arpa/inet.h])
+AC_CHECK_HEADERS([fcntl.h])
+AC_CHECK_HEADERS([libintl.h])
+AC_CHECK_HEADERS([limits.h])
+AC_CHECK_HEADERS([malloc.h])
+AC_CHECK_HEADERS([netdb.h])
+AC_CHECK_HEADERS([netinet/in.h])
+AC_CHECK_HEADERS([stddef.h])
+AC_CHECK_HEADERS([sys/time.h])
+AC_FUNC_ALLOCA
+AC_FUNC_ERROR_AT_LINE
+AC_FUNC_FORK
+AC_FUNC_MALLOC
+AC_FUNC_REALLOC
+AC_FUNC_STRERROR_R
+AC_HEADER_STDBOOL
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_OFF_T
+AC_TYPE_PID_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+AC_TYPE_UINT8_T
+
dnl The sasl functions should only be visible if we build with sasl support
AS_IF([test "x$ac_cv_sasl" = "xyes"],
[LIBMEMCACHED_WITH_SASL_SUPPORT="#define LIBMEMCACHED_WITH_SASL_SUPPORT 1"])
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2006-2009 Brian Aker All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <config.h>
+
+#include <sys/types.h>
+
+#include <example/byteorder.h>
+
+/* Byte swap a 64-bit number. */
+#ifndef swap64
+static inline uint64_t swap64(uint64_t in)
+{
+#ifndef WORDS_BIGENDIAN
+ /* Little endian, flip the bytes around until someone makes a faster/better
+ * way to do this. */
+ uint64_t rv= 0;
+ for (uint8_t x= 0; x < 8; x++)
+ {
+ rv= (rv << 8) | (in & 0xff);
+ in >>= 8;
+ }
+ return rv;
+#else
+ /* big-endian machines don't need byte swapping */
+ return in;
+#endif // WORDS_BIGENDIAN
+}
+#endif
+
+#ifdef HAVE_HTONLL
+
+uint64_t example_ntohll(uint64_t value)
+{
+ return ntohll(value);
+}
+
+uint64_t example_htonll(uint64_t value)
+{
+ return htonll(value);
+}
+
+#else // HAVE_HTONLL
+
+uint64_t example_ntohll(uint64_t value)
+{
+ return swap64(value);
+}
+
+uint64_t example_htonll(uint64_t value)
+{
+ return swap64(value);
+}
+
+#endif // HAVE_HTONLL
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Byteorder for example
+ *
+ * Copyright (C) 2011 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
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+uint64_t example_ntohll(uint64_t);
+
+uint64_t example_htonll(uint64_t);
+
+#ifdef __cplusplus
+}
+#endif
example/interface_v0.c \
example/interface_v1.c \
example/memcached_light.c \
- libmemcached/byteorder.cc \
+ example/byteorder.cc \
example/memcached_light.h \
example/storage.h
#include <string.h>
#include <libmemcached/protocol_handler.h>
-#include <libmemcached/byteorder.h>
+#include <example/byteorder.h>
#include "storage.h"
#include "memcached_light.h"
msg.response.message.body.flags= htonl(item->flags);
char *ptr= (char*)(msg.response.bytes + sizeof(*header) + 4);
uint32_t bodysize= 4;
- msg.response.message.header.response.cas= memcached_htonll(item->cas);
+ msg.response.message.header.response.cas= example_htonll(item->cas);
if (opcode == PROTOCOL_BINARY_CMD_GETK || opcode == PROTOCOL_BINARY_CMD_GETKQ)
{
memcpy(ptr, item->key, item->nkey);
};
uint16_t keylen= ntohs(header->request.keylen);
- uint64_t initial= memcached_ntohll(req->message.body.initial);
- uint64_t delta= memcached_ntohll(req->message.body.delta);
+ uint64_t initial= example_ntohll(req->message.body.initial);
+ uint64_t delta= example_ntohll(req->message.body.delta);
uint32_t expiration= ntohl(req->message.body.expiration);
uint32_t flags= 0;
void *key= req->bytes + sizeof(req->bytes);
if (rval == PROTOCOL_BINARY_RESPONSE_SUCCESS)
{
response.message.header.response.bodylen= ntohl(8);
- response.message.body.value= memcached_ntohll((*(uint64_t*)item->data));
- response.message.header.response.cas= memcached_ntohll(item->cas);
+ response.message.body.value= example_ntohll((*(uint64_t*)item->data));
+ response.message.header.response.cas= example_ntohll(item->cas);
release_item(item);
if (header->request.opcode == PROTOCOL_BINARY_CMD_INCREMENTQ ||
{
protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS;
uint16_t keylen= ntohs(header->request.keylen);
- uint64_t cas= memcached_ntohll(header->request.cas);
+ uint64_t cas= example_ntohll(header->request.cas);
void *key= header + 1;
uint32_t vallen= ntohl(header->request.bodylen) - keylen;
void *val= (char*)key + keylen;
.opcode= header->request.opcode,
.status= htons(rval),
.opaque= header->request.opaque,
- .cas= memcached_htonll(cas),
+ .cas= example_htonll(cas),
}
}
};
struct item* item= get_item(key, keylen);
if (item != NULL)
{
- if (item->cas != memcached_ntohll(header->request.cas))
+ if (item->cas != example_ntohll(header->request.cas))
{
release_item(item);
response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_EEXISTS);
/* SETQ shouldn't return a message */
if (header->request.opcode == PROTOCOL_BINARY_CMD_SET)
{
- response.message.header.response.cas= memcached_htonll(item->cas);
+ response.message.header.response.cas= example_htonll(item->cas);
release_item(item);
return response_handler(cookie, header, (void*)&response);
}
/* ADDQ shouldn't return a message */
if (header->request.opcode == PROTOCOL_BINARY_CMD_ADD)
{
- response.message.header.response.cas= memcached_htonll(item->cas);
+ response.message.header.response.cas= example_htonll(item->cas);
release_item(item);
return response_handler(cookie, header, (void*)&response);
}
{
response.message.header.response.status= htons(PROTOCOL_BINARY_RESPONSE_KEY_ENOENT);
}
- else if (header->request.cas == 0 || memcached_ntohll(header->request.cas) == item->cas)
+ else if (header->request.cas == 0 || example_ntohll(header->request.cas) == item->cas)
{
release_item(item);
delete_item(key, keylen);
/* REPLACEQ shouldn't return a message */
if (header->request.opcode == PROTOCOL_BINARY_CMD_REPLACE)
{
- response.message.header.response.cas= memcached_htonll(item->cas);
+ response.message.header.response.cas= example_htonll(item->cas);
release_item(item);
return response_handler(cookie, header, (void*)&response);
}
#include <string.h>
#include <libmemcached/protocol_handler.h>
-#include <libmemcached/byteorder.h>
+#include <example/byteorder.h>
#include "storage.h"
static protocol_binary_response_status add_handler(const void *cookie,
#include <event.h>
#include <libmemcached/protocol_handler.h>
-#include <libmemcached/byteorder.h>
+#include <example/byteorder.h>
#include "storage.h"
#include "memcached_light.h"
libhashkit_libhashkit_la_SOURCES+= libhashkit/murmur.cc
endif
+libhashkit_libhashkit_la_CPPFLAGS= \
+ ${AM_CPPFLAGS} \
+ -DBUILDING_HASHKIT
+
+libhashkit_libhashkit_la_CFLAGS= \
+ ${AM_CFLAGS} \
+ -DBUILDING_HASHKIT
+
libhashkit_libhashkit_la_CXXFLAGS= \
${AM_CXXFLAGS} \
-DBUILDING_HASHKIT
$(LIBM) \
-version-info $(HASHKIT_LIBRARY_VERSION)
+# library used for testing
noinst_LTLIBRARIES+= libhashkit/libhashkitinc.la
libhashkit_libhashkitinc_la_SOURCES= ${libhashkit_libhashkit_la_SOURCES}
*
*/
-#include <config.h>
-
-#include <sys/types.h>
-
-#include <libmemcached/visibility.h>
-#include <libmemcached/byteorder.h>
+#include <libmemcached/common.h>
/* Byte swap a 64-bit number. */
#ifndef swap64
#include <libmemcached/is.h>
#include <libmemcached/namespace.h>
+#include <libmemcached/server_instance.h>
+
#ifdef __cplusplus
extern "C" {
#endif
-typedef struct memcached_server_st * memcached_server_write_instance_st;
-
typedef memcached_return_t (*memcached_server_execute_fn)(memcached_st *ptr, memcached_server_write_instance_st server, void *context);
LIBMEMCACHED_LOCAL
#include <libmemcached/assert.hpp>
#endif
-/* string value */
-struct memcached_continuum_item_st
-{
- uint32_t index;
- uint32_t value;
-};
+#include <libmemcached/continuum.hpp>
#if !defined(__GNUC__) || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * LibMemcached
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2006-2009 Brian Aker
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+/* string value */
+struct memcached_continuum_item_st
+{
+ uint32_t index;
+ uint32_t value;
+};
}
if (value_length)
+ {
*value_length= memcached_string_length(&result_buffer->value);
+ }
if (key)
{
libmemcached/backtrace.hpp \
libmemcached/byteorder.h \
libmemcached/common.h \
+ libmemcached/continuum.hpp \
libmemcached/do.hpp \
libmemcached/error.hpp \
libmemcached/initialize_query.h \
libmemcached/protocol/binary_handler.h \
libmemcached/protocol/common.h \
libmemcached/response.h \
+ libmemcached/server_instance.h \
libmemcached/string.hpp \
libmemcached/virtual_bucket.h
libmemcached/visibility.h \
libmemcached/watchpoint.h
-# This noinst lib contains things we want to be ABI private but still want to
-# either use in client programs or be able to test in test cases
-# These symbols will not be exposed in the shipped .so
-noinst_LTLIBRARIES+= libmemcached/libmemcachedinternal.la
-libmemcached_libmemcachedinternal_la_SOURCES= \
- libmemcached/array.c \
- libmemcached/backtrace.cc \
- libmemcached/error.cc \
- libmemcached/string.cc
-libmemcached_libmemcachedinternal_la_CFLAGS= \
- ${AM_CFLAGS} \
- ${NO_CONVERSION} \
- -DBUILDING_LIBMEMCACHED
-
-libmemcached_libmemcachedinternal_la_CXXFLAGS= \
- ${AM_CXXFLAGS} \
- ${NO_CONVERSION} \
- -DBUILDING_LIBMEMCACHED
-
lib_LTLIBRARIES+= libmemcached/libmemcached.la
libmemcached_libmemcached_la_CFLAGS= \
${AM_CFLAGS} \
libmemcached_libmemcached_la_DEPENDENCIES=
libmemcached_libmemcached_la_LIBADD= $(LIBM)
-libmemcached_libmemcached_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_LIBRARY_VERSION}
+libmemcached_libmemcached_la_LDFLAGS+= ${AM_LDFLAGS} -version-info ${MEMCACHED_LIBRARY_VERSION}
if HAVE_SASL
libmemcached_libmemcached_la_LDFLAGS+= $(LTLIBSASL) $(LTLIBSASL2)
if HAVE_DTRACE
BUILT_SOURCES+= libmemcached/dtrace_probes.h
CLEANFILES+= libmemcached/dtrace_probes.h
-endif
+CLEANFILES+= libmemcached/libmemcached_probes.o
-if DTRACE_NEEDS_OBJECTS
-libmemcached_libmemcached_la_SOURCES += libmemcached/libmemcached_probes.d
libmemcached_libmemcached_la_DEPENDENCIES += libmemcached/libmemcached_probes.o
libmemcached_libmemcached_la_LIBADD += libmemcached/libmemcached_probes.o
-CLEANFILES+= libmemcached/libmemcached_probes.o
+libmemcached_libmemcached_la_SOURCES += libmemcached/libmemcached_probes.d
endif
SUFFIXES+= .d
libmemcached/dtrace_probes.h: libmemcached/libmemcached_probes.d
- $(DTRACE) $(DTRACEFLAGS) -h -o libmemcached/dtrace_probes.h -s ${top_srcdir}/libmemcached/libmemcached_probes.d
+ $(DTRACE) $(DTRACEFLAGS) -h -o ${top_srcdir}/libmemcached/dtrace_probes.h -s ${top_srcdir}/libmemcached/libmemcached_probes.d
libmemcached/libmemcached_probes.o: libmemcached/libmemcached_probes.d ${libmemcached_libmemcached_la_OBJECTS} config.h
.d.o:
- $(DTRACE) $(DTRACEFLAGS) -o $@ -G -s $< `grep '^pic_object' ${top_builddir}/libmemcached/*.lo | cut -f 2 -d\' | sed "s/^/${top_builddir}\/libmemcached\//"`
-
+ $(DTRACE) $(DTRACEFLAGS) -o $@ -G -s libmemcached/libmemcached_probes.d
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * LibMemcached
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct memcached_server_st * memcached_server_write_instance_st;
+
+#ifdef __cplusplus
+}
+#endif
void memcached_string_free(memcached_string_st *ptr)
{
if (not ptr)
+ {
return;
+ }
if (ptr->string)
{
size_t memcached_string_length(const memcached_string_st *self)
{
- return (size_t)(self->end - self->string);
+ return size_t(self->end -self->string);
}
size_t memcached_string_size(const memcached_string_st *self)
} options;
};
-#ifdef BUILDING_LIBMEMCACHED
-
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
-
-#endif
# included from Top Level Makefile.am
# All paths should be given relative to the root
-if BUILD_LIBMEMCACHEDUTIL
nobase_include_HEADERS+= \
libmemcached/memcached_util.h \
libmemcached/util.h \
libmemcached/util/pool.h \
libmemcached/util/version.h
lib_LTLIBRARIES+= libmemcached/libmemcachedutil.la
-endif
libmemcached_libmemcachedutil_la_SOURCES= \
libmemcached/backtrace.cc \
${NO_CONVERSION} \
${PTHREAD_CFLAGS} \
-DBUILDING_LIBMEMCACHED
-libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la
-libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} ${PTHREAD_LIBS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION}
+libmemcached_libmemcachedutil_la_LIBADD= libmemcached/libmemcached.la ${PTHREAD_LIBS}
+libmemcached_libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION}
libmemcached_libmemcachedutil_la_DEPENDENCIES= libmemcached/libmemcached.la
* LIBMEMCACHED_LOCAL is used for non-api symbols.
*/
-#if defined(BUILDING_LIBMEMCACHED)
+#if defined(BUILDING_LIBMEMCACHEDINTERNAL)
# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
# define LIBMEMCACHED_API __attribute__ ((visibility("default")))
-# define LIBMEMCACHED_LOCAL __attribute__ ((visibility("hidden")))
+# define LIBMEMCACHED_LOCAL __attribute__ ((visibility("default")))
# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
# define LIBMEMCACHED_API __global
-# define LIBMEMCACHED_LOCAL __hidden
+# define LIBMEMCACHED_LOCAL __global
# elif defined(_MSC_VER)
# define LIBMEMCACHED_API extern __declspec(dllexport)
-# define LIBMEMCACHED_LOCAL
-# else
-# define LIBMEMCACHED_API
-# define LIBMEMCACHED_LOCAL
-# endif /* defined(HAVE_VISIBILITY) */
-#else /* defined(BUILDING_LIBMEMCACHED) */
-# if defined(_MSC_VER)
-# define LIBMEMCACHED_API extern __declspec(dllimport)
-# define LIBMEMCACHED_LOCAL
+# define LIBMEMCACHED_LOCAL extern __declspec(dllexport)
# else
# define LIBMEMCACHED_API
# define LIBMEMCACHED_LOCAL
-# endif /* defined(_MSC_VER) */
-#endif /* defined(BUILDING_LIBMEMCACHED) */
+# endif
+#else
+# if defined(BUILDING_LIBMEMCACHED)
+# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
+# define LIBMEMCACHED_API __attribute__ ((visibility("default")))
+# define LIBMEMCACHED_LOCAL __attribute__ ((visibility("hidden")))
+# elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+# define LIBMEMCACHED_API __global
+# define LIBMEMCACHED_LOCAL __hidden
+# elif defined(_MSC_VER)
+# define LIBMEMCACHED_API extern __declspec(dllexport)
+# define LIBMEMCACHED_LOCAL
+# else
+# define LIBMEMCACHED_API
+# define LIBMEMCACHED_LOCAL
+# endif /* defined(HAVE_VISIBILITY) */
+# else /* defined(BUILDING_LIBMEMCACHED) */
+# if defined(_MSC_VER)
+# define LIBMEMCACHED_API extern __declspec(dllimport)
+# define LIBMEMCACHED_LOCAL
+# else
+# define LIBMEMCACHED_API
+# define LIBMEMCACHED_LOCAL
+# endif /* defined(_MSC_VER) */
+# endif /* defined(BUILDING_LIBMEMCACHED) */
+#endif /* defined(BUILDING_LIBMEMCACHEDINTERNAL) */
--- /dev/null
+# vim:ft=automake
+# included from Top Level Makefile.am
+# All paths should be given relative to the root
+
+# This noinst lib contains things we want to be ABI private but still want to
+# either use in client programs or be able to test in test cases These symbols
+# will not be exposed in the shipped .so
+noinst_LTLIBRARIES+= libmemcachedinternal/libmemcachedinternal.la
+
+libmemcachedinternal_libmemcachedinternal_la_SOURCES= $(libmemcached_libmemcached_la_SOURCES)
+libmemcachedinternal_libmemcachedinternal_la_CFLAGS= \
+ ${AM_CFLAGS} \
+ ${NO_CONVERSION} \
+ -DBUILDING_LIBMEMCACHEDINTERNAL
+libmemcachedinternal_libmemcachedinternal_la_CPPFLAGS= \
+ ${AM_CPPFLAGS} \
+ ${NO_CONVERSION} \
+ -DBUILDING_LIBMEMCACHEDINTERNAL
+libmemcachedinternal_libmemcachedinternal_la_CXXFLAGS= \
+ ${AM_CXXFLAGS} \
+ ${NO_CONVERSION} \
+ -DBUILDING_LIBMEMCACHEDINTERNAL
+libmemcachedinternal_libmemcachedinternal_la_LDFLAGS= ${AM_LDFLAGS}
+libmemcachedinternal_libmemcachedinternal_la_LIBADD= $(libmemcached_libmemcached_la_LIBADD)
+libmemcachedinternal_libmemcachedinternal_la_DEPENDENCIES= $(libmemcached_libmemcached_la_DEPENDENCIES)
--- /dev/null
+# vim:ft=automake
+# included from Top Level Makefile.am
+# All paths should be given relative to the root
+
+# This noinst lib contains things we want to be ABI private but still want to
+# either use in client programs or be able to test in test cases These symbols
+# will not be exposed in the shipped .so
+noinst_LTLIBRARIES+= libmemcachedinternal/libmemcachedutilinternal.la
+
+libmemcachedinternal_libmemcachedutilinternal_la_SOURCES= $(libmemcached_libmemcachedutil_la_SOURCES)
+libmemcachedinternal_libmemcachedutilinternal_la_CFLAGS= \
+ ${AM_CFLAGS} \
+ ${NO_CONVERSION} \
+ ${PTHREAD_CFLAGS} \
+ -DBUILDING_LIBMEMCACHEDINTERNAL
+libmemcachedinternal_libmemcachedutilinternal_la_CXXFLAGS= \
+ ${AM_CXXFLAGS} \
+ ${NO_CONVERSION} \
+ ${PTHREAD_CFLAGS} \
+ -DBUILDING_LIBMEMCACHEDINTERNAL
+libmemcachedinternal_libmemcachedutilinternal_la_LIBADD= libmemcachedinternal/libmemcachedinternal.la ${PTHREAD_LIBS}
+libmemcachedinternal_libmemcachedutilinternal_la_LDFLAGS= ${AM_LDFLAGS} -version-info ${MEMCACHED_UTIL_LIBRARY_VERSION}
+libmemcachedinternal_libmemcachedutilinternal_la_DEPENDENCIES= libmemcached/libmemcached.la
+
+
libtest/signal.cc \
libtest/test.cc
-libtest_libtest_la_CFLAGS= ${AM_CFLAGS} ${NO_CONVERSION} -DBUILDING_LIBTEST
-libtest_libtest_la_CXXFLAGS= ${AM_CXXFLAGS} ${NO_CONVERSION} -DBUILDING_LIBTEST
+libtest_libtest_la_CFLAGS= ${AM_CFLAGS}
+libtest_libtest_la_CFLAGS+= ${NO_CONVERSION}
+libtest_libtest_la_CFLAGS+= $(PTHREAD_CFLAGS)
+libtest_libtest_la_CFLAGS+= -DBUILDING_LIBTEST
+libtest_libtest_la_CPPFLAGS= ${AM_CPPFLAGS}
+libtest_libtest_la_CPPFLAGS+= ${NO_CONVERSION}
+libtest_libtest_la_CPPFLAGS+= $(PTHREAD_LIBS)
+libtest_libtest_la_CPPFLAGS+= -DBUILDING_LIBTEST
+libtest_libtest_la_CXXFLAGS= ${AM_CXXFLAGS}
+libtest_libtest_la_CXXFLAGS+= ${NO_CONVERSION}
+libtest_libtest_la_CXXFLAGS+= -DBUILDING_LIBTEST
+libtest_libtest_la_CXXFLAGS+= $(PTHREAD_CFLAGS)
libtest_libtest_la_LIBADD=
+libtest_libtest_la_LIBADD+= $(PTHREAD_LIBS)
LIBTEST_LDADD= libtest/libtest.la
if HAVE_LIBMEMCACHED
-if BUILD_LIBMEMCACHEDUTIL
-LIBTEST_LDADD+= libmemcached/libmemcached.la
-LIBTEST_LDADD+= libmemcached/libmemcachedutil.la
-else
-LIBTEST_LDADD+= $(libmemcached_LIBS)
-endif
+libtest_libtest_la_LIBADD+= libmemcached/libmemcached.la
+libtest_libtest_la_LIBADD+= libmemcached/libmemcachedutil.la
libtest_libtest_la_SOURCES+= libtest/memcached.cc
endif
dnl ---------------------------------------------------------------------------
AC_DEFUN([PANDORA_ENABLE_DTRACE],[
AC_ARG_ENABLE([dtrace],
- [AS_HELP_STRING([--disable-dtrace],
- [Build with support for the DTRACE. @<:@default=on@:>@])],
+ [AS_HELP_STRING([--enable-dtrace],
+ [Build with support for the DTRACE. @<:@default=no@:>@])],
[ac_cv_enable_dtrace="$enableval"],
- [ac_cv_enable_dtrace="yes"])
+ [ac_cv_enable_dtrace="no"])
AS_IF([test "$ac_cv_enable_dtrace" = "yes"],[
AC_CHECK_PROGS([DTRACE], [dtrace])
TESTS_LDADDS= \
libmemcached/libmemcached.la \
+ libmemcached/libmemcachedutil.la \
libtest/libtest.la
DEBUG_COMMAND= $(LIBTOOL) --mode=execute gdb
PAHOLE_COMMAND= $(LIBTOOL) --mode=execute pahole
-if BUILD_LIBMEMCACHEDUTIL
-TESTS_LDADDS+= libmemcached/libmemcachedutil.la
-endif
-
EXTRA_DIST+= \
tests/cpp_example.cc \
tests/output_plus.res
# Cycle should always run first
tests_cycle_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)
+tests_cycle_CXXFLAGS = $(AM_CXXFLAGS) ${PTHREAD_CFLAGS}
tests_cycle_SOURCES= tests/cycle.cc
tests_cycle_DEPENDENCIES= $(TESTS_LDADDS)
tests_cycle_LDADD= $(tests_cycle_DEPENDENCIES)
+tests_cycle_LDADD+= ${PTHREAD_LIBS}
check_PROGRAMS+= tests/cycle
noinst_PROGRAMS+= tests/cycle
+# Test internals
+tests_internals_SOURCES= tests/internals.cc
+tests_internals_SOURCES+= tests/string.cc
+tests_internals_CXXFLAGS = $(AM_CXXFLAGS) ${PTHREAD_CFLAGS}
+tests_internals_DEPENDENCIES= libmemcachedinternal/libmemcachedinternal.la libtest/libtest.la libmemcachedinternal/libmemcachedutilinternal.la
+tests_internals_LDADD= libmemcachedinternal/libmemcachedinternal.la
+tests_internals_LDADD+= ${PTHREAD_LIBS}
+tests_internals_LDADD+= libmemcachedinternal/libmemcachedutilinternal.la
+tests_internals_LDADD+= libtest/libtest.la
+check_PROGRAMS+= tests/internals
+noinst_PROGRAMS+= tests/internals
+
+tests_testapp_CXXFLAGS = $(AM_CXXFLAGS) ${PTHREAD_CFLAGS}
tests_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)
tests_testapp_SOURCES= \
tests/basic.cc \
tests/debug.cc \
tests/deprecated.cc \
tests/error_conditions.cc \
+ tests/ketama.cc \
tests/mem_functions.cc \
tests/namespace.cc \
tests/parser.cc \
tests/pool.cc \
tests/print.cc \
tests/replication.cc \
- tests/string.cc \
tests/virtual_buckets.cc
tests_testapp_SOURCES+= clients/generator.cc clients/execute.cc
-
tests_testapp_DEPENDENCIES= \
- $(BUILT_SOURCES) \
- $(TESTS_LDADDS) \
+ libmemcached/libmemcached.la \
+ libtest/libtest.la
libhashkit/libhashkit.la \
- libmemcached/libmemcachedinternal.la
-
+ libmemcached/libmemcachedutil.la
tests_testapp_LDADD= \
$(LIBSASL) \
- $(TESTS_LDADDS) \
- libhashkit/libhashkit.la \
- libmemcached/libmemcachedinternal.la
+ ${PTHREAD_LIBS} \
+ libmemcached/libmemcached.la \
+ libmemcached/libmemcachedutil.la \
+ libtest/libtest.la \
+ libhashkit/libhashkit.la
check_PROGRAMS+= tests/testapp
noinst_PROGRAMS+= tests/testapp
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached internals test
+ *
+ * Copyright (C) 2011 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
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+using namespace libtest;
+
+#include "tests/string.h"
+
+/*
+ Test cases
+*/
+test_st string_tests[] ={
+ {"string static with null", false, string_static_null },
+ {"string alloc with null", false, string_alloc_null },
+ {"string alloc with 1K", false, string_alloc_with_size },
+ {"string alloc with malloc failure", false, string_alloc_with_size_toobig },
+ {"string append", false, string_alloc_append },
+ {"string append failure (too big)", false, string_alloc_append_toobig },
+ {"string_alloc_append_multiple", false, string_alloc_append_multiple },
+ {0, 0, 0}
+};
+
+
+collection_st collection[] ={
+ {"string", 0, 0, string_tests},
+ {0, 0, 0, 0}
+};
+
+void get_world(Framework *frame)
+{
+ frame->collections= collection;
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2011 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
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include <libmemcached/memcached.h>
+#include <libmemcached/server_instance.h>
+#include <libmemcached/continuum.hpp>
+
+#include <tests/ketama.h>
+#include <tests/ketama_test_cases.h>
+
+test_return_t ketama_compatibility_libmemcached(memcached_st *)
+{
+ memcached_st *memc= memcached_create(NULL);
+ test_true(memc);
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1));
+
+ test_compare(uint64_t(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED));
+
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA));
+ test_compare(MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, memcached_behavior_get_distribution(memc));
+
+ memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
+ memcached_server_push(memc, server_pool);
+
+ /* verify that the server list was parsed okay. */
+ test_compare(8U, memcached_server_count(memc));
+ test_strcmp(server_pool[0].hostname, "10.0.1.1");
+ test_compare(in_port_t(11211), server_pool[0].port);
+ test_compare(600U, server_pool[0].weight);
+ test_strcmp(server_pool[2].hostname, "10.0.1.3");
+ test_compare(in_port_t(11211), server_pool[2].port);
+ test_compare(200U, server_pool[2].weight);
+ test_strcmp(server_pool[7].hostname, "10.0.1.8");
+ test_compare(in_port_t(11211), server_pool[7].port);
+ test_compare(100U, server_pool[7].weight);
+
+ /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets
+ * us test the boundary wraparound.
+ */
+ test_true(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->ketama.continuum[0].index);
+
+ /* verify the standard ketama set. */
+ for (uint32_t x= 0; x < 99; x++)
+ {
+ uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
+ memcached_server_instance_st instance=
+ memcached_server_instance_by_position(memc, server_idx);
+ const char *hostname = memcached_server_name(instance);
+
+ test_strcmp(hostname, ketama_test_cases[x].server);
+ }
+
+ memcached_server_list_free(server_pool);
+ memcached_free(memc);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t user_supplied_bug18(memcached_st *trash)
+{
+ memcached_return_t rc;
+ uint64_t value;
+ int x;
+ memcached_st *memc;
+
+ (void)trash;
+
+ memc= memcached_create(NULL);
+ test_true(memc);
+
+ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
+ test_compare(MEMCACHED_SUCCESS, rc);
+
+ value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
+ test_true(value == 1);
+
+ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5);
+ test_compare(MEMCACHED_SUCCESS, rc);
+
+ value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH);
+ test_true(value == MEMCACHED_HASH_MD5);
+
+ memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
+ memcached_server_push(memc, server_pool);
+
+ /* verify that the server list was parsed okay. */
+ test_true(memcached_server_count(memc) == 8);
+ test_strcmp(server_pool[0].hostname, "10.0.1.1");
+ test_true(server_pool[0].port == 11211);
+ test_true(server_pool[0].weight == 600);
+ test_strcmp(server_pool[2].hostname, "10.0.1.3");
+ test_true(server_pool[2].port == 11211);
+ test_true(server_pool[2].weight == 200);
+ test_strcmp(server_pool[7].hostname, "10.0.1.8");
+ test_true(server_pool[7].port == 11211);
+ test_true(server_pool[7].weight == 100);
+
+ /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets
+ * us test the boundary wraparound.
+ */
+ test_true(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->ketama.continuum[0].index);
+
+ /* verify the standard ketama set. */
+ for (x= 0; x < 99; x++)
+ {
+ uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
+
+ memcached_server_instance_st instance=
+ memcached_server_instance_by_position(memc, server_idx);
+
+ const char *hostname = memcached_server_name(instance);
+ test_strcmp(hostname, ketama_test_cases[x].server);
+ }
+
+ memcached_server_list_free(server_pool);
+ memcached_free(memc);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t auto_eject_hosts(memcached_st *trash)
+{
+ (void) trash;
+ memcached_server_instance_st instance;
+
+ memcached_return_t rc;
+ memcached_st *memc= memcached_create(NULL);
+ test_true(memc);
+
+ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
+ test_compare(MEMCACHED_SUCCESS, rc);
+
+ uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
+ test_true(value == 1);
+
+ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5);
+ test_compare(MEMCACHED_SUCCESS, rc);
+
+ value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH);
+ test_true(value == MEMCACHED_HASH_MD5);
+
+ /* server should be removed when in delay */
+ rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS, 1);
+ test_compare(MEMCACHED_SUCCESS, rc);
+
+ value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS);
+ test_true(value == 1);
+
+ memcached_server_st *server_pool;
+ server_pool = memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
+ memcached_server_push(memc, server_pool);
+
+ /* verify that the server list was parsed okay. */
+ test_true(memcached_server_count(memc) == 8);
+ test_strcmp(server_pool[0].hostname, "10.0.1.1");
+ test_true(server_pool[0].port == 11211);
+ test_true(server_pool[0].weight == 600);
+ test_strcmp(server_pool[2].hostname, "10.0.1.3");
+ test_true(server_pool[2].port == 11211);
+ test_true(server_pool[2].weight == 200);
+ test_strcmp(server_pool[7].hostname, "10.0.1.8");
+ test_true(server_pool[7].port == 11211);
+ test_true(server_pool[7].weight == 100);
+
+ instance= memcached_server_instance_by_position(memc, 2);
+ ((memcached_server_write_instance_st)instance)->next_retry = time(NULL) + 15;
+ memc->ketama.next_distribution_rebuild= time(NULL) - 1;
+
+ /*
+ This would not work if there were only two hosts.
+ */
+ for (size_t x= 0; x < 99; x++)
+ {
+ memcached_autoeject(memc);
+ uint32_t server_idx= memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
+ test_true(server_idx != 2);
+ }
+
+ /* and re-added when it's back. */
+ ((memcached_server_write_instance_st)instance)->next_retry = time(NULL) - 1;
+ memc->ketama.next_distribution_rebuild= time(NULL) - 1;
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION,
+ memc->distribution);
+ for (size_t x= 0; x < 99; x++)
+ {
+ uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
+ // We re-use instance from above.
+ instance=
+ memcached_server_instance_by_position(memc, server_idx);
+ const char *hostname = memcached_server_name(instance);
+ test_strcmp(hostname, ketama_test_cases[x].server);
+ }
+
+ memcached_server_list_free(server_pool);
+ memcached_free(memc);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t ketama_compatibility_spymemcached(memcached_st *)
+{
+ memcached_st *memc= memcached_create(NULL);
+ test_true(memc);
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1));
+
+ test_compare(UINT64_C(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED));
+
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY));
+ test_compare(MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY, memcached_behavior_get_distribution(memc));
+
+ memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
+ test_true(server_pool);
+ memcached_server_push(memc, server_pool);
+
+ /* verify that the server list was parsed okay. */
+ test_compare(8U, memcached_server_count(memc));
+ test_strcmp(server_pool[0].hostname, "10.0.1.1");
+ test_compare(in_port_t(11211), server_pool[0].port);
+ test_compare(600U, server_pool[0].weight);
+ test_strcmp(server_pool[2].hostname, "10.0.1.3");
+ test_compare(in_port_t(11211), server_pool[2].port);
+ test_compare(200U, server_pool[2].weight);
+ test_strcmp(server_pool[7].hostname, "10.0.1.8");
+ test_compare(in_port_t(11211), server_pool[7].port);
+ test_compare(100U, server_pool[7].weight);
+
+ /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets
+ * us test the boundary wraparound.
+ */
+ test_true(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->ketama.continuum[0].index);
+
+ /* verify the standard ketama set. */
+ for (uint32_t x= 0; x < 99; x++)
+ {
+ uint32_t server_idx= memcached_generate_hash(memc, ketama_test_cases_spy[x].key, strlen(ketama_test_cases_spy[x].key));
+
+ memcached_server_instance_st instance=
+ memcached_server_instance_by_position(memc, server_idx);
+
+ const char *hostname= memcached_server_name(instance);
+
+ test_strcmp(hostname, ketama_test_cases_spy[x].server);
+ }
+
+ memcached_server_list_free(server_pool);
+ memcached_free(memc);
+
+ return TEST_SUCCESS;
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2011 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
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+test_return_t auto_eject_hosts(memcached_st *);
+test_return_t ketama_compatibility_libmemcached(memcached_st *);
+test_return_t ketama_compatibility_spymemcached(memcached_st *);
+test_return_t user_supplied_bug18(memcached_st *);
* the COPYING file in the parent directory for full text.
*/
-#ifndef TESTS_KETAMA_TEST_CASES_H
-#define TESTS_KETAMA_TEST_CASES_H
+#pragma once
static struct {
const char *key;
};
#include "ketama_test_cases_spy.h"
-
-#endif
* the COPYING file in the parent directory for full text.
*/
-#ifndef TESTS_KETAMA_TEST_CASES_SPY_H
-#define TESTS_KETAMA_TEST_CASES_SPY_H
+#pragma once
static struct {
const char *key;
{ "\\MQ_XNT7L-", 1259349383UL, 1259509450UL, "10.0.1.5" },
{ "VD6D0]ba_\\", 3842502950UL, 3842588691UL, "10.0.1.7" },
};
-#endif
Test cases
*/
-#define BUILDING_LIBMEMCACHED
-// !NEVER use common.h, always use memcached.h in your own apps
-#include <libmemcached/common.h>
+#include <libmemcached/memcached.h>
+#include <libmemcached/is.h>
+#include <libmemcached/server_instance.h>
+
+#include <libhashkit/hashkit.h>
#include <cassert>
+#include <cerrno>
#include <memory>
+#include <pthread.h>
#include <signal.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <libtest/test.hpp>
#include "tests/deprecated.h"
#include "tests/parser.h"
+#include "tests/ketama.h"
#include "tests/pool.h"
#include "tests/namespace.h"
-#include "tests/string.h"
#include "tests/replication.h"
#include "tests/debug.h"
#include "tests/basic.h"
using namespace libtest;
-#ifdef HAVE_LIBMEMCACHEDUTIL
-#include <pthread.h>
-#include "libmemcached/memcached_util.h"
-#endif
+#include <libmemcached/memcached_util.h>
#include "hash_results.h"
return TEST_SUCCESS;
}
-#include "ketama_test_cases.h"
-static test_return_t user_supplied_bug18(memcached_st *trash)
-{
- memcached_return_t rc;
- uint64_t value;
- int x;
- memcached_st *memc;
-
- (void)trash;
-
- memc= memcached_create(NULL);
- test_true(memc);
-
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
- test_compare(MEMCACHED_SUCCESS, rc);
-
- value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
- test_true(value == 1);
-
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5);
- test_compare(MEMCACHED_SUCCESS, rc);
-
- value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH);
- test_true(value == MEMCACHED_HASH_MD5);
-
- memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
- memcached_server_push(memc, server_pool);
-
- /* verify that the server list was parsed okay. */
- test_true(memcached_server_count(memc) == 8);
- test_strcmp(server_pool[0].hostname, "10.0.1.1");
- test_true(server_pool[0].port == 11211);
- test_true(server_pool[0].weight == 600);
- test_strcmp(server_pool[2].hostname, "10.0.1.3");
- test_true(server_pool[2].port == 11211);
- test_true(server_pool[2].weight == 200);
- test_strcmp(server_pool[7].hostname, "10.0.1.8");
- test_true(server_pool[7].port == 11211);
- test_true(server_pool[7].weight == 100);
-
- /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets
- * us test the boundary wraparound.
- */
- test_true(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->ketama.continuum[0].index);
-
- /* verify the standard ketama set. */
- for (x= 0; x < 99; x++)
- {
- uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
-
- memcached_server_instance_st instance=
- memcached_server_instance_by_position(memc, server_idx);
-
- const char *hostname = memcached_server_name(instance);
- test_strcmp(hostname, ketama_test_cases[x].server);
- }
-
- memcached_server_list_free(server_pool);
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
/* Large mget() of missing keys with binary proto
*
* If many binary quiet commands (such as getq's in an mget) fill the output
return TEST_SUCCESS;
}
-static test_return_t auto_eject_hosts(memcached_st *trash)
-{
- (void) trash;
- memcached_server_instance_st instance;
-
- memcached_return_t rc;
- memcached_st *memc= memcached_create(NULL);
- test_true(memc);
-
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1);
- test_compare(MEMCACHED_SUCCESS, rc);
-
- uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
- test_true(value == 1);
-
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5);
- test_compare(MEMCACHED_SUCCESS, rc);
-
- value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH);
- test_true(value == MEMCACHED_HASH_MD5);
-
- /* server should be removed when in delay */
- rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS, 1);
- test_compare(MEMCACHED_SUCCESS, rc);
-
- value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS);
- test_true(value == 1);
-
- memcached_server_st *server_pool;
- server_pool = memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
- memcached_server_push(memc, server_pool);
-
- /* verify that the server list was parsed okay. */
- test_true(memcached_server_count(memc) == 8);
- test_strcmp(server_pool[0].hostname, "10.0.1.1");
- test_true(server_pool[0].port == 11211);
- test_true(server_pool[0].weight == 600);
- test_strcmp(server_pool[2].hostname, "10.0.1.3");
- test_true(server_pool[2].port == 11211);
- test_true(server_pool[2].weight == 200);
- test_strcmp(server_pool[7].hostname, "10.0.1.8");
- test_true(server_pool[7].port == 11211);
- test_true(server_pool[7].weight == 100);
-
- instance= memcached_server_instance_by_position(memc, 2);
- ((memcached_server_write_instance_st)instance)->next_retry = time(NULL) + 15;
- memc->ketama.next_distribution_rebuild= time(NULL) - 1;
-
- /*
- This would not work if there were only two hosts.
- */
- for (size_t x= 0; x < 99; x++)
- {
- memcached_autoeject(memc);
- uint32_t server_idx= memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
- test_true(server_idx != 2);
- }
-
- /* and re-added when it's back. */
- ((memcached_server_write_instance_st)instance)->next_retry = time(NULL) - 1;
- memc->ketama.next_distribution_rebuild= time(NULL) - 1;
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION,
- memc->distribution);
- for (size_t x= 0; x < 99; x++)
- {
- uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
- // We re-use instance from above.
- instance=
- memcached_server_instance_by_position(memc, server_idx);
- const char *hostname = memcached_server_name(instance);
- test_strcmp(hostname, ketama_test_cases[x].server);
- }
-
- memcached_server_list_free(server_pool);
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
static test_return_t output_ketama_weighted_keys(memcached_st *trash)
{
(void) trash;
return TEST_SUCCESS;
}
-
-static test_return_t ketama_compatibility_libmemcached(memcached_st *)
-{
- memcached_st *memc= memcached_create(NULL);
- test_true(memc);
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1));
-
- test_compare(uint64_t(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED));
-
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA));
- test_compare(MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, memcached_behavior_get_distribution(memc));
-
- memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
- memcached_server_push(memc, server_pool);
-
- /* verify that the server list was parsed okay. */
- test_compare(8U, memcached_server_count(memc));
- test_strcmp(server_pool[0].hostname, "10.0.1.1");
- test_compare(in_port_t(11211), server_pool[0].port);
- test_compare(600U, server_pool[0].weight);
- test_strcmp(server_pool[2].hostname, "10.0.1.3");
- test_compare(in_port_t(11211), server_pool[2].port);
- test_compare(200U, server_pool[2].weight);
- test_strcmp(server_pool[7].hostname, "10.0.1.8");
- test_compare(in_port_t(11211), server_pool[7].port);
- test_compare(100U, server_pool[7].weight);
-
- /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets
- * us test the boundary wraparound.
- */
- test_true(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->ketama.continuum[0].index);
-
- /* verify the standard ketama set. */
- for (uint32_t x= 0; x < 99; x++)
- {
- uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
- memcached_server_instance_st instance=
- memcached_server_instance_by_position(memc, server_idx);
- const char *hostname = memcached_server_name(instance);
-
- test_strcmp(hostname, ketama_test_cases[x].server);
- }
-
- memcached_server_list_free(server_pool);
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t ketama_compatibility_spymemcached(memcached_st *)
-{
- memcached_st *memc= memcached_create(NULL);
- test_true(memc);
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1));
-
- test_compare(UINT64_C(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED));
-
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set_distribution(memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY));
- test_compare(MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY, memcached_behavior_get_distribution(memc));
-
- memcached_server_st *server_pool= memcached_servers_parse("10.0.1.1:11211 600,10.0.1.2:11211 300,10.0.1.3:11211 200,10.0.1.4:11211 350,10.0.1.5:11211 1000,10.0.1.6:11211 800,10.0.1.7:11211 950,10.0.1.8:11211 100");
- test_true(server_pool);
- memcached_server_push(memc, server_pool);
-
- /* verify that the server list was parsed okay. */
- test_compare(8U, memcached_server_count(memc));
- test_strcmp(server_pool[0].hostname, "10.0.1.1");
- test_compare(in_port_t(11211), server_pool[0].port);
- test_compare(600U, server_pool[0].weight);
- test_strcmp(server_pool[2].hostname, "10.0.1.3");
- test_compare(in_port_t(11211), server_pool[2].port);
- test_compare(200U, server_pool[2].weight);
- test_strcmp(server_pool[7].hostname, "10.0.1.8");
- test_compare(in_port_t(11211), server_pool[7].port);
- test_compare(100U, server_pool[7].weight);
-
- /* VDEAAAAA hashes to fffcd1b5, after the last continuum point, and lets
- * us test the boundary wraparound.
- */
- test_true(memcached_generate_hash(memc, (char *)"VDEAAAAA", 8) == memc->ketama.continuum[0].index);
-
- /* verify the standard ketama set. */
- for (uint32_t x= 0; x < 99; x++)
- {
- uint32_t server_idx= memcached_generate_hash(memc, ketama_test_cases_spy[x].key, strlen(ketama_test_cases_spy[x].key));
-
- memcached_server_instance_st instance=
- memcached_server_instance_by_position(memc, server_idx);
-
- const char *hostname= memcached_server_name(instance);
-
- test_strcmp(hostname, ketama_test_cases_spy[x].server);
- }
-
- memcached_server_list_free(server_pool);
- memcached_free(memc);
-
- return TEST_SUCCESS;
-}
-
static test_return_t regression_bug_434484(memcached_st *memc)
{
test_return_t test_rc;
{
fprintf(stderr, "Iteration #%u: ", it);
- if(error == MEMCACHED_ERRNO)
+ if (error == MEMCACHED_ERRNO)
{
fprintf(stderr, "system error %d from %s: %s\n",
errno, what, strerror(errno));
{0, 0, 0}
};
-test_st string_tests[] ={
- {"string static with null", false, (test_callback_fn*)string_static_null },
- {"string alloc with null", false, (test_callback_fn*)string_alloc_null },
- {"string alloc with 1K", false, (test_callback_fn*)string_alloc_with_size },
- {"string alloc with malloc failure", false, (test_callback_fn*)string_alloc_with_size_toobig },
- {"string append", false, (test_callback_fn*)string_alloc_append },
- {"string append failure (too big)", false, (test_callback_fn*)string_alloc_append_toobig },
- {"string_alloc_append_multiple", false, (test_callback_fn*)string_alloc_append_multiple },
- {0, 0, (test_callback_fn*)0}
-};
-
test_st memcached_server_get_last_disconnect_tests[] ={
{"memcached_server_get_last_disconnect()", false, (test_callback_fn*)test_multiple_get_last_disconnect},
{0, 0, (test_callback_fn*)0}
{"sasl_auth", (test_callback_fn*)pre_sasl, 0, sasl_auth_tests },
{"sasl", (test_callback_fn*)pre_sasl, 0, tests },
{"version_1_2_3", (test_callback_fn*)check_for_1_2_3, 0, version_1_2_3},
- {"string", 0, 0, string_tests},
{"result", 0, 0, result_tests},
{"async", (test_callback_fn*)pre_nonblock, 0, async_tests},
{"async(BINARY)", (test_callback_fn*)pre_nonblock_binary, 0, async_tests},
memcached_st *memc_ptr;
memc_ptr= memcached(test_literal_param("--CONFIGURE-FILE=\"support/example.cnf\""));
test_true_got(memc_ptr, "memcached() failed");
- test_strcmp(SUPPORT_EXAMPLE_CNF, memcached_array_string(memc_ptr->configure.filename));
memcached_free(memc_ptr);
return TEST_SUCCESS;
// We let libmemcached/common.h define config since we are looking at
// library internals.
-#define BUILDING_LIBMEMCACHED
+#include <config.h>
-#include <libmemcached/common.h>
+#include <libmemcached/memcached.h>
+#include <libmemcached/is.h>
#include <libtest/test.hpp>
-#include <libmemcached/error.h>
#include <tests/string.h>
-test_return_t string_static_null(memcached_st *memc)
+test_return_t string_static_null(void*)
{
+ memcached_st *memc= memcached_create(NULL);
memcached_string_st string;
- memcached_string_st *string_ptr;
- string_ptr= memcached_string_create(memc, &string, 0);
- test_true(string.options.is_initialized == true);
+ memcached_string_st *string_ptr= memcached_string_create(memc, &string, 0);
+ test_true(string.options.is_initialized);
test_true(string_ptr);
/* The following two better be the same! */
- test_true(memcached_is_allocated(string_ptr) == false);
- test_true(memcached_is_allocated(&string) == false);
+ test_false(memcached_is_allocated(string_ptr));
+ test_false(memcached_is_allocated(&string));
test_true(&string == string_ptr);
- test_true(string.options.is_initialized == true);
- test_true(memcached_is_initialized(&string) == true);
+ test_true(string.options.is_initialized);
+ test_true(memcached_is_initialized(&string));
memcached_string_free(&string);
- test_true(memcached_is_initialized(&string) == false);
+ test_false(memcached_is_initialized(&string));
+
+ memcached_free(memc);
return TEST_SUCCESS;
}
-test_return_t string_alloc_null(memcached_st *memc)
+test_return_t string_alloc_null(void*)
{
- memcached_string_st *string;
+ memcached_st *memc= memcached_create(NULL);
- string= memcached_string_create(memc, NULL, 0);
+ memcached_string_st *string= memcached_string_create(memc, NULL, 0);
test_true(string);
- test_true(memcached_is_allocated(string) == true);
- test_true(memcached_is_initialized(string) == true);
+ test_true(memcached_is_allocated(string));
+ test_true(memcached_is_initialized(string));
memcached_string_free(string);
+ memcached_free(memc);
+
return TEST_SUCCESS;
}
-test_return_t string_alloc_with_size(memcached_st *memc)
+test_return_t string_alloc_with_size(void*)
{
- memcached_string_st *string;
-
- string= memcached_string_create(memc, NULL, 1024);
+ memcached_st *memc= memcached_create(NULL);
+ memcached_string_st *string= memcached_string_create(memc, NULL, 1024);
test_true(string);
- test_true(memcached_is_allocated(string) == true);
- test_true(memcached_is_initialized(string) == true);
+ test_true(memcached_is_allocated(string));
+ test_true(memcached_is_initialized(string));
memcached_string_free(string);
+ memcached_free(memc);
+
return TEST_SUCCESS;
}
-test_return_t string_alloc_with_size_toobig(memcached_st *memc)
+test_return_t string_alloc_with_size_toobig(void*)
{
- memcached_string_st *string;
-
- string= memcached_string_create(memc, NULL, SIZE_MAX);
- test_true(string == NULL);
+ memcached_st *memc= memcached_create(NULL);
+ memcached_string_st *string= memcached_string_create(memc, NULL, SIZE_MAX);
+ test_zero(string);
+ memcached_free(memc);
return TEST_SUCCESS;
}
-test_return_t string_alloc_append(memcached_st *memc)
+test_return_t string_alloc_append(void*)
{
- unsigned int x;
- char buffer[SMALL_STRING_LEN];
+ memcached_st *memc= memcached_create(NULL);
+
+ char buffer[BUFSIZ];
memcached_string_st *string;
/* Ring the bell! */
- memset(buffer, 6, SMALL_STRING_LEN);
+ memset(buffer, 6, BUFSIZ);
string= memcached_string_create(memc, NULL, 100);
test_true(string);
- test_true(memcached_is_allocated(string) == true);
- test_true(memcached_is_initialized(string) == true);
+ test_true(memcached_is_allocated(string));
+ test_true(memcached_is_initialized(string));
- for (x= 0; x < 1024; x++)
+ for (unsigned int x= 0; x < 1024; x++)
{
memcached_return_t rc;
- rc= memcached_string_append(string, buffer, SMALL_STRING_LEN);
+ rc= memcached_string_append(string, buffer, BUFSIZ);
test_true(rc == MEMCACHED_SUCCESS);
}
- test_true(memcached_is_allocated(string) == true);
+ test_true(memcached_is_allocated(string));
memcached_string_free(string);
+ memcached_free(memc);
+
return TEST_SUCCESS;
}
-test_return_t string_alloc_append_toobig(memcached_st *memc)
+test_return_t string_alloc_append_toobig(void*)
{
+ memcached_st *memc= memcached_create(NULL);
+
memcached_return_t rc;
- char buffer[SMALL_STRING_LEN];
+ char buffer[BUFSIZ];
memcached_string_st *string;
/* Ring the bell! */
string= memcached_string_create(memc, NULL, 100);
test_true(string);
- test_true(memcached_is_allocated(string) == true);
- test_true(memcached_is_initialized(string) == true);
+ test_true(memcached_is_allocated(string));
+ test_true(memcached_is_initialized(string));
for (unsigned int x= 0; x < 1024; x++)
{
- rc= memcached_string_append(string, buffer, SMALL_STRING_LEN);
+ rc= memcached_string_append(string, buffer, BUFSIZ);
test_true(rc == MEMCACHED_SUCCESS);
}
rc= memcached_string_append(string, buffer, SIZE_MAX);
test_true(rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE);
- test_true(memcached_is_allocated(string) == true);
+ test_true(memcached_is_allocated(string));
memcached_string_free(string);
+ memcached_free(memc);
+
return TEST_SUCCESS;
}
-test_return_t string_alloc_append_multiple(memcached_st *memc)
+test_return_t string_alloc_append_multiple(void*)
{
+ memcached_st *memc= memcached_create(NULL);
+
memcached_string_st *error_string= memcached_string_create(memc, NULL, 1024);
- memcached_string_append(error_string, memcached_literal_param("Error occured while parsing: "));
- memcached_string_append(error_string, memcached_string_make_from_cstr("jog the strlen() method"));
- memcached_string_append(error_string, memcached_literal_param(" ("));
+ memcached_string_append(error_string, test_literal_param("Error occured while parsing: "));
+ memcached_string_append(error_string, test_string_make_from_cstr("jog the strlen() method"));
+ memcached_string_append(error_string, test_literal_param(" ("));
- memcached_string_append(error_string, memcached_string_make_from_cstr(memcached_strerror(NULL, MEMCACHED_SUCCESS)));
- memcached_string_append(error_string, memcached_literal_param(")"));
+ memcached_string_append(error_string, test_string_make_from_cstr(memcached_strerror(NULL, MEMCACHED_SUCCESS)));
+ memcached_string_append(error_string, test_literal_param(")"));
memcached_string_free(error_string);
+ memcached_free(memc);
+
return TEST_SUCCESS;
}
#endif
LIBTEST_INTERNAL_API
-test_return_t string_static_null(memcached_st *memc);
+test_return_t string_static_null(void *);
LIBTEST_INTERNAL_API
-test_return_t string_alloc_null(memcached_st *memc);
+test_return_t string_alloc_null(void *);
LIBTEST_INTERNAL_API
-test_return_t string_alloc_with_size(memcached_st *memc);
+test_return_t string_alloc_with_size(void *);
LIBTEST_INTERNAL_API
-test_return_t string_alloc_with_size_toobig(memcached_st *memc);
+test_return_t string_alloc_with_size_toobig(void *);
LIBTEST_INTERNAL_API
-test_return_t string_alloc_append(memcached_st *memc);
+test_return_t string_alloc_append(void *);
LIBTEST_INTERNAL_API
-test_return_t string_alloc_append_toobig(memcached_st *memc);
+test_return_t string_alloc_append_toobig(void *);
LIBTEST_INTERNAL_API
-test_return_t string_alloc_append_multiple(memcached_st *memc);
+test_return_t string_alloc_append_multiple(void *);
#ifdef __cplusplus
}