clients/memcp
clients/memdump
clients/memerror
+clients/memexist
clients/memflush
clients/memparse
clients/memping
clients/memrm
clients/memslap
clients/memstat
+clients/memtouch
config.h
config.h.in
config.in
config/config.guess
config/config.sub
config/depcomp
+config/install-sh
config/ltmain.sh
config/missing
config/pandora_vc_revinfo
docs/text
example/memcached_light
libhashkit-1.0/configure.h
-libmemcached-?.??/
libmemcached-1.0/configure.h
+libmemcached-1.0/t/c_sasl_test
+libmemcached-1.0/t/c_test
+libmemcached-1.0/t/cc_test
+libmemcached-1.2/configure.h
+libmemcached-2.0/configure.h
+libmemcached-?.??/
+libmemcached/configure.h
libmemcached/dtrace_probes.h
libmemcached/generated_probes.h
libmemcached/memcached_configure.h
tests/hash_plus
tests/hashplus
tests/internals
+tests/libmemcached-1.0/internals
+tests/libmemcached-1.0/sasl
+tests/libmemcached-1.0/testapp
tests/memcapable
+tests/memcat
+tests/memcp
+tests/memdump
+tests/memerror
+tests/memexist
+tests/memflush
tests/memplus
+tests/memrm
tests/memslap
+tests/memstat
+tests/memtouch
tests/output.cmp
tests/sasl
tests/startservers
tests/var/
tmp_chroot
unittests/unittests
-tests/memerror
-tests/memcp
-tests/memdump
-tests/memflush
-tests/memrm
-tests/memstat
-tests/memcat
-clients/memexist
-tests/memexist
-libmemcached/configure.h
-clients/memtouch
-tests/memtouch
-libmemcached-1.2/configure.h
-tests/libmemcached-1.0/internals
-tests/libmemcached-1.0/sasl
-tests/libmemcached-1.0/testapp
-libmemcached-2.0/configure.h
-libmemcached-1.0/t/c_test
-libmemcached-1.0/t/c_sasl_test
-libmemcached-1.0/t/cc_test
+tests/libmemcached-1.0/testsocket
+++ /dev/null
-#!/bin/sh
-# install - install a program, script, or datafile
-
-scriptversion=2009-04-28.21; # UTC
-
-# This originates from X11R5 (mit/util/scripts/install.sh), which was
-# later released in X11R6 (xc/config/util/install.sh) with the
-# following copyright and license.
-#
-# Copyright (C) 1994 X Consortium
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to
-# deal in the Software without restriction, including without limitation the
-# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
-# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-# Except as contained in this notice, the name of the X Consortium shall not
-# be used in advertising or otherwise to promote the sale, use or other deal-
-# ings in this Software without prior written authorization from the X Consor-
-# tium.
-#
-#
-# FSF changes to this file are in the public domain.
-#
-# Calling this script install-sh is preferred over install.sh, to prevent
-# `make' implicit rules from creating a file called install from it
-# when there is no Makefile.
-#
-# This script is compatible with the BSD install script, but was written
-# from scratch.
-
-nl='
-'
-IFS=" "" $nl"
-
-# set DOITPROG to echo to test this script
-
-# Don't use :- since 4.3BSD and earlier shells don't like it.
-doit=${DOITPROG-}
-if test -z "$doit"; then
- doit_exec=exec
-else
- doit_exec=$doit
-fi
-
-# Put in absolute file names if you don't have them in your path;
-# or use environment vars.
-
-chgrpprog=${CHGRPPROG-chgrp}
-chmodprog=${CHMODPROG-chmod}
-chownprog=${CHOWNPROG-chown}
-cmpprog=${CMPPROG-cmp}
-cpprog=${CPPROG-cp}
-mkdirprog=${MKDIRPROG-mkdir}
-mvprog=${MVPROG-mv}
-rmprog=${RMPROG-rm}
-stripprog=${STRIPPROG-strip}
-
-posix_glob='?'
-initialize_posix_glob='
- test "$posix_glob" != "?" || {
- if (set -f) 2>/dev/null; then
- posix_glob=
- else
- posix_glob=:
- fi
- }
-'
-
-posix_mkdir=
-
-# Desired mode of installed file.
-mode=0755
-
-chgrpcmd=
-chmodcmd=$chmodprog
-chowncmd=
-mvcmd=$mvprog
-rmcmd="$rmprog -f"
-stripcmd=
-
-src=
-dst=
-dir_arg=
-dst_arg=
-
-copy_on_change=false
-no_target_directory=
-
-usage="\
-Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
- or: $0 [OPTION]... SRCFILES... DIRECTORY
- or: $0 [OPTION]... -t DIRECTORY SRCFILES...
- or: $0 [OPTION]... -d DIRECTORIES...
-
-In the 1st form, copy SRCFILE to DSTFILE.
-In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
-In the 4th, create DIRECTORIES.
-
-Options:
- --help display this help and exit.
- --version display version info and exit.
-
- -c (ignored)
- -C install only if different (preserve the last data modification time)
- -d create directories instead of installing files.
- -g GROUP $chgrpprog installed files to GROUP.
- -m MODE $chmodprog installed files to MODE.
- -o USER $chownprog installed files to USER.
- -s $stripprog installed files.
- -t DIRECTORY install into DIRECTORY.
- -T report an error if DSTFILE is a directory.
-
-Environment variables override the default commands:
- CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
- RMPROG STRIPPROG
-"
-
-while test $# -ne 0; do
- case $1 in
- -c) ;;
-
- -C) copy_on_change=true;;
-
- -d) dir_arg=true;;
-
- -g) chgrpcmd="$chgrpprog $2"
- shift;;
-
- --help) echo "$usage"; exit $?;;
-
- -m) mode=$2
- case $mode in
- *' '* | *' '* | *'
-'* | *'*'* | *'?'* | *'['*)
- echo "$0: invalid mode: $mode" >&2
- exit 1;;
- esac
- shift;;
-
- -o) chowncmd="$chownprog $2"
- shift;;
-
- -s) stripcmd=$stripprog;;
-
- -t) dst_arg=$2
- shift;;
-
- -T) no_target_directory=true;;
-
- --version) echo "$0 $scriptversion"; exit $?;;
-
- --) shift
- break;;
-
- -*) echo "$0: invalid option: $1" >&2
- exit 1;;
-
- *) break;;
- esac
- shift
-done
-
-if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
- # When -d is used, all remaining arguments are directories to create.
- # When -t is used, the destination is already specified.
- # Otherwise, the last argument is the destination. Remove it from $@.
- for arg
- do
- if test -n "$dst_arg"; then
- # $@ is not empty: it contains at least $arg.
- set fnord "$@" "$dst_arg"
- shift # fnord
- fi
- shift # arg
- dst_arg=$arg
- done
-fi
-
-if test $# -eq 0; then
- if test -z "$dir_arg"; then
- echo "$0: no input file specified." >&2
- exit 1
- fi
- # It's OK to call `install-sh -d' without argument.
- # This can happen when creating conditional directories.
- exit 0
-fi
-
-if test -z "$dir_arg"; then
- trap '(exit $?); exit' 1 2 13 15
-
- # Set umask so as not to create temps with too-generous modes.
- # However, 'strip' requires both read and write access to temps.
- case $mode in
- # Optimize common cases.
- *644) cp_umask=133;;
- *755) cp_umask=22;;
-
- *[0-7])
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw='% 200'
- fi
- cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
- *)
- if test -z "$stripcmd"; then
- u_plus_rw=
- else
- u_plus_rw=,u+rw
- fi
- cp_umask=$mode$u_plus_rw;;
- esac
-fi
-
-for src
-do
- # Protect names starting with `-'.
- case $src in
- -*) src=./$src;;
- esac
-
- if test -n "$dir_arg"; then
- dst=$src
- dstdir=$dst
- test -d "$dstdir"
- dstdir_status=$?
- else
-
- # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
- # might cause directories to be created, which would be especially bad
- # if $src (and thus $dsttmp) contains '*'.
- if test ! -f "$src" && test ! -d "$src"; then
- echo "$0: $src does not exist." >&2
- exit 1
- fi
-
- if test -z "$dst_arg"; then
- echo "$0: no destination specified." >&2
- exit 1
- fi
-
- dst=$dst_arg
- # Protect names starting with `-'.
- case $dst in
- -*) dst=./$dst;;
- esac
-
- # If destination is a directory, append the input filename; won't work
- # if double slashes aren't ignored.
- if test -d "$dst"; then
- if test -n "$no_target_directory"; then
- echo "$0: $dst_arg: Is a directory" >&2
- exit 1
- fi
- dstdir=$dst
- dst=$dstdir/`basename "$src"`
- dstdir_status=0
- else
- # Prefer dirname, but fall back on a substitute if dirname fails.
- dstdir=`
- (dirname "$dst") 2>/dev/null ||
- expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$dst" : 'X\(//\)[^/]' \| \
- X"$dst" : 'X\(//\)$' \| \
- X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
- echo X"$dst" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
- s//\1/
- q
- }
- /^X\(\/\/\)[^/].*/{
- s//\1/
- q
- }
- /^X\(\/\/\)$/{
- s//\1/
- q
- }
- /^X\(\/\).*/{
- s//\1/
- q
- }
- s/.*/./; q'
- `
-
- test -d "$dstdir"
- dstdir_status=$?
- fi
- fi
-
- obsolete_mkdir_used=false
-
- if test $dstdir_status != 0; then
- case $posix_mkdir in
- '')
- # Create intermediate dirs using mode 755 as modified by the umask.
- # This is like FreeBSD 'install' as of 1997-10-28.
- umask=`umask`
- case $stripcmd.$umask in
- # Optimize common cases.
- *[2367][2367]) mkdir_umask=$umask;;
- .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
- *[0-7])
- mkdir_umask=`expr $umask + 22 \
- - $umask % 100 % 40 + $umask % 20 \
- - $umask % 10 % 4 + $umask % 2
- `;;
- *) mkdir_umask=$umask,go-w;;
- esac
-
- # With -d, create the new directory with the user-specified mode.
- # Otherwise, rely on $mkdir_umask.
- if test -n "$dir_arg"; then
- mkdir_mode=-m$mode
- else
- mkdir_mode=
- fi
-
- posix_mkdir=false
- case $umask in
- *[123567][0-7][0-7])
- # POSIX mkdir -p sets u+wx bits regardless of umask, which
- # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
- ;;
- *)
- tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
- trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
-
- if (umask $mkdir_umask &&
- exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
- then
- if test -z "$dir_arg" || {
- # Check for POSIX incompatibilities with -m.
- # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
- # other-writeable bit of parent directory when it shouldn't.
- # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
- ls_ld_tmpdir=`ls -ld "$tmpdir"`
- case $ls_ld_tmpdir in
- d????-?r-*) different_mode=700;;
- d????-?--*) different_mode=755;;
- *) false;;
- esac &&
- $mkdirprog -m$different_mode -p -- "$tmpdir" && {
- ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
- test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
- }
- }
- then posix_mkdir=:
- fi
- rmdir "$tmpdir/d" "$tmpdir"
- else
- # Remove any dirs left behind by ancient mkdir implementations.
- rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
- fi
- trap '' 0;;
- esac;;
- esac
-
- if
- $posix_mkdir && (
- umask $mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
- )
- then :
- else
-
- # The umask is ridiculous, or mkdir does not conform to POSIX,
- # or it failed possibly due to a race condition. Create the
- # directory the slow way, step by step, checking for races as we go.
-
- case $dstdir in
- /*) prefix='/';;
- -*) prefix='./';;
- *) prefix='';;
- esac
-
- eval "$initialize_posix_glob"
-
- oIFS=$IFS
- IFS=/
- $posix_glob set -f
- set fnord $dstdir
- shift
- $posix_glob set +f
- IFS=$oIFS
-
- prefixes=
-
- for d
- do
- test -z "$d" && continue
-
- prefix=$prefix$d
- if test -d "$prefix"; then
- prefixes=
- else
- if $posix_mkdir; then
- (umask=$mkdir_umask &&
- $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
- # Don't fail if two instances are running concurrently.
- test -d "$prefix" || exit 1
- else
- case $prefix in
- *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
- *) qprefix=$prefix;;
- esac
- prefixes="$prefixes '$qprefix'"
- fi
- fi
- prefix=$prefix/
- done
-
- if test -n "$prefixes"; then
- # Don't fail if two instances are running concurrently.
- (umask $mkdir_umask &&
- eval "\$doit_exec \$mkdirprog $prefixes") ||
- test -d "$dstdir" || exit 1
- obsolete_mkdir_used=true
- fi
- fi
- fi
-
- if test -n "$dir_arg"; then
- { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
- { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
- { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
- test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
- else
-
- # Make a couple of temp file names in the proper directory.
- dsttmp=$dstdir/_inst.$$_
- rmtmp=$dstdir/_rm.$$_
-
- # Trap to clean up those temp files at exit.
- trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
-
- # Copy the file name to the temp name.
- (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
-
- # and set any options; do chmod last to preserve setuid bits.
- #
- # If any of these fail, we abort the whole thing. If we want to
- # ignore errors from any of these, just make sure not to ignore
- # errors from the above "$doit $cpprog $src $dsttmp" command.
- #
- { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
- { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
- { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
- { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
-
- # If -C, don't bother to copy if it wouldn't change the file.
- if $copy_on_change &&
- old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
- new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
-
- eval "$initialize_posix_glob" &&
- $posix_glob set -f &&
- set X $old && old=:$2:$4:$5:$6 &&
- set X $new && new=:$2:$4:$5:$6 &&
- $posix_glob set +f &&
-
- test "$old" = "$new" &&
- $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
- then
- rm -f "$dsttmp"
- else
- # Rename the file to the real destination.
- $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
-
- # The rename failed, perhaps because mv can't rename something else
- # to itself, or perhaps because mv is so ancient that it does not
- # support -f.
- {
- # Now remove or move aside any old file at destination location.
- # We try this two ways since rm can't unlink itself on some
- # systems and the destination file might be busy for other
- # reasons. In this case, the final cleanup might fail but the new
- # file should still install successfully.
- {
- test ! -f "$dst" ||
- $doit $rmcmd -f "$dst" 2>/dev/null ||
- { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
- { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
- } ||
- { echo "$0: cannot unlink or rename $dst" >&2
- (exit 1); exit 1
- }
- } &&
-
- # Now rename the file to the real destination.
- $doit $mvcmd "$dsttmp" "$dst"
- }
- fi || exit 1
-
- trap '' 0
- fi
-done
-
-# Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
-# End:
AX_CXX_GCC_ABI_DEMANGLE
+AX_CHECK_LIBRARY([LIBUUID], [uuid/uuid.h], [uuid],
+ [
+ LIBUUID_LDFLAGS="-luuid"
+ ],
+ [
+ AC_DEFINE([HAVE_LIBUUID], [ 0 ], [Have libuuid])
+ ])
+
AC_CHECK_LIB([rt], [clock_gettime],
[
RT_LIB="-lrt"
return NULL;
}
- size_t dummy_length;
- uint32_t dummy_flags;
- memcached_return_t dummy_error;
-
- char *dummy_value= memcached_fetch(ptr, NULL, NULL,
- &dummy_length, &dummy_flags,
- &dummy_error);
- 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;
}
#include <libtest/common.h>
-static char global_socket[1024];
+static char global_socket[1024]= { 0 };
namespace libtest {
const char *default_socket()
{
- assert(global_socket[0]);
+ if (global_socket[0] == 0)
+ {
+ return NULL;
+ }
+
return global_socket;
}
#define test_literal_param_size util_literal_param_size
#define test_string_make_from_cstr util_string_make_from_cstr
#define test_array_length util_array_length
+
+namespace libtest {
+typedef std::vector<char> vchar_t;
+typedef std::vector<char*> vchar_ptr_t;
+}
noinst_HEADERS+= \
tests/exist.h \
tests/hash_results.h \
- tests/libmemcached_world.h
+ tests/libmemcached_world.h \
+ tests/libmemcached_world_socket.h
# Cycle should always run first
tests_cycle_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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.
+ *
+ */
+
+#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include "tests/basic.h"
+#include "tests/debug.h"
+#include "tests/deprecated.h"
+#include "tests/error_conditions.h"
+#include "tests/exist.h"
+#include "tests/ketama.h"
+#include "tests/namespace.h"
+#include "tests/parser.h"
+#include "tests/libmemcached-1.0/dump.h"
+#include "tests/libmemcached-1.0/generate.h"
+#include "tests/libmemcached-1.0/haldenbrand.h"
+#include "tests/libmemcached-1.0/stat.h"
+#include "tests/touch.h"
+#include "tests/callbacks.h"
+#include "tests/pool.h"
+#include "tests/print.h"
+#include "tests/replication.h"
+#include "tests/server_add.h"
+#include "tests/virtual_buckets.h"
+
+#include "tests/libmemcached-1.0/setup_and_teardowns.h"
+
+
+#include "tests/libmemcached-1.0/mem_functions.h"
+
+/* Collections we are running */
+#include "tests/libmemcached-1.0/all_tests.h"
+
+#include "tests/libmemcached_world.h"
+
+void get_world(Framework *world)
+{
+ world->collections= collection;
+
+ world->_create= (test_callback_create_fn*)world_create;
+ world->_destroy= (test_callback_destroy_fn*)world_destroy;
+
+ world->item._startup= (test_callback_fn*)world_test_startup;
+ world->item.set_pre((test_callback_fn*)world_pre_run);
+ world->item.set_flush((test_callback_fn*)world_flush);
+ world->item.set_post((test_callback_fn*)world_post_run);
+ world->_on_error= (test_callback_error_fn*)world_on_error;
+
+ world->collection_startup= (test_callback_fn*)world_container_startup;
+ world->collection_shutdown= (test_callback_fn*)world_container_shutdown;
+
+ world->set_runner(&defualt_libmemcached_runner);
+
+ world->set_socket();
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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
+
+
+/* Clean the server before beginning testing */
+test_st tests[] ={
+ {"util_version", true, (test_callback_fn*)util_version_test },
+ {"flush", false, (test_callback_fn*)flush_test },
+ {"init", false, (test_callback_fn*)init_test },
+ {"allocation", false, (test_callback_fn*)allocation_test },
+ {"server_list_null_test", false, (test_callback_fn*)server_list_null_test},
+ {"server_unsort", false, (test_callback_fn*)server_unsort_test},
+ {"server_sort", false, (test_callback_fn*)server_sort_test},
+ {"server_sort2", false, (test_callback_fn*)server_sort2_test},
+ {"memcached_server_remove", false, (test_callback_fn*)memcached_server_remove_test},
+ {"clone_test", false, (test_callback_fn*)clone_test },
+ {"connection_test", false, (test_callback_fn*)connection_test},
+ {"callback_test", false, (test_callback_fn*)callback_test},
+ {"userdata_test", false, (test_callback_fn*)userdata_test},
+ {"memcached_set()", false, (test_callback_fn*)set_test },
+ {"memcached_set() 2", false, (test_callback_fn*)set_test2 },
+ {"memcached_set() 3", false, (test_callback_fn*)set_test3 },
+ {"add", true, (test_callback_fn*)add_test },
+ {"memcached_fetch_result(MEMCACHED_NOTFOUND)", true, (test_callback_fn*)memcached_fetch_result_NOT_FOUND },
+ {"replace", true, (test_callback_fn*)replace_test },
+ {"delete", true, (test_callback_fn*)delete_test },
+ {"get", true, (test_callback_fn*)get_test },
+ {"get2", false, (test_callback_fn*)get_test2 },
+ {"get3", false, (test_callback_fn*)get_test3 },
+ {"get4", false, (test_callback_fn*)get_test4 },
+ {"partial mget", false, (test_callback_fn*)get_test5 },
+ {"stats_servername", false, (test_callback_fn*)stats_servername_test },
+ {"increment", false, (test_callback_fn*)increment_test },
+ {"increment_with_initial", true, (test_callback_fn*)increment_with_initial_test },
+ {"decrement", false, (test_callback_fn*)decrement_test },
+ {"decrement_with_initial", true, (test_callback_fn*)decrement_with_initial_test },
+ {"increment_by_key", false, (test_callback_fn*)increment_by_key_test },
+ {"increment_with_initial_by_key", true, (test_callback_fn*)increment_with_initial_by_key_test },
+ {"decrement_by_key", false, (test_callback_fn*)decrement_by_key_test },
+ {"decrement_with_initial_by_key", true, (test_callback_fn*)decrement_with_initial_by_key_test },
+ {"binary_increment_with_prefix", true, (test_callback_fn*)binary_increment_with_prefix_test },
+ {"quit", false, (test_callback_fn*)quit_test },
+ {"mget", true, (test_callback_fn*)mget_test },
+ {"mget_result", true, (test_callback_fn*)mget_result_test },
+ {"mget_result_alloc", true, (test_callback_fn*)mget_result_alloc_test },
+ {"mget_result_function", true, (test_callback_fn*)mget_result_function },
+ {"mget_execute", true, (test_callback_fn*)mget_execute },
+ {"mget_end", false, (test_callback_fn*)mget_end },
+ {"get_stats", false, (test_callback_fn*)get_stats },
+ {"add_host_test", false, (test_callback_fn*)add_host_test },
+ {"add_host_test_1", false, (test_callback_fn*)add_host_test1 },
+ {"get_stats_keys", false, (test_callback_fn*)get_stats_keys },
+ {"version_string_test", true, (test_callback_fn*)version_string_test},
+ {"memcached_mget() mixed memcached_get()", true, (test_callback_fn*)memcached_mget_mixed_memcached_get_TEST},
+ {"bad_key", true, (test_callback_fn*)bad_key_test },
+ {"memcached_server_cursor", true, (test_callback_fn*)memcached_server_cursor_test },
+ {"read_through", true, (test_callback_fn*)read_through },
+ {"delete_through", true, (test_callback_fn*)test_MEMCACHED_CALLBACK_DELETE_TRIGGER },
+ {"noreply", true, (test_callback_fn*)noreply_test},
+ {"analyzer", true, (test_callback_fn*)analyzer_test},
+ {"memcached_pool_st", true, (test_callback_fn*)connection_pool_test },
+ {"memcached_pool_st #2", true, (test_callback_fn*)connection_pool2_test },
+#if 0
+ {"memcached_pool_st #3", true, (test_callback_fn*)connection_pool3_test },
+#endif
+ {"memcached_pool_test", true, (test_callback_fn*)memcached_pool_test },
+ {"test_get_last_disconnect", true, (test_callback_fn*)test_get_last_disconnect},
+ {"verbosity", true, (test_callback_fn*)test_verbosity},
+ {"memcached_stat_execute", true, (test_callback_fn*)memcached_stat_execute_test},
+ {"memcached_exist(MEMCACHED_NOTFOUND)", true, (test_callback_fn*)memcached_exist_NOTFOUND },
+ {"memcached_exist(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_exist_SUCCESS },
+ {"memcached_exist_by_key(MEMCACHED_NOTFOUND)", true, (test_callback_fn*)memcached_exist_by_key_NOTFOUND },
+ {"memcached_exist_by_key(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_exist_by_key_SUCCESS },
+ {"memcached_touch", 0, (test_callback_fn*)test_memcached_touch},
+ {"memcached_touch_with_prefix", 0, (test_callback_fn*)test_memcached_touch_by_key},
+#if 0
+ {"memcached_dump() no data", true, (test_callback_fn*)memcached_dump_TEST },
+#endif
+ {"memcached_dump() with data", true, (test_callback_fn*)memcached_dump_TEST2 },
+ {0, 0, 0}
+};
+
+test_st touch_tests[] ={
+ {"memcached_touch", 0, (test_callback_fn*)test_memcached_touch},
+ {"memcached_touch_with_prefix", 0, (test_callback_fn*)test_memcached_touch_by_key},
+ {0, 0, 0}
+};
+
+test_st memcached_stat_tests[] ={
+ {"memcached_stat() INVALID ARG", 0, (test_callback_fn*)memcached_stat_TEST},
+ {"memcached_stat()", 0, (test_callback_fn*)memcached_stat_TEST2},
+ {0, 0, 0}
+};
+
+test_st behavior_tests[] ={
+ {"libmemcached_string_behavior()", false, (test_callback_fn*)libmemcached_string_behavior_test},
+ {"libmemcached_string_distribution()", false, (test_callback_fn*)libmemcached_string_distribution_test},
+ {"behavior_test", false, (test_callback_fn*)behavior_test},
+ {"MEMCACHED_BEHAVIOR_CORK", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_CORK_test},
+ {"MEMCACHED_BEHAVIOR_TCP_KEEPALIVE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test},
+ {"MEMCACHED_BEHAVIOR_TCP_KEEPIDLE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test},
+ {"MEMCACHED_BEHAVIOR_POLL_TIMEOUT", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test},
+ {"MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY", false, (test_callback_fn*)test_MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY},
+ {0, 0, 0}
+};
+
+test_st libmemcachedutil_tests[] ={
+ {"libmemcached_util_ping()", true, (test_callback_fn*)ping_test },
+ {"libmemcached_util_getpid()", true, (test_callback_fn*)getpid_test },
+ {"libmemcached_util_getpid(MEMCACHED_CONNECTION_FAILURE)", true, (test_callback_fn*)getpid_connection_failure_test },
+ {0, 0, 0}
+};
+
+test_st basic_tests[] ={
+ {"init", true, (test_callback_fn*)basic_init_test},
+ {"clone", true, (test_callback_fn*)basic_clone_test},
+ {"reset", true, (test_callback_fn*)basic_reset_stack_test},
+ {"reset heap", true, (test_callback_fn*)basic_reset_heap_test},
+ {"reset stack clone", true, (test_callback_fn*)basic_reset_stack_clone_test},
+ {"reset heap clone", true, (test_callback_fn*)basic_reset_heap_clone_test},
+ {"memcached_return_t", false, (test_callback_fn*)memcached_return_t_TEST },
+ {0, 0, 0}
+};
+
+test_st regression_binary_vs_block[] ={
+ {"block add", true, (test_callback_fn*)block_add_regression},
+ {"binary add", true, (test_callback_fn*)binary_add_regression},
+ {0, 0, 0}
+};
+
+test_st async_tests[] ={
+ {"add", true, (test_callback_fn*)add_wrapper },
+ {0, 0, 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}
+};
+
+
+test_st result_tests[] ={
+ {"result static", false, (test_callback_fn*)result_static},
+ {"result alloc", false, (test_callback_fn*)result_alloc},
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st version_1_2_3[] ={
+ {"append", false, (test_callback_fn*)append_test },
+ {"prepend", false, (test_callback_fn*)prepend_test },
+ {"cas", false, (test_callback_fn*)cas_test },
+ {"cas2", false, (test_callback_fn*)cas2_test },
+ {"append_binary", false, (test_callback_fn*)append_binary_test },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st haldenbrand_TESTS[] ={
+ {"memcached_set", false, (test_callback_fn*)haldenbrand_TEST1 },
+ {"memcached_get()", false, (test_callback_fn*)haldenbrand_TEST2 },
+ {"memcached_mget()", false, (test_callback_fn*)haldenbrand_TEST3 },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st user_tests[] ={
+ {"user_supplied_bug4", true, (test_callback_fn*)user_supplied_bug4 },
+ {"user_supplied_bug5", true, (test_callback_fn*)user_supplied_bug5 },
+ {"user_supplied_bug6", true, (test_callback_fn*)user_supplied_bug6 },
+ {"user_supplied_bug7", true, (test_callback_fn*)user_supplied_bug7 },
+ {"user_supplied_bug8", true, (test_callback_fn*)user_supplied_bug8 },
+ {"user_supplied_bug9", true, (test_callback_fn*)user_supplied_bug9 },
+ {"user_supplied_bug10", true, (test_callback_fn*)user_supplied_bug10 },
+ {"user_supplied_bug11", true, (test_callback_fn*)user_supplied_bug11 },
+ {"user_supplied_bug12", true, (test_callback_fn*)user_supplied_bug12 },
+ {"user_supplied_bug13", true, (test_callback_fn*)user_supplied_bug13 },
+ {"user_supplied_bug14", true, (test_callback_fn*)user_supplied_bug14 },
+ {"user_supplied_bug15", true, (test_callback_fn*)user_supplied_bug15 },
+ {"user_supplied_bug16", true, (test_callback_fn*)user_supplied_bug16 },
+#if !defined(__sun) && !defined(__OpenBSD__)
+ /*
+ ** It seems to be something weird with the character sets..
+ ** value_fetch is unable to parse the value line (iscntrl "fails"), so I
+ ** guess I need to find out how this is supposed to work.. Perhaps I need
+ ** to run the test in a specific locale (I tried zh_CN.UTF-8 without success,
+ ** so just disable the code for now...).
+ */
+ {"user_supplied_bug17", true, (test_callback_fn*)user_supplied_bug17 },
+#endif
+ {"user_supplied_bug18", true, (test_callback_fn*)user_supplied_bug18 },
+ {"user_supplied_bug19", true, (test_callback_fn*)user_supplied_bug19 },
+ {"user_supplied_bug20", true, (test_callback_fn*)user_supplied_bug20 },
+ {"user_supplied_bug21", true, (test_callback_fn*)user_supplied_bug21 },
+ {"wrong_failure_counter_test", true, (test_callback_fn*)wrong_failure_counter_test},
+ {"wrong_failure_counter_two_test", true, (test_callback_fn*)wrong_failure_counter_two_test},
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st replication_tests[]= {
+ {"set", true, (test_callback_fn*)replication_set_test },
+ {"get", false, (test_callback_fn*)replication_get_test },
+ {"mget", false, (test_callback_fn*)replication_mget_test },
+ {"delete", true, (test_callback_fn*)replication_delete_test },
+ {"rand_mget", false, (test_callback_fn*)replication_randomize_mget_test },
+ {"miss", false, (test_callback_fn*)replication_miss_test },
+ {"fail", false, (test_callback_fn*)replication_randomize_mget_fail_test },
+ {0, 0, (test_callback_fn*)0}
+};
+
+/*
+ * The following test suite is used to verify that we don't introduce
+ * regression bugs. If you want more information about the bug / test,
+ * you should look in the bug report at
+ * http://bugs.launchpad.net/libmemcached
+ */
+test_st regression_tests[]= {
+ {"lp:434484", true, (test_callback_fn*)regression_bug_434484 },
+ {"lp:434843", true, (test_callback_fn*)regression_bug_434843 },
+ {"lp:434843-buffered", true, (test_callback_fn*)regression_bug_434843_buffered },
+ {"lp:421108", true, (test_callback_fn*)regression_bug_421108 },
+ {"lp:442914", true, (test_callback_fn*)regression_bug_442914 },
+ {"lp:447342", true, (test_callback_fn*)regression_bug_447342 },
+ {"lp:463297", true, (test_callback_fn*)regression_bug_463297 },
+ {"lp:490486", true, (test_callback_fn*)regression_bug_490486 },
+ {"lp:583031", true, (test_callback_fn*)regression_bug_583031 },
+ {"lp:?", true, (test_callback_fn*)regression_bug_ },
+ {"lp:728286", true, (test_callback_fn*)regression_bug_728286 },
+ {"lp:581030", true, (test_callback_fn*)regression_bug_581030 },
+ {"lp:71231153 connect()", true, (test_callback_fn*)regression_bug_71231153_connect },
+ {"lp:71231153 poll()", true, (test_callback_fn*)regression_bug_71231153_poll },
+ {"lp:655423", true, (test_callback_fn*)regression_bug_655423 },
+ {"lp:490520", true, (test_callback_fn*)regression_bug_490520 },
+ {"lp:854604", true, (test_callback_fn*)regression_bug_854604 },
+ {0, false, (test_callback_fn*)0}
+};
+
+test_st ketama_compatibility[]= {
+ {"libmemcached", true, (test_callback_fn*)ketama_compatibility_libmemcached },
+ {"spymemcached", true, (test_callback_fn*)ketama_compatibility_spymemcached },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st generate_tests[] ={
+ {"generate_pairs", true, (test_callback_fn*)generate_pairs },
+ {"generate_data", true, (test_callback_fn*)generate_data },
+ {"get_read", false, (test_callback_fn*)get_read },
+ {"delete_generate", false, (test_callback_fn*)delete_generate },
+ {"generate_buffer_data", true, (test_callback_fn*)generate_buffer_data },
+ {"delete_buffer", false, (test_callback_fn*)delete_buffer_generate},
+ {"generate_data", true, (test_callback_fn*)generate_data },
+ {"mget_read", false, (test_callback_fn*)mget_read },
+ {"mget_read_result", false, (test_callback_fn*)mget_read_result },
+ {"memcached_fetch_result() use internal result", false, (test_callback_fn*)mget_read_internal_result },
+ {"memcached_fetch_result() partial read", false, (test_callback_fn*)mget_read_partial_result },
+ {"mget_read_function", false, (test_callback_fn*)mget_read_function },
+ {"cleanup", true, (test_callback_fn*)cleanup_pairs },
+ {"generate_large_pairs", true, (test_callback_fn*)generate_large_pairs },
+ {"generate_data", true, (test_callback_fn*)generate_data },
+ {"generate_buffer_data", true, (test_callback_fn*)generate_buffer_data },
+ {"cleanup", true, (test_callback_fn*)cleanup_pairs },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st consistent_tests[] ={
+ {"generate_pairs", true, (test_callback_fn*)generate_pairs },
+ {"generate_data", true, (test_callback_fn*)generate_data },
+ {"get_read", 0, (test_callback_fn*)get_read_count },
+ {"cleanup", true, (test_callback_fn*)cleanup_pairs },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st consistent_weighted_tests[] ={
+ {"generate_pairs", true, (test_callback_fn*)generate_pairs },
+ {"generate_data", true, (test_callback_fn*)generate_data_with_stats },
+ {"get_read", false, (test_callback_fn*)get_read_count },
+ {"cleanup", true, (test_callback_fn*)cleanup_pairs },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st hsieh_availability[] ={
+ {"hsieh_avaibility_test", false, (test_callback_fn*)hsieh_avaibility_test},
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st murmur_availability[] ={
+ {"murmur_avaibility_test", false, (test_callback_fn*)murmur_avaibility_test},
+ {0, 0, (test_callback_fn*)0}
+};
+
+#if 0
+test_st hash_sanity[] ={
+ {"hash sanity", 0, (test_callback_fn*)hash_sanity_test},
+ {0, 0, (test_callback_fn*)0}
+};
+#endif
+
+test_st ketama_auto_eject_hosts[] ={
+ {"auto_eject_hosts", true, (test_callback_fn*)auto_eject_hosts },
+ {"output_ketama_weighted_keys", true, (test_callback_fn*)output_ketama_weighted_keys },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st hash_tests[] ={
+ {"one_at_a_time_run", false, (test_callback_fn*)one_at_a_time_run },
+ {"md5", false, (test_callback_fn*)md5_run },
+ {"crc", false, (test_callback_fn*)crc_run },
+ {"fnv1_64", false, (test_callback_fn*)fnv1_64_run },
+ {"fnv1a_64", false, (test_callback_fn*)fnv1a_64_run },
+ {"fnv1_32", false, (test_callback_fn*)fnv1_32_run },
+ {"fnv1a_32", false, (test_callback_fn*)fnv1a_32_run },
+ {"hsieh", false, (test_callback_fn*)hsieh_run },
+ {"murmur", false, (test_callback_fn*)murmur_run },
+ {"jenkis", false, (test_callback_fn*)jenkins_run },
+ {"memcached_get_hashkit", false, (test_callback_fn*)memcached_get_hashkit_test },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st error_conditions[] ={
+ {"memcached_get(MEMCACHED_ERRNO)", false, (test_callback_fn*)memcached_get_MEMCACHED_ERRNO },
+ {"memcached_get(MEMCACHED_NOTFOUND)", false, (test_callback_fn*)memcached_get_MEMCACHED_NOTFOUND },
+ {"memcached_get_by_key(MEMCACHED_ERRNO)", false, (test_callback_fn*)memcached_get_by_key_MEMCACHED_ERRNO },
+ {"memcached_get_by_key(MEMCACHED_NOTFOUND)", false, (test_callback_fn*)memcached_get_by_key_MEMCACHED_NOTFOUND },
+ {"memcached_get_by_key(MEMCACHED_NOTFOUND)", false, (test_callback_fn*)memcached_get_by_key_MEMCACHED_NOTFOUND },
+ {"memcached_increment(MEMCACHED_NO_SERVERS)", false, (test_callback_fn*)memcached_increment_MEMCACHED_NO_SERVERS },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st parser_tests[] ={
+ {"behavior", false, (test_callback_fn*)behavior_parser_test },
+ {"boolean_options", false, (test_callback_fn*)parser_boolean_options_test },
+ {"configure_file", false, (test_callback_fn*)memcached_create_with_options_with_filename },
+ {"distribtions", false, (test_callback_fn*)parser_distribution_test },
+ {"hash", false, (test_callback_fn*)parser_hash_test },
+ {"libmemcached_check_configuration", false, (test_callback_fn*)libmemcached_check_configuration_test },
+ {"libmemcached_check_configuration_with_filename", false, (test_callback_fn*)libmemcached_check_configuration_with_filename_test },
+ {"number_options", false, (test_callback_fn*)parser_number_options_test },
+ {"randomly generated options", false, (test_callback_fn*)random_statement_build_test },
+ {"namespace", false, (test_callback_fn*)parser_key_prefix_test },
+ {"server", false, (test_callback_fn*)server_test },
+ {"bad server strings", false, (test_callback_fn*)servers_bad_test },
+ {"server with weights", false, (test_callback_fn*)server_with_weight_test },
+ {"parsing servername, port, and weight", false, (test_callback_fn*)test_hostname_port_weight },
+ {"--socket=", false, (test_callback_fn*)test_parse_socket },
+ {"--namespace=", false, (test_callback_fn*)test_namespace_keyword },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st virtual_bucket_tests[] ={
+ {"basic", false, (test_callback_fn*)virtual_back_map },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st memcached_server_add_tests[] ={
+ {"memcached_server_add(\"\")", false, (test_callback_fn*)memcached_server_add_empty_test },
+ {"memcached_server_add(NULL)", false, (test_callback_fn*)memcached_server_add_null_test },
+ {0, 0, (test_callback_fn*)0}
+};
+
+test_st namespace_tests[] ={
+ {"basic tests", true, (test_callback_fn*)selection_of_namespace_tests },
+ {"increment", true, (test_callback_fn*)memcached_increment_namespace },
+ {0, 0, (test_callback_fn*)0}
+};
+
+collection_st collection[] ={
+#if 0
+ {"hash_sanity", 0, 0, hash_sanity},
+#endif
+ {"libmemcachedutil", 0, 0, libmemcachedutil_tests},
+ {"basic", 0, 0, basic_tests},
+ {"hsieh_availability", 0, 0, hsieh_availability},
+ {"murmur_availability", 0, 0, murmur_availability},
+ {"memcached_server_add", 0, 0, memcached_server_add_tests},
+ {"block", 0, 0, tests},
+ {"binary", (test_callback_fn*)pre_binary, 0, tests},
+ {"nonblock", (test_callback_fn*)pre_nonblock, 0, tests},
+ {"nodelay", (test_callback_fn*)pre_nodelay, 0, tests},
+ {"settimer", (test_callback_fn*)pre_settimer, 0, tests},
+ {"md5", (test_callback_fn*)pre_md5, 0, tests},
+ {"crc", (test_callback_fn*)pre_crc, 0, tests},
+ {"hsieh", (test_callback_fn*)pre_hsieh, 0, tests},
+ {"jenkins", (test_callback_fn*)pre_jenkins, 0, tests},
+ {"fnv1_64", (test_callback_fn*)pre_hash_fnv1_64, 0, tests},
+ {"fnv1a_64", (test_callback_fn*)pre_hash_fnv1a_64, 0, tests},
+ {"fnv1_32", (test_callback_fn*)pre_hash_fnv1_32, 0, tests},
+ {"fnv1a_32", (test_callback_fn*)pre_hash_fnv1a_32, 0, tests},
+ {"ketama", (test_callback_fn*)pre_behavior_ketama, 0, tests},
+ {"ketama_auto_eject_hosts", (test_callback_fn*)pre_behavior_ketama, 0, ketama_auto_eject_hosts},
+ {"unix_socket", (test_callback_fn*)pre_unix_socket, 0, tests},
+ {"unix_socket_nodelay", (test_callback_fn*)pre_nodelay, 0, tests},
+ {"gets", (test_callback_fn*)enable_cas, 0, tests},
+ {"consistent_crc", (test_callback_fn*)enable_consistent_crc, 0, tests},
+ {"consistent_hsieh", (test_callback_fn*)enable_consistent_hsieh, 0, tests},
+#ifdef MEMCACHED_ENABLE_DEPRECATED
+ {"deprecated_memory_allocators", (test_callback_fn*)deprecated_set_memory_alloc, 0, tests},
+#endif
+ {"memory_allocators", (test_callback_fn*)set_memory_alloc, 0, tests},
+ {"namespace", (test_callback_fn*)set_namespace, 0, tests},
+ {"namespace(BINARY)", (test_callback_fn*)set_namespace_and_binary, 0, tests},
+ {"specific namespace", 0, 0, namespace_tests},
+ {"specific namespace(BINARY)", (test_callback_fn*)pre_binary, 0, namespace_tests},
+ {"version_1_2_3", (test_callback_fn*)check_for_1_2_3, 0, version_1_2_3},
+ {"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},
+ {"Cal Haldenbrand's tests", 0, 0, haldenbrand_TESTS},
+ {"user written tests", 0, 0, user_tests},
+ {"generate", 0, 0, generate_tests},
+ {"generate_hsieh", (test_callback_fn*)pre_hsieh, 0, generate_tests},
+ {"generate_ketama", (test_callback_fn*)pre_behavior_ketama, 0, generate_tests},
+ {"generate_hsieh_consistent", (test_callback_fn*)enable_consistent_hsieh, 0, generate_tests},
+ {"generate_md5", (test_callback_fn*)pre_md5, 0, generate_tests},
+ {"generate_murmur", (test_callback_fn*)pre_murmur, 0, generate_tests},
+ {"generate_jenkins", (test_callback_fn*)pre_jenkins, 0, generate_tests},
+ {"generate_nonblock", (test_callback_fn*)pre_nonblock, 0, generate_tests},
+ // Too slow
+ {"generate_corked", (test_callback_fn*)pre_cork, 0, generate_tests},
+ {"generate_corked_and_nonblock", (test_callback_fn*)pre_cork_and_nonblock, 0, generate_tests},
+ {"consistent_not", 0, 0, consistent_tests},
+ {"consistent_ketama", (test_callback_fn*)pre_behavior_ketama, 0, consistent_tests},
+ {"consistent_ketama_weighted", (test_callback_fn*)pre_behavior_ketama_weighted, 0, consistent_weighted_tests},
+ {"ketama_compat", 0, 0, ketama_compatibility},
+ {"test_hashes", 0, 0, hash_tests},
+ {"replication", (test_callback_fn*)pre_replication, 0, replication_tests},
+ {"replication_noblock", (test_callback_fn*)pre_replication_noblock, 0, replication_tests},
+ {"regression", 0, 0, regression_tests},
+ {"behaviors", 0, 0, behavior_tests},
+ {"regression_binary_vs_block", (test_callback_fn*)key_setup, (test_callback_fn*)key_teardown, regression_binary_vs_block},
+ {"error_conditions", 0, 0, error_conditions},
+ {"parser", 0, 0, parser_tests},
+ {"virtual buckets", 0, 0, virtual_bucket_tests},
+ {"memcached_server_get_last_disconnect", 0, 0, memcached_server_get_last_disconnect_tests},
+ {"touch", 0, 0, touch_tests},
+ {"touch", (test_callback_fn*)pre_binary, 0, touch_tests},
+ {"memcached_stat()", 0, 0, memcached_stat_tests},
+ {0, 0, 0, 0}
+};
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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.
+ *
+ */
+
+#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include "tests/basic.h"
+#include "tests/debug.h"
+#include "tests/deprecated.h"
+#include "tests/error_conditions.h"
+#include "tests/exist.h"
+#include "tests/ketama.h"
+#include "tests/namespace.h"
+#include "tests/parser.h"
+#include "tests/libmemcached-1.0/dump.h"
+#include "tests/libmemcached-1.0/generate.h"
+#include "tests/libmemcached-1.0/haldenbrand.h"
+#include "tests/libmemcached-1.0/stat.h"
+#include "tests/touch.h"
+#include "tests/callbacks.h"
+#include "tests/pool.h"
+#include "tests/print.h"
+#include "tests/replication.h"
+#include "tests/server_add.h"
+#include "tests/virtual_buckets.h"
+
+#include "tests/libmemcached-1.0/setup_and_teardowns.h"
+
+
+#include "tests/libmemcached-1.0/mem_functions.h"
+
+/* Collections we are running */
+#include "tests/libmemcached-1.0/all_tests.h"
+
+#include "tests/libmemcached_world_socket.h"
+
+void get_world(Framework *world)
+{
+ world->collections= collection;
+
+ world->_create= (test_callback_create_fn*)world_create;
+ world->_destroy= (test_callback_destroy_fn*)world_destroy;
+
+ world->item._startup= (test_callback_fn*)world_test_startup;
+ world->item.set_pre((test_callback_fn*)world_pre_run);
+ world->item.set_flush((test_callback_fn*)world_flush);
+ world->item.set_post((test_callback_fn*)world_post_run);
+ world->_on_error= (test_callback_error_fn*)world_on_error;
+
+ world->collection_startup= (test_callback_fn*)world_container_startup;
+ world->collection_shutdown= (test_callback_fn*)world_container_shutdown;
+
+ world->set_runner(&defualt_libmemcached_runner);
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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.
+ *
+ */
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include "tests/libmemcached-1.0/callback_counter.h"
+
+memcached_return_t callback_counter(const memcached_st*, memcached_result_st*, void *context)
+{
+ size_t *counter= (size_t *)context;
+
+ *counter= *counter + 1;
+
+ return MEMCACHED_SUCCESS;
+}
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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
+
+memcached_return_t callback_counter(const memcached_st*, memcached_result_st*, void *);
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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.
+ *
+ */
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include <tests/libmemcached-1.0/fetch_all_results.h>
+
+test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned, memcached_return_t& rc)
+{
+ keys_returned= 0;
+
+ memcached_result_st* result= NULL;
+ while ((result= memcached_fetch_result(memc, result, &rc)))
+ {
+ test_compare(MEMCACHED_SUCCESS, rc);
+ keys_returned+= 1;
+ }
+ memcached_result_free(result);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned)
+{
+ memcached_return_t rc;
+ return fetch_all_results(memc, keys_returned, rc);
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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
+
+test_return_t fetch_all_results(memcached_st *, unsigned int&, memcached_return_t&);
+test_return_t fetch_all_results(memcached_st *, unsigned int&);
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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.
+ *
+ */
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include <libmemcached/util.h>
+#include <libmemcached/is.h>
+
+#include <tests/libmemcached-1.0/generate.h>
+#include <tests/libmemcached-1.0/fetch_all_results.h>
+#include "tests/libmemcached-1.0/servers_to_create.h"
+#include "tests/libmemcached-1.0/callback_counter.h"
+
+#include "clients/generator.h"
+#include "clients/execute.h"
+
+#define GLOBAL_COUNT 10000
+#define GLOBAL2_COUNT 100
+
+static pairs_st *global_pairs;
+static const char *global_keys[GLOBAL_COUNT];
+static size_t global_keys_length[GLOBAL_COUNT];
+static size_t global_count= 0;
+
+test_return_t cleanup_pairs(memcached_st *memc)
+{
+ (void)memc;
+ pairs_free(global_pairs);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t generate_pairs(memcached_st *)
+{
+ global_pairs= pairs_generate(GLOBAL_COUNT, 400);
+ global_count= GLOBAL_COUNT;
+
+ for (size_t x= 0; x < global_count; x++)
+ {
+ global_keys[x]= global_pairs[x].key;
+ global_keys_length[x]= global_pairs[x].key_length;
+ }
+
+ return TEST_SUCCESS;
+}
+
+test_return_t generate_large_pairs(memcached_st *)
+{
+ global_pairs= pairs_generate(GLOBAL2_COUNT, MEMCACHED_MAX_BUFFER+10);
+ global_count= GLOBAL2_COUNT;
+
+ for (size_t x= 0; x < global_count; x++)
+ {
+ global_keys[x]= global_pairs[x].key;
+ global_keys_length[x]= global_pairs[x].key_length;
+ }
+
+ return TEST_SUCCESS;
+}
+
+test_return_t generate_data(memcached_st *memc)
+{
+ unsigned int check_execute= execute_set(memc, global_pairs, global_count);
+
+ test_compare_warn_hint(global_count, check_execute, "Possible false, positive, memcached may have ejected key/value based on memory needs");
+
+ return TEST_SUCCESS;
+}
+
+test_return_t generate_data_with_stats(memcached_st *memc)
+{
+ unsigned int check_execute= execute_set(memc, global_pairs, global_count);
+
+ test_compare(check_execute, global_count);
+
+ // @todo hosts used size stats
+ memcached_return_t rc;
+ memcached_stat_st *stat_p= memcached_stat(memc, NULL, &rc);
+ test_true(stat_p);
+
+ for (uint32_t host_index= 0; host_index < SERVERS_TO_CREATE; host_index++)
+ {
+ /* This test was changes so that "make test" would work properlly */
+ if (DEBUG)
+ {
+ memcached_server_instance_st instance=
+ memcached_server_instance_by_position(memc, host_index);
+
+ printf("\nserver %u|%s|%u bytes: %llu\n", host_index, instance->hostname, instance->port, (unsigned long long)(stat_p + host_index)->bytes);
+ }
+ test_true((unsigned long long)(stat_p + host_index)->bytes);
+ }
+
+ memcached_stat_free(NULL, stat_p);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t generate_buffer_data(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true);
+ generate_data(memc);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t get_read_count(memcached_st *memc)
+{
+ memcached_st *memc_clone= memcached_clone(NULL, memc);
+ test_true(memc_clone);
+
+ memcached_server_add_with_weight(memc_clone, "localhost", 6666, 0);
+
+ {
+ char *return_value;
+ size_t return_value_length;
+ uint32_t flags;
+ uint32_t count;
+
+ for (size_t x= count= 0; x < global_count; x++)
+ {
+ memcached_return_t rc;
+ return_value= memcached_get(memc_clone, global_keys[x], global_keys_length[x],
+ &return_value_length, &flags, &rc);
+ if (rc == MEMCACHED_SUCCESS)
+ {
+ count++;
+ if (return_value)
+ {
+ free(return_value);
+ }
+ }
+ }
+ }
+
+ memcached_free(memc_clone);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t get_read(memcached_st *memc)
+{
+ size_t keys_returned= 0;
+ for (size_t x= 0; x < global_count; x++)
+ {
+ size_t return_value_length;
+ uint32_t flags;
+ memcached_return_t rc;
+ char *return_value= memcached_get(memc, global_keys[x], global_keys_length[x],
+ &return_value_length, &flags, &rc);
+ /*
+ test_true(return_value);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ */
+ if (rc == MEMCACHED_SUCCESS && return_value)
+ {
+ keys_returned++;
+ free(return_value);
+ }
+ }
+ test_compare_warn_hint(global_count, keys_returned, "Possible false, positive, memcached may have ejected key/value based on memory needs");
+
+ return TEST_SUCCESS;
+}
+
+test_return_t mget_read(memcached_st *memc)
+{
+
+ test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, global_keys, global_keys_length, global_count));
+
+ // Go fetch the keys and test to see if all of them were returned
+ {
+ unsigned int keys_returned;
+ test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned));
+ test_true(keys_returned > 0);
+ test_compare_warn_hint(global_count, keys_returned, "Possible false, positive, memcached may have ejected key/value based on memory needs");
+ }
+
+ return TEST_SUCCESS;
+}
+
+test_return_t mget_read_result(memcached_st *memc)
+{
+
+ test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, global_keys, global_keys_length, global_count));
+
+ /* Turn this into a help function */
+ {
+ memcached_result_st results_obj;
+ memcached_result_st *results= memcached_result_create(memc, &results_obj);
+ test_true(results);
+
+ memcached_return_t rc;
+ while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
+ {
+ if (rc == MEMCACHED_IN_PROGRESS)
+ {
+ continue;
+ }
+
+ test_true(results);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ }
+ test_compare(MEMCACHED_END, rc);
+
+ memcached_result_free(&results_obj);
+ }
+
+ return TEST_SUCCESS;
+}
+
+test_return_t mget_read_partial_result(memcached_st *memc)
+{
+
+ test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, global_keys, global_keys_length, global_count));
+
+ // We will scan for just one key
+ {
+ memcached_result_st results_obj;
+ memcached_result_st *results= memcached_result_create(memc, &results_obj);
+
+ memcached_return_t rc;
+ results= memcached_fetch_result(memc, results, &rc);
+ test_true(results);
+ test_compare(MEMCACHED_SUCCESS, rc);
+
+ memcached_result_free(&results_obj);
+ }
+
+ // We already have a read happening, lets start up another one.
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, global_keys, global_keys_length, global_count));
+ {
+ memcached_result_st results_obj;
+ memcached_result_st *results= memcached_result_create(memc, &results_obj);
+ test_true(results);
+ test_false(memcached_is_allocated(results));
+
+ memcached_return_t rc;
+ while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
+ {
+ test_true(results);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ }
+ test_compare(MEMCACHED_END, rc);
+
+ memcached_result_free(&results_obj);
+ }
+
+ return TEST_SUCCESS;
+}
+
+test_return_t mget_read_function(memcached_st *memc)
+{
+ test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, global_keys, global_keys_length, global_count));
+
+ memcached_execute_fn callbacks[]= { &callback_counter };
+ size_t counter= 0;
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
+
+ return TEST_SUCCESS;
+}
+
+test_return_t delete_generate(memcached_st *memc)
+{
+ size_t total= 0;
+ for (size_t x= 0; x < global_count; x++)
+ {
+ if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0)))
+ {
+ total++;
+ }
+ }
+ test_compare_warn_hint(global_count, total, "Possible false, positive, memcached may have ejected key/value based on memory needs");
+
+ return TEST_SUCCESS;
+}
+
+test_return_t delete_buffer_generate(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true);
+
+ size_t total= 0;
+ for (size_t x= 0; x < global_count; x++)
+ {
+ if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0)))
+ {
+ total++;
+ }
+ }
+ test_compare_warn_hint(global_count, total, "Possible false, positive, memcached may have ejected key/value based on memory needs");
+
+ return TEST_SUCCESS;
+}
+
+test_return_t mget_read_internal_result(memcached_st *memc)
+{
+
+ test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, global_keys, global_keys_length, global_count));
+ {
+ memcached_result_st *results= NULL;
+ memcached_return_t rc;
+ while ((results= memcached_fetch_result(memc, results, &rc)))
+ {
+ test_true(results);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ }
+ test_compare(MEMCACHED_END, rc);
+
+ memcached_result_free(results);
+ }
+
+ return TEST_SUCCESS;
+}
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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
+
+test_return_t cleanup_pairs(memcached_st*);
+test_return_t delete_buffer_generate(memcached_st*);
+test_return_t delete_generate(memcached_st*);
+test_return_t generate_buffer_data(memcached_st*);
+test_return_t generate_data(memcached_st*);
+test_return_t generate_data_with_stats(memcached_st*);
+test_return_t generate_large_pairs(memcached_st *);
+test_return_t generate_pairs(memcached_st*);
+test_return_t get_read(memcached_st*);
+test_return_t get_read_count(memcached_st*);
+test_return_t mget_read(memcached_st*);
+test_return_t mget_read_function(memcached_st*);
+test_return_t mget_read_partial_result(memcached_st*);
+test_return_t mget_read_result(memcached_st*);
+test_return_t mget_read_internal_result(memcached_st*);
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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.
+ *
+ */
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include "tests/libmemcached-1.0/haldenbrand.h"
+#include "tests/libmemcached-1.0/fetch_all_results.h"
+
+/* Test case provided by Cal Haldenbrand */
+#define HALDENBRAND_KEY_COUNT 3000U // * 1024576
+#define HALDENBRAND_FLAG_KEY 99 // * 1024576
+
+test_return_t haldenbrand_TEST1(memcached_st *memc)
+{
+ /* We just keep looking at the same values over and over */
+ srandom(10);
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true));
+
+
+ /* add key */
+ unsigned long long total= 0;
+ for (uint32_t x= 0 ; total < 20 * 1024576 ; x++ )
+ {
+ uint32_t size= (uint32_t)(rand() % ( 5 * 1024 ) ) + 400;
+ char randomstuff[6 * 1024];
+ memset(randomstuff, 0, 6 * 1024);
+ test_true(size < 6 * 1024); /* Being safe here */
+
+ for (uint32_t j= 0 ; j < size ;j++)
+ {
+ randomstuff[j] = (signed char) ((rand() % 26) + 97);
+ }
+
+ total+= size;
+ char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
+ int key_length= snprintf(key, sizeof(key), "%u", x);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(memc, key, key_length,
+ randomstuff, strlen(randomstuff),
+ time_t(0), HALDENBRAND_FLAG_KEY));
+ }
+ test_true(total > HALDENBRAND_KEY_COUNT);
+
+ return TEST_SUCCESS;
+}
+
+/* Test case provided by Cal Haldenbrand */
+test_return_t haldenbrand_TEST2(memcached_st *memc)
+{
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true));
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true));
+
+#ifdef NOT_YET
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, 20 * 1024576));
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, 20 * 1024576));
+ getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE);
+ getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE);
+
+ for (x= 0, errors= 0; total < 20 * 1024576 ; x++)
+#endif
+
+ size_t total_value_length= 0;
+ for (uint32_t x= 0, errors= 0; total_value_length < 24576 ; x++)
+ {
+ uint32_t flags= 0;
+ size_t val_len= 0;
+
+ char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
+ int key_length= snprintf(key, sizeof(key), "%u", x);
+
+ memcached_return_t rc;
+ char *getval= memcached_get(memc, key, key_length, &val_len, &flags, &rc);
+ if (memcached_failed(rc))
+ {
+ if (rc == MEMCACHED_NOTFOUND)
+ {
+ errors++;
+ }
+ else
+ {
+ test_true(rc);
+ }
+
+ continue;
+ }
+ test_compare(uint32_t(HALDENBRAND_FLAG_KEY), flags);
+ test_true(getval);
+
+ total_value_length+= val_len;
+ errors= 0;
+ ::free(getval);
+ }
+
+ return TEST_SUCCESS;
+}
+
+/* Do a large mget() over all the keys we think exist */
+test_return_t haldenbrand_TEST3(memcached_st *memc)
+{
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true));
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true));
+
+#ifdef NOT_YET
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, 20 * 1024576);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, 20 * 1024576);
+ getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE);
+ getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE);
+#endif
+
+ std::vector<size_t> key_lengths;
+ key_lengths.resize(HALDENBRAND_KEY_COUNT);
+ std::vector<char *> keys;
+ keys.resize(key_lengths.size());
+ for (uint32_t x= 0; x < key_lengths.size(); x++)
+ {
+ char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
+ int key_length= snprintf(key, sizeof(key), "%u", x);
+ test_true(key_length > 0 and key_length < MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1);
+ keys[x]= strdup(key);
+ key_lengths[x]= key_length;
+ }
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, &keys[0], &key_lengths[0], key_lengths.size()));
+
+ unsigned int keys_returned;
+ test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned));
+ test_compare(HALDENBRAND_KEY_COUNT, keys_returned);
+
+ for (libtest::vchar_ptr_t::iterator iter= keys.begin();
+ iter != keys.end();
+ iter++)
+ {
+ ::free(*iter);
+ }
+
+
+ return TEST_SUCCESS;
+}
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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
+
+test_return_t haldenbrand_TEST1(memcached_st *);
+test_return_t haldenbrand_TEST2(memcached_st *);
+test_return_t haldenbrand_TEST3(memcached_st *);
tests/ketama.h \
tests/ketama_test_cases.h \
tests/ketama_test_cases_spy.h \
+ tests/libmemcached-1.0/all_tests.h \
+ tests/libmemcached-1.0/callback_counter.h \
tests/libmemcached-1.0/dump.h \
+ tests/libmemcached-1.0/fetch_all_results.h \
+ tests/libmemcached-1.0/generate.h \
+ tests/libmemcached-1.0/haldenbrand.h \
+ tests/libmemcached-1.0/servers_to_create.h \
+ tests/libmemcached-1.0/setup_and_teardowns.h \
tests/libmemcached-1.0/stat.h \
tests/namespace.h \
tests/parser.h \
tests_libmemcached_1_0_testapp_CXXFLAGS = $(AM_CXXFLAGS) ${PTHREAD_CFLAGS}
tests_libmemcached_1_0_testapp_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)
tests_libmemcached_1_0_testapp_SOURCES= \
+ tests/libmemcached-1.0/all_tests.cc \
+ tests/libmemcached-1.0/basic.cc \
+ tests/libmemcached-1.0/callback_counter.cc \
+ tests/libmemcached-1.0/callbacks.cc \
+ tests/libmemcached-1.0/debug.cc \
+ tests/libmemcached-1.0/deprecated.cc \
+ tests/libmemcached-1.0/dump.cc \
+ tests/libmemcached-1.0/error_conditions.cc \
+ tests/libmemcached-1.0/exist.cc \
+ tests/libmemcached-1.0/fetch_all_results.cc \
+ tests/libmemcached-1.0/generate.cc \
+ tests/libmemcached-1.0/haldenbrand.cc \
+ tests/libmemcached-1.0/ketama.cc \
+ tests/libmemcached-1.0/mem_functions.cc \
+ tests/libmemcached-1.0/namespace.cc \
+ tests/libmemcached-1.0/parser.cc \
tests/libmemcached-1.0/pool.cc \
tests/libmemcached-1.0/print.cc \
tests/libmemcached-1.0/replication.cc \
- tests/libmemcached-1.0/basic.cc \
- tests/libmemcached-1.0/callbacks.cc \
- tests/libmemcached-1.0/debug.cc \
- tests/libmemcached-1.0/deprecated.cc \
- tests/libmemcached-1.0/dump.cc \
- tests/libmemcached-1.0/error_conditions.cc \
- tests/libmemcached-1.0/exist.cc \
- tests/libmemcached-1.0/ketama.cc \
- tests/libmemcached-1.0/mem_functions.cc \
- tests/libmemcached-1.0/namespace.cc \
- tests/libmemcached-1.0/parser.cc \
- tests/libmemcached-1.0/server_add.cc \
- tests/libmemcached-1.0/stat.cc \
- tests/libmemcached-1.0/touch.cc \
- tests/libmemcached-1.0/virtual_buckets.cc
+ tests/libmemcached-1.0/server_add.cc \
+ tests/libmemcached-1.0/setup_and_teardowns.cc \
+ tests/libmemcached-1.0/stat.cc \
+ tests/libmemcached-1.0/touch.cc \
+ tests/libmemcached-1.0/virtual_buckets.cc
tests_libmemcached_1_0_testapp_SOURCES+= clients/generator.cc clients/execute.cc
tests_libmemcached_1_0_testapp_DEPENDENCIES= \
libmemcached/libmemcachedutil.la
tests_libmemcached_1_0_testapp_LDADD= \
+ $(LIBUUID_LDFLAGS) \
${PTHREAD_LIBS} \
libmemcached/libmemcached.la \
libmemcached/libmemcachedutil.la \
check_PROGRAMS+= tests/libmemcached-1.0/testapp
noinst_PROGRAMS+= tests/libmemcached-1.0/testapp
+tests_libmemcached_1_0_testsocket_CXXFLAGS = $(AM_CXXFLAGS) ${PTHREAD_CFLAGS}
+tests_libmemcached_1_0_testsocket_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)
+tests_libmemcached_1_0_testsocket_SOURCES= \
+ tests/libmemcached-1.0/all_tests_socket.cc \
+ tests/libmemcached-1.0/basic.cc \
+ tests/libmemcached-1.0/callback_counter.cc \
+ tests/libmemcached-1.0/callbacks.cc \
+ tests/libmemcached-1.0/debug.cc \
+ tests/libmemcached-1.0/deprecated.cc \
+ tests/libmemcached-1.0/dump.cc \
+ tests/libmemcached-1.0/error_conditions.cc \
+ tests/libmemcached-1.0/exist.cc \
+ tests/libmemcached-1.0/fetch_all_results.cc \
+ tests/libmemcached-1.0/generate.cc \
+ tests/libmemcached-1.0/haldenbrand.cc \
+ tests/libmemcached-1.0/ketama.cc \
+ tests/libmemcached-1.0/mem_functions.cc \
+ tests/libmemcached-1.0/namespace.cc \
+ tests/libmemcached-1.0/parser.cc \
+ tests/libmemcached-1.0/pool.cc \
+ tests/libmemcached-1.0/print.cc \
+ tests/libmemcached-1.0/replication.cc \
+ tests/libmemcached-1.0/server_add.cc \
+ tests/libmemcached-1.0/setup_and_teardowns.cc \
+ tests/libmemcached-1.0/stat.cc \
+ tests/libmemcached-1.0/touch.cc \
+ tests/libmemcached-1.0/virtual_buckets.cc
+
+tests_libmemcached_1_0_testsocket_SOURCES+= clients/generator.cc clients/execute.cc
+tests_libmemcached_1_0_testsocket_DEPENDENCIES= \
+ libmemcached/libmemcached.la \
+ libtest/libtest.la \
+ libhashkit/libhashkit.la \
+ libmemcached/libmemcachedutil.la
+
+tests_libmemcached_1_0_testsocket_LDADD= \
+ $(LIBUUID_LDFLAGS) \
+ ${PTHREAD_LIBS} \
+ libmemcached/libmemcached.la \
+ libmemcached/libmemcachedutil.la \
+ libtest/libtest.la \
+ libhashkit/libhashkit.la
+
+check_PROGRAMS+= tests/libmemcached-1.0/testsocket
+noinst_PROGRAMS+= tests/libmemcached-1.0/testsocket
+
tests_libmemcached_1_0_sasl_CXXFLAGS = $(AM_CXXFLAGS) ${PTHREAD_CFLAGS}
tests_libmemcached_1_0_sasl_CFLAGS= $(AM_CFLAGS) $(NO_CONVERSION) $(NO_STRICT_ALIASING)
tests_libmemcached_1_0_sasl_SOURCES= \
#include <config.h>
#include <libtest/test.hpp>
+#if defined(HAVE_LIBUUID) && HAVE_LIBUUID
+#include <uuid/uuid.h>
+#endif
+
/*
Test cases
*/
#include <libtest/server.h>
#include "clients/generator.h"
-#include "clients/execute.h"
#define SMALL_STRING_LEN 1024
#include <libtest/test.hpp>
-#include "tests/basic.h"
-#include "tests/debug.h"
-#include "tests/deprecated.h"
-#include "tests/error_conditions.h"
-#include "tests/exist.h"
-#include "tests/ketama.h"
-#include "tests/namespace.h"
-#include "tests/parser.h"
-#include "tests/libmemcached-1.0/dump.h"
-#include "tests/libmemcached-1.0/stat.h"
-#include "tests/touch.h"
-#include "tests/callbacks.h"
-#include "tests/pool.h"
-#include "tests/print.h"
-#include "tests/replication.h"
-#include "tests/server_add.h"
-#include "tests/virtual_buckets.h"
-
using namespace libtest;
#include <libmemcached/util.h>
#include "tests/hash_results.h"
-#define GLOBAL_COUNT 10000
-#define GLOBAL2_COUNT 100
-#define SERVERS_TO_CREATE 5
-static uint32_t global_count= GLOBAL2_COUNT;
+#include "tests/libmemcached-1.0/servers_to_create.h"
-static pairs_st *global_pairs;
-static const char *global_keys[GLOBAL_COUNT];
-static size_t global_keys_length[GLOBAL_COUNT];
+#include "tests/libmemcached-1.0/callback_counter.h"
+#include "tests/libmemcached-1.0/fetch_all_results.h"
+#include "tests/libmemcached-1.0/mem_functions.h"
+#include "tests/libmemcached-1.0/setup_and_teardowns.h"
+#include "tests/print.h"
+#include "tests/debug.h"
-/**
- @note This should be testing to see if the server really supports the binary protocol.
-*/
-static test_return_t pre_binary(memcached_st *memc)
-{
- test_skip(true, libmemcached_util_version_check(memc, 1, 4, 4));
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true));
+#define UUID_STRING_MAXLENGTH 36
- return TEST_SUCCESS;
-}
+struct keys_st {
+public:
+ keys_st(size_t arg)
+ {
+ init(arg, UUID_STRING_MAXLENGTH);
+ }
+
+ keys_st(size_t arg, size_t padding)
+ {
+ init(arg, padding);
+ }
+
+ void init(size_t arg, size_t padding)
+ {
+ _lengths.resize(arg);
+ _keys.resize(arg);
+
+ for (size_t x= 0; x < _keys.size(); x++)
+ {
+ libtest::vchar_t key_buffer;
+ key_buffer.resize(padding +1);
+ memset(&key_buffer[0], 'x', padding);
+
+ if (HAVE_LIBUUID)
+ {
+ uuid_t out;
+ uuid_generate(out);
+
+ uuid_unparse(out, &key_buffer[0]);
+ _keys[x]= strdup(&key_buffer[0]);
+ (_keys[x])[UUID_STRING_MAXLENGTH]= 'x';
+ }
+ else // We just use a number and pad the string if UUID is not available
+ {
+ char int_buffer[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
+ int key_length= snprintf(int_buffer, sizeof(int_buffer), "%u", uint32_t(x));
+ memcpy(&key_buffer[0], int_buffer, key_length);
+ _keys[x]= strdup(&key_buffer[0]);
+ }
+ _lengths[x]= padding;
+ }
+ }
+
+ ~keys_st()
+ {
+ for (libtest::vchar_ptr_t::iterator iter= _keys.begin();
+ iter != _keys.end();
+ iter++)
+ {
+ ::free(*iter);
+ }
+ }
+
+ libtest::vchar_ptr_t::iterator begin()
+ {
+ return _keys.begin();
+ }
+
+ libtest::vchar_ptr_t::iterator end()
+ {
+ return _keys.end();
+ }
+
+ size_t size() const
+ {
+ return _keys.size();
+ }
+
+ std::vector<size_t>& lengths()
+ {
+ return _lengths;
+ }
+
+ libtest::vchar_ptr_t& keys()
+ {
+ return _keys;
+ }
+
+ size_t* lengths_ptr()
+ {
+ return &_lengths[0];
+ }
+
+ char** keys_ptr()
+ {
+ return &_keys[0];
+ }
+
+ char* key_at(size_t arg)
+ {
+ return _keys[arg];
+ }
+
+ size_t length_at(size_t arg)
+ {
+ return _lengths[arg];
+ }
+
+private:
+ libtest::vchar_ptr_t _keys;
+ std::vector<size_t> _lengths;
+};
static memcached_return_t return_value_based_on_buffering(memcached_st *memc)
{
char server_string[1024];
int server_string_length;
- if (options)
+ if (instance->type == MEMCACHED_CONNECTION_UNIX_SOCKET)
{
- server_string_length= snprintf(server_string, sizeof(server_string), "--server=%s:%d %s",
- memcached_server_name(instance), int(memcached_server_port(instance)),
- options);
+ if (options)
+ {
+ server_string_length= snprintf(server_string, sizeof(server_string), "--SOCKET=\"%s\" %s",
+ memcached_server_name(instance), options);
+ }
+ else
+ {
+ server_string_length= snprintf(server_string, sizeof(server_string), "--SOCKET=\"%s\"",
+ memcached_server_name(instance));
+ }
}
else
{
- server_string_length= snprintf(server_string, sizeof(server_string), "--server=%s:%d",
- memcached_server_name(instance), int(memcached_server_port(instance)));
+ if (options)
+ {
+ server_string_length= snprintf(server_string, sizeof(server_string), "--server=%s:%d %s",
+ memcached_server_name(instance), int(memcached_server_port(instance)),
+ options);
+ }
+ else
+ {
+ server_string_length= snprintf(server_string, sizeof(server_string), "--server=%s:%d",
+ memcached_server_name(instance), int(memcached_server_port(instance)));
+ }
}
if (server_string_length <= 0)
char buffer[1024];
if (memcached_failed(libmemcached_check_configuration(server_string, server_string_length, buffer, sizeof(buffer))))
{
- Error << "Failed to parse " << server_string_length;
+ Error << "Failed to parse (" << server_string << ") " << buffer;
return NULL;
}
}
-static test_return_t init_test(memcached_st *not_used)
+test_return_t init_test(memcached_st *not_used)
{
memcached_st memc;
(void)not_used;
return MEMCACHED_SUCCESS;
}
-static test_return_t server_sort_test(memcached_st *ptr)
+test_return_t server_sort_test(memcached_st *ptr)
{
size_t bigger= 0; /* Prime the value for the test_true in server_display_function */
return TEST_SUCCESS;
}
-static test_return_t server_sort2_test(memcached_st *ptr)
+test_return_t server_sort2_test(memcached_st *ptr)
{
size_t bigger= 0; /* Prime the value for the test_true in server_display_function */
memcached_server_fn callbacks[1];
return TEST_SUCCESS;
}
-static test_return_t memcached_server_remove_test(memcached_st*)
+test_return_t memcached_server_remove_test(memcached_st*)
{
const char *server_string= "--server=localhost:4444 --server=localhost:4445 --server=localhost:4446 --server=localhost:4447 --server=localhost --server=memcache1.memcache.bk.sapo.pt:11211 --server=memcache1.memcache.bk.sapo.pt:11212 --server=memcache1.memcache.bk.sapo.pt:11213 --server=memcache1.memcache.bk.sapo.pt:11214 --server=memcache2.memcache.bk.sapo.pt:11211 --server=memcache2.memcache.bk.sapo.pt:11212 --server=memcache2.memcache.bk.sapo.pt:11213 --server=memcache2.memcache.bk.sapo.pt:11214";
char buffer[BUFSIZ];
return MEMCACHED_SUCCESS;
}
-static test_return_t server_unsort_test(memcached_st *ptr)
+test_return_t server_unsort_test(memcached_st *ptr)
{
size_t counter= 0; /* Prime the value for the test_true in server_display_function */
size_t bigger= 0; /* Prime the value for the test_true in server_display_function */
return TEST_SUCCESS;
}
-static test_return_t allocation_test(memcached_st *not_used)
+test_return_t allocation_test(memcached_st *not_used)
{
(void)not_used;
memcached_st *memc;
return TEST_SUCCESS;
}
-static test_return_t clone_test(memcached_st *memc)
+test_return_t clone_test(memcached_st *memc)
{
/* All null? */
{
return TEST_SUCCESS;
}
-static test_return_t userdata_test(memcached_st *memc)
+test_return_t userdata_test(memcached_st *memc)
{
void* foo= NULL;
test_false(memcached_set_user_data(memc, foo));
return TEST_SUCCESS;
}
-static test_return_t connection_test(memcached_st *memc)
+test_return_t connection_test(memcached_st *memc)
{
test_compare(MEMCACHED_SUCCESS,
memcached_server_add_with_weight(memc, "localhost", 0, 0));
return TEST_SUCCESS;
}
-static test_return_t libmemcached_string_behavior_test(memcached_st *)
+test_return_t libmemcached_string_behavior_test(memcached_st *)
{
for (int x= MEMCACHED_BEHAVIOR_NO_BLOCK; x < int(MEMCACHED_BEHAVIOR_MAX); ++x)
{
return TEST_SUCCESS;
}
-static test_return_t libmemcached_string_distribution_test(memcached_st *)
+test_return_t libmemcached_string_distribution_test(memcached_st *)
{
for (int x= MEMCACHED_DISTRIBUTION_MODULA; x < int(MEMCACHED_DISTRIBUTION_CONSISTENT_MAX); ++x)
{
return TEST_SUCCESS;
}
-static test_return_t memcached_return_t_TEST(memcached_st *memc)
+test_return_t memcached_return_t_TEST(memcached_st *memc)
{
uint32_t values[] = { 851992627U, 2337886783U, 4109241422U, 4001849190U,
982370485U, 1263635348U, 4242906218U, 3829656100U,
return TEST_SUCCESS;
}
-static test_return_t set_test(memcached_st *memc)
+test_return_t set_test(memcached_st *memc)
{
memcached_return_t rc= memcached_set(memc,
test_literal_param("foo"),
return TEST_SUCCESS;
}
-static test_return_t append_test(memcached_st *memc)
+test_return_t append_test(memcached_st *memc)
{
memcached_return_t rc;
const char *in_value= "we";
return TEST_SUCCESS;
}
-static test_return_t append_binary_test(memcached_st *memc)
+test_return_t append_binary_test(memcached_st *memc)
{
uint32_t store_list[] = { 23, 56, 499, 98, 32847, 0 };
return TEST_SUCCESS;
}
-static test_return_t cas2_test(memcached_st *memc)
+test_return_t memcached_mget_mixed_memcached_get_TEST(memcached_st *memc)
+{
+ keys_st keys(200);
+
+ for (libtest::vchar_ptr_t::iterator iter= keys.begin();
+ iter != keys.end();
+ iter++)
+ {
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(memc,
+ (*iter), 36,
+ NULL, 0,
+ time_t(0), uint32_t(0)));
+ }
+
+ for (size_t loop= 0; loop < 20; loop++)
+ {
+ if (random() %2)
+ {
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_mget(memc, keys.keys_ptr(), keys.lengths_ptr(), keys.size()));
+
+ memcached_result_st *results= memcached_result_create(memc, NULL);
+ test_true(results);
+
+ size_t result_count= 0;
+ memcached_return_t rc;
+ while (memcached_fetch_result(memc, results, &rc))
+ {
+ result_count++;
+ }
+ test_compare(keys.size(), result_count);
+ }
+ else
+ {
+ int which_key= random() %keys.size();
+ size_t value_length;
+ uint32_t flags;
+ memcached_return_t rc;
+ char *out_value= memcached_get(memc, keys.key_at(which_key), keys.length_at(which_key),
+ &value_length, &flags, &rc);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_null(out_value);
+ test_zero(value_length);
+ test_zero(flags);
+ }
+ }
+
+ return TEST_SUCCESS;
+}
+
+test_return_t cas2_test(memcached_st *memc)
{
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
return TEST_SUCCESS;
}
-static test_return_t cas_test(memcached_st *memc)
+test_return_t cas_test(memcached_st *memc)
{
const char* keys[2] = { __func__, NULL };
size_t keylengths[2] = { strlen(__func__), 0 };
return TEST_SUCCESS;
}
-static test_return_t prepend_test(memcached_st *memc)
+
+test_return_t prepend_test(memcached_st *memc)
{
const char *key= "fig";
const char *value= "people";
Set the value, then quit to make sure it is flushed.
Come back in and test that add fails.
*/
-static test_return_t add_test(memcached_st *memc)
+test_return_t add_test(memcached_st *memc)
{
test_compare_hint(return_value_based_on_buffering(memc),
memcached_set(memc,
** because the connects starts to time out (the test doesn't do much
** anyway, so just loop 10 iterations)
*/
-static test_return_t add_wrapper(memcached_st *memc)
+test_return_t add_wrapper(memcached_st *memc)
{
unsigned int max= 10000;
#ifdef __sun
return TEST_SUCCESS;
}
-static test_return_t replace_test(memcached_st *memc)
+test_return_t replace_test(memcached_st *memc)
{
test_compare(return_value_based_on_buffering(memc),
memcached_set(memc,
return TEST_SUCCESS;
}
-static test_return_t delete_test(memcached_st *memc)
+test_return_t delete_test(memcached_st *memc)
{
test_compare(return_value_based_on_buffering(memc),
memcached_set(memc,
return TEST_SUCCESS;
}
-static test_return_t flush_test(memcached_st *memc)
+test_return_t flush_test(memcached_st *memc)
{
uint64_t query_id= memcached_query_id(memc);
test_compare(MEMCACHED_SUCCESS,
return MEMCACHED_SUCCESS;
}
-static test_return_t memcached_server_cursor_test(memcached_st *memc)
+test_return_t memcached_server_cursor_test(memcached_st *memc)
{
char context[10];
strncpy(context, "foo bad", sizeof(context));
return TEST_SUCCESS;
}
-static test_return_t bad_key_test(memcached_st *memc)
+test_return_t bad_key_test(memcached_st *memc)
{
memcached_return_t rc;
const char *key= "foo bad";
test_compare(MEMCACHED_SUCCESS,
memcached_callback_set(memc_clone, MEMCACHED_CALLBACK_NAMESPACE, NULL));
- std::vector <char> longkey;
+ libtest::vchar_t longkey;
{
- std::vector<char>::iterator it= longkey.begin();
+ libtest::vchar_t::iterator it= longkey.begin();
longkey.insert(it, MEMCACHED_MAX_KEY, 'a');
}
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
-static test_return_t read_through(memcached_st *memc)
+test_return_t read_through(memcached_st *memc)
{
memcached_trigger_key_fn cb= (memcached_trigger_key_fn)read_through_trigger;
return TEST_SUCCESS;
}
-static test_return_t get_test(memcached_st *memc)
+test_return_t get_test(memcached_st *memc)
{
memcached_return_t rc;
char *string;
return TEST_SUCCESS;
}
-static test_return_t get_test2(memcached_st *memc)
+test_return_t get_test2(memcached_st *memc)
{
const char *value= "when we sanitize";
return TEST_SUCCESS;
}
-static test_return_t set_test2(memcached_st *memc)
+test_return_t set_test2(memcached_st *memc)
{
for (uint32_t x= 0; x < 10; x++)
{
return TEST_SUCCESS;
}
-static test_return_t set_test3(memcached_st *memc)
+test_return_t set_test3(memcached_st *memc)
{
size_t value_length= 8191;
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(value_length);
for (uint32_t x= 0; x < value_length; x++)
{
return TEST_SUCCESS;
}
-static test_return_t get_test3(memcached_st *memc)
+test_return_t get_test3(memcached_st *memc)
{
size_t value_length= 8191;
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(value_length);
for (uint32_t x= 0; x < value_length; x++)
{
return TEST_SUCCESS;
}
-static test_return_t get_test4(memcached_st *memc)
+test_return_t get_test4(memcached_st *memc)
{
size_t value_length= 8191;
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(value_length);
for (uint32_t x= 0; x < value_length; x++)
{
* dereference a NIL-pointer if you issue a multi-get and don't read out all
* responses before you execute a storage command.
*/
-static test_return_t get_test5(memcached_st *memc)
+test_return_t get_test5(memcached_st *memc)
{
/*
** Request the same key twice, to ensure that we hash to the same server
return TEST_SUCCESS;
}
-static test_return_t mget_end(memcached_st *memc)
+test_return_t mget_end(memcached_st *memc)
{
const char *keys[]= { "foo", "foo2" };
size_t lengths[]= { 3, 4 };
}
/* Do not copy the style of this code, I just access hosts to testthis function */
-static test_return_t stats_servername_test(memcached_st *memc)
+test_return_t stats_servername_test(memcached_st *memc)
{
memcached_stat_st memc_stat;
memcached_server_instance_st instance=
return TEST_SUCCESS;
}
-static test_return_t increment_test(memcached_st *memc)
+test_return_t increment_test(memcached_st *memc)
{
uint64_t new_number;
return TEST_SUCCESS;
}
-static test_return_t increment_with_initial_test(memcached_st *memc)
+test_return_t increment_with_initial_test(memcached_st *memc)
{
test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
return TEST_SUCCESS;
}
-static test_return_t decrement_test(memcached_st *memc)
+test_return_t decrement_test(memcached_st *memc)
{
test_compare(return_value_based_on_buffering(memc),
memcached_set(memc,
return TEST_SUCCESS;
}
-static test_return_t decrement_with_initial_test(memcached_st *memc)
+test_return_t decrement_with_initial_test(memcached_st *memc)
{
test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
return TEST_SUCCESS;
}
-static test_return_t increment_by_key_test(memcached_st *memc)
+test_return_t increment_by_key_test(memcached_st *memc)
{
const char *master_key= "foo";
const char *key= "number";
return TEST_SUCCESS;
}
-static test_return_t increment_with_initial_by_key_test(memcached_st *memc)
+test_return_t increment_with_initial_by_key_test(memcached_st *memc)
{
test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
return TEST_SUCCESS;
}
-static test_return_t decrement_by_key_test(memcached_st *memc)
+test_return_t decrement_by_key_test(memcached_st *memc)
{
uint64_t new_number;
const char *value= "3";
return TEST_SUCCESS;
}
-static test_return_t decrement_with_initial_by_key_test(memcached_st *memc)
+test_return_t decrement_with_initial_by_key_test(memcached_st *memc)
{
test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
return TEST_SUCCESS;
}
-static test_return_t binary_increment_with_prefix_test(memcached_st *memc)
+test_return_t binary_increment_with_prefix_test(memcached_st *memc)
{
test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
return TEST_SUCCESS;
}
-static test_return_t quit_test(memcached_st *memc)
+test_return_t quit_test(memcached_st *memc)
{
const char *value= "sanford and sun";
return TEST_SUCCESS;
}
-static test_return_t mget_result_test(memcached_st *memc)
+test_return_t mget_result_test(memcached_st *memc)
{
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
return TEST_SUCCESS;
}
-static test_return_t mget_result_alloc_test(memcached_st *memc)
+test_return_t mget_result_alloc_test(memcached_st *memc)
{
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
return TEST_SUCCESS;
}
-/* Count the results */
-static memcached_return_t callback_counter(const memcached_st*, memcached_result_st*, void *context)
-{
- size_t *counter= (size_t *)context;
-
- *counter= *counter + 1;
-
- return MEMCACHED_SUCCESS;
-}
-
-static test_return_t mget_result_function(memcached_st *memc)
+test_return_t mget_result_function(memcached_st *memc)
{
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
return TEST_SUCCESS;
}
-static test_return_t mget_test(memcached_st *memc)
+test_return_t mget_test(memcached_st *memc)
{
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
return TEST_SUCCESS;
}
-static test_return_t mget_execute(memcached_st *original_memc)
+test_return_t mget_execute(memcached_st *original_memc)
{
test_skip(true, memcached_behavior_get(original_memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
memcached_st *memc= create_single_instance_memcached(original_memc, "--BINARY-PROTOCOL");
test_true(memc);
- size_t max_keys= 20480;
-
-
- char **keys= static_cast<char **>(calloc(max_keys, sizeof(char*)));
- size_t *key_length=static_cast<size_t *>(calloc(max_keys, sizeof(size_t)));
+ keys_st keys(20480);
/* First add all of the items.. */
char blob[1024] = {0};
- for (size_t x= 0; x < max_keys; ++x)
+ for (size_t x= 0; x < keys.size(); ++x)
{
- char k[251];
-
- key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%lu", (unsigned long)x);
- keys[x]= strdup(k);
- test_true(keys[x] != NULL);
uint64_t query_id= memcached_query_id(memc);
- memcached_return_t rc= memcached_add(memc, keys[x], key_length[x], blob, sizeof(blob), 0, 0);
- test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc));
+ memcached_return_t rc= memcached_add(memc,
+ keys.key_at(x), keys.length_at(x),
+ blob, sizeof(blob),
+ 0, 0);
+ test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED,
+ memcached_strerror(NULL, rc));
test_compare(query_id +1, memcached_query_id(memc));
}
size_t counter= 0;
memcached_execute_fn callbacks[]= { &callback_counter };
test_compare(MEMCACHED_SUCCESS,
- memcached_mget_execute(memc, (const char**)keys, key_length,
- max_keys, callbacks, &counter, 1));
+ memcached_mget_execute(memc,
+ keys.keys_ptr(), keys.lengths_ptr(),
+ keys.size(), callbacks, &counter, 1));
{
uint64_t query_id= memcached_query_id(memc);
test_compare(query_id, memcached_query_id(memc));
/* Verify that we got all of the items */
- test_true(counter == max_keys);
- }
-
- /* Release all allocated resources */
- for (size_t x= 0; x < max_keys; ++x)
- {
- free(keys[x]);
+ test_compare(keys.size(), counter);
}
- free(keys);
- free(key_length);
memcached_free(memc);
}
#define REGRESSION_BINARY_VS_BLOCK_COUNT 20480
+static pairs_st *global_pairs;
-static test_return_t key_setup(memcached_st *memc)
+test_return_t key_setup(memcached_st *memc)
{
test_skip(TEST_SUCCESS, pre_binary(memc));
return TEST_SUCCESS;
}
-static test_return_t key_teardown(memcached_st *memc)
+test_return_t key_teardown(memcached_st *)
{
- (void)memc;
pairs_free(global_pairs);
return TEST_SUCCESS;
}
-static test_return_t block_add_regression(memcached_st *memc)
+test_return_t block_add_regression(memcached_st *memc)
{
/* First add all of the items.. */
for (size_t x= 0; x < REGRESSION_BINARY_VS_BLOCK_COUNT; ++x)
return TEST_SUCCESS;
}
-static test_return_t binary_add_regression(memcached_st *memc)
+test_return_t binary_add_regression(memcached_st *memc)
{
test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true));
test_return_t rc= block_add_regression(memc);
return rc;
}
-static test_return_t get_stats_keys(memcached_st *memc)
+test_return_t get_stats_keys(memcached_st *memc)
{
char **stat_list;
char **ptr;
return TEST_SUCCESS;
}
-static test_return_t version_string_test(memcached_st *)
+test_return_t version_string_test(memcached_st *)
{
test_strcmp(LIBMEMCACHED_VERSION_STRING, memcached_lib_version());
return TEST_SUCCESS;
}
-static test_return_t get_stats(memcached_st *memc)
+test_return_t get_stats(memcached_st *memc)
{
memcached_return_t rc;
return TEST_SUCCESS;
}
-static test_return_t add_host_test(memcached_st *memc)
+test_return_t add_host_test(memcached_st *memc)
{
char servername[]= "0.example.com";
return TEST_SUCCESS;
}
-static test_return_t memcached_fetch_result_NOT_FOUND(memcached_st *memc)
+test_return_t memcached_fetch_result_NOT_FOUND(memcached_st *memc)
{
memcached_return_t rc;
return MEMCACHED_SUCCESS;
}
-static test_return_t callback_test(memcached_st *memc)
+test_return_t callback_test(memcached_st *memc)
{
/* Test User Data */
{
}
/* We don't test the behavior itself, we test the switches */
-static test_return_t behavior_test(memcached_st *memc)
+test_return_t behavior_test(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 1);
test_compare(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NO_BLOCK));
return TEST_SUCCESS;
}
-static test_return_t MEMCACHED_BEHAVIOR_CORK_test(memcached_st *memc)
+test_return_t MEMCACHED_BEHAVIOR_CORK_test(memcached_st *memc)
{
test_compare(MEMCACHED_DEPRECATED,
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_CORK, true));
}
-static test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test(memcached_st *memc)
+test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test(memcached_st *memc)
{
memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_KEEPALIVE, true);
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOT_SUPPORTED);
}
-static test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test(memcached_st *memc)
+test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test(memcached_st *memc)
{
memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_KEEPIDLE, true);
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_NOT_SUPPORTED);
return TEST_SUCCESS;
}
-static test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned, memcached_return_t& rc)
-{
- keys_returned= 0;
-
- memcached_result_st* result= NULL;
- while ((result= memcached_fetch_result(memc, result, &rc)))
- {
- test_compare(MEMCACHED_SUCCESS, rc);
- keys_returned+= 1;
- }
- memcached_result_free(result);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned)
-{
- memcached_return_t rc;
- return fetch_all_results(memc, keys_returned, rc);
-}
-
-/* Test case provided by Cal Haldenbrand */
-#define HALDENBRAND_KEY_COUNT 3000U // * 1024576
-#define HALDENBRAND_FLAG_KEY 99 // * 1024576
-static test_return_t user_supplied_bug1(memcached_st *memc)
-{
- /* We just keep looking at the same values over and over */
- srandom(10);
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true));
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true));
-
-
- /* add key */
- unsigned long long total= 0;
- for (uint32_t x= 0 ; total < 20 * 1024576 ; x++ )
- {
- uint32_t size= (uint32_t)(rand() % ( 5 * 1024 ) ) + 400;
- char randomstuff[6 * 1024];
- memset(randomstuff, 0, 6 * 1024);
- test_true(size < 6 * 1024); /* Being safe here */
-
- for (uint32_t j= 0 ; j < size ;j++)
- {
- randomstuff[j] = (signed char) ((rand() % 26) + 97);
- }
-
- total+= size;
- char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- int key_length= snprintf(key, sizeof(key), "%u", x);
- test_compare(MEMCACHED_SUCCESS,
- memcached_set(memc, key, key_length,
- randomstuff, strlen(randomstuff),
- time_t(0), HALDENBRAND_FLAG_KEY));
- }
- test_true(total > HALDENBRAND_KEY_COUNT);
-
- return TEST_SUCCESS;
-}
-
-/* Test case provided by Cal Haldenbrand */
-static test_return_t user_supplied_bug2(memcached_st *memc)
-{
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true));
-
-#ifdef NOT_YET
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, 20 * 1024576));
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, 20 * 1024576));
- getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE);
- getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE);
-
- for (x= 0, errors= 0; total < 20 * 1024576 ; x++)
-#endif
-
- size_t total_value_length= 0;
- for (uint32_t x= 0, errors= 0; total_value_length < 24576 ; x++)
- {
- uint32_t flags= 0;
- size_t val_len= 0;
-
- char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- int key_length= snprintf(key, sizeof(key), "%u", x);
-
- memcached_return_t rc;
- char *getval= memcached_get(memc, key, key_length, &val_len, &flags, &rc);
- if (memcached_failed(rc))
- {
- if (rc == MEMCACHED_NOTFOUND)
- {
- errors++;
- }
- else
- {
- test_true(rc);
- }
-
- continue;
- }
- test_compare(uint32_t(HALDENBRAND_FLAG_KEY), flags);
- test_true(getval);
-
- total_value_length+= val_len;
- errors= 0;
- ::free(getval);
- }
-
- return TEST_SUCCESS;
-}
-
-/* Do a large mget() over all the keys we think exist */
-static test_return_t user_supplied_bug3(memcached_st *memc)
-{
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, true));
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true));
-
-#ifdef NOT_YET
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, 20 * 1024576);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, 20 * 1024576);
- getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE);
- getter = memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE);
-#endif
-
- std::vector<size_t> key_lengths;
- key_lengths.resize(HALDENBRAND_KEY_COUNT);
- std::vector<char *> keys;
- keys.resize(key_lengths.size());
- for (uint32_t x= 0; x < key_lengths.size(); x++)
- {
- char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- int key_length= snprintf(key, sizeof(key), "%u", x);
- test_true(key_length > 0 and key_length < MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1);
- keys[x]= strdup(key);
- key_lengths[x]= key_length;
- }
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, &keys[0], &key_lengths[0], key_lengths.size()));
-
- unsigned int keys_returned;
- test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned));
- test_compare(HALDENBRAND_KEY_COUNT, keys_returned);
-
- for (std::vector<char *>::iterator iter= keys.begin();
- iter != keys.end();
- iter++)
- {
- ::free(*iter);
- }
-
- return TEST_SUCCESS;
-}
-
/* Make sure we behave properly if server list has no values */
-static test_return_t user_supplied_bug4(memcached_st *memc)
+test_return_t user_supplied_bug4(memcached_st *memc)
{
const char *keys[]= {"fudge", "son", "food"};
size_t key_length[]= {5, 3, 4};
}
#define VALUE_SIZE_BUG5 1048064
-static test_return_t user_supplied_bug5(memcached_st *memc)
+test_return_t user_supplied_bug5(memcached_st *memc)
{
const char *keys[]= {"036790384900", "036790384902", "036790384904", "036790384906"};
size_t key_length[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")};
return TEST_SUCCESS;
}
-static test_return_t user_supplied_bug6(memcached_st *memc)
+test_return_t user_supplied_bug6(memcached_st *memc)
{
const char *keys[]= {"036790384900", "036790384902", "036790384904", "036790384906"};
size_t key_length[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")};
return TEST_SUCCESS;
}
-static test_return_t user_supplied_bug8(memcached_st *)
+test_return_t user_supplied_bug8(memcached_st *)
{
memcached_return_t rc;
memcached_st *mine;
}
/* Test flag store/retrieve */
-static test_return_t user_supplied_bug7(memcached_st *memc)
+test_return_t user_supplied_bug7(memcached_st *memc)
{
char *insert_data= new (std::nothrow) char[VALUE_SIZE_BUG5];
test_true(insert_data);
return TEST_SUCCESS;
}
-static test_return_t user_supplied_bug9(memcached_st *memc)
+test_return_t user_supplied_bug9(memcached_st *memc)
{
const char *keys[]= {"UDATA:edevil@sapo.pt", "fudge&*@#", "for^#@&$not"};
size_t key_length[3];
}
/* We are testing with aggressive timeout to get failures */
-static test_return_t user_supplied_bug10(memcached_st *memc)
+test_return_t user_supplied_bug10(memcached_st *memc)
{
+ test_skip(memc->servers[0].type, MEMCACHED_CONNECTION_TCP);
+
size_t value_length= 512;
unsigned int set= 1;
memcached_st *mclone= memcached_clone(NULL, memc);
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_TCP_NODELAY, set);
memcached_behavior_set(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, uint64_t(0));
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(value_length);
for (uint32_t x= 0; x < value_length; x++)
{
/*
We are looking failures in the async protocol
*/
-static test_return_t user_supplied_bug11(memcached_st *memc)
+test_return_t user_supplied_bug11(memcached_st *memc)
{
memcached_st *mclone= memcached_clone(NULL, memc);
test_compare(-1, int32_t(memcached_behavior_get(mclone, MEMCACHED_BEHAVIOR_POLL_TIMEOUT)));
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(512);
for (unsigned int x= 0; x < 512; x++)
{
/*
Bug found where incr was not returning MEMCACHED_NOTFOUND when object did not exist.
*/
-static test_return_t user_supplied_bug12(memcached_st *memc)
+test_return_t user_supplied_bug12(memcached_st *memc)
{
memcached_return_t rc;
uint32_t flags;
Bug found where command total one more than MEMCACHED_MAX_BUFFER
set key34567890 0 0 8169 \r\n is sent followed by buffer of size 8169, followed by 8169
*/
-static test_return_t user_supplied_bug13(memcached_st *memc)
+test_return_t user_supplied_bug13(memcached_st *memc)
{
char key[] = "key34567890";
- memcached_return_t rc;
- size_t overflowSize;
char commandFirst[]= "set key34567890 0 0 ";
char commandLast[] = " \r\n"; /* first line of command sent to server */
size_t commandLength;
- size_t testSize;
commandLength = strlen(commandFirst) + strlen(commandLast) + 4; /* 4 is number of characters in size, probably 8196 */
- overflowSize = MEMCACHED_MAX_BUFFER - commandLength;
+ size_t overflowSize = MEMCACHED_MAX_BUFFER - commandLength;
- for (testSize= overflowSize - 1; testSize < overflowSize + 1; testSize++)
+ for (size_t testSize= overflowSize - 1; testSize < overflowSize + 1; testSize++)
{
char *overflow= new (std::nothrow) char[testSize];
test_true(overflow);
memset(overflow, 'x', testSize);
- rc= memcached_set(memc, key, strlen(key),
- overflow, testSize, 0, 0);
- test_compare(MEMCACHED_SUCCESS, rc);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(memc, key, strlen(key),
+ overflow, testSize, 0, 0));
delete [] overflow;
}
set key34567890 0 0 8169 \r\n
is sent followed by buffer of size 8169, followed by 8169
*/
-static test_return_t user_supplied_bug14(memcached_st *memc)
+test_return_t user_supplied_bug14(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true);
- std::vector<char> value;
+ libtest::vchar_t value;
value.reserve(18000);
for (size_t x= 0; x < 18000; x++)
{
/*
Look for zero length value problems
*/
-static test_return_t user_supplied_bug15(memcached_st *memc)
+test_return_t user_supplied_bug15(memcached_st *memc)
{
for (uint32_t x= 0; x < 2; x++)
{
&length, &flags, &rc);
test_compare(MEMCACHED_SUCCESS, rc);
- test_true(value == NULL);
+ test_null(value);
test_zero(length);
test_zero(flags);
}
}
/* Check the return sizes on FLAGS to make sure it stores 32bit unsigned values correctly */
-static test_return_t user_supplied_bug16(memcached_st *memc)
+test_return_t user_supplied_bug16(memcached_st *memc)
{
test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("mykey"),
NULL, 0,
#if !defined(__sun) && !defined(__OpenBSD__)
/* Check the validity of chinese key*/
-static test_return_t user_supplied_bug17(memcached_st *memc)
+test_return_t user_supplied_bug17(memcached_st *memc)
{
const char *key= "豆瓣";
const char *value="我们在炎热抑郁的夏天无法停止豆瓣";
From Andrei on IRC
*/
-static test_return_t user_supplied_bug19(memcached_st *)
+test_return_t user_supplied_bug19(memcached_st *)
{
memcached_return_t res;
}
/* CAS test from Andei */
-static test_return_t user_supplied_bug20(memcached_st *memc)
+test_return_t user_supplied_bug20(memcached_st *memc)
{
const char *key= "abc";
size_t key_len= strlen("abc");
}
-static test_return_t _user_supplied_bug21(memcached_st* memc, size_t key_count)
+test_return_t _user_supplied_bug21(memcached_st* memc, size_t key_count)
{
#ifdef WIN32
(void)memc;
/* empty the cache to ensure misses (hence non-responses) */
test_compare(MEMCACHED_SUCCESS, memcached_flush(memc_clone, 0));
- std::vector<size_t> key_lengths;
- key_lengths.resize(key_count);
- std::vector<char *> keys;
- keys.resize(key_lengths.size());
- for (unsigned int x= 0; x < key_lengths.size(); x++)
- {
- char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- int key_length= snprintf(key, sizeof(key), "%u", x);
- test_true(key_length > 0 and key_length < MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1);
- keys[x]= strdup(key);
- key_lengths[x]= key_length;
- }
+ keys_st keys(key_count);
oldalarm= signal(SIGALRM, fail);
alarm(5);
test_compare_got(MEMCACHED_SUCCESS,
- memcached_mget(memc_clone, &keys[0], &key_lengths[0], key_count), memcached_last_error_message(memc_clone));
+ memcached_mget(memc_clone, keys.keys_ptr(), keys.lengths_ptr(), keys.size()),
+ memcached_last_error_message(memc_clone));
alarm(0);
signal(SIGALRM, oldalarm);
test_false(return_key[0]);
test_false(return_value);
- for (std::vector<char *>::iterator iter= keys.begin();
- iter != keys.end();
- iter++)
- {
- free(*iter);
- }
-
memcached_free(memc_clone);
return TEST_SUCCESS;
#endif
}
-static test_return_t user_supplied_bug21(memcached_st *memc)
+test_return_t user_supplied_bug21(memcached_st *memc)
{
test_skip(TEST_SUCCESS, pre_binary(memc));
return TEST_SUCCESS;
}
-static test_return_t output_ketama_weighted_keys(memcached_st *)
+test_return_t output_ketama_weighted_keys(memcached_st *)
{
memcached_st *memc= memcached_create(NULL);
test_true(memc);
}
-static test_return_t result_static(memcached_st *memc)
+test_return_t result_static(memcached_st *memc)
{
memcached_result_st result;
memcached_result_st *result_ptr= memcached_result_create(memc, &result);
return TEST_SUCCESS;
}
-static test_return_t result_alloc(memcached_st *memc)
+test_return_t result_alloc(memcached_st *memc)
{
memcached_result_st *result_ptr= memcached_result_create(memc, NULL);
test_true(result_ptr);
return TEST_SUCCESS;
}
-static test_return_t cleanup_pairs(memcached_st *memc)
-{
- (void)memc;
- pairs_free(global_pairs);
-
- return TEST_SUCCESS;
-}
-static test_return_t generate_pairs(memcached_st *)
+test_return_t add_host_test1(memcached_st *memc)
{
- global_pairs= pairs_generate(GLOBAL_COUNT, 400);
- global_count= GLOBAL_COUNT;
+ memcached_return_t rc;
+ char servername[]= "0.example.com";
+
+ memcached_server_st *servers= memcached_server_list_append_with_weight(NULL, servername, 400, 0, &rc);
+ test_true(servers);
+ test_compare(1U, memcached_server_list_count(servers));
- for (size_t x= 0; x < global_count; x++)
+ for (uint32_t x= 2; x < 20; x++)
{
- global_keys[x]= global_pairs[x].key;
- global_keys_length[x]= global_pairs[x].key_length;
- }
+ char buffer[SMALL_STRING_LEN];
- return TEST_SUCCESS;
-}
+ snprintf(buffer, SMALL_STRING_LEN, "%lu.example.com", (unsigned long)(400 +x));
+ servers= memcached_server_list_append_with_weight(servers, buffer, 401, 0,
+ &rc);
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_compare(x, memcached_server_list_count(servers));
+ }
-static test_return_t generate_large_pairs(memcached_st *)
-{
- global_pairs= pairs_generate(GLOBAL2_COUNT, MEMCACHED_MAX_BUFFER+10);
- global_count= GLOBAL2_COUNT;
+ test_compare(MEMCACHED_SUCCESS, memcached_server_push(memc, servers));
+ test_compare(MEMCACHED_SUCCESS, memcached_server_push(memc, servers));
- for (size_t x= 0; x < global_count; x++)
- {
- global_keys[x]= global_pairs[x].key;
- global_keys_length[x]= global_pairs[x].key_length;
- }
+ memcached_server_list_free(servers);
return TEST_SUCCESS;
}
-static test_return_t generate_data(memcached_st *memc)
-{
- unsigned int check_execute= execute_set(memc, global_pairs, global_count);
-
- test_compare_warn_hint(global_count, check_execute, "Possible false, positive, memcached may have ejected key/value based on memory needs");
-
- return TEST_SUCCESS;
-}
-
-static test_return_t generate_data_with_stats(memcached_st *memc)
-{
- unsigned int check_execute= execute_set(memc, global_pairs, global_count);
-
- test_compare(check_execute, global_count);
-
- // @todo hosts used size stats
- memcached_return_t rc;
- memcached_stat_st *stat_p= memcached_stat(memc, NULL, &rc);
- test_true(stat_p);
-
- for (uint32_t host_index= 0; host_index < SERVERS_TO_CREATE; host_index++)
- {
- /* This test was changes so that "make test" would work properlly */
- if (DEBUG)
- {
- memcached_server_instance_st instance=
- memcached_server_instance_by_position(memc, host_index);
-
- printf("\nserver %u|%s|%u bytes: %llu\n", host_index, instance->hostname, instance->port, (unsigned long long)(stat_p + host_index)->bytes);
- }
- test_true((unsigned long long)(stat_p + host_index)->bytes);
- }
-
- memcached_stat_free(NULL, stat_p);
-
- return TEST_SUCCESS;
-}
-static test_return_t generate_buffer_data(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true);
- generate_data(memc);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t get_read_count(memcached_st *memc)
-{
- memcached_st *memc_clone= memcached_clone(NULL, memc);
- test_true(memc_clone);
-
- memcached_server_add_with_weight(memc_clone, "localhost", 6666, 0);
-
- {
- char *return_value;
- size_t return_value_length;
- uint32_t flags;
- uint32_t count;
-
- for (size_t x= count= 0; x < global_count; x++)
- {
- memcached_return_t rc;
- return_value= memcached_get(memc_clone, global_keys[x], global_keys_length[x],
- &return_value_length, &flags, &rc);
- if (rc == MEMCACHED_SUCCESS)
- {
- count++;
- if (return_value)
- {
- free(return_value);
- }
- }
- }
- }
-
- memcached_free(memc_clone);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t get_read(memcached_st *memc)
-{
- size_t keys_returned= 0;
- for (size_t x= 0; x < global_count; x++)
- {
- size_t return_value_length;
- uint32_t flags;
- memcached_return_t rc;
- char *return_value= memcached_get(memc, global_keys[x], global_keys_length[x],
- &return_value_length, &flags, &rc);
- /*
- test_true(return_value);
- test_compare(MEMCACHED_SUCCESS, rc);
- */
- if (rc == MEMCACHED_SUCCESS && return_value)
- {
- keys_returned++;
- free(return_value);
- }
- }
- test_compare_warn_hint(global_count, keys_returned, "Possible false, positive, memcached may have ejected key/value based on memory needs");
-
- return TEST_SUCCESS;
-}
-
-static test_return_t mget_read(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- // Go fetch the keys and test to see if all of them were returned
- {
- unsigned int keys_returned;
- test_compare(TEST_SUCCESS, fetch_all_results(memc, keys_returned));
- test_true(keys_returned > 0);
- test_compare_warn_hint(global_count, keys_returned, "Possible false, positive, memcached may have ejected key/value based on memory needs");
- }
-
- return TEST_SUCCESS;
-}
-
-static test_return_t mget_read_result(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- /* Turn this into a help function */
- {
- memcached_result_st results_obj;
- memcached_result_st *results= memcached_result_create(memc, &results_obj);
- test_true(results);
-
- memcached_return_t rc;
- while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
- {
- if (rc == MEMCACHED_IN_PROGRESS)
- {
- continue;
- }
-
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
- }
- test_compare(MEMCACHED_END, rc);
-
- memcached_result_free(&results_obj);
- }
-
- return TEST_SUCCESS;
-}
-
-static test_return_t mget_read_internal_result(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
- {
- memcached_result_st *results= NULL;
- memcached_return_t rc;
- while ((results= memcached_fetch_result(memc, results, &rc)))
- {
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
- }
- test_compare(MEMCACHED_END, rc);
-
- memcached_result_free(results);
- }
-
- return TEST_SUCCESS;
-}
-
-static test_return_t mget_read_partial_result(memcached_st *memc)
-{
-
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- // We will scan for just one key
- {
- memcached_result_st results_obj;
- memcached_result_st *results= memcached_result_create(memc, &results_obj);
-
- memcached_return_t rc;
- results= memcached_fetch_result(memc, results, &rc);
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
-
- memcached_result_free(&results_obj);
- }
-
- // We already have a read happening, lets start up another one.
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
- {
- memcached_result_st results_obj;
- memcached_result_st *results= memcached_result_create(memc, &results_obj);
- test_true(results);
- test_false(memcached_is_allocated(results));
-
- memcached_return_t rc;
- while ((results= memcached_fetch_result(memc, &results_obj, &rc)))
- {
- test_true(results);
- test_compare(MEMCACHED_SUCCESS, rc);
- }
- test_compare(MEMCACHED_END, rc);
-
- memcached_result_free(&results_obj);
- }
-
- return TEST_SUCCESS;
-}
-
-static test_return_t mget_read_function(memcached_st *memc)
-{
- test_skip(true, bool(libmemcached_util_version_check(memc, 1, 4, 4)));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, global_keys, global_keys_length, global_count));
-
- memcached_execute_fn callbacks[]= { &callback_counter };
- size_t counter= 0;
- test_compare(MEMCACHED_SUCCESS,
- memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t delete_generate(memcached_st *memc)
-{
- size_t total= 0;
- for (size_t x= 0; x < global_count; x++)
- {
- if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0)))
- {
- total++;
- }
- }
- test_compare_warn_hint(global_count, total, "Possible false, positive, memcached may have ejected key/value based on memory needs");
-
- return TEST_SUCCESS;
-}
-
-static test_return_t delete_buffer_generate(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true);
-
- size_t total= 0;
- for (size_t x= 0; x < global_count; x++)
- {
- if (memcached_success(memcached_delete(memc, global_keys[x], global_keys_length[x], (time_t)0)))
- {
- total++;
- }
- }
- test_compare_warn_hint(global_count, total, "Possible false, positive, memcached may have ejected key/value based on memory needs");
-
- return TEST_SUCCESS;
-}
-
-static test_return_t add_host_test1(memcached_st *memc)
-{
- memcached_return_t rc;
- char servername[]= "0.example.com";
-
- memcached_server_st *servers= memcached_server_list_append_with_weight(NULL, servername, 400, 0, &rc);
- test_true(servers);
- test_compare(1U, memcached_server_list_count(servers));
-
- for (uint32_t x= 2; x < 20; x++)
- {
- char buffer[SMALL_STRING_LEN];
-
- snprintf(buffer, SMALL_STRING_LEN, "%lu.example.com", (unsigned long)(400 +x));
- servers= memcached_server_list_append_with_weight(servers, buffer, 401, 0,
- &rc);
- test_compare(MEMCACHED_SUCCESS, rc);
- test_compare(x, memcached_server_list_count(servers));
- }
-
- test_compare(MEMCACHED_SUCCESS, memcached_server_push(memc, servers));
- test_compare(MEMCACHED_SUCCESS, memcached_server_push(memc, servers));
-
- memcached_server_list_free(servers);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_nonblock(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_cork(memcached_st *memc)
-{
-#ifdef __APPLE__
- return TEST_SKIPPED;
-#endif
- bool set= true;
- if (memcached_success(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_CORK, set)))
- return TEST_SUCCESS;
-
- return TEST_SKIPPED;
-}
-
-static test_return_t pre_cork_and_nonblock(memcached_st *memc)
-{
-#ifdef __APPLE__
- return TEST_SKIPPED;
-#endif
- test_return_t test_rc;
- if ((test_rc= pre_cork(memc)) != TEST_SUCCESS)
- return test_rc;
-
- return pre_nonblock(memc);
-}
-
-static test_return_t pre_nonblock_binary(memcached_st *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);
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1));
- test_compare(uint64_t(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
- }
- else
- {
- memcached_free(memc_clone);
- return TEST_SKIPPED;
- }
-
- memcached_free(memc_clone);
-
- return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED;
-}
-
-static test_return_t pre_murmur(memcached_st *memc)
-{
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR));
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_jenkins(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_JENKINS);
-
- return TEST_SKIPPED;
-}
-
-
-static test_return_t pre_md5(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MD5);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_crc(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_CRC);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_hsieh(memcached_st *memc)
-{
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH));
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_hash_fnv1_64(memcached_st *memc)
-{
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_hash_fnv1a_64(memcached_st *memc)
-{
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_64));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_hash_fnv1_32(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1_32);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_hash_fnv1a_32(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_32);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_behavior_ketama(memcached_st *memc)
-{
- memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA, 1);
- test_compare(MEMCACHED_SUCCESS, rc);
-
- uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA);
- test_compare(value, uint64_t(1));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_behavior_ketama_weighted(memcached_st *memc)
-{
- memcached_return_t 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_compare(value, uint64_t(1));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5));
-
- value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH);
- test_compare(MEMCACHED_HASH_MD5, memcached_hash_t(value));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_replication(memcached_st *memc)
-{
- test_skip(TEST_SUCCESS, pre_binary(memc));
-
- /*
- * Make sure that we store the item on all servers
- * (master + replicas == number of servers)
- */
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, memcached_server_count(memc) - 1));
- test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS), uint64_t(memcached_server_count(memc) - 1));
-
- return TEST_SUCCESS;
-}
-
-
-static test_return_t pre_replication_noblock(memcached_st *memc)
-{
- test_skip(TEST_SUCCESS, pre_replication(memc));
-
- return pre_nonblock(memc);
-}
-
static void my_free(const memcached_st *ptr, void *mem, void *context)
{
#endif
}
-static test_return_t selection_of_namespace_tests(memcached_st *memc)
+test_return_t selection_of_namespace_tests(memcached_st *memc)
{
memcached_return_t rc;
const char *key= "mine";
return TEST_SUCCESS;
}
-static test_return_t set_namespace(memcached_st *memc)
+test_return_t set_namespace(memcached_st *memc)
{
memcached_return_t rc;
const char *key= "mine";
return TEST_SUCCESS;
}
-static test_return_t set_namespace_and_binary(memcached_st *memc)
+test_return_t set_namespace_and_binary(memcached_st *memc)
{
test_return_if(pre_binary(memc));
test_return_if(set_namespace(memc));
}
#ifdef MEMCACHED_ENABLE_DEPRECATED
-static test_return_t deprecated_set_memory_alloc(memcached_st *memc)
+test_return_t deprecated_set_memory_alloc(memcached_st *memc)
{
void *test_ptr= NULL;
void *cb_ptr= NULL;
{
- memcached_malloc_fn malloc_cb=
- (memcached_malloc_fn)my_malloc;
+ memcached_malloc_fn malloc_cb= (memcached_malloc_fn)my_malloc;
cb_ptr= *(void **)&malloc_cb;
memcached_return_t rc;
#endif
-static test_return_t set_memory_alloc(memcached_st *memc)
+test_return_t set_memory_alloc(memcached_st *memc)
{
test_compare(MEMCACHED_INVALID_ARGUMENTS,
memcached_set_memory_allocators(memc, NULL, my_free,
return TEST_SUCCESS;
}
-static test_return_t enable_consistent_crc(memcached_st *memc)
+test_return_t enable_consistent_crc(memcached_st *memc)
{
test_return_t rc;
memcached_server_distribution_t value= MEMCACHED_DISTRIBUTION_CONSISTENT;
return TEST_SUCCESS;
}
-static test_return_t enable_consistent_hsieh(memcached_st *memc)
+test_return_t enable_consistent_hsieh(memcached_st *memc)
{
test_return_t rc;
memcached_server_distribution_t value= MEMCACHED_DISTRIBUTION_CONSISTENT;
return TEST_SUCCESS;
}
-static test_return_t enable_cas(memcached_st *memc)
+test_return_t enable_cas(memcached_st *memc)
{
unsigned int set= 1;
return TEST_SKIPPED;
}
-static test_return_t check_for_1_2_3(memcached_st *memc)
+test_return_t check_for_1_2_3(memcached_st *memc)
{
memcached_version(memc);
return TEST_SKIPPED;
}
-static test_return_t pre_unix_socket(memcached_st *memc)
-{
- struct stat buf;
-
- memcached_servers_reset(memc);
- const char *socket_file= default_socket();
-
- test_skip(0, stat(socket_file, &buf));
-
- test_compare(MEMCACHED_SUCCESS,
- memcached_server_add_unix_socket_with_weight(memc, socket_file, 0));
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_nodelay(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 0);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t pre_settimer(memcached_st *memc)
-{
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SND_TIMEOUT, 1000);
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RCV_TIMEOUT, 1000);
-
- return TEST_SUCCESS;
-}
-
-static test_return_t MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test(memcached_st *memc)
+test_return_t MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test(memcached_st *memc)
{
const uint64_t timeout= 100; // Not using, just checking that it sets
return TEST_SUCCESS;
}
-static test_return_t noreply_test(memcached_st *memc)
+test_return_t noreply_test(memcached_st *memc)
{
test_compare(MEMCACHED_SUCCESS,
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, true));
test_true(count);
break;
}
- test_true_got(ret == MEMCACHED_SUCCESS or ret == MEMCACHED_BUFFERED, memcached_strerror(NULL, ret));
+ test_true_got(ret == MEMCACHED_SUCCESS or ret == MEMCACHED_BUFFERED,
+ memcached_strerror(NULL, ret));
}
/*
** API and is _ONLY_ done this way to verify that the library works the
** way it is supposed to do!!!!
*/
+#if 0
int no_msg=0;
for (uint32_t x= 0; x < memcached_server_count(memc); ++x)
{
}
test_true(no_msg == 0);
+#endif
test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
/*
return TEST_SUCCESS;
}
-static test_return_t analyzer_test(memcached_st *memc)
+test_return_t analyzer_test(memcached_st *memc)
{
memcached_analysis_st *report;
memcached_return_t rc;
return TEST_SUCCESS;
}
-static test_return_t util_version_test(memcached_st *memc)
+test_return_t util_version_test(memcached_st *memc)
{
test_compare_hint(MEMCACHED_SUCCESS, memcached_version(memc), memcached_last_error_message(memc));
test_true(libmemcached_util_version_check(memc, 0, 0, 0));
return TEST_SUCCESS;
}
-static test_return_t getpid_connection_failure_test(memcached_st *memc)
+test_return_t getpid_connection_failure_test(memcached_st *memc)
{
+ test_skip(memc->servers[0].type, MEMCACHED_CONNECTION_TCP);
memcached_return_t rc;
memcached_server_instance_st instance=
memcached_server_instance_by_position(memc, 0);
}
-static test_return_t getpid_test(memcached_st *memc)
+test_return_t getpid_test(memcached_st *memc)
{
memcached_return_t rc;
memcached_server_instance_st instance=
return TEST_SUCCESS;
}
-static test_return_t ping_test(memcached_st *memc)
+test_return_t ping_test(memcached_st *memc)
{
memcached_return_t rc;
memcached_server_instance_st instance=
#if 0
-static test_return_t hash_sanity_test (memcached_st *memc)
+test_return_t hash_sanity_test (memcached_st *memc)
{
(void)memc;
}
#endif
-static test_return_t hsieh_avaibility_test (memcached_st *memc)
+test_return_t hsieh_avaibility_test (memcached_st *memc)
{
test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_HSIEH));
return TEST_SUCCESS;
}
-static test_return_t murmur_avaibility_test (memcached_st *memc)
+test_return_t murmur_avaibility_test (memcached_st *memc)
{
test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_MURMUR));
return TEST_SUCCESS;
}
-static test_return_t one_at_a_time_run (memcached_st *)
+test_return_t one_at_a_time_run (memcached_st *)
{
uint32_t x;
const char **ptr;
return TEST_SUCCESS;
}
-static test_return_t md5_run (memcached_st *)
+test_return_t md5_run (memcached_st *)
{
uint32_t x;
const char **ptr;
return TEST_SUCCESS;
}
-static test_return_t crc_run (memcached_st *)
+test_return_t crc_run (memcached_st *)
{
uint32_t x;
const char **ptr;
return TEST_SUCCESS;
}
-static test_return_t fnv1_64_run (memcached_st *)
+test_return_t fnv1_64_run (memcached_st *)
{
test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_FNV1_64));
return TEST_SUCCESS;
}
-static test_return_t fnv1a_64_run (memcached_st *)
+test_return_t fnv1a_64_run (memcached_st *)
{
test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_FNV1A_64));
return TEST_SUCCESS;
}
-static test_return_t fnv1_32_run (memcached_st *)
+test_return_t fnv1_32_run (memcached_st *)
{
uint32_t x;
const char **ptr;
return TEST_SUCCESS;
}
-static test_return_t fnv1a_32_run (memcached_st *)
+test_return_t fnv1a_32_run (memcached_st *)
{
uint32_t x;
const char **ptr;
return TEST_SUCCESS;
}
-static test_return_t hsieh_run (memcached_st *)
+test_return_t hsieh_run (memcached_st *)
{
test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_HSIEH));
return TEST_SUCCESS;
}
-static test_return_t murmur_run (memcached_st *)
+test_return_t murmur_run (memcached_st *)
{
test_skip(true, libhashkit_has_algorithm(HASHKIT_HASH_MURMUR));
#endif
}
-static test_return_t jenkins_run (memcached_st *)
+test_return_t jenkins_run (memcached_st *)
{
uint32_t x;
const char **ptr;
return libhashkit_crc32(string, string_length);
}
-static test_return_t memcached_get_hashkit_test (memcached_st *)
+test_return_t memcached_get_hashkit_test (memcached_st *)
{
uint32_t x;
const char **ptr;
We are testing the error condition when we connect to a server via memcached_get()
but find that the server is not available.
*/
-static test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *)
+test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *)
{
const char *key= "MemcachedLives";
size_t len;
/*
We connect to a server which exists, but search for a key that does not exist.
*/
-static test_return_t memcached_get_MEMCACHED_NOTFOUND(memcached_st *memc)
+test_return_t memcached_get_MEMCACHED_NOTFOUND(memcached_st *memc)
{
const char *key= "MemcachedKeyNotEXIST";
size_t len;
We are testing the error condition when we connect to a server via memcached_get_by_key()
but find that the server is not available.
*/
-static test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *memc)
+test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *memc)
{
(void)memc;
memcached_st *tl_memc_h;
/*
We connect to a server which exists, but search for a key that does not exist.
*/
-static test_return_t memcached_get_by_key_MEMCACHED_NOTFOUND(memcached_st *memc)
+test_return_t memcached_get_by_key_MEMCACHED_NOTFOUND(memcached_st *memc)
{
const char *key= "MemcachedKeyNotEXIST";
size_t len;
return TEST_SUCCESS;
}
-static test_return_t regression_bug_434484(memcached_st *memc)
+test_return_t regression_bug_434484(memcached_st *memc)
{
test_skip(TEST_SUCCESS, pre_binary(memc));
return TEST_SUCCESS;
}
-static test_return_t regression_bug_434843(memcached_st *original_memc)
+test_return_t regression_bug_434843(memcached_st *original_memc)
{
test_skip(TEST_SUCCESS, pre_binary(original_memc));
return TEST_SUCCESS;
}
-static test_return_t regression_bug_434843_buffered(memcached_st *memc)
+test_return_t regression_bug_434843_buffered(memcached_st *memc)
{
memcached_return_t rc;
rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
return regression_bug_434843(memc);
}
-static test_return_t regression_bug_421108(memcached_st *memc)
+test_return_t regression_bug_421108(memcached_st *memc)
{
memcached_return_t rc;
memcached_stat_st *memc_stat= memcached_stat(memc, NULL, &rc);
* delete command or the watermarks, we need to update this
* test....
*/
-static test_return_t regression_bug_442914(memcached_st *memc)
+test_return_t regression_bug_442914(memcached_st *memc)
{
test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1));
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1);
return TEST_SUCCESS;
}
-static test_return_t regression_bug_447342(memcached_st *memc)
+test_return_t regression_bug_447342(memcached_st *memc)
{
memcached_server_instance_st instance_one;
memcached_server_instance_st instance_two;
return TEST_SUCCESS;
}
-static test_return_t regression_bug_463297(memcached_st *memc)
+test_return_t regression_bug_463297(memcached_st *memc)
{
test_compare(MEMCACHED_INVALID_ARGUMENTS, memcached_delete(memc, "foo", 3, 1));
* For a working server set, shall be NULL
* For a set of non existing server, shall not be NULL
*/
-static test_return_t test_get_last_disconnect(memcached_st *memc)
+test_return_t test_get_last_disconnect(memcached_st *memc)
{
memcached_return_t rc;
memcached_server_instance_st disconnected_server;
return TEST_SUCCESS;
}
-static test_return_t test_multiple_get_last_disconnect(memcached_st *)
+test_return_t test_multiple_get_last_disconnect(memcached_st *)
{
const char *server_string= "--server=localhost:8888 --server=localhost:8889 --server=localhost:8890 --server=localhost:8891 --server=localhost:8892";
char buffer[BUFSIZ];
return TEST_SUCCESS;
}
-static test_return_t test_verbosity(memcached_st *memc)
+test_return_t test_verbosity(memcached_st *memc)
{
memcached_verbosity(memc, 3);
return MEMCACHED_SUCCESS;
}
-static test_return_t memcached_stat_execute_test(memcached_st *memc)
+test_return_t memcached_stat_execute_test(memcached_st *memc)
{
memcached_return_t rc= memcached_stat_execute(memc, NULL, stat_printer, NULL);
test_compare(MEMCACHED_SUCCESS, rc);
* This test ensures that the failure counter isn't incremented during
* normal termination of the memcached instance.
*/
-static test_return_t wrong_failure_counter_test(memcached_st *memc)
+test_return_t wrong_failure_counter_test(memcached_st *memc)
{
memcached_return_t rc;
memcached_server_instance_st instance;
* This tests ensures expected disconnections (for some behavior changes
* for instance) do not wrongly increase failure counter
*/
-static test_return_t wrong_failure_counter_two_test(memcached_st *memc)
+test_return_t wrong_failure_counter_two_test(memcached_st *memc)
{
/* Set value to force connection to the server */
const char *key= "marmotte";
/*
* Test that ensures mget_execute does not end into recursive calls that finally fails
*/
-static test_return_t regression_bug_490486(memcached_st *original_memc)
+test_return_t regression_bug_490486(memcached_st *original_memc)
{
#ifdef __APPLE__
return TEST_SUCCESS;
}
-static test_return_t regression_bug_583031(memcached_st *)
+test_return_t regression_bug_583031(memcached_st *)
{
memcached_st *memc= memcached_create(NULL);
test_true(memc);
return TEST_SUCCESS;
}
-static test_return_t regression_bug_581030(memcached_st *)
+test_return_t regression_bug_581030(memcached_st *)
{
#ifndef DEBUG
memcached_stat_st *local_stat= memcached_stat(NULL, NULL, NULL);
}
#define regression_bug_655423_COUNT 6000
-static test_return_t regression_bug_655423(memcached_st *memc)
+test_return_t regression_bug_655423(memcached_st *memc)
{
memcached_st *clone= memcached_clone(NULL, memc);
memc= NULL; // Just to make sure it is not used
* Test that ensures that buffered set to not trigger problems during io_flush
*/
#define regression_bug_490520_COUNT 200480
-static test_return_t regression_bug_490520(memcached_st *memc)
+test_return_t regression_bug_490520(memcached_st *memc)
{
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK,1);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS,1);
}
-static test_return_t regression_bug_854604(memcached_st *)
+test_return_t regression_bug_854604(memcached_st *)
{
char buffer[1024];
#define TEST_CONSTANT_CREATION 200
-static test_return_t regression_bug_(memcached_st *memc)
+test_return_t regression_bug_(memcached_st *memc)
{
const char *remote_server;
(void)memc;
return TEST_SUCCESS;
}
-
-/* Clean the server before beginning testing */
-test_st tests[] ={
- {"util_version", true, (test_callback_fn*)util_version_test },
- {"flush", false, (test_callback_fn*)flush_test },
- {"init", false, (test_callback_fn*)init_test },
- {"allocation", false, (test_callback_fn*)allocation_test },
- {"server_list_null_test", false, (test_callback_fn*)server_list_null_test},
- {"server_unsort", false, (test_callback_fn*)server_unsort_test},
- {"server_sort", false, (test_callback_fn*)server_sort_test},
- {"server_sort2", false, (test_callback_fn*)server_sort2_test},
- {"memcached_server_remove", false, (test_callback_fn*)memcached_server_remove_test},
- {"clone_test", false, (test_callback_fn*)clone_test },
- {"connection_test", false, (test_callback_fn*)connection_test},
- {"callback_test", false, (test_callback_fn*)callback_test},
- {"userdata_test", false, (test_callback_fn*)userdata_test},
- {"memcached_set()", false, (test_callback_fn*)set_test },
- {"memcached_set() 2", false, (test_callback_fn*)set_test2 },
- {"memcached_set() 3", false, (test_callback_fn*)set_test3 },
- {"add", true, (test_callback_fn*)add_test },
- {"memcached_fetch_result(MEMCACHED_NOTFOUND)", true, (test_callback_fn*)memcached_fetch_result_NOT_FOUND },
- {"replace", true, (test_callback_fn*)replace_test },
- {"delete", true, (test_callback_fn*)delete_test },
- {"get", true, (test_callback_fn*)get_test },
- {"get2", false, (test_callback_fn*)get_test2 },
- {"get3", false, (test_callback_fn*)get_test3 },
- {"get4", false, (test_callback_fn*)get_test4 },
- {"partial mget", false, (test_callback_fn*)get_test5 },
- {"stats_servername", false, (test_callback_fn*)stats_servername_test },
- {"increment", false, (test_callback_fn*)increment_test },
- {"increment_with_initial", true, (test_callback_fn*)increment_with_initial_test },
- {"decrement", false, (test_callback_fn*)decrement_test },
- {"decrement_with_initial", true, (test_callback_fn*)decrement_with_initial_test },
- {"increment_by_key", false, (test_callback_fn*)increment_by_key_test },
- {"increment_with_initial_by_key", true, (test_callback_fn*)increment_with_initial_by_key_test },
- {"decrement_by_key", false, (test_callback_fn*)decrement_by_key_test },
- {"decrement_with_initial_by_key", true, (test_callback_fn*)decrement_with_initial_by_key_test },
- {"binary_increment_with_prefix", 1, (test_callback_fn*)binary_increment_with_prefix_test },
- {"quit", false, (test_callback_fn*)quit_test },
- {"mget", true, (test_callback_fn*)mget_test },
- {"mget_result", true, (test_callback_fn*)mget_result_test },
- {"mget_result_alloc", true, (test_callback_fn*)mget_result_alloc_test },
- {"mget_result_function", true, (test_callback_fn*)mget_result_function },
- {"mget_execute", true, (test_callback_fn*)mget_execute },
- {"mget_end", false, (test_callback_fn*)mget_end },
- {"get_stats", false, (test_callback_fn*)get_stats },
- {"add_host_test", false, (test_callback_fn*)add_host_test },
- {"add_host_test_1", false, (test_callback_fn*)add_host_test1 },
- {"get_stats_keys", false, (test_callback_fn*)get_stats_keys },
- {"version_string_test", false, (test_callback_fn*)version_string_test},
- {"bad_key", true, (test_callback_fn*)bad_key_test },
- {"memcached_server_cursor", true, (test_callback_fn*)memcached_server_cursor_test },
- {"read_through", true, (test_callback_fn*)read_through },
- {"delete_through", true, (test_callback_fn*)test_MEMCACHED_CALLBACK_DELETE_TRIGGER },
- {"noreply", true, (test_callback_fn*)noreply_test},
- {"analyzer", true, (test_callback_fn*)analyzer_test},
- {"memcached_pool_st", true, (test_callback_fn*)connection_pool_test },
- {"memcached_pool_st #2", true, (test_callback_fn*)connection_pool2_test },
-#if 0
- {"memcached_pool_st #3", true, (test_callback_fn*)connection_pool3_test },
-#endif
- {"memcached_pool_test", true, (test_callback_fn*)memcached_pool_test },
- {"test_get_last_disconnect", true, (test_callback_fn*)test_get_last_disconnect},
- {"verbosity", true, (test_callback_fn*)test_verbosity},
- {"memcached_stat_execute", true, (test_callback_fn*)memcached_stat_execute_test},
- {"memcached_exist(MEMCACHED_NOTFOUND)", true, (test_callback_fn*)memcached_exist_NOTFOUND },
- {"memcached_exist(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_exist_SUCCESS },
- {"memcached_exist_by_key(MEMCACHED_NOTFOUND)", true, (test_callback_fn*)memcached_exist_by_key_NOTFOUND },
- {"memcached_exist_by_key(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_exist_by_key_SUCCESS },
- {"memcached_touch", 0, (test_callback_fn*)test_memcached_touch},
- {"memcached_touch_with_prefix", 0, (test_callback_fn*)test_memcached_touch_by_key},
-#if 0
- {"memcached_dump() no data", true, (test_callback_fn*)memcached_dump_TEST },
-#endif
- {"memcached_dump() with data", true, (test_callback_fn*)memcached_dump_TEST2 },
- {0, 0, 0}
-};
-
-test_st touch_tests[] ={
- {"memcached_touch", 0, (test_callback_fn*)test_memcached_touch},
- {"memcached_touch_with_prefix", 0, (test_callback_fn*)test_memcached_touch_by_key},
- {0, 0, 0}
-};
-
-test_st memcached_stat_tests[] ={
- {"memcached_stat() INVALID ARG", 0, (test_callback_fn*)memcached_stat_TEST},
- {"memcached_stat()", 0, (test_callback_fn*)memcached_stat_TEST2},
- {0, 0, 0}
-};
-
-test_st behavior_tests[] ={
- {"libmemcached_string_behavior()", false, (test_callback_fn*)libmemcached_string_behavior_test},
- {"libmemcached_string_distribution()", false, (test_callback_fn*)libmemcached_string_distribution_test},
- {"behavior_test", false, (test_callback_fn*)behavior_test},
- {"MEMCACHED_BEHAVIOR_CORK", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_CORK_test},
- {"MEMCACHED_BEHAVIOR_TCP_KEEPALIVE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test},
- {"MEMCACHED_BEHAVIOR_TCP_KEEPIDLE", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test},
- {"MEMCACHED_BEHAVIOR_POLL_TIMEOUT", false, (test_callback_fn*)MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test},
- {"MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY", false, (test_callback_fn*)test_MEMCACHED_CALLBACK_DELETE_TRIGGER_and_MEMCACHED_BEHAVIOR_NOREPLY},
- {0, 0, 0}
-};
-
-test_st libmemcachedutil_tests[] ={
- {"libmemcached_util_ping()", true, (test_callback_fn*)ping_test },
- {"libmemcached_util_getpid()", true, (test_callback_fn*)getpid_test },
- {"libmemcached_util_getpid(MEMCACHED_CONNECTION_FAILURE)", true, (test_callback_fn*)getpid_connection_failure_test },
- {0, 0, 0}
-};
-
-test_st basic_tests[] ={
- {"init", true, (test_callback_fn*)basic_init_test},
- {"clone", true, (test_callback_fn*)basic_clone_test},
- {"reset", true, (test_callback_fn*)basic_reset_stack_test},
- {"reset heap", true, (test_callback_fn*)basic_reset_heap_test},
- {"reset stack clone", true, (test_callback_fn*)basic_reset_stack_clone_test},
- {"reset heap clone", true, (test_callback_fn*)basic_reset_heap_clone_test},
- {"memcached_return_t", false, (test_callback_fn*)memcached_return_t_TEST },
- {0, 0, 0}
-};
-
-test_st regression_binary_vs_block[] ={
- {"block add", true, (test_callback_fn*)block_add_regression},
- {"binary add", true, (test_callback_fn*)binary_add_regression},
- {0, 0, 0}
-};
-
-test_st async_tests[] ={
- {"add", true, (test_callback_fn*)add_wrapper },
- {0, 0, 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}
-};
-
-
-test_st result_tests[] ={
- {"result static", false, (test_callback_fn*)result_static},
- {"result alloc", false, (test_callback_fn*)result_alloc},
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st version_1_2_3[] ={
- {"append", false, (test_callback_fn*)append_test },
- {"prepend", false, (test_callback_fn*)prepend_test },
- {"cas", false, (test_callback_fn*)cas_test },
- {"cas2", false, (test_callback_fn*)cas2_test },
- {"append_binary", false, (test_callback_fn*)append_binary_test },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st haldenbrand_tests[] ={
- {"memcached_set", false, (test_callback_fn*)user_supplied_bug1 },
- {"memcached_get()", false, (test_callback_fn*)user_supplied_bug2 },
- {"memcached_mget()", false, (test_callback_fn*)user_supplied_bug3 },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st user_tests[] ={
- {"user_supplied_bug4", true, (test_callback_fn*)user_supplied_bug4 },
- {"user_supplied_bug5", true, (test_callback_fn*)user_supplied_bug5 },
- {"user_supplied_bug6", true, (test_callback_fn*)user_supplied_bug6 },
- {"user_supplied_bug7", true, (test_callback_fn*)user_supplied_bug7 },
- {"user_supplied_bug8", true, (test_callback_fn*)user_supplied_bug8 },
- {"user_supplied_bug9", true, (test_callback_fn*)user_supplied_bug9 },
- {"user_supplied_bug10", true, (test_callback_fn*)user_supplied_bug10 },
- {"user_supplied_bug11", true, (test_callback_fn*)user_supplied_bug11 },
- {"user_supplied_bug12", true, (test_callback_fn*)user_supplied_bug12 },
- {"user_supplied_bug13", true, (test_callback_fn*)user_supplied_bug13 },
- {"user_supplied_bug14", true, (test_callback_fn*)user_supplied_bug14 },
- {"user_supplied_bug15", true, (test_callback_fn*)user_supplied_bug15 },
- {"user_supplied_bug16", true, (test_callback_fn*)user_supplied_bug16 },
-#if !defined(__sun) && !defined(__OpenBSD__)
- /*
- ** It seems to be something weird with the character sets..
- ** value_fetch is unable to parse the value line (iscntrl "fails"), so I
- ** guess I need to find out how this is supposed to work.. Perhaps I need
- ** to run the test in a specific locale (I tried zh_CN.UTF-8 without success,
- ** so just disable the code for now...).
- */
- {"user_supplied_bug17", true, (test_callback_fn*)user_supplied_bug17 },
-#endif
- {"user_supplied_bug18", true, (test_callback_fn*)user_supplied_bug18 },
- {"user_supplied_bug19", true, (test_callback_fn*)user_supplied_bug19 },
- {"user_supplied_bug20", true, (test_callback_fn*)user_supplied_bug20 },
- {"user_supplied_bug21", true, (test_callback_fn*)user_supplied_bug21 },
- {"wrong_failure_counter_test", true, (test_callback_fn*)wrong_failure_counter_test},
- {"wrong_failure_counter_two_test", true, (test_callback_fn*)wrong_failure_counter_two_test},
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st replication_tests[]= {
- {"set", true, (test_callback_fn*)replication_set_test },
- {"get", false, (test_callback_fn*)replication_get_test },
- {"mget", false, (test_callback_fn*)replication_mget_test },
- {"delete", true, (test_callback_fn*)replication_delete_test },
- {"rand_mget", false, (test_callback_fn*)replication_randomize_mget_test },
- {"miss", false, (test_callback_fn*)replication_miss_test },
- {"fail", false, (test_callback_fn*)replication_randomize_mget_fail_test },
- {0, 0, (test_callback_fn*)0}
-};
-
-/*
- * The following test suite is used to verify that we don't introduce
- * regression bugs. If you want more information about the bug / test,
- * you should look in the bug report at
- * http://bugs.launchpad.net/libmemcached
- */
-test_st regression_tests[]= {
- {"lp:434484", true, (test_callback_fn*)regression_bug_434484 },
- {"lp:434843", true, (test_callback_fn*)regression_bug_434843 },
- {"lp:434843-buffered", true, (test_callback_fn*)regression_bug_434843_buffered },
- {"lp:421108", true, (test_callback_fn*)regression_bug_421108 },
- {"lp:442914", true, (test_callback_fn*)regression_bug_442914 },
- {"lp:447342", true, (test_callback_fn*)regression_bug_447342 },
- {"lp:463297", true, (test_callback_fn*)regression_bug_463297 },
- {"lp:490486", true, (test_callback_fn*)regression_bug_490486 },
- {"lp:583031", true, (test_callback_fn*)regression_bug_583031 },
- {"lp:?", true, (test_callback_fn*)regression_bug_ },
- {"lp:728286", true, (test_callback_fn*)regression_bug_728286 },
- {"lp:581030", true, (test_callback_fn*)regression_bug_581030 },
- {"lp:71231153 connect()", true, (test_callback_fn*)regression_bug_71231153_connect },
- {"lp:71231153 poll()", true, (test_callback_fn*)regression_bug_71231153_poll },
- {"lp:655423", true, (test_callback_fn*)regression_bug_655423 },
- {"lp:490520", true, (test_callback_fn*)regression_bug_490520 },
- {"lp:854604", true, (test_callback_fn*)regression_bug_854604 },
- {0, false, (test_callback_fn*)0}
-};
-
-test_st ketama_compatibility[]= {
- {"libmemcached", true, (test_callback_fn*)ketama_compatibility_libmemcached },
- {"spymemcached", true, (test_callback_fn*)ketama_compatibility_spymemcached },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st generate_tests[] ={
- {"generate_pairs", true, (test_callback_fn*)generate_pairs },
- {"generate_data", true, (test_callback_fn*)generate_data },
- {"get_read", false, (test_callback_fn*)get_read },
- {"delete_generate", false, (test_callback_fn*)delete_generate },
- {"generate_buffer_data", true, (test_callback_fn*)generate_buffer_data },
- {"delete_buffer", false, (test_callback_fn*)delete_buffer_generate},
- {"generate_data", true, (test_callback_fn*)generate_data },
- {"mget_read", false, (test_callback_fn*)mget_read },
- {"mget_read_result", false, (test_callback_fn*)mget_read_result },
- {"memcached_fetch_result() use internal result", false, (test_callback_fn*)mget_read_internal_result },
- {"memcached_fetch_result() partial read", false, (test_callback_fn*)mget_read_partial_result },
- {"mget_read_function", false, (test_callback_fn*)mget_read_function },
- {"cleanup", true, (test_callback_fn*)cleanup_pairs },
- {"generate_large_pairs", true, (test_callback_fn*)generate_large_pairs },
- {"generate_data", true, (test_callback_fn*)generate_data },
- {"generate_buffer_data", true, (test_callback_fn*)generate_buffer_data },
- {"cleanup", true, (test_callback_fn*)cleanup_pairs },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st consistent_tests[] ={
- {"generate_pairs", true, (test_callback_fn*)generate_pairs },
- {"generate_data", true, (test_callback_fn*)generate_data },
- {"get_read", 0, (test_callback_fn*)get_read_count },
- {"cleanup", true, (test_callback_fn*)cleanup_pairs },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st consistent_weighted_tests[] ={
- {"generate_pairs", true, (test_callback_fn*)generate_pairs },
- {"generate_data", true, (test_callback_fn*)generate_data_with_stats },
- {"get_read", false, (test_callback_fn*)get_read_count },
- {"cleanup", true, (test_callback_fn*)cleanup_pairs },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st hsieh_availability[] ={
- {"hsieh_avaibility_test", false, (test_callback_fn*)hsieh_avaibility_test},
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st murmur_availability[] ={
- {"murmur_avaibility_test", false, (test_callback_fn*)murmur_avaibility_test},
- {0, 0, (test_callback_fn*)0}
-};
-
-#if 0
-test_st hash_sanity[] ={
- {"hash sanity", 0, (test_callback_fn*)hash_sanity_test},
- {0, 0, (test_callback_fn*)0}
-};
-#endif
-
-test_st ketama_auto_eject_hosts[] ={
- {"auto_eject_hosts", true, (test_callback_fn*)auto_eject_hosts },
- {"output_ketama_weighted_keys", true, (test_callback_fn*)output_ketama_weighted_keys },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st hash_tests[] ={
- {"one_at_a_time_run", false, (test_callback_fn*)one_at_a_time_run },
- {"md5", false, (test_callback_fn*)md5_run },
- {"crc", false, (test_callback_fn*)crc_run },
- {"fnv1_64", false, (test_callback_fn*)fnv1_64_run },
- {"fnv1a_64", false, (test_callback_fn*)fnv1a_64_run },
- {"fnv1_32", false, (test_callback_fn*)fnv1_32_run },
- {"fnv1a_32", false, (test_callback_fn*)fnv1a_32_run },
- {"hsieh", false, (test_callback_fn*)hsieh_run },
- {"murmur", false, (test_callback_fn*)murmur_run },
- {"jenkis", false, (test_callback_fn*)jenkins_run },
- {"memcached_get_hashkit", false, (test_callback_fn*)memcached_get_hashkit_test },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st error_conditions[] ={
- {"memcached_get(MEMCACHED_ERRNO)", false, (test_callback_fn*)memcached_get_MEMCACHED_ERRNO },
- {"memcached_get(MEMCACHED_NOTFOUND)", false, (test_callback_fn*)memcached_get_MEMCACHED_NOTFOUND },
- {"memcached_get_by_key(MEMCACHED_ERRNO)", false, (test_callback_fn*)memcached_get_by_key_MEMCACHED_ERRNO },
- {"memcached_get_by_key(MEMCACHED_NOTFOUND)", false, (test_callback_fn*)memcached_get_by_key_MEMCACHED_NOTFOUND },
- {"memcached_get_by_key(MEMCACHED_NOTFOUND)", false, (test_callback_fn*)memcached_get_by_key_MEMCACHED_NOTFOUND },
- {"memcached_increment(MEMCACHED_NO_SERVERS)", false, (test_callback_fn*)memcached_increment_MEMCACHED_NO_SERVERS },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st parser_tests[] ={
- {"behavior", false, (test_callback_fn*)behavior_parser_test },
- {"boolean_options", false, (test_callback_fn*)parser_boolean_options_test },
- {"configure_file", false, (test_callback_fn*)memcached_create_with_options_with_filename },
- {"distribtions", false, (test_callback_fn*)parser_distribution_test },
- {"hash", false, (test_callback_fn*)parser_hash_test },
- {"libmemcached_check_configuration", false, (test_callback_fn*)libmemcached_check_configuration_test },
- {"libmemcached_check_configuration_with_filename", false, (test_callback_fn*)libmemcached_check_configuration_with_filename_test },
- {"number_options", false, (test_callback_fn*)parser_number_options_test },
- {"randomly generated options", false, (test_callback_fn*)random_statement_build_test },
- {"namespace", false, (test_callback_fn*)parser_key_prefix_test },
- {"server", false, (test_callback_fn*)server_test },
- {"bad server strings", false, (test_callback_fn*)servers_bad_test },
- {"server with weights", false, (test_callback_fn*)server_with_weight_test },
- {"parsing servername, port, and weight", false, (test_callback_fn*)test_hostname_port_weight },
- {"--socket=", false, (test_callback_fn*)test_parse_socket },
- {"--namespace=", false, (test_callback_fn*)test_namespace_keyword },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st virtual_bucket_tests[] ={
- {"basic", false, (test_callback_fn*)virtual_back_map },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st memcached_server_add_tests[] ={
- {"memcached_server_add(\"\")", false, (test_callback_fn*)memcached_server_add_empty_test },
- {"memcached_server_add(NULL)", false, (test_callback_fn*)memcached_server_add_null_test },
- {0, 0, (test_callback_fn*)0}
-};
-
-test_st namespace_tests[] ={
- {"basic tests", true, (test_callback_fn*)selection_of_namespace_tests },
- {"increment", true, (test_callback_fn*)memcached_increment_namespace },
- {0, 0, (test_callback_fn*)0}
-};
-
-collection_st collection[] ={
-#if 0
- {"hash_sanity", 0, 0, hash_sanity},
-#endif
- {"libmemcachedutil", 0, 0, libmemcachedutil_tests},
- {"basic", 0, 0, basic_tests},
- {"hsieh_availability", 0, 0, hsieh_availability},
- {"murmur_availability", 0, 0, murmur_availability},
- {"memcached_server_add", 0, 0, memcached_server_add_tests},
- {"block", 0, 0, tests},
- {"binary", (test_callback_fn*)pre_binary, 0, tests},
- {"nonblock", (test_callback_fn*)pre_nonblock, 0, tests},
- {"nodelay", (test_callback_fn*)pre_nodelay, 0, tests},
- {"settimer", (test_callback_fn*)pre_settimer, 0, tests},
- {"md5", (test_callback_fn*)pre_md5, 0, tests},
- {"crc", (test_callback_fn*)pre_crc, 0, tests},
- {"hsieh", (test_callback_fn*)pre_hsieh, 0, tests},
- {"jenkins", (test_callback_fn*)pre_jenkins, 0, tests},
- {"fnv1_64", (test_callback_fn*)pre_hash_fnv1_64, 0, tests},
- {"fnv1a_64", (test_callback_fn*)pre_hash_fnv1a_64, 0, tests},
- {"fnv1_32", (test_callback_fn*)pre_hash_fnv1_32, 0, tests},
- {"fnv1a_32", (test_callback_fn*)pre_hash_fnv1a_32, 0, tests},
- {"ketama", (test_callback_fn*)pre_behavior_ketama, 0, tests},
- {"ketama_auto_eject_hosts", (test_callback_fn*)pre_behavior_ketama, 0, ketama_auto_eject_hosts},
- {"unix_socket", (test_callback_fn*)pre_unix_socket, 0, tests},
- {"unix_socket_nodelay", (test_callback_fn*)pre_nodelay, 0, tests},
- {"gets", (test_callback_fn*)enable_cas, 0, tests},
- {"consistent_crc", (test_callback_fn*)enable_consistent_crc, 0, tests},
- {"consistent_hsieh", (test_callback_fn*)enable_consistent_hsieh, 0, tests},
-#ifdef MEMCACHED_ENABLE_DEPRECATED
- {"deprecated_memory_allocators", (test_callback_fn*)deprecated_set_memory_alloc, 0, tests},
-#endif
- {"memory_allocators", (test_callback_fn*)set_memory_alloc, 0, tests},
- {"namespace", (test_callback_fn*)set_namespace, 0, tests},
- {"namespace(BINARY)", (test_callback_fn*)set_namespace_and_binary, 0, tests},
- {"specific namespace", 0, 0, namespace_tests},
- {"specific namespace(BINARY)", (test_callback_fn*)pre_binary, 0, namespace_tests},
- {"version_1_2_3", (test_callback_fn*)check_for_1_2_3, 0, version_1_2_3},
- {"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},
- {"Cal Haldenbrand's tests", 0, 0, haldenbrand_tests},
- {"user written tests", 0, 0, user_tests},
- {"generate", 0, 0, generate_tests},
- {"generate_hsieh", (test_callback_fn*)pre_hsieh, 0, generate_tests},
- {"generate_ketama", (test_callback_fn*)pre_behavior_ketama, 0, generate_tests},
- {"generate_hsieh_consistent", (test_callback_fn*)enable_consistent_hsieh, 0, generate_tests},
- {"generate_md5", (test_callback_fn*)pre_md5, 0, generate_tests},
- {"generate_murmur", (test_callback_fn*)pre_murmur, 0, generate_tests},
- {"generate_jenkins", (test_callback_fn*)pre_jenkins, 0, generate_tests},
- {"generate_nonblock", (test_callback_fn*)pre_nonblock, 0, generate_tests},
- // Too slow
- {"generate_corked", (test_callback_fn*)pre_cork, 0, generate_tests},
- {"generate_corked_and_nonblock", (test_callback_fn*)pre_cork_and_nonblock, 0, generate_tests},
- {"consistent_not", 0, 0, consistent_tests},
- {"consistent_ketama", (test_callback_fn*)pre_behavior_ketama, 0, consistent_tests},
- {"consistent_ketama_weighted", (test_callback_fn*)pre_behavior_ketama_weighted, 0, consistent_weighted_tests},
- {"ketama_compat", 0, 0, ketama_compatibility},
- {"test_hashes", 0, 0, hash_tests},
- {"replication", (test_callback_fn*)pre_replication, 0, replication_tests},
- {"replication_noblock", (test_callback_fn*)pre_replication_noblock, 0, replication_tests},
- {"regression", 0, 0, regression_tests},
- {"behaviors", 0, 0, behavior_tests},
- {"regression_binary_vs_block", (test_callback_fn*)key_setup, (test_callback_fn*)key_teardown, regression_binary_vs_block},
- {"error_conditions", 0, 0, error_conditions},
- {"parser", 0, 0, parser_tests},
- {"virtual buckets", 0, 0, virtual_bucket_tests},
- {"memcached_server_get_last_disconnect", 0, 0, memcached_server_get_last_disconnect_tests},
- {"touch", 0, 0, touch_tests},
- {"touch", (test_callback_fn*)pre_binary, 0, touch_tests},
- {"memcached_stat()", 0, 0, memcached_stat_tests},
- {0, 0, 0, 0}
-};
-
-#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10
-
-#include "tests/libmemcached_world.h"
-
-void get_world(Framework *world)
-{
- world->collections= collection;
-
- world->_create= (test_callback_create_fn*)world_create;
- world->_destroy= (test_callback_destroy_fn*)world_destroy;
-
- world->item._startup= (test_callback_fn*)world_test_startup;
- world->item.set_pre((test_callback_fn*)world_pre_run);
- world->item.set_flush((test_callback_fn*)world_flush);
- world->item.set_post((test_callback_fn*)world_post_run);
- world->_on_error= (test_callback_error_fn*)world_on_error;
-
- world->collection_startup= (test_callback_fn*)world_container_startup;
- world->collection_shutdown= (test_callback_fn*)world_container_shutdown;
-
- world->set_runner(&defualt_libmemcached_runner);
-
- world->set_socket();
-}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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
+
+test_return_t MEMCACHED_BEHAVIOR_CORK_test(memcached_st *memc);
+test_return_t MEMCACHED_BEHAVIOR_POLL_TIMEOUT_test(memcached_st *memc);
+test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPALIVE_test(memcached_st *memc);
+test_return_t MEMCACHED_BEHAVIOR_TCP_KEEPIDLE_test(memcached_st *memc);
+test_return_t _user_supplied_bug21(memcached_st* memc, size_t key_count);
+test_return_t add_host_test(memcached_st *memc);
+test_return_t add_host_test1(memcached_st *memc);
+test_return_t add_test(memcached_st *memc);
+test_return_t add_wrapper(memcached_st *memc);
+test_return_t allocation_test(memcached_st *not_used);
+test_return_t analyzer_test(memcached_st *memc);
+test_return_t append_binary_test(memcached_st *memc);
+test_return_t append_test(memcached_st *memc);
+test_return_t bad_key_test(memcached_st *memc);
+test_return_t behavior_test(memcached_st *memc);
+test_return_t binary_add_regression(memcached_st *memc);
+test_return_t binary_increment_with_prefix_test(memcached_st *memc);
+test_return_t block_add_regression(memcached_st *memc);
+test_return_t callback_test(memcached_st *memc);
+test_return_t cas2_test(memcached_st *memc);
+test_return_t cas_test(memcached_st *memc);
+test_return_t check_for_1_2_3(memcached_st *memc);
+test_return_t clone_test(memcached_st *memc);
+test_return_t connection_test(memcached_st *memc);
+test_return_t crc_run (memcached_st *);
+test_return_t decrement_by_key_test(memcached_st *memc);
+test_return_t decrement_test(memcached_st *memc);
+test_return_t decrement_with_initial_by_key_test(memcached_st *memc);
+test_return_t decrement_with_initial_test(memcached_st *memc);
+test_return_t delete_test(memcached_st *memc);
+test_return_t deprecated_set_memory_alloc(memcached_st *memc);
+test_return_t enable_cas(memcached_st *memc);
+test_return_t enable_consistent_crc(memcached_st *memc);
+test_return_t enable_consistent_hsieh(memcached_st *memc);
+test_return_t flush_test(memcached_st *memc);
+test_return_t fnv1_32_run (memcached_st *);
+test_return_t fnv1_64_run (memcached_st *);
+test_return_t fnv1a_32_run (memcached_st *);
+test_return_t fnv1a_64_run (memcached_st *);
+test_return_t get_stats(memcached_st *memc);
+test_return_t get_stats_keys(memcached_st *memc);
+test_return_t get_test(memcached_st *memc);
+test_return_t get_test2(memcached_st *memc);
+test_return_t get_test3(memcached_st *memc);
+test_return_t get_test4(memcached_st *memc);
+test_return_t get_test5(memcached_st *memc);
+test_return_t getpid_connection_failure_test(memcached_st *memc);
+test_return_t getpid_test(memcached_st *memc);
+test_return_t hash_sanity_test (memcached_st *memc);
+test_return_t hsieh_avaibility_test (memcached_st *memc);
+test_return_t hsieh_run (memcached_st *);
+test_return_t increment_by_key_test(memcached_st *memc);
+test_return_t increment_test(memcached_st *memc);
+test_return_t increment_with_initial_by_key_test(memcached_st *memc);
+test_return_t increment_with_initial_test(memcached_st *memc);
+test_return_t init_test(memcached_st *not_used);
+test_return_t jenkins_run (memcached_st *);
+test_return_t key_setup(memcached_st *memc);
+test_return_t key_teardown(memcached_st *);
+test_return_t libmemcached_string_behavior_test(memcached_st *);
+test_return_t libmemcached_string_distribution_test(memcached_st *);
+test_return_t md5_run (memcached_st *);
+test_return_t memcached_fetch_result_NOT_FOUND(memcached_st *memc);
+test_return_t memcached_get_MEMCACHED_ERRNO(memcached_st *);
+test_return_t memcached_get_MEMCACHED_NOTFOUND(memcached_st *memc);
+test_return_t memcached_get_by_key_MEMCACHED_ERRNO(memcached_st *memc);
+test_return_t memcached_get_by_key_MEMCACHED_NOTFOUND(memcached_st *memc);
+test_return_t memcached_get_hashkit_test (memcached_st *);
+test_return_t memcached_mget_mixed_memcached_get_TEST(memcached_st *memc);
+test_return_t memcached_return_t_TEST(memcached_st *memc);
+test_return_t memcached_server_cursor_test(memcached_st *memc);
+test_return_t memcached_server_remove_test(memcached_st*);
+test_return_t memcached_stat_execute_test(memcached_st *memc);
+test_return_t mget_end(memcached_st *memc);
+test_return_t mget_execute(memcached_st *original_memc);
+test_return_t mget_result_alloc_test(memcached_st *memc);
+test_return_t mget_result_function(memcached_st *memc);
+test_return_t mget_result_test(memcached_st *memc);
+test_return_t mget_test(memcached_st *memc);
+test_return_t murmur_avaibility_test (memcached_st *memc);
+test_return_t murmur_run (memcached_st *);
+test_return_t noreply_test(memcached_st *memc);
+test_return_t one_at_a_time_run (memcached_st *);
+test_return_t output_ketama_weighted_keys(memcached_st *);
+test_return_t ping_test(memcached_st *memc);
+test_return_t prepend_test(memcached_st *memc);
+test_return_t quit_test(memcached_st *memc);
+test_return_t read_through(memcached_st *memc);
+test_return_t regression_bug_(memcached_st *memc);
+test_return_t regression_bug_421108(memcached_st *memc);
+test_return_t regression_bug_434484(memcached_st *memc);
+test_return_t regression_bug_434843(memcached_st *original_memc);
+test_return_t regression_bug_434843_buffered(memcached_st *memc);
+test_return_t regression_bug_442914(memcached_st *memc);
+test_return_t regression_bug_447342(memcached_st *memc);
+test_return_t regression_bug_463297(memcached_st *memc);
+test_return_t regression_bug_490486(memcached_st *original_memc);
+test_return_t regression_bug_490520(memcached_st *memc);
+test_return_t regression_bug_581030(memcached_st *);
+test_return_t regression_bug_583031(memcached_st *);
+test_return_t regression_bug_655423(memcached_st *memc);
+test_return_t regression_bug_854604(memcached_st *);
+test_return_t replace_test(memcached_st *memc);
+test_return_t result_alloc(memcached_st *memc);
+test_return_t result_static(memcached_st *memc);
+test_return_t selection_of_namespace_tests(memcached_st *memc);
+test_return_t server_sort2_test(memcached_st *ptr);
+test_return_t server_sort_test(memcached_st *ptr);
+test_return_t server_unsort_test(memcached_st *ptr);
+test_return_t set_memory_alloc(memcached_st *memc);
+test_return_t set_namespace(memcached_st *memc);
+test_return_t set_namespace_and_binary(memcached_st *memc);
+test_return_t set_test(memcached_st *memc);
+test_return_t set_test2(memcached_st *memc);
+test_return_t set_test3(memcached_st *memc);
+test_return_t stats_servername_test(memcached_st *memc);
+test_return_t test_get_last_disconnect(memcached_st *memc);
+test_return_t test_multiple_get_last_disconnect(memcached_st *);
+test_return_t test_verbosity(memcached_st *memc);
+test_return_t user_supplied_bug10(memcached_st *memc);
+test_return_t user_supplied_bug11(memcached_st *memc);
+test_return_t user_supplied_bug12(memcached_st *memc);
+test_return_t user_supplied_bug13(memcached_st *memc);
+test_return_t user_supplied_bug14(memcached_st *memc);
+test_return_t user_supplied_bug15(memcached_st *memc);
+test_return_t user_supplied_bug16(memcached_st *memc);
+test_return_t user_supplied_bug17(memcached_st *memc);
+test_return_t user_supplied_bug19(memcached_st *);
+test_return_t user_supplied_bug20(memcached_st *memc);
+test_return_t user_supplied_bug21(memcached_st *memc);
+test_return_t user_supplied_bug4(memcached_st *memc);
+test_return_t user_supplied_bug5(memcached_st *memc);
+test_return_t user_supplied_bug6(memcached_st *memc);
+test_return_t user_supplied_bug7(memcached_st *memc);
+test_return_t user_supplied_bug8(memcached_st *);
+test_return_t user_supplied_bug9(memcached_st *memc);
+test_return_t userdata_test(memcached_st *memc);
+test_return_t util_version_test(memcached_st *memc);
+test_return_t version_string_test(memcached_st *);
+test_return_t wrong_failure_counter_test(memcached_st *memc);
+test_return_t wrong_failure_counter_two_test(memcached_st *memc);
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2012 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-1.0/memcached.h>
+#include <libmemcached/util.h>
+
+using namespace libtest;
+
+static test_return_t memcached_fetch_execute_MEMCACHED_SUCCESS_TEST(memcached_st *memc)
+{
+ (void)memc;
+ return TEST_SUCCESS;
+}
+
+static test_return_t memcached_fetch_execute_MEMCACHED_NOTFOUND_TEST(memcached_st *memc)
+{
+ (void)memc;
+ return TEST_SUCCESS;
+}
+
+test_st memcached_fetch_execute_TESTS[] ={
+ {"memcached_fetch_execute(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_fetch_execute_MEMCACHED_SUCCESS_TEST },
+ {"memcached_fetch_execute(MEMCACHED_SUCCESS)", true, (test_callback_fn*)memcached_fetch_execute_MEMCACHED_NOTFOUND_TEST },
+ { 0, 0, (test_callback_fn*)0 }
+};
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached library
+ *
+ * Copyright (C) 2012 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
+
+extern test_st *memcached_fetch_execute_TESTS;
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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
+#define SERVERS_TO_CREATE 5
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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.
+ *
+ */
+
+#include <config.h>
+#include <libtest/test.hpp>
+
+#include <libmemcached/util.h>
+
+#include "tests/libmemcached-1.0/setup_and_teardowns.h"
+
+#include <sys/stat.h>
+
+/**
+ @note This should be testing to see if the server really supports the binary protocol.
+*/
+test_return_t pre_binary(memcached_st *memc)
+{
+ test_skip(true, libmemcached_util_version_check(memc, 1, 4, 4));
+ test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, true));
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_unix_socket(memcached_st *memc)
+{
+ struct stat buf;
+
+ memcached_servers_reset(memc);
+ const char *socket_file= libtest::default_socket();
+ test_skip(true, bool(socket_file));
+
+ test_skip(0, stat(socket_file, &buf));
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_server_add_unix_socket_with_weight(memc, socket_file, 0));
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_nodelay(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 0);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_settimer(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SND_TIMEOUT, 1000);
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RCV_TIMEOUT, 1000);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_murmur(memcached_st *memc)
+{
+ test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR));
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_jenkins(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_JENKINS);
+
+ return TEST_SKIPPED;
+}
+
+
+test_return_t pre_md5(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MD5);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_crc(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_CRC);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_hsieh(memcached_st *memc)
+{
+ test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH));
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_hash_fnv1_64(memcached_st *memc)
+{
+ test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR));
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_hash_fnv1a_64(memcached_st *memc)
+{
+ test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_64));
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_hash_fnv1_32(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1_32);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_hash_fnv1a_32(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_32);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_behavior_ketama(memcached_st *memc)
+{
+ memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA, 1);
+ test_compare(MEMCACHED_SUCCESS, rc);
+
+ uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA);
+ test_compare(value, uint64_t(1));
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_behavior_ketama_weighted(memcached_st *memc)
+{
+ memcached_return_t 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_compare(value, uint64_t(1));
+
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5));
+
+ value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH);
+ test_compare(MEMCACHED_HASH_MD5, memcached_hash_t(value));
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_replication(memcached_st *memc)
+{
+ test_skip(TEST_SUCCESS, pre_binary(memc));
+
+ /*
+ * Make sure that we store the item on all servers
+ * (master + replicas == number of servers)
+ */
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, memcached_server_count(memc) - 1));
+ test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS), uint64_t(memcached_server_count(memc) - 1));
+
+ return TEST_SUCCESS;
+}
+
+
+test_return_t pre_replication_noblock(memcached_st *memc)
+{
+ test_skip(TEST_SUCCESS, pre_replication(memc));
+
+ return pre_nonblock(memc);
+}
+
+test_return_t pre_nonblock(memcached_st *memc)
+{
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t pre_cork(memcached_st *memc)
+{
+#ifdef __APPLE__
+ return TEST_SKIPPED;
+#endif
+ bool set= true;
+ if (memcached_success(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_CORK, set)))
+ return TEST_SUCCESS;
+
+ return TEST_SKIPPED;
+}
+
+test_return_t pre_cork_and_nonblock(memcached_st *memc)
+{
+#ifdef __APPLE__
+ return TEST_SKIPPED;
+#endif
+ test_return_t test_rc;
+ if ((test_rc= pre_cork(memc)) != TEST_SUCCESS)
+ return test_rc;
+
+ return pre_nonblock(memc);
+}
+
+test_return_t pre_nonblock_binary(memcached_st *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);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1));
+ test_compare(uint64_t(1), memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
+ }
+ else
+ {
+ memcached_free(memc_clone);
+ return TEST_SKIPPED;
+ }
+
+ memcached_free(memc_clone);
+
+ return rc == MEMCACHED_SUCCESS ? TEST_SUCCESS : TEST_SKIPPED;
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2012 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
+
+test_return_t pre_behavior_ketama(memcached_st*);
+test_return_t pre_behavior_ketama_weighted(memcached_st*);
+test_return_t pre_binary(memcached_st*);
+test_return_t pre_cork(memcached_st*);
+test_return_t pre_cork_and_nonblock(memcached_st*);
+test_return_t pre_crc(memcached_st*);
+test_return_t pre_hash_fnv1_32(memcached_st*);
+test_return_t pre_hash_fnv1_64(memcached_st*);
+test_return_t pre_hash_fnv1a_32(memcached_st*);
+test_return_t pre_hash_fnv1a_64(memcached_st*);
+test_return_t pre_hsieh(memcached_st*);
+test_return_t pre_jenkins(memcached_st*);
+test_return_t pre_md5(memcached_st*);
+test_return_t pre_murmur(memcached_st*);
+test_return_t pre_nodelay(memcached_st*);
+test_return_t pre_nonblock(memcached_st*);
+test_return_t pre_nonblock_binary(memcached_st*);
+test_return_t pre_replication(memcached_st*);
+test_return_t pre_replication_noblock(memcached_st*);
+test_return_t pre_settimer(memcached_st*);
+test_return_t pre_unix_socket(memcached_st*);
-/* libMemcached Functions Test
- * Copyright (C) 2006-2009 Brian Aker
- * All rights reserved.
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
*
- * Use and distribution licensed under the BSD license. See
- * the COPYING file in the parent directory for full text.
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2006-2009 Brian Aker
+ * All rights reserved.
*
- * Description: This is the startup bits for any libmemcached test.
+ * 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
#include <cassert>
/* The structure we use for the test system */
struct libmemcached_test_container_st
{
- server_startup_st& construct;
+ libtest::server_startup_st& construct;
memcached_st *parent;
memcached_st *memc;
- libmemcached_test_container_st(server_startup_st &construct_arg) :
+ libmemcached_test_container_st(libtest::server_startup_st &construct_arg) :
construct(construct_arg),
parent(NULL),
memc(NULL)
{ }
};
-static void *world_create(server_startup_st& servers, test_return_t& error)
+static void *world_create(libtest::server_startup_st& servers, test_return_t& error)
{
if (HAVE_MEMCACHED_BINARY == 0)
{
return NULL;
}
- in_port_t max_port= TEST_PORT_BASE;
for (uint32_t x= 0; x < servers.count(); x++)
{
in_port_t port;
port= in_port_t(TEST_PORT_BASE +x);
}
- max_port= port;
const char *argv[1]= { "memcached" };
if (servers.sasl())
{
}
}
- if (servers.socket())
- {
- if (servers.sasl())
- {
- const char *argv[1]= { "memcached" };
- if (not servers.start_socket_server("memcached-sasl", max_port +1, 1, argv))
- {
- error= TEST_FATAL;
- return NULL;
- }
- }
- else
- {
- const char *argv[1]= { "memcached" };
- if (not servers.start_socket_server("memcached", max_port +1, 1, argv))
- {
- error= TEST_FATAL;
- return NULL;
- }
- }
- }
-
-
libmemcached_test_container_st *global_container= new libmemcached_test_container_st(servers);
if (global_container == NULL)
{
}
catch (std::exception& e)
{
- Error << e.what();
+ libtest::Error << e.what();
return TEST_FAILURE;
}
return TEST_SUCCESS;
}
-class LibmemcachedRunner : public Runner {
+class LibmemcachedRunner : public libtest::Runner {
public:
test_return_t run(test_callback_fn* func, void *object)
{
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Libmemcached Client and Server
+ *
+ * Copyright (C) 2011-2012 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
+
+#include <cassert>
+
+/* The structure we use for the test system */
+struct libmemcached_test_container_st
+{
+ libtest::server_startup_st& construct;
+ memcached_st *parent;
+ memcached_st *memc;
+
+ libmemcached_test_container_st(libtest::server_startup_st &construct_arg) :
+ construct(construct_arg),
+ parent(NULL),
+ memc(NULL)
+ { }
+};
+
+static void *world_create(libtest::server_startup_st& servers, test_return_t& error)
+{
+ if (HAVE_MEMCACHED_BINARY == 0)
+ {
+ error= TEST_SKIPPED;
+ return NULL;
+ }
+
+ in_port_t max_port= TEST_PORT_BASE;
+ for (uint32_t x= 0; x < servers.count(); x++)
+ {
+ const char *argv[1]= { "memcached" };
+ if (not servers.start_socket_server("memcached", max_port +1, 1, argv))
+ {
+ error= TEST_FATAL;
+ return NULL;
+ }
+ }
+
+
+ libmemcached_test_container_st *global_container= new libmemcached_test_container_st(servers);
+ if (global_container == NULL)
+ {
+ error= TEST_MEMORY_ALLOCATION_FAILURE;
+ return NULL;
+ }
+
+ error= TEST_SUCCESS;
+
+ return global_container;
+}
+
+static test_return_t world_container_startup(libmemcached_test_container_st *container)
+{
+ char buffer[BUFSIZ];
+
+ test_compare_got(MEMCACHED_SUCCESS,
+ libmemcached_check_configuration(container->construct.option_string().c_str(), container->construct.option_string().size(),
+ buffer, sizeof(buffer)),
+ container->construct.option_string().c_str());
+
+ test_null(container->parent);
+ container->parent= memcached(container->construct.option_string().c_str(), container->construct.option_string().size());
+ test_true(container->parent);
+ test_compare(MEMCACHED_SUCCESS, memcached_version(container->parent));
+
+ if (container->construct.sasl())
+ {
+ if (memcached_failed(memcached_behavior_set(container->parent, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1)))
+ {
+ memcached_free(container->parent);
+ return TEST_FAILURE;
+ }
+
+ if (memcached_failed(memcached_set_sasl_auth_data(container->parent, container->construct.username().c_str(), container->construct.password().c_str())))
+ {
+ memcached_free(container->parent);
+ return TEST_FAILURE;
+ }
+ }
+
+ for (uint32_t host= 0; host < memcached_server_count(container->parent); ++host)
+ {
+ memcached_server_instance_st instance=
+ memcached_server_instance_by_position(container->parent, host);
+
+ if (instance->type == MEMCACHED_CONNECTION_TCP)
+ {
+ test_true_got(memcached_server_port(instance) >= TEST_PORT_BASE, memcached_server_port(instance));
+ }
+ }
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t world_container_shutdown(libmemcached_test_container_st *container)
+{
+ memcached_free(container->parent);
+ container->parent= NULL;
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t world_test_startup(libmemcached_test_container_st *container)
+{
+ test_true(container);
+ test_null(container->memc);
+ test_true(container->parent);
+ container->memc= memcached_clone(NULL, container->parent);
+ test_true(container->memc);
+
+ return TEST_SUCCESS;
+}
+
+test_return_t world_flush(libmemcached_test_container_st *container);
+test_return_t world_flush(libmemcached_test_container_st *container)
+{
+ test_true(container->memc);
+ memcached_flush(container->memc, 0);
+ memcached_quit(container->memc);
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t world_pre_run(libmemcached_test_container_st *container)
+{
+ test_true(container->memc);
+ for (uint32_t loop= 0; loop < memcached_server_list_count(container->memc->servers); loop++)
+ {
+ memcached_server_instance_st instance=
+ memcached_server_instance_by_position(container->memc, loop);
+
+ test_compare(-1, instance->fd);
+ test_compare(0U, instance->cursor_active);
+ }
+
+ return TEST_SUCCESS;
+}
+
+
+static test_return_t world_post_run(libmemcached_test_container_st *container)
+{
+ test_true(container->memc);
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t world_on_error(test_return_t , libmemcached_test_container_st *container)
+{
+ test_true(container->memc);
+ memcached_free(container->memc);
+ container->memc= NULL;
+
+ return TEST_SUCCESS;
+}
+
+static bool world_destroy(void *object)
+{
+ libmemcached_test_container_st *container= (libmemcached_test_container_st *)object;
+#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
+ if (LIBMEMCACHED_WITH_SASL_SUPPORT)
+ {
+ sasl_done();
+ }
+#endif
+
+ delete container;
+
+ return TEST_SUCCESS;
+}
+
+typedef test_return_t (*libmemcached_test_callback_fn)(memcached_st *);
+
+static test_return_t _runner_default(libmemcached_test_callback_fn func, libmemcached_test_container_st *container)
+{
+ if (func)
+ {
+ test_true(container);
+ test_true(container->memc);
+ test_return_t ret;
+ try {
+ ret= func(container->memc);
+ }
+ catch (std::exception& e)
+ {
+ libtest::Error << e.what();
+ return TEST_FAILURE;
+ }
+
+ return ret;
+ }
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t _pre_runner_default(libmemcached_test_callback_fn func, libmemcached_test_container_st *container)
+{
+ if (func)
+ {
+ return func(container->parent);
+ }
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t _post_runner_default(libmemcached_test_callback_fn func, libmemcached_test_container_st *container)
+{
+ if (func)
+ {
+ return func(container->parent);
+ }
+
+ return TEST_SUCCESS;
+}
+
+class LibmemcachedRunner : public libtest::Runner {
+public:
+ test_return_t run(test_callback_fn* func, void *object)
+ {
+ return _runner_default(libmemcached_test_callback_fn(func), (libmemcached_test_container_st*)object);
+ }
+
+ test_return_t pre(test_callback_fn* func, void *object)
+ {
+ return _pre_runner_default(libmemcached_test_callback_fn(func), (libmemcached_test_container_st*)object);
+ }
+
+ test_return_t post(test_callback_fn* func, void *object)
+ {
+ return _post_runner_default(libmemcached_test_callback_fn(func), (libmemcached_test_container_st*)object);
+ }
+};
+
+static LibmemcachedRunner defualt_libmemcached_runner;
#pragma once
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-LIBTEST_LOCAL
memcached_return_t server_print_callback(const memcached_st *ptr,
const memcached_server_st *server,
void *context);
-
-#ifdef __cplusplus
-}
-#endif