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
memcached_return_t rc= memcached_set(memc, pairs[x].key, pairs[x].key_length,
pairs[x].value, pairs[x].value_length,
0, 0);
- if (rc != MEMCACHED_SUCCESS and rc != MEMCACHED_BUFFERED)
+ if (memcached_failed(rc))
{
fprintf(stderr, "%s:%d Failure on insert (%s) of %.*s\n",
__FILE__, __LINE__,
*/
unsigned int execute_get(memcached_st *memc, pairs_st *pairs, unsigned int number_of)
{
- memcached_return_t rc;
unsigned int x;
unsigned int retrieved;
unsigned int fetch_key= (unsigned int)((unsigned int)random() % number_of);
+ memcached_return_t rc;
char *value= memcached_get(memc, pairs[fetch_key].key, pairs[fetch_key].key_length,
&value_length, &flags, &rc);
- if (rc != MEMCACHED_SUCCESS)
+ if (memcached_failed(rc))
{
fprintf(stderr, "%s:%d Failure on read(%s) of %.*s\n",
__FILE__, __LINE__,
if (!val)
{
if (verbose)
+ {
fprintf(stderr, "\n%s:%d: %s", file, line, expression);
+ }
if (do_core)
+ {
abort();
+ }
return TEST_FAIL;
}
size_t num_bytes= len - offset;
ssize_t nw= timeout_io_op(sock, POLLOUT, (void*)(ptr + offset), num_bytes);
if (nw == -1)
+ {
verify(get_socket_errno() == EINTR || get_socket_errno() == EAGAIN);
+ }
else
+ {
offset+= (size_t)nw;
+ }
+
} while (offset < len);
return TEST_PASS;
static enum test_return resend_packet(command *cmd)
{
size_t length= sizeof (protocol_binary_request_no_extras) +
- ntohl(cmd->plain.message.header.request.bodylen);
+ ntohl(cmd->plain.message.header.request.bodylen);
execute(retry_write(cmd, length));
return TEST_PASS;
fprintf(stderr, "Errno: %d %s\n", get_socket_errno(), strerror(errno));
verify(get_socket_errno() == EINTR || get_socket_errno() == EAGAIN);
break;
+
case 0:
return TEST_FAIL;
+
default:
offset+= (size_t)nr;
}
for (int ii= 0; ii < 10; ii++)
{
if (ii == 0)
+ {
execute(send_packet(&cmd));
+ }
else
+ {
execute(resend_packet(&cmd));
+ }
if (cc == PROTOCOL_BINARY_CMD_SET)
{
for (int ii= 0; ii < 10; ii++)
{
if (ii == 0)
+ {
execute(send_packet(&cmd));
+ }
else
+ {
execute(resend_packet(&cmd));
+ }
if (cc == PROTOCOL_BINARY_CMD_REPLACE || ii == 0)
{
uint16_t expected_result;
if (ii == 0)
+ {
expected_result=PROTOCOL_BINARY_RESPONSE_KEY_ENOENT;
+ }
else
+ {
expected_result=PROTOCOL_BINARY_RESPONSE_SUCCESS;
+ }
execute(send_binary_noop());
execute(recv_packet(&rsp));
execute(binary_set_item(key, key));
}
else
+ {
execute(test_binary_noop());
+ }
}
/* verify that replace with CAS value works! */
const char *value;
if (cc == PROTOCOL_BINARY_CMD_APPEND || cc == PROTOCOL_BINARY_CMD_APPENDQ)
+ {
value="hello";
+ }
else
+ {
value=" world";
+ }
execute(binary_set_item(key, value));
if (cc == PROTOCOL_BINARY_CMD_APPEND || cc == PROTOCOL_BINARY_CMD_APPENDQ)
+ {
value=" world";
+ }
else
+ {
value="hello";
+ }
raw_command(&cmd, cc, key, strlen(key), value, strlen(value));
execute(send_packet(&cmd));
verify(validate_response_header(&rsp, cc, PROTOCOL_BINARY_RESPONSE_SUCCESS));
}
else
+ {
execute(test_binary_noop());
+ }
raw_command(&cmd, PROTOCOL_BINARY_CMD_GET, key, strlen(key), NULL, 0);
execute(send_packet(&cmd));
execute(send_string(buffer));
if (!noreply)
+ {
execute(receive_response("STORED\r\n"));
+ }
return test_ascii_version();
}
execute(send_string(buffer));
if (!noreply)
+ {
execute(receive_response("STORED\r\n"));
+ }
execute(send_string(buffer));
if (!noreply)
+ {
execute(receive_response("NOT_STORED\r\n"));
+ }
return test_ascii_version();
}
char buffer[1024];
size_t datasize= 0;
if (value != NULL)
+ {
datasize= strlen(value);
+ }
verify(datasize < sizeof(buffer));
snprintf(buffer, sizeof(buffer), "get %s\r\n", key);
execute(send_string(buffer));
if (exist)
+ {
execute(ascii_get_value(key, value));
+ }
execute(retry_read(buffer, 5));
verify(memcmp(buffer, "END\r\n", 5) == 0);
char buffer[1024];
size_t datasize= 0;
if (value != NULL)
+ {
datasize= strlen(value);
+ }
verify(datasize < sizeof(buffer));
snprintf(buffer, sizeof(buffer), "gets %s\r\n", key);
execute(send_string(buffer));
if (noreply)
+ {
execute(test_ascii_version());
+ }
else
+ {
execute(receive_response("NOT_STORED\r\n"));
+ }
execute(ascii_set_item(key, "value"));
execute(ascii_get_item(key, "value", true));
execute(send_string(buffer));
if (noreply)
+ {
execute(test_ascii_version());
+ }
else
+ {
execute(receive_response("STORED\r\n"));
+ }
/* reexecute the same command should fail due to illegal cas */
execute(send_string(buffer));
if (noreply)
+ {
execute(test_ascii_version());
+ }
else
+ {
execute(receive_response("EXISTS\r\n"));
+ }
return test_ascii_version();
}
};
for (uint32_t x= 0; x < nkeys; ++x)
+ {
execute(ascii_set_item(keys[x], "value"));
+ }
/* Ask for a key that doesn't exist as well */
execute(send_string("get test_ascii_mget1 test_ascii_mget2 test_ascii_mget3 "
}
for (uint32_t x= 0; x < nkeys; ++x)
+ {
free(returned[x]);
+ }
return TEST_PASS;
}
execute(send_string(cmd));
if (noreply)
+ {
execute(test_ascii_version());
+ }
else
{
char buffer[80];
/* verify that it doesn't wrap */
execute(send_string(cmd));
if (noreply)
+ {
execute(test_ascii_version());
+ }
else
{
char buffer[80];
execute(ascii_set_item(key, value));
if (append)
+ {
value=" world";
+ }
else
+ {
value="hello";
+ }
char cmd[400];
snprintf(cmd, sizeof(cmd), "%s %s 0 0 %u%s\r\n%s\r\n",
execute(send_string(cmd));
if (noreply)
+ {
execute(test_ascii_version());
+ }
else
+ {
execute(receive_response("STORED\r\n"));
+ }
execute(ascii_get_item(key, "hello world", true));
execute(send_string(cmd));
if (noreply)
+ {
execute(test_ascii_version());
+ }
else
+ {
execute(receive_response("NOT_STORED\r\n"));
+ }
return TEST_PASS;
}
"\t-a\tOnly test the ascii protocol\n"
"\t-b\tOnly test the binary protocol\n",
argv[0]);
- return EXIT_FAILURE;
+ return EXIT_SUCCESS;
}
}
for (int ii= 0; testcases[ii].description != NULL; ++ii)
{
if (testname != NULL && strcmp(testcases[ii].description, testname) != 0)
- continue;
+ {
+ continue;
+ }
if ((testcases[ii].description[0] == 'a' && (tests.ascii) == 0) ||
(testcases[ii].description[0] == 'b' && (tests.binary) == 0))
continue;
}
if (strncmp(buffer, "quit", 4) == 0)
- exit(0);
+ {
+ exit(EXIT_SUCCESS);
+ }
}
fprintf(stdout, "%-40s", testcases[ii].description);
closesocket(sock);
if ((sock= connect_server(hostname, port)) == INVALID_SOCKET)
{
- fprintf(stderr, "Failed to connect to <%s:%s>: %s\n",
- hostname, port, strerror(get_socket_errno()));
+ fprintf(stderr, "Failed to connect to <%s:%s>: %s\n", hostname, port, strerror(get_socket_errno()));
fprintf(stderr, "%d of %d tests failed\n", failed, total);
return EXIT_FAILURE;
}
closesocket(sock);
if (failed == 0)
+ {
fprintf(stdout, "All tests passed\n");
+ }
else
+ {
fprintf(stderr, "%d of %d tests failed\n", failed, total);
+ }
- return (failed == 0) ? 0 : 1;
+ return (failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
memcached_return_t rc;
memcached_server_st *servers;
- int return_code= 0;
+ int return_code= EXIT_SUCCESS;
options_parse(argc, argv);
initialize_sockets();
char *temp;
if ((temp= getenv("MEMCACHED_SERVERS")))
+ {
opt_servers= strdup(temp);
+ }
else
{
- fprintf(stderr, "No Servers provided\n");
- exit(1);
+ std::cerr << "No servers provied" << std::endl;
+ exit(EXIT_FAILURE);
}
}
if (opt_displayflag)
{
if (opt_verbose)
- printf("key: %s\nflags: ", argv[optind]);
- printf("%x\n", flags);
+ {
+ std::cout << "key: " << argv[optind] << std::endl << "flags: " << flags << std::endl;
+ }
}
else
{
if (opt_verbose)
{
- printf("key: %s\nflags: %x\nlength: %lu\nvalue: ",
- argv[optind], flags, (unsigned long)string_length);
+ std::cout << "key: " << argv[optind] << std::endl << "flags: " << flags << "length: " << string_length << std::endl << "value: ";
}
if (opt_file)
{
- FILE *fp;
- size_t written;
-
- fp= fopen(opt_file, "w");
- if (!fp)
+ FILE *fp= fopen(opt_file, "w");
+ if (fp == NULL)
{
perror("fopen");
- return_code= -1;
+ return_code= EXIT_FAILURE;
break;
}
- written= fwrite(string, 1, string_length, fp);
+ size_t written= fwrite(string, 1, string_length, fp);
if (written != string_length)
{
- fprintf(stderr, "error writing file (written %lu, should be %lu)\n", (unsigned long)written, (unsigned long)string_length);
- return_code= -1;
+ std::cerr << "error writing file to file " << opt_file << " wrote " << written << ", should have written" << string_length << std::endl;
+ return_code= EXIT_FAILURE;
break;
}
if (fclose(fp))
{
- fprintf(stderr, "error closing file\n");
- return_code= -1;
+ std::cerr << "error closing " << opt_file << std::endl;
+ return_code= EXIT_FAILURE;
break;
}
}
else
{
- printf("%.*s\n", (int)string_length, string);
+ std::cout.write(string, string_length);
+ std::cout << std::endl;
}
free(string);
}
}
else if (rc != MEMCACHED_NOTFOUND)
{
- fprintf(stderr, "memcat: %s: memcache error %s",
- argv[optind], memcached_strerror(memc, rc));
+ std::cerr << "error on " << argv[optind] << "(" << memcached_strerror(memc, rc) << ")";
if (memcached_last_error_errno(memc))
{
- fprintf(stderr, " system error %s", strerror(memcached_last_error_errno(memc)));
+ std::cerr << " system error (" << strerror(memcached_last_error_errno(memc)) << ")" << std::endl;
}
- fprintf(stderr, "\n");
+ std::cerr << std::endl;
- return_code= -1;
+ return_code= EXIT_FAILURE;
break;
}
else // Unknown Issue
{
- fprintf(stderr, "memcat: %s not found\n", argv[optind]);
- return_code= -1;
+ std::cerr << "error on " << argv[optind] << "("<< memcached_strerror(NULL, rc) << ")" << std::endl;
+ return_code= EXIT_FAILURE;
}
optind++;
}
memcached_free(memc);
if (opt_servers)
+ {
free(opt_servers);
+ }
if (opt_hash)
+ {
free(opt_hash);
+ }
return return_code;
}
*/
#include "config.h"
-#include <inttypes.h>
+#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <climits>
+
#include <getopt.h>
#include <iostream>
#include <unistd.h>
/* Prototypes */
void options_parse(int argc, char *argv[]);
-static int opt_verbose= 0;
-
int main(int argc, char *argv[])
{
options_parse(argc, argv);
- if (argc != 2)
+ if (argc < 2)
{
return EXIT_FAILURE;
}
- unsigned long value= strtoul(argv[1], (char **) NULL, 10);
-
- if (value < MEMCACHED_MAXIMUM_RETURN)
+ while (optind < argc)
{
- std::cout << memcached_strerror(NULL, (memcached_return_t)value) << std::endl;
- }
- else
- {
- std::cerr << memcached_strerror(NULL, MEMCACHED_MAXIMUM_RETURN) << std::endl;
- return EXIT_FAILURE;
+ errno= 0;
+ char *nptr;
+ unsigned long value= strtoul(argv[optind], &nptr, 10);
+
+ if ((nptr == argv[optind] and value == 0) or
+ (value == ULONG_MAX and errno == ERANGE) or
+ (value == 0 and errno == EINVAL))
+ {
+ std::cerr << "strtoul() was unable to parse given value" << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ if (value < MEMCACHED_MAXIMUM_RETURN)
+ {
+ std::cout << memcached_strerror(NULL, (memcached_return_t)value) << std::endl;
+ }
+ else
+ {
+ std::cerr << memcached_strerror(NULL, MEMCACHED_MAXIMUM_RETURN) << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ optind++;
}
return EXIT_SUCCESS;
{
{(OPTIONSTRING)"version", no_argument, NULL, OPT_VERSION},
{(OPTIONSTRING)"help", no_argument, NULL, OPT_HELP},
- {(OPTIONSTRING)"quiet", no_argument, NULL, OPT_QUIET},
- {(OPTIONSTRING)"verbose", no_argument, &opt_verbose, OPT_VERBOSE},
- {(OPTIONSTRING)"debug", no_argument, &opt_verbose, OPT_DEBUG},
{0, 0, 0, 0},
};
case 0:
break;
- case OPT_VERBOSE: /* --verbose or -v */
- opt_verbose = OPT_VERBOSE;
- break;
-
- case OPT_DEBUG: /* --debug or -d */
- opt_verbose = OPT_DEBUG;
- break;
-
case OPT_VERSION: /* --version or -V */
opt_version= true;
break;
opt_help= true;
break;
- case OPT_QUIET:
- close_stdio();
- break;
-
case '?':
/* getopt_long already printed an error message. */
exit(EXIT_FAILURE);
default:
- abort();
+ exit(EXIT_FAILURE);
}
}
static char *opt_passwd;
#define PROGRAM_NAME "memexist"
-#define PROGRAM_DESCRIPTION "Erase a key or set of keys from a memcached cluster."
+#define PROGRAM_DESCRIPTION "Check for the existance of a key within a cluster."
/* Prototypes */
static void options_parse(int argc, char *argv[]);
+++ /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_CINTTYPES
CONFIG_EXTRA
DETECT_BYTEORDER
-ENABLE_UTILLIB
SETSOCKOPT_SANITY
ENABLE_HSIEH_HASH
ENABLE_MURMUR_HASH
ENABLE_MEMASLAP
PROTOCOL_BINARY_TEST
ENABLE_DEPRECATED
-PANDORA_HAVE_LIBINNODB
-PANDORA_HAVE_SASL
AC_CHECK_FUNCS([alarm])
AC_CHECK_FUNCS([dup2])
AC_CHECK_HEADERS([netinet/in.h])
AC_CHECK_HEADERS([stddef.h])
AC_CHECK_HEADERS([sys/time.h])
-AC_CHECK_HEADERS([sasl/sasl.h])
AC_CHECK_HEADERS([execinfo.h])
AC_CHECK_HEADERS([cxxabi.h],
AC_DEFINE([HAVE_CXXABI_H], [1], [Have cxxabi.h]),
AC_DEFINE([HAVE_CXXABI_H], [0], [Have cxxabi.h]))
AX_COMPILER_VENDOR
-AC_CXX_HEADER_STDCXX_98
AC_FUNC_ALLOCA
AC_FUNC_ERROR_AT_LINE
AX_CXX_GCC_ABI_DEMANGLE
+AX_SASL_OPTION
+
+dnl
+dnl The sasl functions should only be visible if we build with sasl support
+dnl
+AS_IF([test "x$ac_enable_sasl" = "xyes"], [
+ [ LIBMEMCACHED_WITH_SASL_SUPPORT="#define LIBMEMCACHED_WITH_SASL_SUPPORT 1" ]
+ ], [
+ [ LIBMEMCACHED_WITH_SASL_SUPPORT="#define LIBMEMCACHED_WITH_SASL_SUPPORT 0" ]
+ ])
+AC_SUBST(LIBMEMCACHED_WITH_SASL_SUPPORT)
+
+AX_CHECK_LIBRARY([LIBUUID], [uuid/uuid.h], [uuid],
+ [
+ LIBUUID_LDFLAGS="-luuid"
+ AC_DEFINE([HAVE_LIBUUID], [ 1 ], [Have libuuid])
+ ],
+ [
+ AC_DEFINE([HAVE_LIBUUID], [ 0 ], [Have libuuid])
+ ])
+
AC_CHECK_LIB([rt], [clock_gettime],
[
RT_LIB="-lrt"
AC_CHECK_LIB([m], [floor])
-dnl The sasl functions should only be visible if we build with sasl support
-AS_IF([test "x$ac_cv_sasl" = "xyes"],
- [
- [ LIBMEMCACHED_WITH_SASL_SUPPORT="#define LIBMEMCACHED_WITH_SASL_SUPPORT 1" ]
- ],
- [
- [ LIBMEMCACHED_WITH_SASL_SUPPORT="#define LIBMEMCACHED_WITH_SASL_SUPPORT 0" ]
- ]
- )
-AC_SUBST(LIBMEMCACHED_WITH_SASL_SUPPORT)
-
AC_CHECK_HEADERS([atomic.h])
AS_IF([test "x$ac_cv_header_atomic_h" = "xyes"],[
AC_CHECK_FUNCS(atomic_add_64)
[1],
[Define to true if you want to use functions from atomic.h])])])
+AC_DEFINE([HAVE_LIBDRIZZLE], [0], [Support for libdrizzle])
+AC_DEFINE([HAVE_DRIZZLED_BINARY], [0], [Support for DrizzleD])
+AC_DEFINE([GEARMAND_BLOBSLAP_WORKER], [0], [Support for Gearman Blobslap worker])
+AC_DEFINE([HAVE_LIBPQ], [0], [Support for Postgres])
+AC_DEFINE([HAVE_LIBCURL], [0], [Support for libcurl])
+
AC_CHECK_HEADERS_ONCE(winsock2.h poll.h sys/wait.h fnmatch.h)
AM_CONDITIONAL(BUILD_POLL, test "x$ac_cv_header_poll_h" = "xno")
AM_CONDITIONAL(BUILD_WIN32_WRAPPERS, test "x$ac_cv_header_winsock2_h" = "xyes")
echo " * Assertions enabled: $ac_cv_assert"
echo " * Debug enabled: $with_debug"
echo " * Warnings as failure: $ac_cv_warnings_as_errors"
+echo " * SASL support: $ac_enable_sasl"
echo ""
echo "---"
--- /dev/null
+===========================================
+memexist - Check for the existance of a key
+===========================================
+
+
+--------
+SYNOPSIS
+--------
+
+memexist [options] [key]
+
+.. program:: memexist
+
+
+-----------
+DESCRIPTION
+-----------
+
+:program:`memexist` checks for the existance of a key within a cluster.
+
+
+-------
+OPTIONS
+-------
+
+
+You can specify servers via the option:
+
+.. option:: --servers
+
+or via the environment variable:
+
+.. envvar:: `MEMCACHED_SERVERS`
+
+If you do not specify either these, the final value in the command line list is the name of a server(s).
+
+For a full list of operations run the tool with the option:
+
+.. option:: --help
+
+
+----
+HOME
+----
+
+
+To find out more information please check:
+`http://libmemcached.org/ <http://libmemcached.org/>`_
+
+
+------
+AUTHOR
+------
+
+
+Brian Aker, <brian@tangent.org>
+
+--------
+SEE ALSO
+--------
+
+
+:manpage:`memcached(1)` :manpage:`libmemcached(3)`
+
--- /dev/null
+=================================
+memparse - Parse an option string
+=================================
+
+
+Copies files to a collection of memcached servers
+
+
+--------
+SYNOPSIS
+--------
+
+memparse [options] "option string"
+
+.. program:: memparse
+
+
+-----------
+DESCRIPTION
+-----------
+
+
+:program:`memparse` can be used to validate an option string.
+
+-------
+OPTIONS
+-------
+
+For a full list of operations run the tool with the option:
+
+.. option:: --help
+
+
+----
+HOME
+----
+
+
+To find out more information please check:
+`http://libmemcached.org/ <http://libmemcached.org/>`_
+
+
+------
+AUTHOR
+------
+
+
+Brian Aker, <brian@tangent.org>
+
+--------
+SEE ALSO
+--------
+
+
+:manpage:`memcached(1)` :manpage:`libmemcached(3)`
+
--- /dev/null
+===============================================
+memping - Test to see if a server is available.
+===============================================
+
+
+--------
+SYNOPSIS
+--------
+
+memping [options] [server]
+
+.. program:: memping
+
+
+-----------
+DESCRIPTION
+-----------
+
+
+:program:`memping` can be used to ping a memcached server to see if it is taking connections.
+
+-------
+OPTIONS
+-------
+
+
+You can specify servers via the option:
+
+.. option:: --servers
+
+or via the environment variable:
+
+.. envvar:: `MEMCACHED_SERVERS`
+
+If you do not specify either these, the final value in the command line list is the name of a server(s).
+
+For a full list of operations run the tool with the option:
+
+.. option:: --help
+
+
+----
+HOME
+----
+
+
+To find out more information please check:
+`http://libmemcached.org/ <http://libmemcached.org/>`_
+
+
+------
+AUTHOR
+------
+
+Brian Aker, <brian@tangent.org>
+
+--------
+SEE ALSO
+--------
+
+:manpage:`memcached(1)` :manpage:`libmemcached(3)`
--- /dev/null
+=========================
+memtouch - Touches a key.
+=========================
+
+
+--------
+SYNOPSIS
+--------
+
+memtouch [options] key
+
+.. program:: memtouch
+
+
+-----------
+DESCRIPTION
+-----------
+
+
+:program:`memtouch` does a "touch" on the specified key.
+
+-------
+OPTIONS
+-------
+
+
+You can specify servers via the option:
+
+.. option:: --servers
+
+or via the environment variable:
+
+.. envvar:: `MEMCACHED_SERVERS`
+
+If you do not specify either these, the final value in the command line list is the name of a server(s).
+
+For a full list of operations run the tool with the option:
+
+.. option:: --help
+
+
+----
+HOME
+----
+
+
+To find out more information please check:
+`http://libmemcached.org/ <http://libmemcached.org/>`_
+
+
+------
+AUTHOR
+------
+
+Brian Aker, <brian@tangent.org>
+
+--------
+SEE ALSO
+--------
+
+
+:manpage:`memcached(1)` :manpage:`libmemcached(3)`
+
('bin/memaslap', 'memaslap', u'libmemcached Documentation', [u'Brian Aker'], 1),
('bin/memslap', 'memslap', u'libmemcached Documentation', [u'Brian Aker'], 1),
('bin/memstat', 'memstat', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('bin/memexist', 'memexist', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('bin/memparse', 'memparse', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('bin/memping', 'memping', u'libmemcached Documentation', [u'Brian Aker'], 1),
+ ('bin/memtouch', 'memtouch', u'libmemcached Documentation', [u'Brian Aker'], 1),
]
bin/memslap
bin/memaslap
bin/memstat
+ bin/memexist.rst
+ bin/memparse.rst
+ bin/memping.rst
+ bin/memtouch.rst
----------
Libhashkit
the list) are not saved.
:c:func:`memcached_server_by_key()` allows you to provide a key and retrieve the
-server which would be used for assignment. This structure is cloned
-from its original structure and must be freed. If NULL is returned you
-should consult \*error. The returning structure should be freed with
-:c:func:`memcached_server_free()`.
+server which would be used for assignment.
:c:func:`memcached_server_get_last_disconnect()` returns a pointer to the last
server for which there was a connection problem. It does not mean this
#include <libmemcached/common.h>
#include <libmemcached/memcached/protocol_binary.h>
-memcached_return_t memcached_delete(memcached_st *ptr, const char *key, size_t key_length,
+memcached_return_t memcached_delete(memcached_st *memc, const char *key, size_t key_length,
time_t expiration)
{
- return memcached_delete_by_key(ptr, key, key_length, key, key_length, expiration);
+ return memcached_delete_by_key(memc, key, key_length, key, key_length, expiration);
}
static inline memcached_return_t ascii_delete(memcached_server_write_instance_st instance,
const char *key,
const size_t key_length,
const bool reply,
- const bool flush)
+ const bool is_buffering)
{
libmemcached_io_vector_st vector[]=
{
{ memcached_literal_param("\r\n") }
};
- /* Send command header */
- return memcached_vdo(instance, vector, 6, flush);
+ /* Send command header, only flush if we are NOT buffering */
+ return memcached_vdo(instance, vector, 6, is_buffering ? false : true);
}
static inline memcached_return_t binary_delete(memcached_server_write_instance_st instance,
const char *key,
const size_t key_length,
const bool reply,
- const bool flush)
+ const bool is_buffering)
{
protocol_binary_request_delete request= {};
+ bool should_flush= is_buffering ? false : true;
+
request.message.header.request.magic= PROTOCOL_BINARY_REQ;
if (reply)
{
{
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETEQ;
}
- request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(instance->root->_namespace)));
+ request.message.header.request.keylen= htons(uint16_t(key_length + memcached_array_size(instance->root->_namespace)));
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
- request.message.header.request.bodylen= htonl((uint32_t)(key_length + memcached_array_size(instance->root->_namespace)));
+ request.message.header.request.bodylen= htonl(uint32_t(key_length + memcached_array_size(instance->root->_namespace)));
libmemcached_io_vector_st vector[]=
{
{ key, key_length }
};
- memcached_return_t rc= MEMCACHED_SUCCESS;
-
- if ((rc= memcached_vdo(instance, vector, 4, flush)) != MEMCACHED_SUCCESS)
+ memcached_return_t rc;
+ if (memcached_fatal(rc= memcached_vdo(instance, vector, 4, should_flush)))
{
memcached_io_reset(instance);
}
- if (instance->root->number_of_replicas > 0)
+ if (memcached_has_replicas(instance))
{
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETEQ;
- for (uint32_t x= 0; x < instance->root->number_of_replicas; ++x)
+ for (uint32_t x= 0; x < memcached_has_replicas(instance); ++x)
{
-
++server_key;
+
if (server_key == memcached_server_count(instance->root))
{
server_key= 0;
memcached_server_write_instance_st replica= memcached_server_instance_fetch(instance->root, server_key);
- if (memcached_vdo(replica, vector, 4, flush) != MEMCACHED_SUCCESS)
+ if (memcached_fatal(memcached_vdo(replica, vector, 4, should_flush)))
{
memcached_io_reset(replica);
}
return rc;
}
-memcached_return_t memcached_delete_by_key(memcached_st *ptr,
+memcached_return_t memcached_delete_by_key(memcached_st *memc,
const char *group_key, size_t group_key_length,
const char *key, size_t key_length,
time_t expiration)
LIBMEMCACHED_MEMCACHED_DELETE_START();
memcached_return_t rc;
- if (memcached_failed(rc= initialize_query(ptr, true)))
+ if (memcached_fatal(rc= initialize_query(memc, true)))
{
return rc;
}
- if (memcached_failed(rc= memcached_key_test(*ptr, (const char **)&key, &key_length, 1)))
+ if (memcached_fatal(rc= memcached_key_test(*memc, (const char **)&key, &key_length, 1)))
{
- return memcached_last_error(ptr);
+ return memcached_last_error(memc);
}
if (expiration)
{
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
+ return memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
memcached_literal_param("Memcached server version does not allow expiration of deleted items"));
}
- uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length);
- memcached_server_write_instance_st instance= memcached_server_instance_fetch(ptr, server_key);
+ uint32_t server_key= memcached_generate_hash_with_redistribution(memc, group_key, group_key_length);
+ memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, server_key);
- bool buffering= memcached_is_buffering(instance->root);
- bool reply= memcached_is_replying(instance->root);
+ bool is_buffering= memcached_is_buffering(instance->root);
+ bool is_replying= memcached_is_replying(instance->root);
// If a delete trigger exists, we need a response, so no buffering/noreply
- if (ptr->delete_trigger)
+ if (memc->delete_trigger)
{
- if (buffering)
+ if (is_buffering)
{
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
+ return memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
memcached_literal_param("Delete triggers cannot be used if buffering is enabled"));
}
- if (reply == false)
+ if (is_replying == false)
{
- return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
+ return memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
memcached_literal_param("Delete triggers cannot be used if MEMCACHED_BEHAVIOR_NOREPLY is set"));
}
}
- if (memcached_is_binary(ptr))
+ if (memcached_is_binary(memc))
{
- rc= binary_delete(instance, server_key, key, key_length, reply, buffering ? false : true);
+ rc= binary_delete(instance, server_key, key, key_length, is_replying, is_buffering);
}
else
{
- rc= ascii_delete(instance, server_key, key, key_length, reply, buffering ? false : true);
+ rc= ascii_delete(instance, server_key, key, key_length, is_replying, is_buffering);
}
if (rc == MEMCACHED_SUCCESS)
{
- if (buffering == true)
+ if (is_buffering == true)
{
rc= MEMCACHED_BUFFERED;
}
- else if (reply == false)
+ else if (is_replying == false)
{
rc= MEMCACHED_SUCCESS;
}
if (rc == MEMCACHED_DELETED)
{
rc= MEMCACHED_SUCCESS;
- if (ptr->delete_trigger)
+ if (memc->delete_trigger)
{
- ptr->delete_trigger(ptr, key, key_length);
+ memc->delete_trigger(memc, key, key_length);
}
}
}
}
LIBMEMCACHED_MEMCACHED_DELETE_END();
- return memcached_set_error(*ptr, rc, MEMCACHED_AT );
+ return rc;
}
return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT);
}
- perror(__func__);
return memcached_set_errno(*instance, errno, MEMCACHED_AT);
}
}
if (sent_length == -1 or size_t(sent_length) != command_length)
{
- rc= MEMCACHED_WRITE_FAILURE;
- WATCHPOINT_ERROR(rc);
- WATCHPOINT_ERRNO(errno);
+ if (memcached_last_error(instance->root) == MEMCACHED_SUCCESS)
+ {
+ return memcached_set_error(*instance, MEMCACHED_WRITE_FAILURE, MEMCACHED_AT);
+ }
+ else
+ {
+ rc= MEMCACHED_WRITE_FAILURE;
+ }
}
else if (memcached_is_replying(instance->root))
{
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;
}
libmemcached/namespace.h \
libmemcached/options.hpp \
libmemcached/response.h \
+ libmemcached/sasl.hpp \
libmemcached/server.hpp \
libmemcached/server_instance.h \
libmemcached/socket.hpp \
libmemcached/quit.hpp \
libmemcached/response.cc \
libmemcached/result.cc \
- libmemcached/sasl.hpp \
+ libmemcached/sasl.cc \
libmemcached/server.cc \
libmemcached/server_list.cc \
libmemcached/server_list.hpp \
libmemcached_libmemcached_la_LDFLAGS=
libmemcached_libmemcached_la_LDFLAGS+= -version-info ${MEMCACHED_LIBRARY_VERSION}
-libmemcached_libmemcached_la_LIBADD+= $(LTLIBSASL) $(LTLIBSASL2)
-libmemcached_libmemcached_la_SOURCES += libmemcached/sasl.cc
if HAVE_SASL
-libmemcached_libmemcached_la_CXXFLAGS+= ${PTHREAD_CFLAGS}
-libmemcached_libmemcached_la_LIBADD+= ${PTHREAD_LIBS}
+libmemcached_libmemcached_la_CXXFLAGS+= $(LIBSASL_CPPFLAGS)
+libmemcached_libmemcached_la_CXXFLAGS+= $(PTHREAD_CFLAGS)
+libmemcached_libmemcached_la_LIBADD+= $(PTHREAD_LIBS)
+libmemcached_libmemcached_la_LIBADD+= $(LIBSASL_LDFLAGS)
endif
if HAVE_DTRACE
*/
if (read_or_write == MEM_WRITE)
{
- memcached_return_t rc= memcached_purge(ptr);
- if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED)
+ if (memcached_fatal(memcached_purge(ptr)))
{
return MEMCACHED_FAILURE;
}
** in the purge function to avoid duplicating the logic..
*/
{
- memcached_return_t rc;
WATCHPOINT_ASSERT(ptr->fd != INVALID_SOCKET);
- rc= memcached_purge(ptr);
+ memcached_return_t rc= memcached_purge(ptr);
- if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED)
+ if (rc != MEMCACHED_SUCCESS and rc != MEMCACHED_STORED)
{
return false;
}
{
#define MAX_SERVERS_TO_POLL 100
struct pollfd fds[MAX_SERVERS_TO_POLL];
- unsigned int host_index= 0;
+ nfds_t host_index= 0;
for (uint32_t x= 0; x < memcached_server_count(memc) and host_index < MAX_SERVERS_TO_POLL; ++x)
{
break;
default:
- for (size_t x= 0; x < host_index; ++x)
+ for (nfds_t x= 0; x < host_index; ++x)
{
if (fds[x].revents & POLLIN)
{
#define memcached_has_error(__object) ((__object)->error_messages)
+#define memcached_has_replicas(__object) ((__object)->root->number_of_replicas)
+
#define memcached_set_purging(__object, __value) ((__object)->state.is_purging= (__value))
#define memcached_set_processing_input(__object, __value) ((__object)->state.is_processing_input= (__value))
#define memcached_set_initialized(__object, __value) ((__object)->options.is_initialized(= (__value))
// we just check the size of the key
if (memc.flags.verify_key == false or memc.flags.binary_protocol == true)
{
- for (uint32_t x= 0; x < number_of_keys; x++)
+ for (size_t x= 0; x < number_of_keys; x++)
{
// We should set binary key, but the memcached server is broken for
// longer keys at the moment.
return MEMCACHED_SUCCESS;
}
- for (uint32_t x= 0; x < number_of_keys; x++)
+ for (size_t x= 0; x < number_of_keys; x++)
{
memcached_return_t rc= memcached_validate_key_length(*(key_length + x), false);
if (memcached_failed(rc))
#include <libmemcached-1.0/struct/memcached.h>
+#ifdef __cplusplus
+#include <cstddef>
+#include <cstdlib>
+#else
+#include <stddef.h>
+#include <stdlib.h>
+#endif
+
static inline void libmemcached_free(const memcached_st *self, void *mem)
{
if (self)
{
for (uint32_t y= 0; y < cb.number_of_callback; y++)
{
- rc = (*cb.callback[y])(ptr->root, result_ptr, cb.context);
- if (rc != MEMCACHED_SUCCESS)
+ if (memcached_fatal((*cb.callback[y])(ptr->root, result_ptr, cb.context)))
{
break;
}
char *key= result->item_key;
result->key_length= 0;
- for (size_t prefix_length= memcached_array_size(instance->root->_namespace); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++)
+ for (ptrdiff_t prefix_length= memcached_array_size(instance->root->_namespace); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++)
{
if (prefix_length == 0)
{
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version"));
}
instance->major_version= uint8_t(version);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse minor version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse minor version"));
}
instance->minor_version= uint8_t(version);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
}
instance->micro_version= uint8_t(version);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX or version == 0)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse major version"));
}
instance->major_version= uint8_t(version);
if (version == LONG_MIN or version == LONG_MAX or errno == EINVAL or version > UINT8_MAX)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
}
instance->minor_version= uint8_t(version);
if (errno == ERANGE)
{
instance->major_version= instance->minor_version= instance->micro_version= UINT8_MAX;
- return memcached_set_error(*instance, MEMCACHED_PROTOCOL_ERROR, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
+ return memcached_set_error(*instance, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT, memcached_literal_param("strtol() failed to parse micro version"));
}
instance->micro_version= uint8_t(version);
}
else
{
rc= textual_read_one_response(instance, buffer, buffer_length, result);
- assert(rc != MEMCACHED_PROTOCOL_ERROR);
}
if (memcached_fatal(rc))
#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
+#if defined(HAVE_LIBSASL) && HAVE_LIBSASL
#include <sasl/sasl.h>
+#endif
+
#include <pthread.h>
void memcached_set_sasl_callbacks(memcached_st *ptr,
* into the list, but if we don't know the ID we don't know how to handle
* the context...
*/
- size_t total= 0;
+ ptrdiff_t total= 0;
while (source->sasl.callbacks[total].id != SASL_CB_LIST_END)
{
memcpy(callbacks, source->sasl.callbacks, (total + 1) * sizeof(sasl_callback_t));
/* Now update the context... */
- for (size_t x= 0; x < total; ++x)
+ for (ptrdiff_t x= 0; x < total; ++x)
{
if (callbacks[x].id == SASL_CB_USER || callbacks[x].id == SASL_CB_AUTHNAME)
{
if (callbacks[x].context == NULL)
{
/* Failed to allocate memory, clean up previously allocated memory */
- for (size_t y= 0; y < x; ++y)
+ for (ptrdiff_t y= 0; y < x; ++y)
{
libmemcached_free(clone, clone->sasl.callbacks[y].context);
}
if (n == NULL)
{
/* Failed to allocate memory, clean up previously allocated memory */
- for (size_t y= 0; y < x; ++y)
+ for (ptrdiff_t y= 0; y < x; ++y)
{
libmemcached_free(clone, clone->sasl.callbacks[y].context);
}
bool has_gearmand_binary()
{
#if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
- if (access(GEARMAND_BINARY,R_OK|X_OK) == 0)
+ std::stringstream arg_buffer;
+
+ if (getenv("PWD"))
+ {
+ arg_buffer << getenv("PWD");
+ arg_buffer << "/";
+ }
+ arg_buffer << GEARMAND_BINARY;
+
+ if (access(arg_buffer.str().c_str() ,R_OK|X_OK) == 0)
{
return true;
}
const char *executable()
{
- return GEARMAND_BLOBSLAP_WORKER;
+ return "benchmark/blobslap_worker";
}
const char *pid_file_option()
using namespace libtest;
#include <cstdlib>
-#include <string>
+#include <cstring>
+#include <fcntl.h>
+#include <memory>
+#include <spawn.h>
#include <sstream>
+#include <string>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+extern "C" {
+ static int exited_successfully(int status)
+ {
+ if (status == 0)
+ {
+ return EXIT_SUCCESS;
+ }
+
+ if (WIFEXITED(status) == true)
+ {
+ return WEXITSTATUS(status);
+ }
+ else if (WIFSIGNALED(status) == true)
+ {
+ return WTERMSIG(status);
+ }
+
+ return EXIT_FAILURE;
+ }
+}
+
+namespace {
+
+ std::string print_argv(char * * & built_argv, const size_t& argc, const pid_t& pid)
+ {
+ std::stringstream arg_buffer;
+
+ for (size_t x= 0; x < argc; x++)
+ {
+ arg_buffer << built_argv[x] << " ";
+ }
+
+ return arg_buffer.str();
+ }
+
+}
namespace libtest {
-bool exec_cmdline(const std::string& executable, const char *args[])
+Application::Application(const std::string& arg, const bool _use_libtool_arg) :
+ _use_libtool(_use_libtool_arg),
+ _argc(0),
+ _exectuble(arg),
+ built_argv(NULL),
+ _pid(-1)
+ {
+ if (_use_libtool)
+ {
+ if (libtool() == NULL)
+ {
+ throw "libtool requested, but know libtool was found";
+ }
+ }
+
+ if (_use_libtool and getenv("PWD"))
+ {
+ _exectuble_with_path+= getenv("PWD");
+ _exectuble_with_path+= "/";
+ }
+ _exectuble_with_path+= _exectuble;
+ }
+
+Application::~Application()
+{
+ delete_argv();
+}
+
+Application::error_t Application::run(const char *args[])
{
- std::stringstream arg_buffer;
+ stdin_fd.reset();
+ stdout_fd.reset();
+ stderr_fd.reset();
+ _stdout_buffer.clear();
+ _stderr_buffer.clear();
- arg_buffer << libtool();
+ posix_spawn_file_actions_t file_actions;
+ posix_spawn_file_actions_init(&file_actions);
- if (getenv("PWD"))
+ stdin_fd.dup_for_spawn(Application::Pipe::READ, file_actions, STDIN_FILENO);
+ stdout_fd.dup_for_spawn(Application::Pipe::WRITE, file_actions, STDOUT_FILENO);
+ stderr_fd.dup_for_spawn(Application::Pipe::WRITE, file_actions, STDERR_FILENO);
+
+ create_argv(args);
+
+ int spawn_ret;
+ if (_use_libtool)
{
- arg_buffer << getenv("PWD");
- arg_buffer << "/";
+ spawn_ret= posix_spawn(&_pid, built_argv[0], &file_actions, NULL, built_argv, NULL);
}
+ else
+ {
+ spawn_ret= posix_spawnp(&_pid, built_argv[0], &file_actions, NULL, built_argv, NULL);
+ }
+
+ posix_spawn_file_actions_destroy(&file_actions);
- arg_buffer << executable;
- for (const char **ptr= args; *ptr; ++ptr)
+ stdin_fd.close(Application::Pipe::READ);
+ stdout_fd.close(Application::Pipe::WRITE);
+ stderr_fd.close(Application::Pipe::WRITE);
+
+ if (spawn_ret)
{
- arg_buffer << " " << *ptr;
+ Error << print();
+ return Application::INVALID;
}
+ return Application::SUCCESS;
+}
+
+Application::error_t Application::wait()
+{
+ if (_pid == -1)
+ {
+ Error << "wait() got an invalid pid_t";
+ return Application::INVALID;
+ }
+
+ {
+ ssize_t read_length;
+ char buffer[1024]= { 0 };
+ bool bail= false;
+ while (((read_length= ::read(stdout_fd.fd()[0], buffer, sizeof(buffer))) != 0) or bail)
+ {
+ if (read_length == -1)
+ {
+ switch(errno)
+ {
+ case EAGAIN:
+ continue;
+
+ default:
+ Error << strerror(errno);
+ bail= true;
+ }
+ }
+ _stdout_buffer.reserve(read_length +1);
+ for (size_t x= 0; x < read_length; x++)
+ {
+ _stdout_buffer.push_back(buffer[x]);
+ }
+ // @todo Suck up all output code here
+ }
+ }
+
+ {
+ ssize_t read_length;
+ char buffer[1024]= { 0 };
+ bool bail= false;
+ while (((read_length= ::read(stderr_fd.fd()[0], buffer, sizeof(buffer))) != 0) or bail)
+ {
+ if (read_length == -1)
+ {
+ switch(errno)
+ {
+ case EAGAIN:
+ continue;
+
+ default:
+ Error << strerror(errno);
+ bail= true;
+ }
+ }
+ _stderr_buffer.reserve(read_length +1);
+ for (size_t x= 0; x < read_length; x++)
+ {
+ _stderr_buffer.push_back(buffer[x]);
+ }
+ // @todo Suck up all errput code here
+ }
+ }
+
+ error_t exit_code= FAILURE;
+ {
+ int status= 0;
+ pid_t waited_pid;
+ if ((waited_pid= waitpid(_pid, &status, 0)) == -1)
+ {
+ Error << "Error occured while waitpid(" << strerror(errno) << ") on pid " << int(_pid);
+ }
+ else
+ {
+ assert(waited_pid == _pid);
+ exit_code= error_t(exited_successfully(status));
+ }
+ }
+
+ if (exit_code == Application::INVALID)
+ {
#if 0
- arg_buffer << " > /dev/null 2>&1";
+ Error << print_argv(built_argv, _argc, _pid);
#endif
+ }
+
+ return exit_code;
+}
+
+void Application::add_option(const std::string& arg)
+{
+ _options.push_back(std::make_pair(arg, std::string()));
+}
+
+void Application::add_option(const std::string& name, const std::string& value)
+{
+ _options.push_back(std::make_pair(name, value));
+}
+
+Application::Pipe::Pipe()
+{
+ _fd[0]= -1;
+ _fd[1]= -1;
+ _open[0]= false;
+ _open[1]= false;
+}
+
+void Application::Pipe::reset()
+{
+ close(READ);
+ close(WRITE);
+
+ int ret;
+ if ((ret= pipe(_fd)) < 0)
+ {
+ throw strerror(ret);
+ }
+ _open[0]= true;
+ _open[1]= true;
+
+ {
+ ret= fcntl(_fd[0], F_GETFL, 0);
+ if (ret == -1)
+ {
+ Error << "fcntl(F_GETFL) " << strerror(ret);
+ throw strerror(ret);
+ }
+
+ ret= fcntl(_fd[0], F_SETFL, ret | O_NONBLOCK);
+ if (ret == -1)
+ {
+ Error << "fcntl(F_SETFL) " << strerror(ret);
+ throw strerror(ret);
+ }
+ }
+}
+
+Application::Pipe::~Pipe()
+{
+ close(READ);
+ close(WRITE);
+}
+
+void Application::Pipe::dup_for_spawn(const close_t& arg, posix_spawn_file_actions_t& file_actions, const int newfildes)
+{
+ int type= int(arg);
+
+ int ret;
+ if ((ret= posix_spawn_file_actions_adddup2(&file_actions, _fd[type], newfildes )) < 0)
+ {
+ Error << "posix_spawn_file_actions_adddup2(" << strerror(ret) << ")";
+ throw strerror(ret);
+ }
+
+ if ((ret= posix_spawn_file_actions_addclose(&file_actions, _fd[type])) < 0)
+ {
+ Error << "posix_spawn_file_actions_adddup2(" << strerror(ret) << ")";
+ throw strerror(ret);
+ }
+}
+
+void Application::Pipe::close(const close_t& arg)
+{
+ int type= int(arg);
+
+ if (_open[type])
+ {
+ int ret;
+ if ((ret= ::close(_fd[type])) < 0)
+ {
+ Error << "close(" << strerror(ret) << ")";
+ }
+ _open[type]= false;
+ }
+}
+
+void Application::create_argv(const char *args[])
+{
+ _argc= 2 +_use_libtool ? 2 : 0; // +1 for the command, +2 for libtool/mode=execute, +1 for the NULL
+
+ if (_use_libtool)
+ {
+ _argc+= 2; // +2 for libtool --mode=execute
+ }
+
+ for (Options::const_iterator iter= _options.begin(); iter != _options.end(); iter++)
+ {
+ _argc++;
+ if ((*iter).second.empty() == false)
+ {
+ _argc++;
+ }
+ }
+
+ if (args)
+ {
+ for (const char **ptr= args; *ptr; ++ptr)
+ {
+ _argc++;
+ }
+ }
+
+ delete_argv();
+ built_argv= new char * [_argc];
+
+ size_t x= 0;
+ if (_use_libtool)
+ {
+ assert(libtool());
+ built_argv[x++]= strdup(libtool());
+ built_argv[x++]= strdup("--mode=execute");
+ }
+ built_argv[x++]= strdup(_exectuble_with_path.c_str());
+
+ for (Options::const_iterator iter= _options.begin(); iter != _options.end(); iter++)
+ {
+ built_argv[x++]= strdup((*iter).first.c_str());
+ if ((*iter).second.empty() == false)
+ {
+ built_argv[x++]= strdup((*iter).second.c_str());
+ }
+ }
+
+ if (args)
+ {
+ for (const char **ptr= args; *ptr; ++ptr)
+ {
+ built_argv[x++]= strdup(*ptr);
+ }
+ }
+ built_argv[_argc -1]= NULL;
+}
+
+std::string Application::print()
+{
+ return print_argv(built_argv, _argc, _pid);
+}
+
+void Application::delete_argv()
+{
+ if (built_argv == NULL)
+ {
+ return;
+ }
+
+ for (size_t x= 0; x < _argc; x++)
+ {
+ if (built_argv[x])
+ {
+ ::free(built_argv[x]);
+ }
+ }
+ delete[] built_argv;
+ built_argv= NULL;
+ _argc= 0;
+}
+
+
+int exec_cmdline(const std::string& command, const char *args[], bool use_libtool)
+{
+ Application app(command, use_libtool);
+
+ Application::error_t ret= app.run(args);
- if (system(arg_buffer.str().c_str()) == -1)
+ if (ret != Application::SUCCESS)
{
- return false;
+ return int(ret);
}
+ ret= app.wait();
- return true;
+ return int(ret);
}
const char *gearmand_binary()
#pragma once
+#include <spawn.h>
+
namespace libtest {
-bool exec_cmdline(const std::string& executable, const char *args[]);
+class Application {
+private:
+ typedef std::vector< std::pair<std::string, std::string> > Options;
+
+public:
+
+ enum error_t {
+ SUCCESS= EXIT_SUCCESS,
+ FAILURE= EXIT_FAILURE,
+ INVALID= 127
+ };
+
+ class Pipe {
+ public:
+ Pipe();
+ ~Pipe();
+
+ int* fd()
+ {
+ return _fd;
+ }
+
+ enum close_t {
+ READ,
+ WRITE
+ };
+
+ void reset();
+ void close(const close_t& arg);
+ void dup_for_spawn(const close_t& arg,
+ posix_spawn_file_actions_t& file_actions,
+ const int newfildes);
+
+ private:
+ int _fd[2];
+ bool _open[2];
+ };
+
+public:
+ Application(const std::string& arg, const bool _use_libtool_arg= false);
+
+ virtual ~Application();
+
+ void add_option(const std::string&);
+ void add_option(const std::string&, const std::string&);
+ error_t run(const char *args[]= NULL);
+ error_t wait();
+
+ libtest::vchar_t stdout_result() const
+ {
+ return _stdout_buffer;
+ }
+
+ size_t stdout_result_length() const
+ {
+ return _stdout_buffer.size();
+ }
+
+ libtest::vchar_t stderr_result() const
+ {
+ return _stderr_buffer;
+ }
+
+ size_t stderr_result_length() const
+ {
+ return _stderr_buffer.size();
+ }
+
+ std::string print();
+
+private:
+ void create_argv(const char *args[]);
+ void delete_argv();
+
+private:
+ const bool _use_libtool;
+ size_t _argc;
+ std::string _exectuble;
+ std::string _exectuble_with_path;
+ Options _options;
+ Pipe stdin_fd;
+ Pipe stdout_fd;
+ Pipe stderr_fd;
+ char * * built_argv;
+ pid_t _pid;
+ libtest::vchar_t _stdout_buffer;
+ libtest::vchar_t _stderr_buffer;
+};
+
+static inline std::ostream& operator<<(std::ostream& output, const enum Application::error_t &arg)
+{
+ switch (arg)
+ {
+ case Application::SUCCESS:
+ output << "EXIT_SUCCESS";
+ break;
+
+ case Application::FAILURE:
+ output << "EXIT_FAILURE";
+ break;
+
+ case Application::INVALID:
+ output << "127";
+ break;
+ }
+
+ return output;
+}
+
+int exec_cmdline(const std::string& executable, const char *args[], bool use_libtool= false);
const char *gearmand_binary();
#endif
#if defined(HAVE_LIBGEARMAN) && HAVE_LIBGEARMAN
-#include <libgearman/gearman.h>
+#include <libgearman-1.0/ostream.hpp>
#endif
namespace libtest {
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include <libtest/common.h>
+
+namespace libtest {
+
+void dream(time_t tv_sec, long tv_nsec)
+{
+#ifdef WIN32
+ if (tv_sec == 0 and tv_nsec)
+ {
+ tv_sec++;
+ }
+ sleep(tv_sec);
+#else
+ struct timespec requested;
+ requested.tv_sec= tv_sec;
+ requested.tv_nsec= tv_nsec;
+ nanosleep(&requested, NULL);
+#endif
+}
+
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+namespace libtest {
+
+void dream(time_t tv_sec, long tv_nsec= 0);
+
+}
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <libtest/common.h>
+#include <cstdarg>
+
+namespace libtest {
+
+fatal::fatal(const char *file, int line, const char *func, const char *format, ...) :
+ std::runtime_error(func)
+ {
+ va_list args;
+ va_start(args, format);
+ char last_error[BUFSIZ];
+ (void)vsnprintf(last_error, sizeof(last_error), format, args);
+ va_end(args);
+
+ snprintf(_error_message, sizeof(_error_message), "%s:%d FATAL:%s (%s)", file, int(line), last_error, func);
+ }
+
+static bool _disabled= false;
+static uint32_t _counter= 0;
+
+bool fatal::is_disabled()
+{
+ return _disabled;
+}
+
+bool fatal::disable()
+{
+ _disabled= true;
+}
+
+bool fatal::enable()
+{
+ _disabled= false;
+}
+
+uint32_t fatal::disabled_counter()
+{
+ return _counter;
+}
+
+void fatal::increment_disabled_counter()
+{
+ _counter++;
+}
+
+} // namespace libtest
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+#include <stdexcept>
+
+#ifndef __PRETTY_FUNCTION__
+#define __PRETTY_FUNCTION__ __func__
+#endif
+
+#define LIBYATL_DEFAULT_PARAM __FILE__, __LINE__, __PRETTY_FUNCTION__
+
+namespace libtest {
+
+class fatal : std::runtime_error
+{
+public:
+ fatal(const char *file, int line, const char *func, const char *format, ...);
+
+ const char* what() const throw()
+ {
+ return _error_message;
+ }
+
+ // The following are just for unittesting the exception class
+ static bool is_disabled();
+ static bool disable();
+ static bool enable();
+ static uint32_t disabled_counter();
+ static void increment_disabled_counter();
+
+private:
+ char _error_message[BUFSIZ];
+};
+
+
+} // namespace libtest
+
+#define fatal_message(__mesg) libtest::fatal(LIBYATL_DEFAULT_PARAM, __mesg)
pid_t get_pid(bool error_is_ok)
{
- if (not pid_file().empty())
+ if (pid_file().empty() == false)
{
Wait wait(pid_file(), 0);
bool ping()
{
gearman_client_st *client= gearman_client_create(NULL);
- if (not client)
+ if (client == NULL)
{
Error << "Could not allocate memory for gearman_client_create()";
return false;
}
- gearman_client_set_timeout(client, 1000);
+ gearman_client_set_timeout(client, 3000);
if (gearman_success(gearman_client_add_server(client, hostname().c_str(), port())))
{
gearman_client_free(client);
return true;
}
+#if 0
+ Error << hostname().c_str() << ":" << port() << " was " << gearman_strerror(rc) << " extended: " << gearman_client_error(client);
+#endif
+ }
+ else
+ {
+ Error << "gearman_client_add_server() " << gearman_client_error(client);
}
gearman_client_free(client);
const char *log_file_option()
{
- return "-vvvvv --log-file=";
+ return "--verbose=DEBUG --log-file=";
}
const char *port_option()
return true;
}
+ bool has_syslog() const
+ {
+ return true;
+ }
+
bool build(int argc, const char *argv[]);
};
arg_buffer << " -u root ";
}
- arg_buffer << " --listen=127.0.0.1 ";
+ arg_buffer << " --listen=localhost ";
for (int x= 1 ; x < argc ; x++)
{
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <config.h>
+#include <libtest/has.hpp>
+
+#include <cstdlib>
+
+bool has_memcached_support(void)
+{
+ if (HAVE_LIBMEMCACHED and HAVE_MEMCACHED_BINARY)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool has_drizzle_support(void)
+{
+ if (HAVE_LIBDRIZZLE and HAVE_DRIZZLED_BINARY)
+ {
+ return true;
+ }
+
+ return false;
+}
+
+bool has_postgres_support(void)
+{
+ if (getenv("POSTGES_IS_RUNNING_AND_SETUP"))
+ {
+
+ if (HAVE_LIBPQ)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#pragma once
+
+bool has_memcached_support(void);
+
+bool has_drizzle_support(void);
+
+bool has_postgres_support(void);
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <libtest/common.h>
+
+#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
+#include <curl/curl.h>
+#else
+class CURL;
+#endif
+
+namespace libtest {
+namespace http {
+
+#define YATL_USERAGENT "YATL/1.0"
+
+extern "C" size_t
+ http_get_result_callback(void *ptr, size_t size, size_t nmemb, void *data)
+ {
+ size_t body_size= size * nmemb;
+
+ vchar_t *_body= (vchar_t*)data;
+
+ _body->resize(size * nmemb);
+ memcpy(&_body[0], ptr, _body->size());
+
+ return _body->size();
+ }
+
+
+static void init(CURL *curl, const std::string& url)
+{
+ if (HAVE_LIBCURL)
+ {
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
+ assert(curl);
+ curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
+ curl_easy_setopt(curl, CURLOPT_USERAGENT, YATL_USERAGENT);
+#endif
+ }
+}
+
+bool GET::execute()
+{
+ if (HAVE_LIBCURL)
+ {
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
+ CURL *curl= curl_easy_init();
+
+ init(curl, url());
+
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, http_get_result_callback);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&_body);
+
+ CURLcode retref= curl_easy_perform(curl);
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, _response);
+
+ curl_easy_cleanup(curl);
+
+ return retref == CURLE_OK;
+#endif
+ }
+
+ return false;
+}
+
+bool POST::execute()
+{
+ if (HAVE_LIBCURL)
+ {
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
+ CURL *curl= curl_easy_init();;
+
+ init(curl, url());
+
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, _body.size());
+ curl_easy_setopt(curl, CURLOPT_POSTFIELDS, (void *)&_body[0]);
+
+ CURLcode retref= curl_easy_perform(curl);
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, _response);
+
+ curl_easy_cleanup(curl);
+#endif
+ }
+
+ return false;
+}
+
+bool TRACE::execute()
+{
+ if (HAVE_LIBCURL)
+ {
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
+ CURL *curl= curl_easy_init();;
+
+ init(curl, url());
+
+ curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "TRACE");
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, http_get_result_callback);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&_body[0]);
+
+ CURLcode retref= curl_easy_perform(curl);
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, _response);
+
+ curl_easy_cleanup(curl);
+
+ return retref == CURLE_OK;
+#endif
+ }
+
+ return false;
+}
+
+bool HEAD::execute()
+{
+ if (HAVE_LIBCURL)
+ {
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
+ CURL *curl= curl_easy_init();;
+
+ init(curl, url());
+
+ curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "HEAD");
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, http_get_result_callback);
+
+ CURLcode retref= curl_easy_perform(curl);
+ curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, _response);
+
+ curl_easy_cleanup(curl);
+
+ return retref == CURLE_OK;
+#endif
+ }
+
+ return false;
+}
+
+} // namespace http
+} // namespace libtest
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#pragma once
+
+namespace libtest {
+namespace http {
+
+class HTTP {
+public:
+
+ HTTP(const std::string& url_arg) :
+ _url(url_arg),
+ _response(0)
+ { }
+
+ virtual bool execute()= 0;
+
+ virtual ~HTTP()
+ { }
+
+ const std::string& url() const
+ {
+ return _url;
+ }
+
+ long response()
+ {
+ return _response;
+ }
+
+private:
+ std::string _url;
+
+protected:
+ long _response;
+};
+
+class GET: public HTTP {
+public:
+
+ GET(const std::string& url_arg) :
+ HTTP(url_arg)
+ {
+ }
+
+ bool execute();
+
+private:
+ libtest::vchar_t _body;
+};
+
+class POST: public HTTP {
+public:
+
+ POST(const std::string& url_arg,
+ const vchar_t& post_arg) :
+ HTTP(url_arg),
+ _post(post_arg)
+ {
+ }
+
+ bool execute();
+
+private:
+ libtest::vchar_t _post;
+ libtest::vchar_t _body;
+};
+
+class TRACE: public HTTP {
+public:
+
+ TRACE(const std::string& url_arg,
+ const vchar_t& body_arg) :
+ HTTP(url_arg),
+ _body(body_arg)
+ {
+ }
+
+ bool execute();
+
+private:
+ libtest::vchar_t _body;
+};
+
+class HEAD: public HTTP {
+public:
+
+ HEAD(const std::string& url_arg) :
+ HTTP(url_arg)
+ {
+ }
+
+ bool execute();
+
+private:
+};
+
+} // namespace http
+} // namespace libtest
libtest/common.h \
libtest/comparison.hpp \
libtest/core.h \
+ libtest/dream.h \
libtest/error.h \
libtest/failed.h \
+ libtest/fatal.hpp \
libtest/framework.h \
libtest/gearmand.h \
libtest/get.h \
+ libtest/has.hpp \
+ libtest/http.hpp \
libtest/is_pid.hpp \
libtest/is_local.hpp \
libtest/killpid.h \
libtest/string.hpp \
libtest/test.h \
libtest/test.hpp \
+ libtest/vchar.hpp \
libtest/visibility.h \
libtest/wait.h
libtest/binaries.cc \
libtest/cmdline.cc \
libtest/core.cc \
+ libtest/dream.cc \
+ libtest/fatal.cc \
libtest/framework.cc \
+ libtest/has.cc \
+ libtest/http.cc \
libtest/is_local.cc \
libtest/killpid.cc \
libtest/libtool.cc \
libtest/signal.cc \
libtest/socket.cc \
libtest/strerror.cc \
- libtest/test.cc
+ libtest/test.cc \
+ libtest/vchar.cc
-libtest_libtest_la_CXXFLAGS= ${AM_CXXFLAGS}
+libtest_libtest_la_CXXFLAGS=
libtest_libtest_la_CXXFLAGS+= ${NO_CONVERSION}
libtest_libtest_la_CXXFLAGS+= -DBUILDING_LIBTEST
libtest_libtest_la_CXXFLAGS+= $(PTHREAD_CFLAGS)
libtest_libtest_la_CXXFLAGS+= -DLIBTEST_TEMP="\"tmp_chroot\""
+libtest_libtest_la_CXXFLAGS+= $(CURL_CFLAGS)
libtest_libtest_la_LIBADD=
libtest_libtest_la_LIBADD+= $(PTHREAD_LIBS)
+libtest_libtest_la_LIBADD+= $(CURL_LIBS)
libtest_libtest_la_DEPENDENCIES= libtest_tmp_dir
# Declare unittest so that we can append to it
libtest_libtest_la_SOURCES+= libtest/gearmand.cc
libtest_libtest_la_SOURCES+= util/instance.cc
libtest_libtest_la_SOURCES+= util/operation.cc
-libtest_libtest_la_CXXFLAGS+= -DGEARMAND_BLOBSLAP_WORKER="\"${abs_top_builddir}/benchmark/blobslap_worker\""
libtest_unittest_LDADD+= libgearman/libgearman.la
libtest_unittest_DEPENDENCIES+= libgearman/libgearman.la
+libtest_unittest_DEPENDENCIES+= gearmand/gearmand
else
if HAVE_LIBGEARMAN
libtest_libtest_la_DEPENDENCIES+= libgearman/libgearman.la
libtest_libtest_la_SOURCES+= libtest/gearmand.cc
libtest_libtest_la_SOURCES+= util/instance.cc
libtest_libtest_la_SOURCES+= util/operation.cc
-libtest_libtest_la_CXXFLAGS+= -DGEARMAND_BLOBSLAP_WORKER=0
-else
-libtest_libtest_la_CXXFLAGS+= -DGEARMAND_BLOBSLAP_WORKER=0
endif
endif
@$(mkdir_p) tmp_chroot/var/run
-libtest_unittest_CXXFLAGS+= ${AM_CXXFLAGS}
libtest_unittest_DEPENDENCIES+= libtest/libtest.la libtest_tmp_dir
libtest_unittest_LDADD+= libtest/libtest.la
libtest_unittest_SOURCES= libtest/unittest.cc
const char *libtool(void)
{
- if (_libtool[0])
+ if (_libtool[0] == 0)
{
std::string libtool_buffer;
- if (getenv("srcdir"))
+ if (getenv("PWD"))
{
- libtool_buffer+= getenv("srcdir");
+ libtool_buffer+= getenv("PWD");
libtool_buffer+= "/";
}
else
libtool_buffer+= "libtool";
if (access(libtool_buffer.c_str(), R_OK | W_OK | X_OK))
{
+ Error << "Could not find libtool via access(" << libtool_buffer << ") :" << strerror(errno);
return NULL;
}
- libtool_buffer+= " --mode=execute ";
-
snprintf(_libtool, sizeof(_libtool), "%s", libtool_buffer.c_str());
}
return _libtool;
}
-}
+} // namespace libtest
#include <libtest/common.h>
-#include <libmemcached/memcached.h>
-#include <libmemcached/util.h>
+#include <libmemcached-1.0/memcached.h>
+#include <libmemcachedutil-1.0/util.h>
using namespace libtest;
#include <cassert>
#include <cstdlib>
#include <cstring>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <unistd.h>
#include <ctime>
#include <fnmatch.h>
#include <iostream>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
#include <signal.h>
using namespace libtest;
+struct socket_st {
+ std::vector<int> fd;
+
+ ~socket_st()
+ {
+ for(std::vector<int>::iterator iter= fd.begin(); iter != fd.end(); iter++)
+ {
+ close(*iter);
+ }
+ }
+};
+
+static socket_st all_socket_fd;
+
static in_port_t global_port= 0;
-static in_port_t global_max_port= 0;
namespace libtest {
in_port_t default_port()
{
+ if (global_port == 0)
+ {
+ global_port= get_free_port();
+ }
+
return global_port;
}
-
-void set_default_port(in_port_t port)
-{
- global_port= port;
-}
-in_port_t max_port()
+in_port_t get_free_port()
{
- return global_max_port;
-}
-
-void set_max_port(in_port_t port)
-{
- if (port > global_max_port)
+ in_port_t ret_port= in_port_t(0);
+
+ int retries= 1024;
+
+ while (retries--)
+ {
+ int sd;
+ if ((sd= socket(AF_INET, SOCK_STREAM, 0)) != -1)
+ {
+ int optval= 1;
+ if (setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) != -1)
+ {
+ struct sockaddr_in sin;
+ sin.sin_port= 0;
+ sin.sin_addr.s_addr= 0;
+ sin.sin_addr.s_addr= INADDR_ANY;
+ sin.sin_family= AF_INET;
+
+ if (bind(sd, (struct sockaddr *)&sin,sizeof(struct sockaddr_in) ) != -1)
+ {
+ socklen_t addrlen= sizeof(sin);
+
+ if (getsockname(sd, (struct sockaddr *)&sin, &addrlen) != -1)
+ {
+ ret_port= sin.sin_port;
+ }
+ }
+ }
+
+ all_socket_fd.fd.push_back(sd);
+ }
+
+ if (ret_port > 1024)
+ {
+ break;
+ }
+ }
+
+ // We handle the case where if we max out retries, we still abort.
+ if (ret_port <= 1024)
{
- global_max_port= port;
+ throw fatal_message("No port could be found");
}
- global_max_port= port;
+ return ret_port;
}
} // namespace libtest
in_port_t default_port();
LIBTEST_API
-void set_default_port(in_port_t port);
-
-LIBTEST_API
-in_port_t max_port();
-
-LIBTEST_API
-void set_max_port(in_port_t port);
+in_port_t get_free_port();
} // namespace libtest
#include <libtest/killpid.h>
extern "C" {
- static bool exited_successfully(int status)
+ static bool exited_successfully(int status, const std::string &command)
{
- if (WEXITSTATUS(status) == 0)
+ if (status == 0)
{
return true;
}
- return true;
+ if (WIFEXITED(status) == true)
+ {
+ int ret= WEXITSTATUS(status);
+
+ if (ret == 0)
+ {
+ return true;
+ }
+ else if (ret == EXIT_FAILURE)
+ {
+ libtest::Error << "Command executed, but returned EXIT_FAILURE: " << command;
+ }
+ else
+ {
+ libtest::Error << "Command executed, but returned " << ret;
+ }
+ }
+ else if (WIFSIGNALED(status) == true)
+ {
+ int ret_signal= WTERMSIG(status);
+ libtest::Error << "Died from signal " << strsignal(ret_signal);
+ }
+
+ return false;
}
}
return output; // for multiple << operators
}
-void Server::nap(void)
-{
-#ifdef WIN32
- sleep(1);
-#else
- struct timespec global_sleep_value= { 0, 50000 };
- nanosleep(&global_sleep_value, NULL);
-#endif
-}
-
Server::Server(const std::string& host_arg, const in_port_t port_arg, bool is_socket_arg) :
_is_socket(is_socket_arg),
_pid(-1),
if (kill(current_pid))
{
Log << "Killed existing server," << *this << " with pid:" << current_pid;
- nap();
+ dream(0, 50000);
continue;
}
}
bool Server::start()
{
// If we find that we already have a pid then kill it.
- if (has_pid() and not kill(_pid))
+ if (has_pid() and kill(_pid) == false)
{
Error << "Could not kill() existing server during start() pid:" << _pid;
return false;
assert(not has_pid());
_running.clear();
- if (not command(_running))
+ if (command(_running) == false)
{
Error << "Could not build command()";
return false;
}
int ret= system(_running.c_str());
- if (not exited_successfully(ret))
+ if (exited_successfully(ret, _running) == false)
{
- Error << "system() failed:" << strerror(errno);
+ Error << "system(" << _running << ") failed: " << strerror(errno);
_running.clear();
return false;
}
if (is_helgrind() or is_valgrind())
{
- sleep(4);
+ dream(5, 50000);
}
- if (pid_file_option() and not pid_file().empty())
+ if (pid_file_option() and pid_file().empty() == false)
{
Wait wait(pid_file(), 8);
}
}
- int count= is_helgrind() or is_valgrind() ? 20 : 5;
- while (not ping() and --count)
+ int counter= 0;
+ bool pinged= false;
+ while ((pinged= ping()) == false and
+ counter < (is_helgrind() or is_valgrind() ? 20 : 5))
{
- nap();
+ dream(counter++, 50000);
}
- if (count == 0)
+ if (pinged == false)
{
// If we happen to have a pid file, lets try to kill it
- if (pid_file_option() and not pid_file().empty())
+ if (pid_file_option() and pid_file().empty() == false)
{
+ Error << "We are going to kill it off";
kill_file(pid_file());
}
Error << "Failed to ping() server started with:" << _running;
if (is_libtool())
{
_base_command+= libtool();
+ _base_command+= " --mode=execute ";
}
if (is_debug() and getenv("GDB_COMMAND"))
_base_command+= " ";
}
+ if (is_libtool())
+ {
+ if (getenv("PWD"))
+ {
+ _base_command+= getenv("PWD");
+ _base_command+= "/";
+ }
+ }
+
_base_command+= executable();
}
arg_buffer << " " << log_file_option() << _log_file;
}
+ if (getenv("LIBTEST_SYSLOG") and has_syslog())
+ {
+ arg_buffer << " --syslog";
+ }
+
// Update pid_file
if (pid_file_option())
{
- if (_pid_file.empty() and not set_pid_file())
+ if (_pid_file.empty() and set_pid_file() == false)
{
return false;
}
{
if (check_pid(pid_arg) and kill_pid(pid_arg)) // If we kill it, reset
{
- if (broken_pid_file() and not pid_file().empty())
+ if (broken_pid_file() and pid_file().empty() == false)
{
unlink(pid_file().c_str());
}
return (_port != 0);
}
+ virtual bool has_syslog() const
+ {
+ return false;
+ }
+
// Reset a server if another process has killed the server
void reset()
{
bool command(std::string& command_arg);
protected:
- void nap();
bool set_pid_file();
private:
bool server_startup_st::shutdown(uint32_t number_of_host)
{
- assert(servers.size() > number_of_host);
if (servers.size() > number_of_host)
{
Server* tmp= servers[number_of_host];
Outn();
(void)try_port;
- set_max_port(try_port);
-
- // Look to see if we are being provided ports to use
- {
- char variable_buffer[1024];
- snprintf(variable_buffer, sizeof(variable_buffer), "LIBTEST_PORT_%lu", (unsigned long)construct.count());
-
- char *var;
- if ((var= getenv(variable_buffer)))
- {
- in_port_t tmp= in_port_t(atoi(var));
-
- if (tmp > 0)
- try_port= tmp;
- }
- }
-
libtest::Server *server= NULL;
if (0)
{ }
construct.push_server(server);
- if (default_port() == 0)
- {
- assert(server->has_port());
- set_default_port(server->port());
- }
-
Outn();
return true;
}
#endif
sem_destroy(&lock);
+
+ int error;
+ if ((error= pthread_sigmask(SIG_UNBLOCK, &set, NULL)) != 0)
+ {
+ Error << "While trying to reset signal mask to original set, pthread_sigmask() died during pthread_sigmask(" << strerror(error) << ")";
+ }
}
extern "C" {
context->set_shutdown(SHUTDOWN_FORCED);
}
break;
+ case SIGPIPE:
+ {
+ Error << "Ignoring SIGPIPE";
+ }
+ break;
default:
Error << "Signal handling thread got unexpected signal " << strsignal(sig);
sigaddset(&set, SIGQUIT);
sigaddset(&set, SIGINT);
}
+ sigaddset(&set, SIGPIPE);
sigaddset(&set, SIGUSR2);
sem_init(&lock, 0, 0);
+
+ sigemptyset(&original_set);
+ pthread_sigmask(SIG_BLOCK, NULL, &original_set);
}
{
set_shutdown(SHUTDOWN_RUNNING);
- sigset_t old_set;
- sigemptyset(&old_set);
- pthread_sigmask(SIG_BLOCK, NULL, &old_set);
-
- if (sigismember(&old_set, SIGQUIT))
+ if (sigismember(&original_set, SIGQUIT))
{
Error << strsignal(SIGQUIT) << " has been previously set.";
}
- if (sigismember(&old_set, SIGINT))
+ if (sigismember(&original_set, SIGINT))
{
Error << strsignal(SIGINT) << " has been previously set.";
}
- if (sigismember(&old_set, SIGUSR2))
+ if (sigismember(&original_set, SIGUSR2))
{
Error << strsignal(SIGUSR2) << " has been previously set.";
}
volatile shutdown_t __shutdown;
pthread_mutex_t shutdown_mutex;
pthread_t thread;
+ sigset_t original_set;
public:
SignalThread();
+ ~SignalThread();
void test();
void post();
return sigwait(&set, &sig);
}
- ~SignalThread();
-
void set_shutdown(shutdown_t arg);
bool is_shutdown();
shutdown_t get_shutdown();
using namespace libtest;
-collection_st collection[] ={
- {0, 0, 0, 0}
-};
-
static void *world_create(server_startup_st&, test_return_t& rc)
{
rc= TEST_SKIPPED;
void get_world(Framework *world)
{
- world->collections= collection;
world->_create= world_create;
}
#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_compare_param util_literal_compare_param
#define test_literal_param_size util_literal_param_size
#define test_string_make_from_cstr util_string_make_from_cstr
+#define test_string_make_from_array util_string_make_from_array
#define test_array_length util_array_length
#include <signal.h>
+#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
+#include <curl/curl.h>
+#endif
+
#ifndef __INTEL_COMPILER
#pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
return s + us;
}
-static Framework *world= NULL;
+static void cleanup_curl(void)
+{
+#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
+ curl_global_cleanup();
+#endif
+}
+
+#include <getopt.h>
+#include <unistd.h>
+
int main(int argc, char *argv[])
{
+#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
+ if (curl_global_init(CURL_GLOBAL_ALL))
+ {
+ Error << "curl_global_init(CURL_GLOBAL_ALL) failed";
+ return EXIT_FAILURE;
+ }
+#endif
+
+ if (atexit(cleanup_curl))
+ {
+ Error << "atexit() failed";
+ return EXIT_FAILURE;
+ }
+
+ bool opt_repeat= false;
+ std::string collection_to_run;
+
+ // Options parsing
+ {
+ enum long_option_t {
+ OPT_LIBYATL_VERSION,
+ OPT_LIBYATL_MATCH_COLLECTION,
+ OPT_LIBYATL_REPEAT
+ };
+
+ static struct option long_options[]=
+ {
+ {"repeat", no_argument, NULL, OPT_LIBYATL_REPEAT},
+ {"collection", required_argument, NULL, OPT_LIBYATL_MATCH_COLLECTION},
+ {0, 0, 0, 0}
+ };
+
+ int option_index= 0;
+ while (1)
+ {
+ int option_rv= getopt_long(argc, argv, "", long_options, &option_index);
+ if (option_rv == -1)
+ {
+ break;
+ }
+
+ switch (option_rv)
+ {
+ case OPT_LIBYATL_VERSION:
+ break;
+
+ case OPT_LIBYATL_REPEAT:
+ opt_repeat= true;
+ break;
+
+ case OPT_LIBYATL_MATCH_COLLECTION:
+ collection_to_run= optarg;
+ break;
+
+ case '?':
+ /* getopt_long already printed an error message. */
+ Error << "unknown option to getopt_long()";
+ exit(EXIT_FAILURE);
+
+ default:
+ break;
+ }
+ }
+ }
+
srandom((unsigned int)time(NULL));
- if (getenv("LIBTEST_QUIET"))
+ if (getenv("LIBTEST_QUIET") and strcmp(getenv("LIBTEST_QUIET"), "0") == 0)
+ {
+ close(STDOUT_FILENO);
+ }
+ else if (getenv("JENKINS_URL"))
{
close(STDOUT_FILENO);
}
return EXIT_FAILURE;
}
- world= new Framework();
+ int exit_code;
- if (world == NULL)
- {
- Error << "Failed to create Framework()";
- return EXIT_FAILURE;
- }
+ try {
+ do {
+ exit_code= EXIT_SUCCESS;
+ Framework *world= new Framework();
- libtest::SignalThread signal;
- if (not signal.setup())
- {
- return EXIT_FAILURE;
- }
+ if (world == NULL)
+ {
+ Error << "Failed to create Framework()";
+ return EXIT_FAILURE;
+ }
- Stats stats;
+ assert(sigignore(SIGPIPE) == 0);
- get_world(world);
+ libtest::SignalThread signal;
+ if (not signal.setup())
+ {
+ Error << "Failed to setup signals";
+ return EXIT_FAILURE;
+ }
- test_return_t error;
- void *creators_ptr= world->create(error);
+ Stats stats;
- switch (error)
- {
- case TEST_SUCCESS:
- break;
-
- case TEST_SKIPPED:
- Out << "SKIP " << argv[0];
- delete world;
- return EXIT_SUCCESS;
-
- case TEST_FATAL:
- case TEST_FAILURE:
- case TEST_MEMORY_ALLOCATION_FAILURE:
- delete world;
- return EXIT_FAILURE;
- }
+ get_world(world);
- char *collection_to_run= NULL;
- if (argc > 1)
- {
- collection_to_run= argv[1];
- }
- else if (getenv("TEST_COLLECTION"))
- {
- if (strlen(getenv("TEST_COLLECTION")))
- {
- collection_to_run= getenv("TEST_COLLECTION");
- }
- }
+ test_return_t error;
+ void *creators_ptr= world->create(error);
- if (collection_to_run)
- {
- Out << "Only testing " << collection_to_run;
- }
+ switch (error)
+ {
+ case TEST_SUCCESS:
+ break;
- char *wildcard= NULL;
- if (argc == 3)
- {
- wildcard= argv[2];
- }
+ case TEST_SKIPPED:
+ Out << "SKIP " << argv[0];
+ delete world;
+ return EXIT_SUCCESS;
- for (collection_st *next= world->collections; next->name and (not signal.is_shutdown()); next++)
- {
- test_return_t collection_rc= TEST_SUCCESS;
- bool failed= false;
- bool skipped= false;
+ case TEST_FATAL:
+ case TEST_FAILURE:
+ case TEST_MEMORY_ALLOCATION_FAILURE:
+ delete world;
+ return EXIT_FAILURE;
+ }
- if (collection_to_run && fnmatch(collection_to_run, next->name, 0))
- continue;
+ if (getenv("TEST_COLLECTION"))
+ {
+ if (strlen(getenv("TEST_COLLECTION")))
+ {
+ collection_to_run= getenv("TEST_COLLECTION");
+ }
+ }
- stats.collection_total++;
+ if (collection_to_run.empty() == false)
+ {
+ Out << "Only testing " << collection_to_run;
+ }
- collection_rc= world->startup(creators_ptr);
+ char *wildcard= NULL;
+ if (argc == 3)
+ {
+ wildcard= argv[2];
+ }
- if (collection_rc == TEST_SUCCESS and next->pre)
- {
- collection_rc= world->runner()->pre(next->pre, creators_ptr);
- }
+ for (collection_st *next= world->collections; next and next->name and (not signal.is_shutdown()); next++)
+ {
+ bool failed= false;
+ bool skipped= false;
- switch (collection_rc)
- {
- case TEST_SUCCESS:
- break;
-
- case TEST_FATAL:
- case TEST_FAILURE:
- Out << next->name << " [ failed ]";
- failed= true;
- signal.set_shutdown(SHUTDOWN_GRACEFUL);
- goto cleanup;
-
- case TEST_SKIPPED:
- Out << next->name << " [ skipping ]";
- skipped= true;
- goto cleanup;
-
- case TEST_MEMORY_ALLOCATION_FAILURE:
- test_assert(0, "Allocation failure, or unknown return");
- }
+ if (collection_to_run.empty() == false and fnmatch(collection_to_run.c_str(), next->name, 0))
+ {
+ continue;
+ }
- Out << "Collection: " << next->name;
+ stats.collection_total++;
- for (test_st *run= next->tests; run->name; run++)
- {
- struct timeval start_time, end_time;
- long int load_time= 0;
+ test_return_t collection_rc= world->startup(creators_ptr);
- if (wildcard && fnmatch(wildcard, run->name, 0))
- {
- continue;
- }
+ if (collection_rc == TEST_SUCCESS and next->pre)
+ {
+ collection_rc= world->runner()->pre(next->pre, creators_ptr);
+ }
- test_return_t return_code;
- if (test_success(return_code= world->item.startup(creators_ptr)))
- {
- if (test_success(return_code= world->item.flush(creators_ptr, run)))
+ switch (collection_rc)
+ {
+ case TEST_SUCCESS:
+ break;
+
+ case TEST_FATAL:
+ case TEST_FAILURE:
+ Out << next->name << " [ failed ]";
+ failed= true;
+ signal.set_shutdown(SHUTDOWN_GRACEFUL);
+ goto cleanup;
+
+ case TEST_SKIPPED:
+ Out << next->name << " [ skipping ]";
+ skipped= true;
+ goto cleanup;
+
+ case TEST_MEMORY_ALLOCATION_FAILURE:
+ test_assert(0, "Allocation failure, or unknown return");
+ }
+
+ Out << "Collection: " << next->name;
+
+ for (test_st *run= next->tests; run->name; run++)
{
- // @note pre will fail is SKIPPED is returned
- if (test_success(return_code= world->item.pre(creators_ptr)))
+ struct timeval start_time, end_time;
+ long int load_time= 0;
+
+ if (wildcard && fnmatch(wildcard, run->name, 0))
{
- { // Runner Code
- gettimeofday(&start_time, NULL);
- assert(world->runner());
- assert(run->test_fn);
- return_code= world->runner()->run(run->test_fn, creators_ptr);
- gettimeofday(&end_time, NULL);
- load_time= timedif(end_time, start_time);
+ continue;
+ }
+
+ test_return_t return_code;
+ try {
+ if (test_success(return_code= world->item.startup(creators_ptr)))
+ {
+ if (test_success(return_code= world->item.flush(creators_ptr, run)))
+ {
+ // @note pre will fail is SKIPPED is returned
+ if (test_success(return_code= world->item.pre(creators_ptr)))
+ {
+ { // Runner Code
+ gettimeofday(&start_time, NULL);
+ assert(world->runner());
+ assert(run->test_fn);
+ try
+ {
+ return_code= world->runner()->run(run->test_fn, creators_ptr);
+ }
+ // Special case where check for the testing of the exception
+ // system.
+ catch (libtest::fatal &e)
+ {
+ if (fatal::is_disabled())
+ {
+ fatal::increment_disabled_counter();
+ return_code= TEST_SUCCESS;
+ }
+ else
+ {
+ throw;
+ }
+ }
+
+ gettimeofday(&end_time, NULL);
+ load_time= timedif(end_time, start_time);
+ }
+ }
+
+ // @todo do something if post fails
+ (void)world->item.post(creators_ptr);
+ }
+ else if (return_code == TEST_SKIPPED)
+ { }
+ else if (return_code == TEST_FAILURE)
+ {
+ Error << " item.flush(failure)";
+ signal.set_shutdown(SHUTDOWN_GRACEFUL);
+ }
+ }
+ else if (return_code == TEST_SKIPPED)
+ { }
+ else if (return_code == TEST_FAILURE)
+ {
+ Error << " item.startup(failure)";
+ signal.set_shutdown(SHUTDOWN_GRACEFUL);
}
}
- // @todo do something if post fails
- (void)world->item.post(creators_ptr);
- }
- else if (return_code == TEST_SKIPPED)
- { }
- else if (return_code == TEST_FAILURE)
- {
- Error << " item.flush(failure)";
- signal.set_shutdown(SHUTDOWN_GRACEFUL);
+ catch (std::exception &e)
+ {
+ Error << "Exception was thrown: " << e.what();
+ return_code= TEST_FAILURE;
+ }
+ catch (...)
+ {
+ Error << "Unknown exception occurred";
+ return_code= TEST_FAILURE;
+ }
+
+ stats.total++;
+
+ switch (return_code)
+ {
+ case TEST_SUCCESS:
+ Out << "\tTesting " << run->name << "\t\t\t\t\t" << load_time / 1000 << "." << load_time % 1000 << "[ " << test_strerror(return_code) << " ]";
+ stats.success++;
+ break;
+
+ case TEST_FATAL:
+ case TEST_FAILURE:
+ stats.failed++;
+ failed= true;
+ Out << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]";
+ break;
+
+ case TEST_SKIPPED:
+ stats.skipped++;
+ skipped= true;
+ Out << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]";
+ break;
+
+ case TEST_MEMORY_ALLOCATION_FAILURE:
+ test_assert(0, "Memory Allocation Error");
+ }
+
+ if (test_failed(world->on_error(return_code, creators_ptr)))
+ {
+ Error << "Failed while running on_error()";
+ signal.set_shutdown(SHUTDOWN_GRACEFUL);
+ break;
+ }
}
- }
- else if (return_code == TEST_SKIPPED)
- { }
- else if (return_code == TEST_FAILURE)
- {
- Error << " item.startup(failure)";
- signal.set_shutdown(SHUTDOWN_GRACEFUL);
- }
- stats.total++;
+ (void) world->runner()->post(next->post, creators_ptr);
- switch (return_code)
- {
- case TEST_SUCCESS:
- Out << "\tTesting " << run->name << "\t\t\t\t\t" << load_time / 1000 << "." << load_time % 1000 << "[ " << test_strerror(return_code) << " ]";
- stats.success++;
- break;
+cleanup:
+ if (failed == false and skipped == false)
+ {
+ stats.collection_success++;
+ }
- case TEST_FATAL:
- case TEST_FAILURE:
- stats.failed++;
- failed= true;
- Out << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]";
- break;
+ if (failed)
+ {
+ stats.collection_failed++;
+ }
- case TEST_SKIPPED:
- stats.skipped++;
- skipped= true;
- Out << "\tTesting " << run->name << "\t\t\t\t\t" << "[ " << test_strerror(return_code) << " ]";
- break;
+ if (skipped)
+ {
+ stats.collection_skipped++;
+ }
- case TEST_MEMORY_ALLOCATION_FAILURE:
- test_assert(0, "Memory Allocation Error");
+ world->shutdown(creators_ptr);
+ Outn();
}
- if (test_failed(world->on_error(return_code, creators_ptr)))
+ if (not signal.is_shutdown())
{
- Error << "Failed while running on_error()";
signal.set_shutdown(SHUTDOWN_GRACEFUL);
- break;
}
- }
-
- (void) world->runner()->post(next->post, creators_ptr);
-
-cleanup:
- if (failed == false and skipped == false)
- {
- stats.collection_success++;
- }
-
- if (failed)
- {
- stats.collection_failed++;
- }
- if (skipped)
- {
- stats.collection_skipped++;
- }
+ shutdown_t status= signal.get_shutdown();
+ if (status == SHUTDOWN_FORCED)
+ {
+ Out << "Tests were aborted.";
+ exit_code= EXIT_FAILURE;
+ }
+ else if (stats.collection_failed)
+ {
+ Out << "Some test failed.";
+ exit_code= EXIT_FAILURE;
+ }
+ else if (stats.collection_skipped and stats.collection_failed and stats.collection_success)
+ {
+ Out << "Some tests were skipped.";
+ }
+ else if (stats.collection_success and stats.collection_failed == 0)
+ {
+ Out << "All tests completed successfully.";
+ }
- world->shutdown(creators_ptr);
- Outn();
- }
+ stats_print(&stats);
- if (not signal.is_shutdown())
- {
- signal.set_shutdown(SHUTDOWN_GRACEFUL);
- }
+ delete world;
- int exit_code= EXIT_SUCCESS;
- shutdown_t status= signal.get_shutdown();
- if (status == SHUTDOWN_FORCED)
- {
- Out << "Tests were aborted.";
- exit_code= EXIT_FAILURE;
+ Outn(); // Generate a blank to break up the messages if make check/test has been run
+ } while (exit_code == EXIT_SUCCESS and opt_repeat);
}
- else if (stats.collection_failed)
+ catch (libtest::fatal& e)
{
- Out << "Some test failed.";
- exit_code= EXIT_FAILURE;
+ std::cerr << e.what() << std::endl;
}
- else if (stats.collection_skipped and stats.collection_failed and stats.collection_success)
+ catch (...)
{
- Out << "Some tests were skipped.";
+ std::cerr << "Unknown exception halted execution" << std::endl;
}
- else if (stats.collection_success and stats.collection_failed == 0)
- {
- Out << "All tests completed successfully.";
- }
-
- stats_print(&stats);
-
- delete world;
-
- Outn(); // Generate a blank to break up the messages if make check/test has been run
return exit_code;
}
return TEST_FAILURE; \
} \
} while (0)
+#define test_true_hint test_true_got
#define test_skip(A,B) \
do \
#define test_strcmp(A,B) \
do \
{ \
- if (strcmp((A), (B))) \
+ if ((A) == NULL or (B) == NULL or strcmp((A), (B))) \
{ \
- fprintf(stderr, "\n%s:%d: Expected %s, got %s\n", __FILE__, __LINE__, (A), (B)); \
+ if ((B) == NULL) fprintf(stderr, "\n%s:%d: Expected %s, got <null>\n", __FILE__, __LINE__, (A)); \
+ else fprintf(stderr, "\n%s:%d: Expected %s, got \"%s\"\n", __FILE__, __LINE__, (A), (B)); \
libtest::create_core(); \
return TEST_FAILURE; \
} \
#define test_memcmp(A,B,C) \
do \
{ \
- if (memcmp((A), (B), (C))) \
+ if ((A) == NULL or (B) == NULL or memcmp((A), (B), (C))) \
{ \
fprintf(stderr, "\n%s:%d: %.*s -> %.*s\n", __FILE__, __LINE__, (int)(C), (char *)(A), (int)(C), (char *)(B)); \
libtest::create_core(); \
} \
} while (0)
+#define test_memcmp_hint(A,B,C,__hint) \
+do \
+{ \
+ if ((A) == NULL or (B) == NULL or memcmp((A), (B), (C))) \
+ { \
+ fprintf(stderr, "\n%s:%d: (hint:%s) %.*s -> %.*s\n", __FILE__, __LINE__, __hint, (int)(C), (char *)(A), (int)(C), (char *)(B)); \
+ libtest::create_core(); \
+ return TEST_FAILURE; \
+ } \
+} while (0)
+
#define test_return_if(__test_return_t) \
do \
{ \
#include <libtest/visibility.h>
#include <libtest/version.h>
+#include <libtest/vchar.hpp>
+#include <libtest/fatal.hpp>
+
+#include <libtest/has.hpp>
#include <libtest/error.h>
#include <libtest/strerror.h>
#include <libtest/stream.h>
#include <libtest/wait.h>
#include <libtest/callbacks.h>
#include <libtest/test.h>
+#include <libtest/dream.h>
#include <libtest/core.h>
#include <libtest/runner.h>
#include <libtest/port.h>
#include <libtest/cmdline.h>
#include <libtest/string.hpp>
#include <libtest/binaries.h>
+#include <libtest/http.hpp>
#include <libtest/test.hpp>
#if defined(LIBTEST_WITH_LIBMEMCACHED_SUPPORT) && LIBTEST_WITH_LIBMEMCACHED_SUPPORT
-#include <libmemcached/memcached.h>
+#include <libmemcached-1.0/memcached.h>
#endif
#if defined(LIBTEST_WITH_LIBGEARMAN_SUPPORT) && LIBTEST_WITH_LIBGEARMAN_SUPPORT
server_startup_st *servers= (server_startup_st*)object;
test_true(servers);
- if (GEARMAND_BINARY)
- {
- if (HAVE_LIBGEARMAN)
- {
- test_true(has_gearmand_binary());
- const char *argv[1]= { "cycle_gearmand" };
- test_true(server_startup(*servers, "gearmand", 9999, 1, argv));
+#if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
+ test_true(has_gearmand_binary());
+#else
+ test_skip(true, has_gearmand_binary());
+#endif
- return TEST_SUCCESS;
- }
- }
+ const char *argv[1]= { "cycle_gearmand" };
+ test_true(server_startup(*servers, "gearmand", get_free_port(), 1, argv));
- return TEST_SKIPPED;
+ return TEST_SUCCESS;
}
static test_return_t memcached_cycle_test(void *object)
{
test_true(has_memcached_binary());
const char *argv[1]= { "cycle_memcached" };
- test_true(server_startup(*servers, "memcached", 9998, 1, argv));
+ test_true(server_startup(*servers, "memcached", get_free_port(), 1, argv));
return TEST_SUCCESS;
}
{
test_true(has_memcached_binary());
const char *argv[1]= { "cycle_memcached" };
- test_true(servers->start_socket_server("memcached", 9997, 1, argv));
+ test_true(servers->start_socket_server("memcached", get_free_port(), 1, argv));
return TEST_SUCCESS;
}
{
test_true(has_memcached_sasl_binary());
const char *argv[1]= { "cycle_memcached_sasl" };
- test_true(server_startup(*servers, "memcached-sasl", 9996, 1, argv));
+ test_true(server_startup(*servers, "memcached-sasl", get_free_port(), 1, argv));
return TEST_SUCCESS;
}
return TEST_SKIPPED;
}
+static test_return_t application_true_BINARY(void *)
+{
+ Application true_app("true");
+
+ test_compare(Application::SUCCESS, true_app.run());
+ test_compare(Application::SUCCESS, true_app.wait());
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t application_true_fubar_BINARY(void *)
+{
+ Application true_app("true");
+
+ const char *args[]= { "--fubar", 0 };
+ test_compare(Application::SUCCESS, true_app.run(args));
+ test_compare(Application::SUCCESS, true_app.wait());
+ test_compare(0, true_app.stdout_result().size());
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t application_true_fubar_eq_doh_BINARY(void *)
+{
+ Application true_app("true");
+
+ const char *args[]= { "--fubar=doh", 0 };
+ test_compare(Application::SUCCESS, true_app.run(args));
+ test_compare(Application::SUCCESS, true_app.wait());
+ test_compare(0, true_app.stdout_result().size());
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t application_true_fubar_eq_doh_option_BINARY(void *)
+{
+ Application true_app("true");
+
+ true_app.add_option("--fubar=", "doh");
+
+ test_compare(Application::SUCCESS, true_app.run());
+ test_compare(Application::SUCCESS, true_app.wait());
+ test_compare(0, true_app.stdout_result().size());
+
+ return TEST_SUCCESS;
+}
+
+
+static test_return_t GET_TEST(void *)
+{
+ libtest::http::GET get("http://foo.example.com/");
+
+ test_compare(false, get.execute());
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t POST_TEST(void *)
+{
+ libtest::vchar_t body;
+ libtest::http::POST post("http://foo.example.com/", body);
+
+ test_compare(false, post.execute());
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t TRACE_TEST(void *)
+{
+ libtest::vchar_t body;
+ libtest::http::TRACE trace("http://foo.example.com/", body);
+
+ test_compare(false, trace.execute());
+
+ return TEST_SUCCESS;
+}
+
+
+static test_return_t vchar_t_TEST(void *)
+{
+ libtest::vchar_t response;
+ libtest::make_vector(response, test_literal_param("fubar\n"));
+ test_compare(response, response);
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t application_echo_fubar_BINARY(void *)
+{
+ Application true_app("echo");
+
+ const char *args[]= { "fubar", 0 };
+ test_compare(Application::SUCCESS, true_app.run(args));
+ test_compare(Application::SUCCESS, true_app.wait());
+
+ libtest::vchar_t response;
+ make_vector(response, test_literal_param("fubar\n"));
+ test_compare(response, true_app.stdout_result());
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t application_echo_fubar_BINARY2(void *)
+{
+ Application true_app("echo");
+
+ true_app.add_option("fubar");
+
+ test_compare(Application::SUCCESS, true_app.run());
+ test_compare(Application::SUCCESS, true_app.wait());
+ libtest::vchar_t response;
+ make_vector(response, test_literal_param("fubar\n"));
+ test_compare(response, true_app.stdout_result());
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t true_BINARY(void *)
+{
+ const char *args[]= { 0 };
+ test_compare(EXIT_SUCCESS, exec_cmdline("true", args));
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t true_fubar_BINARY(void *)
+{
+ const char *args[]= { "--fubar", 0 };
+ test_compare(EXIT_SUCCESS, exec_cmdline("true", args));
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t echo_fubar_BINARY(void *)
+{
+ const char *args[]= { "fubar", 0 };
+ test_compare(EXIT_SUCCESS, exec_cmdline("echo", args));
+
+ return TEST_SUCCESS;
+}
+
static test_return_t wait_BINARY(void *)
{
const char *args[]= { "--quiet", 0 };
- test_true(exec_cmdline("libtest/wait", args));
+ test_compare(EXIT_FAILURE, exec_cmdline("libtest/wait", args, true));
return TEST_SUCCESS;
}
{
const char *args[]= { "--quiet", "--help", 0 };
- test_true(exec_cmdline("libtest/wait", args));
+ test_compare(EXIT_SUCCESS, exec_cmdline("libtest/wait", args, true));
return TEST_SUCCESS;
}
{
const char *args[]= { "--quiet", "--version", 0 };
- test_true(exec_cmdline("libtest/wait", args));
+ test_compare(EXIT_SUCCESS, exec_cmdline("libtest/wait", args, true));
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t wait_services_BINARY(void *)
+{
+ test_skip(0, access("/etc/services", R_OK ));
+
+ const char *args[]= { "--quiet", "/etc/services", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline("libtest/wait", args, true));
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t wait_services_BINARY2(void *)
+{
+ test_skip(0, access("/etc/services", R_OK ));
+
+ const char *args[]= { "/etc/services", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline("libtest/wait", args, true));
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t application_wait_services_BINARY2(void *)
+{
+ test_skip(0, access("/etc/services", R_OK ));
+
+ libtest::Application("libtest/wait", true);
+ const char *args[]= { "/etc/services", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline("libtest/wait", args, true));
return TEST_SUCCESS;
}
+static test_return_t get_free_port_TEST(void *)
+{
+ in_port_t ret_port;
+ test_true_hint((ret_port= get_free_port()), ret_port);
+ test_true(get_free_port() != default_port());
+ test_true(get_free_port() != get_free_port());
+
+ return TEST_SUCCESS;
+}
+
+static uint32_t fatal_calls= 0;
+
+static test_return_t fatal_TEST(void *)
+{
+ test_compare(fatal_calls++, fatal::disabled_counter());
+ throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "Testing va_args based fatal(): %d", 10);
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t fatal_message_TEST(void *)
+{
+ test_compare(fatal_calls++, fatal::disabled_counter());
+ throw fatal_message("Fatal test");
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t default_port_TEST(void *)
+{
+ in_port_t ret_port= default_port();
+ test_compare(ret_port, libtest::default_port());
+ test_compare(ret_port, libtest::default_port());
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t check_for_gearman(void *)
+{
+ test_skip(true, HAVE_LIBGEARMAN);
+ test_skip(true, has_gearmand_binary());
+ return TEST_SUCCESS;
+}
+
+
test_st gearmand_tests[] ={
#if 0
{"pause", 0, pause_test },
#endif
{"gearmand startup-shutdown", 0, gearmand_cycle_test },
+ {"_compare(gearman_return_t)", 0, _compare_gearman_return_t_test },
{0, 0, 0}
};
+static test_return_t check_for_libmemcached(void *)
+{
+ test_skip(true, HAVE_LIBMEMCACHED);
+ test_skip(true, has_memcached_binary());
+ return TEST_SUCCESS;
+}
+
test_st memcached_tests[] ={
{"memcached startup-shutdown", 0, memcached_cycle_test },
{"memcached(socket file) startup-shutdown", 0, memcached_socket_cycle_test },
{"memcached_sasl() startup-shutdown", 0, memcached_sasl_test },
+ {"_compare(memcached_return_t)", 0, _compare_memcached_return_t_test },
{0, 0, 0}
};
test_st comparison_tests[] ={
{"_compare(test_return_t)", 0, _compare_test_return_t_test },
- {"_compare(memcached_return_t)", 0, _compare_memcached_return_t_test },
- {"_compare(gearman_return_t)", 0, _compare_gearman_return_t_test },
{0, 0, 0}
};
test_st cmdline_tests[] ={
+ {"true", 0, true_BINARY },
+ {"true --fubar", 0, true_fubar_BINARY },
+ {"echo fubar", 0, echo_fubar_BINARY },
{"wait --quiet", 0, wait_BINARY },
{"wait --quiet --help", 0, wait_help_BINARY },
{"wait --quiet --version", 0, wait_version_BINARY },
+ {"wait --quiet /etc/services", 0, wait_services_BINARY },
+ {"wait /etc/services", 0, wait_services_BINARY2 },
+ {0, 0, 0}
+};
+
+test_st get_free_port_TESTS[] ={
+ {"get_free_port()", 0, get_free_port_TEST },
+ {"default_port()", 0, default_port_TEST },
+ {0, 0, 0}
+};
+
+test_st fatal_message_TESTS[] ={
+ {"libtest::fatal", 0, fatal_TEST },
+ {"fatal_message()", 0, fatal_message_TEST },
+ {0, 0, 0}
+};
+
+test_st application_tests[] ={
+ {"vchar_t", 0, vchar_t_TEST },
+ {"true", 0, application_true_BINARY },
+ {"true --fubar", 0, application_true_fubar_BINARY },
+ {"true --fubar=doh", 0, application_true_fubar_eq_doh_BINARY },
+ {"true --fubar=doh add_option()", 0, application_true_fubar_eq_doh_option_BINARY },
+ {"echo fubar", 0, application_echo_fubar_BINARY },
+ {"echo fubar (as option)", 0, application_echo_fubar_BINARY2 },
+ {0, 0, 0}
+};
+
+static test_return_t check_for_curl(void *)
+{
+ test_skip(true, HAVE_LIBCURL);
+ return TEST_SUCCESS;
+}
+
+static test_return_t disable_fatal_exception(void *)
+{
+ fatal::disable();
+ return TEST_SUCCESS;
+}
+
+static test_return_t enable_fatal_exception(void *)
+{
+ fatal::disable();
+ return TEST_SUCCESS;
+}
+
+test_st http_tests[] ={
+ {"GET", 0, GET_TEST },
+ {"POST", 0, POST_TEST },
+ {"TRACE", 0, TRACE_TEST },
{0, 0, 0}
};
{"local", 0, 0, local_log},
{"directories", 0, 0, directories_tests},
{"comparison", 0, 0, comparison_tests},
- {"gearmand", 0, 0, gearmand_tests},
- {"memcached", 0, 0, memcached_tests},
+ {"gearmand", check_for_gearman, 0, gearmand_tests},
+ {"memcached", check_for_libmemcached, 0, memcached_tests},
{"cmdline", 0, 0, cmdline_tests},
+ {"application", 0, 0, application_tests},
+ {"http", check_for_curl, 0, http_tests},
+ {"get_free_port()", 0, 0, get_free_port_TESTS },
+ {"fatal", disable_fatal_exception, enable_fatal_exception, fatal_message_TESTS },
{0, 0, 0, 0}
};
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <libtest/common.h>
+
+namespace libtest {
+
+static std::string printer(const char *str, size_t length)
+{
+ std::ostringstream buf;
+ for (size_t x= 0; x < length; x++)
+ {
+ if (isprint(str[x]))
+ {
+ buf << str[x];
+ }
+ else
+ {
+ buf << "(" << int(str[x]) << ")";
+ }
+ }
+
+ return buf.str();
+}
+
+void make_vector(libtest::vchar_t& arg, const char *str, size_t length)
+{
+ arg.resize(length);
+ memcpy(&arg[0], str, length);
+}
+
+std::ostream& operator<<(std::ostream& output, const libtest::vchar_t& arg)
+{
+ std::string tmp= libtest::printer(&arg[0], arg.size());
+ output << tmp << "[" << arg.size() << "]";
+
+ return output;
+}
+
+} // namespace libtest
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#pragma once
+
+#include <cstring>
+#include <iostream>
+#include <ostream>
+#include <sstream>
+#include <vector>
+
+namespace libtest {
+
+typedef std::vector<char*> vchar_ptr_t;
+typedef std::vector<char> vchar_t;
+
+void make_vector(libtest::vchar_t& arg, const char *str, size_t length);
+
+std::ostream& operator<<(std::ostream& output, const libtest::vchar_t& arg);
+
+} // namespace libtest
+
static void version_command(const char *command_name, int major_version, int minor_version)
{
std::cout << command_name << " " << major_version << "." << minor_version << std::endl;
- exit(EXIT_SUCCESS);
}
static void help_command(const char *command_name,
}
std::cout << std::endl;
- exit(EXIT_SUCCESS);
}
static void close_stdio(void)
bool opt_version= false;
bool opt_help= false;
+ bool opt_quiet= false;
int option_index= 0;
while (1)
{
- int option_rv= getopt_long(argc, argv, "Vhvds:", long_options, &option_index);
+ int option_rv= getopt_long(argc, argv, "", long_options, &option_index);
if (option_rv == -1)
{
break;
opt_help= true;
break;
+ case OPT_VERSION: /* --version or -v */
+ opt_version= true;
+ break;
+
case OPT_QUIET:
- close_stdio();
+ opt_quiet= true;
break;
case '?':
/* getopt_long already printed an error message. */
- exit(EXIT_SUCCESS);
+ exit(EXIT_FAILURE);
default:
- abort();
+ help_command(argv[0], 1, 0, long_options);
+ exit(EXIT_FAILURE);
}
}
+ if (opt_quiet)
+ {
+ close_stdio();
+ }
+
if (opt_version)
{
version_command(argv[0], 1, 0);
int main(int argc, char *argv[])
{
+ if (argc == 1)
+ {
+ return EXIT_FAILURE;
+ }
+
options_parse(argc, argv);
- if (argc == 2)
+ int ret= EXIT_FAILURE;
+ while (optind < argc)
{
- libtest::Wait wait(argv[1]);
+ libtest::Wait wait(argv[optind++]);
+
+ if (wait.successful() == false)
+ {
+ return EXIT_FAILURE;
+ }
- if (wait.successful())
- return EXIT_SUCCESS;
+ ret= EXIT_SUCCESS;
}
- return EXIT_FAILURE;
+ return ret;
}
+++ /dev/null
-# ===========================================================================
-# http://autoconf-archive.cryp.to/ac_cxx_header_stdcxx_98.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-# AC_CXX_HEADER_STDCXX_98
-#
-# DESCRIPTION
-#
-# Check for complete library coverage of the C++1998/2003 standard.
-#
-# LICENSE
-#
-# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
-#
-# Copying and distribution of this file, with or without modification, are
-# permitted in any medium without royalty provided the copyright notice
-# and this notice are preserved.
-
-AC_DEFUN([AC_CXX_HEADER_STDCXX_98], [
- AC_CACHE_CHECK(for ISO C++ 98 include files,
- ac_cv_cxx_stdcxx_98,
- [AC_LANG_SAVE
- AC_LANG_CPLUSPLUS
- AC_TRY_COMPILE([
- #include <cassert>
- #include <cctype>
- #include <cerrno>
- #include <cfloat>
- #include <ciso646>
- #include <climits>
- #include <clocale>
- #include <cmath>
- #include <csetjmp>
- #include <csignal>
- #include <cstdarg>
- #include <cstddef>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <ctime>
-
- #include <algorithm>
- #include <bitset>
- #include <complex>
- #include <deque>
- #include <exception>
- #include <fstream>
- #include <functional>
- #include <iomanip>
- #include <ios>
- #include <iosfwd>
- #include <iostream>
- #include <istream>
- #include <iterator>
- #include <limits>
- #include <list>
- #include <locale>
- #include <map>
- #include <memory>
- #include <new>
- #include <numeric>
- #include <ostream>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <stdexcept>
- #include <streambuf>
- #include <string>
- #include <typeinfo>
- #include <utility>
- #include <valarray>
- #include <vector>
- ],,
- ac_cv_cxx_stdcxx_98=yes, ac_cv_cxx_stdcxx_98=no)
- AC_LANG_RESTORE
- ])
- if test "$ac_cv_cxx_stdcxx_98" = yes; then
- AC_DEFINE(STDCXX_98_HEADERS,,[Define if ISO C++ 1998 header files are present. ])
- fi
-])
--- /dev/null
+# ===========================================================================
+# http://www.tangent.org/
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_SASL
+#
+# DESCRIPTION
+#
+# Check for sasl version one or two support.
+#
+# LICENSE
+#
+# Copyright (c) 2012 Brian Aker <brian@tangent.org>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 1
+
+AC_DEFUN([AX_SASL_OPTION],[
+ AC_REQUIRE([AX_SASL_CHECK])
+ AC_ARG_ENABLE([sasl],
+ [AS_HELP_STRING([--disable-sasl], [Build with sasl support @<:@default=on@:>@])],
+ [ac_enable_sasl="$enableval"],
+ [ac_enable_sasl="yes"])
+
+ AS_IF([test "x$ac_enable_sasl" = "xyes"], [
+ ac_enable_sasl="no"
+ ], [
+ ])
+
+ AS_IF([test "x$ac_enable_sasl" = "xyes"], [
+ AC_DEFINE([HAVE_LIBSASL], [ 1 ], [Have libsasl2])
+ ], [
+ AC_DEFINE([HAVE_LIBSASL], [ 0 ], [Have libsasl2])
+ ])
+
+ AM_CONDITIONAL(HAVE_SASL, test "x${ac_enable_sasl}" = "xyes")
+
+ ])
+
+AC_DEFUN([AX_SASL_CHECK],[
+
+ AX_CHECK_LIBRARY([LIBSASL], [sasl/sasl.h], [sasl2],[
+ LIBSASL_LDFLAGS="-lsasl2"
+ ax_cv_sasl=yes
+ ], [
+ ax_cv_sasl=no
+ ])
+ ])
AC_DEFUN([DETECT_BYTEORDER],
-[
+ [
AC_REQUIRE([AC_C_BIGENDIAN])
+ AC_LANG_PUSH([C++])
AC_CACHE_CHECK([for htonll], [ac_cv_have_htonll],
- [AC_TRY_LINK([
-#include <sys/types.h>
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+ [#include <sys/types.h>
#include <netinet/in.h>
#include <inttypes.h>
- ], [
-return htonll(0);
- ],
- [ ac_cv_have_htonll=yes ],
- [ ac_cv_have_htonll=no ])
- ])
+ ], [ return htonll(0) ])],
+ [ ac_cv_have_htonll=yes ],
+ [ ac_cv_have_htonll=no ])
+ ])
+ AC_LANG_POP()
AS_IF([test "x$ac_cv_have_htonll" = "xyes"],[
- AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll])])
+ AC_DEFINE([HAVE_HTONLL], [1], [Have ntohll])])
AM_CONDITIONAL([BUILD_BYTEORDER],[test "x$ac_cv_have_htonll" = "xno"])
-])
+ ])
dnl autoconf doesn't automatically provide a fail-if-no-C++ macro
dnl so we check c++98 features and fail if we don't have them, mainly
dnl for that reason
- PANDORA_CHECK_CXX_STANDARD
m4_if(PCT_REQUIRE_CXX, [yes], [
AS_IF([test "$ac_cv_cxx_stdcxx_98" = "no"],[
AC_MSG_ERROR([No working C++ Compiler has been found. ${PACKAGE} requires a C++ compiler that can handle C++98])
+++ /dev/null
-dnl Copyright (C) 2009 Sun Microsystems, Inc.
-dnl This file is free software; Sun Microsystems, Inc.
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-#--------------------------------------------------------------------
-# Check for libuuid
-#--------------------------------------------------------------------
-
-
-AC_DEFUN([_PANDORA_SEARCH_LIBUUID],[
- AC_REQUIRE([AC_LIB_PREFIX])
-
- dnl Do this by hand. Need to check for uuid/uuid.h, but uuid may or may
- dnl not be a lib is weird.
- AC_CHECK_HEADERS(uuid/uuid.h)
- AC_LIB_HAVE_LINKFLAGS(uuid,,
- [
- #include <uuid/uuid.h>
- ],
- [
- uuid_t uout;
- uuid_generate(uout);
- ])
-
- AM_CONDITIONAL(HAVE_LIBUUID, [test "x${ac_cv_libuuid}" = "xyes"])
-])
-
-AC_DEFUN([_PANDORA_HAVE_LIBUUID],[
-
- AC_ARG_ENABLE([libuuid],
- [AS_HELP_STRING([--disable-libuuid],
- [Build with libuuid support @<:@default=on@:>@])],
- [ac_enable_libuuid="$enableval"],
- [ac_enable_libuuid="yes"])
-
- _PANDORA_SEARCH_LIBUUID
-])
-
-
-AC_DEFUN([PANDORA_HAVE_LIBUUID],[
- AC_REQUIRE([_PANDORA_HAVE_LIBUUID])
-])
-
-AC_DEFUN([_PANDORA_REQUIRE_LIBUUID],[
- ac_enable_libuuid="yes"
- _PANDORA_SEARCH_LIBUUID
- AS_IF([test "x$ac_cv_header_uuid_uuid_h" = "xno"],[
- AC_MSG_ERROR([Couldn't find uuid/uuid.h. On Debian this can be found in uuid-dev. On RHEL 4 this can be found in e2fsprogs-devel and Fedora/RHEL 6 in libuuid-devel.])
- ])
-])
-
-AC_DEFUN([PANDORA_REQUIRE_LIBUUID],[
- AC_REQUIRE([_PANDORA_REQUIRE_LIBUUID])
-])
+++ /dev/null
-dnl Copyright (C) 2009 Sun Microsystems, Inc.
-dnl This file is free software; Sun Microsystems, Inc.
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([_PANDORA_SEARCH_SASL],[
- AC_REQUIRE([AC_LIB_PREFIX])
-
- dnl --------------------------------------------------------------------
- dnl Check for sasl
- dnl --------------------------------------------------------------------
- AC_ARG_ENABLE([sasl],
- [AS_HELP_STRING([--disable-sasl],
- [Build with sasl support @<:@default=on@:>@])],
- [ac_enable_sasl="$enableval"],
- [ac_enable_sasl="yes"])
-
- AS_IF([test "x$ac_enable_sasl" = "xyes"],
- [
- AC_LIB_HAVE_LINKFLAGS(sasl,,[
- #include <stdlib.h>
- #include <sasl/sasl.h>
- ],[
- sasl_server_init(NULL, NULL);
- ])
-
- AS_IF([test "x${ac_cv_libsasl}" != "xyes" ],
- [
- AC_LIB_HAVE_LINKFLAGS(sasl2,,[
- #include <stdlib.h>
- #include <sasl/sasl.h>
- ],[
- sasl_server_init(NULL, NULL);
- ])
- HAVE_LIBSASL="$HAVE_LIBSASL2"
- LIBSASL="$LIBSASL2"
- LIBSASL_PREFIX="$LIBSASL2_PREFIX"
- LTLIBSASL="$LT_LIBSASL2"
- ])
- ])
-
- AS_IF([test "x${ac_cv_libsasl}" = "xyes" -o "x${ac_cv_libsasl2}" = "xyes"],
- [ac_cv_sasl=yes],
- [ac_cv_sasl=no])
-
- AM_CONDITIONAL(HAVE_LIBSASL, [test "x${ac_cv_libsasl}" = "xyes"])
- AM_CONDITIONAL(HAVE_LIBSASL2, [test "x${ac_cv_libsasl2}" = "xyes"])
- AM_CONDITIONAL(HAVE_SASL, [test "x${ac_cv_sasl}" = "xyes"])
-])
-
-AC_DEFUN([PANDORA_HAVE_SASL],[
- AC_REQUIRE([_PANDORA_SEARCH_SASL])
-])
-
-AC_DEFUN([PANDORA_REQUIRE_SASL],[
- AC_REQUIRE([_PANDORA_SEARCH_SASL])
- AS_IF([test "x${ac_cv_sasl}" = "xno"],
- AC_MSG_ERROR([SASL (libsasl or libsasl2) is required for ${PACKAGE}]))
-])
-
-AC_DEFUN([_PANDORA_SEARCH_LIBSASL],[
- AC_REQUIRE([AC_LIB_PREFIX])
-
- dnl --------------------------------------------------------------------
- dnl Check for libsasl
- dnl --------------------------------------------------------------------
-
- AC_ARG_ENABLE([libsasl],
- [AS_HELP_STRING([--disable-libsasl],
- [Build with libsasl support @<:@default=on@:>@])],
- [ac_enable_libsasl="$enableval"],
- [ac_enable_libsasl="yes"])
-
- AS_IF([test "x$ac_enable_libsasl" = "xyes"],[
- AC_LIB_HAVE_LINKFLAGS(sasl,,[
- #include <stdlib.h>
- #include <sasl/sasl.h>
- ],[
- sasl_server_init(NULL, NULL);
- ])
- ],[
- ac_cv_libsasl="no"
- ])
-
- AM_CONDITIONAL(HAVE_LIBSASL, [test "x${ac_cv_libsasl}" = "xyes"])
-])
-
-AC_DEFUN([PANDORA_HAVE_LIBSASL],[
- AC_REQUIRE([_PANDORA_SEARCH_LIBSASL])
-])
-
-AC_DEFUN([PANDORA_REQUIRE_LIBSASL],[
- AC_REQUIRE([_PANDORA_SEARCH_LIBSASL])
- AS_IF([test "x${ac_cv_libsasl}" = "xno"],
- AC_MSG_ERROR([libsasl is required for ${PACKAGE}]))
-])
-
-AC_DEFUN([_PANDORA_SEARCH_LIBSASL2],[
- AC_REQUIRE([AC_LIB_PREFIX])
-
- dnl --------------------------------------------------------------------
- dnl Check for libsasl2
- dnl --------------------------------------------------------------------
-
- AC_ARG_ENABLE([libsasl2],
- [AS_HELP_STRING([--disable-libsasl2],
- [Build with libsasl2 support @<:@default=on@:>@])],
- [ac_enable_libsasl2="$enableval"],
- [ac_enable_libsasl2="yes"])
-
- AS_IF([test "x$ac_enable_libsasl2" = "xyes"],[
- AC_LIB_HAVE_LINKFLAGS(sasl2,,[
- #include <stdlib.h>
- #include <sasl2/sasl2.h>
- ],[
- sasl2_server_init(NULL, NULL);
- ])
- ],[
- ac_cv_libsasl2="no"
- ])
-
- AM_CONDITIONAL(HAVE_LIBSASL2, [test "x${ac_cv_libsasl2}" = "xyes"])
-])
-
-AC_DEFUN([PANDORA_HAVE_LIBSASL2],[
- AC_REQUIRE([_PANDORA_SEARCH_LIBSASL2])
-])
-
-AC_DEFUN([PANDORA_REQUIRE_LIBSASL2],[
- AC_REQUIRE([_PANDORA_SEARCH_LIBSASL2])
- AS_IF([test "x${ac_cv_libsasl2}" = "xno"],
- AC_MSG_ERROR([libsasl2 is required for ${PACKAGE}]))
-])
])
])
- AC_REQUIRE([PANDORA_BUILDING_FROM_VC])
m4_if(PW_WARN_ALWAYS_ON, [yes],
[ac_cv_warnings_as_errors=yes],
AS_IF([test "$pandora_building_from_vc" = "yes"],
[ac_cv_safe_to_use_Wextra_=no])
CFLAGS="$save_CFLAGS"])
- BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wundef -Wshadow ${NO_UNUSED} ${F_DIAGNOSTICS_SHOW_OPTION} ${F_LOOP_PARALLELIZE_ALL} ${BASE_WARNINGS_FULL}"
+ BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wundef -Wshadow -Wparentheses ${NO_UNUSED} ${F_DIAGNOSTICS_SHOW_OPTION} ${F_LOOP_PARALLELIZE_ALL} ${BASE_WARNINGS_FULL}"
AS_IF([test "$ac_cv_safe_to_use_Wextra_" = "yes"],
[BASE_WARNINGS="${BASE_WARNINGS} -Wextra"],
[BASE_WARNINGS="${BASE_WARNINGS} -W"])
[ac_cv_safe_to_use_wformat_=no])
CFLAGS="$save_CFLAGS"])
AS_IF([test "$ac_cv_safe_to_use_wformat_" = "yes"],[
- BASE_WARNINGS="${BASE_WARNINGS} -Wformat -Wno-format-nonliteral -Wno-format-security"
- BASE_WARNINGS_FULL="${BASE_WARNINGS_FULL} -Wformat=2 -Wno-format-nonliteral -Wno-format-security"
+ BASE_WARNINGS="${BASE_WARNINGS} -Wformat -Wno-format-nonliteral -Wformat-security"
+ BASE_WARNINGS_FULL="${BASE_WARNINGS_FULL} -Wformat=2 -Wno-format-nonliteral -Wformat-security"
],[
BASE_WARNINGS="${BASE_WARNINGS} -Wno-format"
BASE_WARNINGS_FULL="${BASE_WARNINGS_FULL} -Wno-format"
[NO_CONVERSION="-Wno-conversion"])
])
- CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align ${CC_WARNINGS_FULL}"
- CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long ${CXX_WARNINGS_FULL}"
+ CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align -Wsign-compare ${CC_WARNINGS_FULL}"
+ CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long -Wsign-compare ${CXX_WARNINGS_FULL}"
AC_CACHE_CHECK([whether it is safe to use -Wmissing-declarations from C++],
[ac_cv_safe_to_use_Wmissing_declarations_],
dnl Macro: PROTOCOL_BINARY_TEST
dnl ---------------------------------------------------------------------------
-AC_DEFUN([PROTOCOL_BINARY_TEST],
-[
- AC_CACHE_CHECK([for supported struct padding], [ac_cv_supported_struct_padding], [
- AC_LANG_PUSH([C])
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS -I${srcdir}"
- AC_TRY_COMPILE([
-#include <inttypes.h>
+AC_DEFUN([PROTOCOL_BINARY_TEST], [
+ AC_LANG_PUSH([C++])
+ AC_CACHE_CHECK([for supported struct padding], [ac_cv_supported_struct_padding], [
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+ [ #include <inttypes.h>
#include "libmemcached/memcached/protocol_binary.h"
- ], [
- protocol_binary_request_set request;
- int a = 1;
- switch (a) {
- case sizeof(request):
- case sizeof(request.bytes):
+ ], [ protocol_binary_request_set request;
+ int a = 1;
+ switch (a) {
+ case sizeof(request):
+ case sizeof(request.bytes):
break;
- default:
+ default:
a = 2;
- }
- ],
- [ ac_cv_supported_struct_padding=no ],
- [ ac_cv_supported_struct_padding=yes ])
- CFLAGS="$save_CFLAGS"
- AC_LANG_POP
- ])
- AS_IF([test "x$ac_cv_supported_struct_padding" = "xno"],[
- AC_MSG_ERROR([Unsupported struct padding done by compiler.])])
-])
+ }
+ ])],
+ [ ac_cv_supported_struct_padding=no ],
+ [ ac_cv_supported_struct_padding=yes ])
+ ])
+ AC_LANG_POP
+ AS_IF([test "x$ac_cv_supported_struct_padding" = "xno"],[ AC_MSG_ERROR([Unsupported struct padding done by compiler.])])
+ ])
dnl ---------------------------------------------------------------------------
dnl End Macro: PROTOCOL_BINARY_TEST
check_PROGRAMS+= tests/memdump
noinst_PROGRAMS+= tests/memdump
+test-memerror: clients/memerror
+ tests/memerror
+
+valgrind-memerror: clients/memerror
+ @$(VALGRIND_COMMAND) tests/memerror
+
test-memcp: clients/memcp
@echo "Testing memcp"
@@MEMC_BINARY@ -d -u root -P `pwd`/tests/Xumemc.pid -p 12555
};
-#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10
#include "tests/libmemcached_world.h"
void get_world(Framework *world)
while (memcached_server_count(memc) < 2)
{
const char *argv[1]= { "add_shutdown_server" };
- in_port_t port= max_port() +1;
- test_true(global_framework->servers().start_socket_server("memcached", port, 1, argv));
- test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, "localhost", port));
+ test_true(global_framework->servers().start_socket_server("memcached", libtest::default_port(), 1, argv));
+ test_compare(MEMCACHED_SUCCESS, memcached_server_add(memc, "localhost", libtest::default_port()));
}
// Disable a single server, just the first
{ 0, 0, 0, 0 }
};
-#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10
#include "libmemcached_world.h"
void get_world(Framework *world)
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.
+ *
+ */
+
+#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)
+{
+ if (getenv("LIBMEMCACHED_SERVER_NUMBER"))
+ {
+ int set_count= atoi(getenv("LIBMEMCACHED_SERVER_NUMBER"));
+ assert(set_count >= 0);
+ world->servers().set_count(set_count);
+ }
+ else
+ {
+ world->servers().set_count(8);
+ }
+
+ 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 },
+ {"memcached_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 kill_TESTS[] ={
+ {"kill(HUP)", 0, (test_callback_fn*)kill_HUP_TEST},
+ {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},
+ {"kill()", 0, 0, kill_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.
+ *
+ */
+
+#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);
+}
/* Number of times to run the test loop */
#define TEST_COUNTER 500000
-static uint32_t global_count;
static pairs_st *global_pairs;
static char *global_keys[GLOBAL_COUNT];
static 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++)
+ for (ptrdiff_t x= 0; x < GLOBAL_COUNT; x++)
{
global_keys[x]= global_pairs[x].key;
global_keys_length[x]= global_pairs[x].key_length;
static test_return_t drizzle(memcached_st *memc)
{
infinite:
- for (size_t x= 0; x < TEST_COUNTER; x++)
+ for (ptrdiff_t x= 0; x < TEST_COUNTER; x++)
{
memcached_return_t rc;
char *return_value;
static test_return_t many_adds(memcached_st *memc)
{
test_true(memc);
- for (size_t x= 0; x < TEST_COUNTER; x++)
+ for (ptrdiff_t x= 0; x < TEST_COUNTER; x++)
{
test_compare_got(TEST_SUCCESS, add_test(memc), x);
}
{
benchmark_state.create_init= true;
- for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++)
+ for (ptrdiff_t x= 0; x < BENCHMARK_TEST_LOOP; x++)
{
memcached_st *ptr;
ptr= memcached_create(&benchmark_state.create[x]);
{
benchmark_state.clone_init= true;
- for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++)
+ for (ptrdiff_t x= 0; x < BENCHMARK_TEST_LOOP; x++)
{
- memcached_st *ptr;
- ptr= memcached_clone(&benchmark_state.clone[x], memc);
+ memcached_st *ptr= memcached_clone(&benchmark_state.clone[x], memc);
test_true(ptr);
}
static test_return_t post_allocate(memcached_st *)
{
- for (size_t x= 0; x < BENCHMARK_TEST_LOOP; x++)
+ for (ptrdiff_t x= 0; x < BENCHMARK_TEST_LOOP; x++)
{
if (benchmark_state.create_init)
{
};
-#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10
-
#include "tests/libmemcached_world.h"
void get_world(Framework *world)
--- /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/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 < memcached_server_count(memc); 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/mem_functions.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= \
/*
This would not work if there were only two hosts.
*/
- for (size_t x= 0; x < 99; x++)
+ for (ptrdiff_t x= 0; x < 99; x++)
{
memcached_autoeject(memc);
uint32_t server_idx= memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
memc->ketama.next_distribution_rebuild= time(NULL) - 1;
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION,
memc->distribution);
- for (size_t x= 0; x < 99; x++)
+ for (ptrdiff_t x= 0; x < 99; x++)
{
uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key));
// We re-use instance from above.
#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/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"
-static pairs_st *global_pairs;
-static const char *global_keys[GLOBAL_COUNT];
-static size_t global_keys_length[GLOBAL_COUNT];
+#define UUID_STRING_MAXLENGTH 36
-/**
- @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));
+struct keys_st {
+public:
+ keys_st(size_t arg)
+ {
+ init(arg, UUID_STRING_MAXLENGTH);
+ }
- return TEST_SUCCESS;
-}
+ 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)
+ {
+#if defined(HAVE_LIBUUID) && 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';
+#endif
+ }
+ 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)
{
static memcached_st * create_single_instance_memcached(const memcached_st *original_memc, const char *options)
{
+ /*
+ If no options are given, copy over at least the binary flag.
+ */
+ char options_buffer[1024]= { 0 };
+ if (options == NULL)
+ {
+ if (memcached_is_binary(original_memc))
+ {
+ snprintf(options_buffer, sizeof(options_buffer), "--BINARY");
+ }
+ }
+
/*
* I only want to hit _one_ server so I know the number of requests I'm
* sending in the pipeline.
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)
return NULL;
}
- char buffer[1024];
- if (memcached_failed(libmemcached_check_configuration(server_string, server_string_length, buffer, sizeof(buffer))))
+ char errror_buffer[1024];
+ if (memcached_failed(libmemcached_check_configuration(server_string, server_string_length, errror_buffer, sizeof(errror_buffer))))
{
- Error << "Failed to parse " << server_string_length;
+ Error << "Failed to parse (" << server_string << ") " << errror_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 (ptrdiff_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;
- size_t string_length;
- uint32_t flags;
-
uint64_t query_id= memcached_query_id(memc);
- rc= memcached_delete(memc,
- test_literal_param(__func__),
- time_t(0));
- test_true_got(rc == MEMCACHED_BUFFERED or rc == MEMCACHED_NOTFOUND, memcached_last_error_message(memc));
+ memcached_return_t rc= memcached_delete(memc,
+ test_literal_param(__func__),
+ time_t(0));
+ test_true_hint(rc == MEMCACHED_BUFFERED or rc == MEMCACHED_NOTFOUND, memcached_last_error_message(memc));
test_compare(query_id +1, memcached_query_id(memc));
- string= memcached_get(memc,
+ size_t string_length;
+ uint32_t flags;
+ char *string= memcached_get(memc,
test_literal_param(__func__),
&string_length, &flags, &rc);
- test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
+ test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_last_error_message(memc));
test_false(string_length);
test_false(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)
+ for (ptrdiff_t x= 0; x < REGRESSION_BINARY_VS_BLOCK_COUNT; ++x)
{
char blob[1024] = {0};
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++)
+ for (ptrdiff_t x= 0; x < 18000; x++)
{
value.push_back((char) (x % 127));
}
- for (size_t current_length= 0; current_length < value.size(); current_length++)
+ for (size_t current_length= 1; current_length < value.size(); current_length++)
{
memcached_return_t rc= memcached_set(memc, test_literal_param("foo"),
&value[0], current_length,
test_compare(MEMCACHED_SUCCESS, rc);
test_compare(string_length, current_length);
- test_memcmp(string, &value[0], string_length);
+ char buffer[1024];
+ snprintf(buffer, sizeof(buffer), "%u", uint32_t(string_length));
+ test_memcmp_hint(string, &value[0], string_length, buffer);
free(string);
}
/*
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];
+
+ 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 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;
-}
-
-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;
uint32_t flags;
memcached_return rc;
memcached_st *tl_memc_h= memcached(test_literal_param("--server=localhost:9898 --server=localhost:9899")); // This server should not exist
// See if memcached is reachable.
- char *value= memcached_get(tl_memc_h, key, strlen(key), &len, &flags, &rc);
+ char *value= memcached_get(tl_memc_h,
+ test_literal_param(__func__),
+ &len, &flags, &rc);
test_false(value);
test_zero(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;
uint32_t flags;
memcached_return rc;
// See if memcached is reachable.
- char *value= memcached_get(memc, key, strlen(key), &len, &flags, &rc);
+ char *value= memcached_get(memc,
+ test_literal_param(__func__),
+ &len, &flags, &rc);
test_false(value);
test_zero(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 *)
{
- (void)memc;
- memcached_st *tl_memc_h;
- memcached_server_st *servers;
-
- const char *key= "MemcachedLives";
size_t len;
uint32_t flags;
memcached_return rc;
- char *value;
// Create a handle.
- tl_memc_h= memcached_create(NULL);
- servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist
+ memcached_st *tl_memc_h= memcached_create(NULL);
+ memcached_server_st *servers= memcached_servers_parse("localhost:9898,localhost:9899"); // This server should not exist
memcached_server_push(tl_memc_h, servers);
memcached_server_list_free(servers);
// See if memcached is reachable.
- value= memcached_get_by_key(tl_memc_h, key, strlen(key), key, strlen(key), &len, &flags, &rc);
+ char *value= memcached_get_by_key(tl_memc_h,
+ test_literal_param(__func__), // Key
+ test_literal_param(__func__), // Value
+ &len, &flags, &rc);
test_false(value);
test_zero(len);
/*
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;
uint32_t flags;
memcached_return rc;
- char *value;
// See if memcached is reachable.
- value= memcached_get_by_key(memc, key, strlen(key), key, strlen(key), &len, &flags, &rc);
+ char *value= memcached_get_by_key(memc,
+ test_literal_param(__func__), // Key
+ test_literal_param(__func__), // Value
+ &len, &flags, &rc);
test_false(value);
test_zero(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));
- const char *key= "regression_bug_434484";
- size_t keylen= strlen(key);
-
- memcached_return_t ret= memcached_append(memc, key, keylen, key, keylen, 0, 0);
- test_compare(MEMCACHED_NOTSTORED, ret);
+ test_compare(MEMCACHED_NOTSTORED,
+ memcached_append(memc,
+ test_literal_param(__func__), // Key
+ test_literal_param(__func__), // Value
+ 0, 0));
- size_t size= 2048 * 1024;
- char *data= (char*)calloc(1, size);
- test_true(data);
+ libtest::vchar_t data;
+ data.resize(2048 * 1024);
test_compare(MEMCACHED_E2BIG,
- memcached_set(memc, key, keylen, data, size, 0, 0));
- free(data);
+ memcached_set(memc,
+ test_literal_param(__func__), // Key
+ &data[0], data.size(), 0, 0));
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));
*/
memcached_st *memc= create_single_instance_memcached(original_memc, "--BINARY-PROTOCOL");
- const size_t max_keys= 1024;
- char **keys= (char**)calloc(max_keys, sizeof(char*));
- size_t *key_length= (size_t *)calloc(max_keys, sizeof(size_t));
-
- for (size_t x= 0; x < max_keys; ++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]);
- }
+ keys_st keys(1024);
/*
* Run two times.. the first time we should have 100% cache miss,
* and the second time we should have 100% cache hits
*/
- for (size_t y= 0; y < 2; y++)
+ for (ptrdiff_t y= 0; y < 2; y++)
{
test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, (const char**)keys, key_length, max_keys));
+ memcached_mget(memc, keys.keys_ptr(), keys.lengths_ptr(), keys.size()));
// One the first run we should get a NOT_FOUND, but on the second some data
// should be returned.
test_false(counter);
- for (size_t x= 0; x < max_keys; ++x)
+ for (size_t x= 0; x < keys.size(); ++x)
{
- rc= memcached_add(memc, keys[x], key_length[x],
+ rc= memcached_add(memc,
+ keys.key_at(x), keys.length_at(x),
blob, sizeof(blob), 0, 0);
test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
}
else
{
/* Verify that we received all of the key/value pairs */
- test_compare(counter, max_keys);
+ test_compare(counter, keys.size());
}
}
- /* Release allocated resources */
- for (size_t x= 0; x < max_keys; ++x)
- {
- free(keys[x]);
- }
- free(keys);
- free(key_length);
-
memcached_free(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);
- test_compare(MEMCACHED_SUCCESS, rc);
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, true));
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 *original_memc)
{
- test_skip(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1));
- memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1);
+ test_skip(original_memc->servers[0].type, MEMCACHED_CONNECTION_TCP);
- uint32_t number_of_hosts= memcached_server_count(memc);
- memc->number_of_hosts= 1;
-
- char k[250];
- size_t len;
+ memcached_st* memc= create_single_instance_memcached(original_memc, "--NOREPLY --TCP-NODELAY");
for (uint32_t x= 0; x < 250; ++x)
{
- len= (size_t)snprintf(k, sizeof(k), "%0250u", x);
- memcached_return_t rc= memcached_delete(memc, k, len, 0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ char key[250];
+ size_t len= (size_t)snprintf(key, sizeof(key), "%0250u", x);
+ memcached_return_t rc= memcached_delete(memc, key, len, 0);
+ char error_buffer[2048]= { 0 };
+ snprintf(error_buffer, sizeof(error_buffer), "%s key: %s", memcached_last_error_message(memc), key);
+ test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, error_buffer);
}
- len= snprintf(k, sizeof(k), "%037u", 251U);
-
- memcached_return_t rc= memcached_delete(memc, k, len, 0);
- test_true(rc == MEMCACHED_SUCCESS || rc == MEMCACHED_BUFFERED);
+ // Delete, and then delete again to look for not found
+ {
+ char key[250];
+ size_t len= snprintf(key, sizeof(key), "%037u", 251U);
+ memcached_return_t rc= memcached_delete(memc, key, len, 0);
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
- test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 0));
- test_compare(MEMCACHED_NOTFOUND, memcached_delete(memc, k, len, 0));
+ test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, false));
+ test_compare(MEMCACHED_NOTFOUND, memcached_delete(memc, key, len, 0));
+ }
- memc->number_of_hosts= number_of_hosts;
+ memcached_free(memc);
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;
-
if (memcached_server_count(memc) < 3 or pre_replication(memc) != TEST_SUCCESS)
+ {
return TEST_SKIPPED;
+ }
test_compare(MEMCACHED_SUCCESS,
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 2));
- const unsigned int max_keys= 100;
- char **keys= (char**)calloc(max_keys, sizeof(char*));
- size_t *key_length= (size_t *)calloc(max_keys, sizeof(size_t));
+ keys_st keys(100);
- for (unsigned int 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]);
test_compare(MEMCACHED_SUCCESS,
- memcached_set(memc, k, key_length[x], k, key_length[x], 0, 0));
+ memcached_set(memc,
+ keys.key_at(x), keys.length_at(x), // Keys
+ keys.key_at(x), keys.length_at(x), // Values
+ 0, 0));
}
/*
* into the servers
*/
test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, (const char* const *)keys, key_length, max_keys));
+ memcached_mget(memc,
+ keys.keys_ptr(), keys.lengths_ptr(), keys.size()));
unsigned int counter= 0;
memcached_execute_fn callbacks[]= { &callback_counter };
memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
/* Verify that we received all of the key/value pairs */
- test_compare(counter, max_keys);
+ test_compare(counter, keys.size());
memcached_quit(memc);
/*
* This is to verify correct behavior in the library. Fake that two servers
* are dead..
*/
- instance_one= memcached_server_instance_by_position(memc, 0);
- instance_two= memcached_server_instance_by_position(memc, 2);
+ memcached_server_instance_st instance_one= memcached_server_instance_by_position(memc, 0);
+ memcached_server_instance_st instance_two= memcached_server_instance_by_position(memc, 2);
in_port_t port0= instance_one->port;
in_port_t port2= instance_two->port;
((memcached_server_write_instance_st)instance_two)->port= 0;
test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, (const char* const *)keys, key_length, max_keys));
+ memcached_mget(memc,
+ keys.keys_ptr(), keys.lengths_ptr(), keys.size()));
counter= 0;
test_compare(MEMCACHED_SUCCESS,
memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
- test_compare(counter, (unsigned int)max_keys);
+ test_compare(counter, keys.size());
/* restore the memc handle */
((memcached_server_write_instance_st)instance_one)->port= port0;
memcached_quit(memc);
/* Remove half of the objects */
- for (size_t x= 0; x < max_keys; ++x)
+ for (size_t x= 0; x < keys.size(); ++x)
{
if (x & 1)
{
test_compare(MEMCACHED_SUCCESS,
- memcached_delete(memc, keys[x], key_length[x], 0));
+ memcached_delete(memc, keys.key_at(x), keys.length_at(x), 0));
}
}
/* now retry the command, this time we should have cache misses */
test_compare(MEMCACHED_SUCCESS,
- memcached_mget(memc, (const char* const *)keys, key_length, max_keys));
+ memcached_mget(memc,
+ keys.keys_ptr(), keys.lengths_ptr(), keys.size()));
counter= 0;
test_compare(MEMCACHED_SUCCESS,
memcached_fetch_execute(memc, callbacks, (void *)&counter, 1));
- test_compare(counter, (unsigned int)(max_keys >> 1));
-
- /* Release allocated resources */
- for (size_t x= 0; x < max_keys; ++x)
- {
- free(keys[x]);
- }
- free(keys);
- free(key_length);
+ test_compare(counter, (unsigned int)(keys.size() >> 1));
/* restore the memc handle */
((memcached_server_write_instance_st)instance_one)->port= port0;
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 *original_memc)
{
- memcached_return_t rc;
- memcached_server_instance_st instance;
-
- /* Set value to force connection to the server */
- const char *key= "marmotte";
- const char *value= "milka";
-
- /*
- * Please note that I'm abusing the internal structures in libmemcached
- * in a non-portable way and you shouldn't be doing this. I'm only
- * doing this in order to verify that the library works the way it should
- */
- uint32_t number_of_hosts= memcached_server_count(memc);
- memc->number_of_hosts= 1;
+ memcached_st* memc= create_single_instance_memcached(original_memc, NULL);
/* Ensure that we are connected to the server by setting a value */
- rc= memcached_set(memc, key, strlen(key),
- value, strlen(value),
- (time_t)0, (uint32_t)0);
+ memcached_return_t rc= memcached_set(memc,
+ test_literal_param(__func__), // Key
+ test_literal_param(__func__), // Value
+ time_t(0), uint32_t(0));
test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
- instance= memcached_server_instance_by_position(memc, 0);
+ memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0);
+
/* The test is to see that the memcached_quit doesn't increase the
* the server failure conter, so let's ensure that it is zero
* before sending quit
*/
test_zero(instance->server_failure_counter);
- /* restore the instance */
- memc->number_of_hosts= number_of_hosts;
+ memcached_free(memc);
return TEST_SUCCESS;
}
* 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__
memcached_st *memc= create_single_instance_memcached(original_memc, "--BINARY-PROTOCOL --POLL-TIMEOUT=1000 --REMOVE-FAILED-SERVERS=1 --RETRY-TIMEOUT=3600");
test_true(memc);
- size_t max_keys= 20480;
-
- char **keys= (char **)calloc(max_keys, sizeof(char*));
- size_t *key_length= (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]);
- memcached_return rc= memcached_set(memc, keys[x], key_length[x], blob, sizeof(blob), 0, 0);
+ memcached_return rc= memcached_set(memc,
+ keys.key_at(x), keys.length_at(x),
+ blob, sizeof(blob), 0, 0);
test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED); // MEMCACHED_TIMEOUT <-- hash been observed on OSX
}
/* Try to get all of them with a large multiget */
size_t counter= 0;
memcached_execute_function callbacks[]= { &callback_counter };
- memcached_return_t rc= memcached_mget_execute(memc, (const char**)keys, key_length,
- (size_t)max_keys, callbacks, &counter, 1);
+ memcached_return_t rc= memcached_mget_execute(memc,
+ keys.keys_ptr(), keys.lengths_ptr(), keys.size(),
+ callbacks, &counter, 1);
test_compare(MEMCACHED_SUCCESS, rc);
char* the_value= NULL;
test_compare(MEMCACHED_END, rc);
/* Verify that we got all of the items */
- test_compare(counter, max_keys);
- }
-
- /* Release all allocated resources */
- for (size_t x= 0; x < max_keys; ++x)
- {
- free(keys[x]);
+ test_compare(counter, keys.size());
}
- free(keys);
- free(key_length);
memcached_free(memc);
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
memset(payload, int('x'), sizeof(payload));
- for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++)
- {
- char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- snprintf(key, sizeof(key), "%u", x);
+ keys_st keys(regression_bug_655423_COUNT);
- test_compare(MEMCACHED_SUCCESS, memcached_set(clone, key, strlen(key), payload, sizeof(payload), 0, 0));
+ for (size_t x= 0; x < keys.size(); x++)
+ {
+ test_compare(MEMCACHED_SUCCESS, memcached_set(clone,
+ keys.key_at(x),
+ keys.length_at(x),
+ payload, sizeof(payload), 0, 0));
}
- for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++)
+ for (size_t x= 0; x < keys.size(); x++)
{
- char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- snprintf(key, sizeof(key), "%u", x);
-
size_t value_length;
memcached_return_t rc;
- char *value= memcached_get(clone, key, strlen(key), &value_length, NULL, &rc);
+ char *value= memcached_get(clone,
+ keys.key_at(x),
+ keys.length_at(x),
+ &value_length, NULL, &rc);
if (rc == MEMCACHED_NOTFOUND)
{
free(value);
}
- char **keys= (char**)calloc(regression_bug_655423_COUNT, sizeof(char*));
- size_t *key_length= (size_t *)calloc(regression_bug_655423_COUNT, sizeof(size_t));
- for (uint32_t x= 0; x < regression_bug_655423_COUNT; x++)
- {
- char key[MEMCACHED_MAXIMUM_INTEGER_DISPLAY_LENGTH +1];
- snprintf(key, sizeof(key), "%u", x);
-
- keys[x]= strdup(key);
- test_true(keys[x]);
- key_length[x]= strlen(key);
- test_true(key_length[x]);
- }
-
test_compare(MEMCACHED_SUCCESS,
- memcached_mget(clone, (const char* const *)keys, key_length, regression_bug_655423_COUNT));
+ memcached_mget(clone,
+ keys.keys_ptr(), keys.lengths_ptr(),
+ keys.size()));
uint32_t count= 0;
memcached_result_st *result= NULL;
test_true(count > 100); // If we don't get back atleast this, something is up
- /* Release all allocated resources */
- for (size_t x= 0; x < regression_bug_655423_COUNT; ++x)
- {
- free(keys[x]);
- }
- free(keys);
- free(key_length);
-
-
memcached_free(clone);
return TEST_SUCCESS;
* 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 *original_memc)
{
+ memcached_st* memc= create_single_instance_memcached(original_memc, NULL);
+
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK,1);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS,1);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_POLL_TIMEOUT, 1000);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT,1);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 3600);
- memc->number_of_hosts= 1;
-
- char **keys= (char **)calloc(regression_bug_490520_COUNT, sizeof(char*));
- size_t *key_length= (size_t *)calloc(regression_bug_490520_COUNT, sizeof(size_t));
-
/* First add all of the items.. */
char blob[3333] = {0};
for (uint32_t x= 0; x < regression_bug_490520_COUNT; ++x)
{
- char k[251];
- key_length[x]= (size_t)snprintf(k, sizeof(k), "0200%u", x);
- keys[x]= strdup(k);
- test_true(keys[x]);
+ char key[251];
+ int key_length= snprintf(key, sizeof(key), "0200%u", x);
- memcached_return rc= memcached_set(memc, keys[x], key_length[x], blob, sizeof(blob), 0, 0);
+ memcached_return rc= memcached_set(memc, key, key_length, blob, sizeof(blob), 0, 0);
test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_last_error_message(memc));
}
- for (uint32_t x= 0; x < regression_bug_490520_COUNT; ++x)
- {
- free(keys[x]);
- }
- free(keys);
- free(key_length);
+ memcached_free(memc);
return TEST_SUCCESS;
}
-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
+test_return_t kill_HUP_TEST(memcached_st *original_memc)
+{
+ memcached_st *memc= create_single_instance_memcached(original_memc, 0);
+ test_true(memc);
-#include "tests/libmemcached_world.h"
+ memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0);
-void get_world(Framework *world)
-{
- world->collections= collection;
+ pid_t pid;
+ test_true((pid= libmemcached_util_getpid(memcached_server_name(instance),
+ memcached_server_port(instance), NULL)) > -1);
- 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;
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(memc,
+ test_literal_param(__func__), // Keys
+ test_literal_param(__func__), // Values
+ 0, 0));
+ test_true_got(kill(pid, SIGHUP) == 0, strerror(errno));
- world->collection_startup= (test_callback_fn*)world_container_startup;
- world->collection_shutdown= (test_callback_fn*)world_container_shutdown;
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(memc,
+ test_literal_param(__func__), // Keys
+ test_literal_param(__func__), // Values
+ 0, 0));
- world->set_runner(&defualt_libmemcached_runner);
+ memcached_free(memc);
- world->set_socket();
+ 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 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);
+test_return_t kill_HUP_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;
Test cases
*/
-#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +20
#include <libmemcached/memcached.h>
static test_return_t pre_sasl(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 <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;
-
char variable_buffer[1024];
snprintf(variable_buffer, sizeof(variable_buffer), "LIBMEMCACHED_PORT_%u", x);
+ in_port_t port;
char *var;
if ((var= getenv(variable_buffer)))
{
}
else
{
- port= in_port_t(TEST_PORT_BASE +x);
+ port= in_port_t(libtest::get_free_port());
}
- 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)
{
}
}
- 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;
}
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);
+ memcached_server_instance_st instance= memcached_server_instance_by_position(container->memc, loop);
test_compare(-1, instance->fd);
test_compare(0U, instance->cursor_active);
}
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;
+ }
+
+ for (uint32_t x= 0; x < servers.count(); x++)
+ {
+ const char *argv[1]= { "memcached" };
+ if (not servers.start_socket_server("memcached", libtest::get_free_port(), 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;
+ }
+ }
+
+ 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;
{0, 0, 0, 0}
};
-#define TEST_PORT_BASE MEMCACHED_DEFAULT_PORT +10
#include "tests/libmemcached_world.h"
void get_world(Framework *world)
{
const char *args[]= { "-q", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
+
return TEST_SUCCESS;
}
static test_return_t help_test(void *)
{
- const char *args[]= { "-q", "--help", 0 };
+ const char *args[]= { "-h", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
static test_return_t ascii_test(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "-p %d", int(default_port()));
- const char *args[]= { "-q", buffer, " -a ", 0 };
+ snprintf(buffer, sizeof(buffer), "%d", int(default_port()));
+ const char *args[]= { "-p", buffer, " -a ", 0 };
+
+ test_true(exec_cmdline(executable, args, true) <= EXIT_FAILURE);
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
static test_return_t binary_test(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "-p %d", int(default_port()));
- const char *args[]= { "-q", buffer, " -b ", 0 };
+ snprintf(buffer, sizeof(buffer), "%d", int(default_port()));
+ const char *args[]= { "-p", buffer, " -b ", 0 };
+
+ test_true(exec_cmdline(executable, args, true) <= EXIT_FAILURE);
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
test_st memcapable_tests[] ={
{"--quiet", 0, quiet_test},
- {"--help", 0, help_test},
+ {"-h", 0, help_test},
{"-a, ascii", 0, ascii_test},
{"-b, binary", 0, binary_test},
{0, 0, 0}
}
const char *argv[1]= { "memcapable" };
- if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv))
+ if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv))
{
error= TEST_FAILURE;
}
{
const char *args[]= { "--quiet", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
+
return TEST_SUCCESS;
}
static test_return_t help_test(void *)
{
- const char *args[]= { "--quiet", "--help", 0 };
+ const char *args[]= { "--help", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "foo", 0 };
+ const char *args[]= { buffer, "foo", 0 };
memcached_st *memc= memcached(buffer, strlen(buffer));
test_true(memc);
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "foo", 0 };
+ const char *args[]= { buffer, "foo", 0 };
memcached_st *memc= memcached(buffer, strlen(buffer));
test_true(memc);
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_NOTFOUND, rc);
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_NOTFOUND, rc);
}
const char *argv[1]= { "memcat" };
- if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv))
+ if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv))
{
error= TEST_FAILURE;
}
{
const char *args[]= { "--quiet", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
+
return TEST_SUCCESS;
}
static test_return_t help_test(void *)
{
- const char *args[]= { "--quiet", "--help", 0 };
+ const char *args[]= { "--help", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, 0 };
+ const char *args[]= { buffer, 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
}
const char *argv[1]= { "memcp" };
- if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv))
+ if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv))
{
error= TEST_FAILURE;
}
{
const char *args[]= { "--quiet", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
+
return TEST_SUCCESS;
}
{
const char *args[]= { "--help", "--quiet", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
+
return TEST_SUCCESS;
}
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
const char *args[]= { buffer, 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
+
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, 0 };
+ const char *args[]= { buffer, 0 };
memcached_st *memc= memcached(buffer, strlen(buffer));
test_true(memc);
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
memcached_free(memc);
}
const char *argv[1]= { "memdump" };
- if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv))
+ if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv))
{
error= TEST_FAILURE;
}
static std::string executable;
-static test_return_t quiet_test(void *)
+static test_return_t help_TEST(void *)
{
- const char *args[]= { "--quiet", 0 };
+ const char *args[]= { "--help", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
-static test_return_t help_test(void *)
+static test_return_t version_TEST(void *)
{
- const char *args[]= { "--quiet", "--help", 0 };
+ const char *args[]= { "--version", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
static test_return_t error_test(void *)
{
- const char *args[]= { "--quiet", "MEMCACHED_SUCCESS", 0 };
+ const char *args[]= { "memcached_success", 0 };
+
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
+
+ return TEST_SUCCESS;
+}
+
+static test_return_t SUCCESS_TEST(void *)
+{
+ const char *args[]= { "0", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
static test_return_t bad_input_test(void *)
{
- const char *args[]= { "--quiet", "bad input", 0 };
+ const char *args[]= { "bad input", 0 };
+
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
test_st memerror_tests[] ={
- {"--quiet", 0, quiet_test},
- {"--help", 0, help_test},
+ {"--help", 0, help_TEST},
+ {"--version", 0, version_TEST},
{"<error>", 0, error_test},
+ {"0", 0, SUCCESS_TEST},
{"<bad input>", 0, bad_input_test},
{0, 0, 0}
};
}
const char *argv[1]= { "memexist" };
- if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv))
+ if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv))
{
error= TEST_FAILURE;
}
{
const char *args[]= { "--quiet", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
+
return TEST_SUCCESS;
}
static test_return_t help_test(void *)
{
- const char *args[]= { "--quiet", "--help", 0 };
+ const char *args[]= { "--help", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, 0 };
+ const char *args[]= { buffer, 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
}
const char *argv[1]= { "memflush" };
- if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv))
+ if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv))
{
error= TEST_FAILURE;
}
{
const char *args[]= { "--quiet", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
return TEST_SUCCESS;
}
static test_return_t help_test(void *)
{
- const char *args[]= { "--quiet", "--help", 0 };
+ const char *args[]= { "--help", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "foo", 0 };
memcached_st *memc= memcached(buffer, strlen(buffer));
test_true(memc);
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
- test_true(exec_cmdline(executable, args));
+ const char *args[]= { buffer, "foo", 0 };
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_NOTFOUND, rc);
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "foo", 0 };
+ const char *args[]= { buffer, "foo", 0 };
memcached_st *memc= memcached(buffer, strlen(buffer));
test_true(memc);
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_NOTFOUND, rc);
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_NOTFOUND, rc);
}
const char *argv[1]= { "memrm" };
- if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv))
+ if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv))
{
error= TEST_FAILURE;
}
{
const char *args[]= { "--quiet", 0 };
- test_true(exec_cmdline(executable, args));
+ test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
+
return TEST_SUCCESS;
}
static test_return_t help_test(void *)
{
- const char *args[]= { "--quiet", "--help", 0 };
+ const char *args[]= { "--help", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, 0 };
+ const char *args[]= { buffer, 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "--concurrency=10", 0 };
+ const char *args[]= { buffer, "--concurrency=10", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "--concurrency=10", "--initial-load=1000", 0 };
+ const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", 0 };
+ const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=get", 0 };
+ const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=get", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=set", 0 };
+ const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=set", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
- const char *args[]= { "--quiet", buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=set", "--non-blocking", 0 };
+ const char *args[]= { buffer, "--concurrency=10", "--initial-load=1000", "--execute-number=10", "--test=set", "--non-blocking", 0 };
+
+ test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
- test_true(exec_cmdline(executable, args));
return TEST_SUCCESS;
}
}
const char *argv[1]= { "memslap" };
- if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv))
+ if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv))
{
error= TEST_FAILURE;
}
static test_return_t binary_TEST(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
+ snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port()));
const char *args[]= { "--quiet", buffer, " --binary ", 0 };
test_true(exec_cmdline(executable, args));
static test_return_t server_version_TEST(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
+ snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port()));
const char *args[]= { "--quiet", buffer, " --server-version", 0 };
test_true(exec_cmdline(executable, args));
static test_return_t binary_server_version_TEST(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
+ snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(libtest::default_port()));
const char *args[]= { "--quiet", buffer, " --binary --server-version", 0 };
test_true(exec_cmdline(executable, args));
}
const char *argv[1]= { "memstat" };
- if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv))
+ if (server_startup(servers, "memcached", libtest::default_port(), 1, argv) == false)
{
error= TEST_FAILURE;
}
}
const char *argv[1]= { "memtouch" };
- if (not server_startup(servers, "memcached", MEMCACHED_DEFAULT_PORT +10, 1, argv))
+ if (not server_startup(servers, "memcached", libtest::default_port(), 1, argv))
{
error= TEST_FAILURE;
}
#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
return false;
}
- if (not close_io)
+ if (close_io == false)
{
return true;;
}
#include "util/instance.hpp"
#include <cstdio>
-#include <sstream>
#include <iostream>
#include <netdb.h>
+#include <netinet/in.h>
#include <poll.h>
+#include <sstream>
#include <sys/socket.h>
#include <sys/types.h>
-#include <netinet/in.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
namespace datadifferential {
do
{
char buffer[BUFSIZ];
- read_length= recv(_sockfd, buffer, sizeof(buffer), 0);
+ read_length= ::recv(_sockfd, buffer, sizeof(buffer), 0);
if (read_length < 0)
{
switch(errno)
{
default:
- std::cerr << "Error occured while reading data from " << _host.c_str() << std::endl;
+ _last_error.clear();
+ _last_error+= "Error occured while reading data from ";
+ _last_error+= _host;
return false;
}
}
+ else if (read_length == 0)
+ {
+ _last_error.clear();
+ _last_error+= "Socket was shutdown while reading from ";
+ _last_error+= _host;
+
+ return false;
+ }
operation->push(buffer, static_cast<size_t>(read_length));
total_read+= static_cast<size_t>(read_length);
+
} while (more_to_read());
} // end has_response
void Instance::close_socket()
{
if (_sockfd == INVALID_SOCKET)
+ {
return;
+ }
/* in case of death shutdown to avoid blocking at close() */
if (shutdown(_sockfd, SHUT_RDWR) == SOCKET_ERROR && get_socket_errno() != ENOTCONN)
void Instance::free_addrinfo()
{
- if (not _addrinfo)
+ if (_addrinfo == NULL)
+ {
return;
+ }
freeaddrinfo(_addrinfo);
_addrinfo= NULL;
bool Operation::response(std::string &arg)
{
if (_response.empty())
+ {
return false;
+ }
if (not memcmp("OK\r\n", &_response[0], 3))
{ }
#include <pthread.h>
#include <semaphore.h>
+#ifdef HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
namespace datadifferential {
namespace util {
#define util_string_make_from_cstr(X) (X), ((X) ? strlen(X) : 0)
+#define util_string_make_from_array(__array) (__array), (strlen(__array))
+
#define util_array_length(__array) sizeof(__array)/sizeof(&__array)