+*.log
+*.trs
*.exe
*.gz
*.lo
example/memcached_light
example/t/memcached_light
libhashkit-1.0/configure.h
+libhashkit/hashkitcon.h
libmemcached-1.0/configure.h
libmemcached-1.0/t/c_sasl_test
libmemcached-1.0/t/c_test
libtest/.hg/
libtest/.hgignore
libtest/abort
+libtest/backtrace
libtest/core-count
libtest/skiptest
libtest/unittest
libtest/version.h
libtest/wait
+libtest/yatlcon.h
libtool
m4/libtool.m4
m4/libtool.m4
tests/memerror
tests/memexist
tests/memflush
+tests/memping
tests/memplus
tests/memrm
tests/memslap
tests/var/
tmp_chroot
unittests/unittests
-libhashkit/hashkitcon.h
-libtest/yatlcon.h
+1.0.18
+
1.0.17 Tue Apr 2 14:02:01 HST 2013
* Remove c++ namespace that was being exposed (the API should be plug compatible)..
* Fix cases where --servers wasn't behaving the same in all clients.
# vim:ft=automake
-ACLOCAL_AMFLAGS = -I m4 -I libtest/m4
+ACLOCAL_AMFLAGS= -I m4 -I libtest/m4
+AM_YFLAGS= -d
# includes append to these:
SUFFIXES =
include_HEADERS =
nobase_include_HEADERS =
check_PROGRAMS =
+check_LTLIBRARIES=
EXTRA_HEADERS =
BUILT_SOURCES=
EXTRA_DIST=
-rm -f build-aux/install-sh
-rm -f build-aux/ltmain.sh
-rm -f build-aux/missing
+ -rm -f build-aux/ylwrap
-rm -f mem_config.in
-rm -f config.log
-rm -f config.status
# WARNINGS
#
+use_banner ()
+{
+ echo "#####################################################################################"
+ echo "#"
+ echo "#"
+ echo "#"
+ echo "# TARGET:$1"
+ echo "#"
+ echo "#"
+ echo "#"
+ echo "#####################################################################################"
+}
+
command_not_found_handle ()
{
warn "$@: command not found"
return 127
}
-function error ()
+error ()
{
echo "$BASH_SOURCE:$BASH_LINENO: $@" >&2
}
-function die ()
+die ()
{
echo "$BASH_SOURCE:$BASH_LINENO: $@" >&2
exit 1;
}
-function warn ()
+warn ()
{
echo "$BASH_SOURCE:$BASH_LINENO: $@"
#echo "$BASH_SOURCE:$BASH_LINENO: $@" >&1
}
-function nassert ()
+nassert ()
{
local param_name=\$"$1"
- local param_value=`eval "expr \"$param_name\" "`
+ local param_value="$(eval "expr \"$param_name\" ")"
if [ -n "$param_value" ]; then
echo "$bash_source:$bash_lineno: assert($param_name) had value of "$param_value"" >&2
fi
}
-function assert ()
+assert ()
{
local param_name=\$"$1"
- local param_value=`eval "expr \"$param_name\" "`
+ local param_value="$(eval "expr \"$param_name\" ")"
if [ -z "$param_value" ]; then
echo "$bash_source:$bash_lineno: assert($param_name)" >&2
fi
}
-function assert_file ()
+assert_file ()
{
if [ ! -f "$1" ]; then
echo "$BASH_SOURCE:$BASH_LINENO: assert($1) does not exist: $2" >&2
fi
}
-function assert_no_file ()
+assert_no_file ()
{
if [ -f "$1" ]; then
echo "$BASH_SOURCE:$BASH_LINENO: assert($1) file exists: $2" >&2
fi
}
-function assert_no_directory ()
+assert_no_directory ()
{
if [ -d "$1" ]; then
echo "$BASH_SOURCE:$BASH_LINENO: assert($1) directory exists: $2" >&2
fi
}
-function assert_exec_file ()
+assert_exec_file ()
{
if [ ! -f "$1" ]; then
echo "$BASH_SOURCE:$BASH_LINENO: assert($1) does not exist: $2" >&2
fi
}
-function command_exists ()
+command_exists ()
{
type "$1" &> /dev/null ;
}
-function rebuild_host_os ()
+rebuild_host_os ()
{
HOST_OS="${UNAME_MACHINE_ARCH}-${VENDOR}-${VENDOR_DISTRIBUTION}-${VENDOR_RELEASE}-${UNAME_KERNEL}-${UNAME_KERNEL_RELEASE}"
if [ -z "$1" ]; then
- if $VERBOSE; then
+ if $verbose; then
echo "HOST_OS=$HOST_OS"
fi
fi
# Validate the distribution name, or toss an erro
# values: darwin,fedora,rhel,ubuntu,debian,opensuse
-function set_VENDOR_DISTRIBUTION ()
+set_VENDOR_DISTRIBUTION ()
{
- local dist=`echo "$1" | tr '[A-Z]' '[a-z]'`
+ local dist="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
case "$dist" in
darwin)
VENDOR_DISTRIBUTION='darwin'
}
# Validate a Vendor's release name/number
-function set_VENDOR_RELEASE ()
+set_VENDOR_RELEASE ()
{
- local release=`echo "$1" | tr '[A-Z]' '[a-z]'`
- case "$VENDOR_DISTRIBUTION" in
+ local release="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
+
+ if $verbose; then
+ echo "VENDOR_DISTRIBUTION:$VENDOR_DISTRIBUTION"
+ echo "VENDOR_RELEASE:$release"
+ fi
+
+ case $VENDOR_DISTRIBUTION in
darwin)
- case "$VENDOR_DISTRIBUTION" in
+ case $release in
10.6*)
VENDOR_RELEASE='snow_leopard'
;;
mountain)
VENDOR_RELEASE='mountain'
;;
- 10.8*)
+ 10.8.*)
+ echo "mountain_lion"
VENDOR_RELEASE='mountain_lion'
;;
*)
+ echo $VENDOR_RELEASE
VENDOR_RELEASE='unknown'
;;
esac
rhel)
VENDOR_RELEASE="$release"
;;
+ debian)
+ VENDOR_RELEASE="$release"
+ ;;
ubuntu)
VENDOR_RELEASE="$release"
if [[ "x$VENDOR_RELEASE" == 'x12.04' ]]; then
VENDOR_RELEASE="precise"
elif [[ "x$VENDOR_RELEASE" == 'x12.10' ]]; then
VENDOR_RELEASE="quantal"
+ elif [[ "x$VENDOR_RELEASE" == 'x13.04' ]]; then
+ VENDOR_RELEASE="raring"
fi
;;
opensuse)
# Valid values are: apple, redhat, centos, canonical, oracle, suse
-function set_VENDOR ()
+set_VENDOR ()
{
- local vendor=`echo "$1" | tr '[A-Z]' '[a-z]'`
+ local vendor="$(echo "$1" | tr '[:upper:]' '[:lower:]')"
case $vendor in
apple)
;;
esac
- set_VENDOR_DISTRIBUTION $2
- set_VENDOR_RELEASE $3
+ set_VENDOR_DISTRIBUTION "$2"
+ set_VENDOR_RELEASE "$3"
# Set which vendor/versions we trust for autoreconf
case $VENDOR_DISTRIBUTION in
}
-function determine_target_platform ()
+determine_target_platform ()
{
- UNAME_MACHINE_ARCH=`(uname -m) 2>/dev/null` || UNAME_MACHINE_ARCH=unknown
- UNAME_KERNEL=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
- UNAME_KERNEL_RELEASE=`(uname -r) 2>/dev/null` || UNAME_KERNEL_RELEASE=unknown
+ UNAME_MACHINE_ARCH="$(uname -m 2>/dev/null)" || UNAME_MACHINE_ARCH=unknown
+ UNAME_KERNEL="$(uname -s 2>/dev/null)" || UNAME_SYSTEM=unknown
+ UNAME_KERNEL_RELEASE="$(uname -r 2>/dev/null)" || UNAME_KERNEL_RELEASE=unknown
if [[ -x '/usr/bin/sw_vers' ]]; then
- local _VERSION=`/usr/bin/sw_vers -productVersion`
+ local _VERSION="$(/usr/bin/sw_vers -productVersion)"
set_VENDOR 'apple' 'darwin' $_VERSION
elif [[ $(uname) == 'Darwin' ]]; then
set_VENDOR 'apple' 'darwin' 'mountain'
elif [[ -f '/etc/fedora-release' ]]; then
- local fedora_version=`cat /etc/fedora-release | awk ' { print $3 } '`
+ local fedora_version="$(awk ' { print $3 } ' < /etc/fedora-release)"
set_VENDOR 'redhat' 'fedora' $fedora_version
elif [[ -f '/etc/centos-release' ]]; then
- local centos_version=`cat /etc/centos-release | awk ' { print $7 } '`
+ local centos_version="$(awk ' { print $7 } ' < /etc/centos-release)"
set_VENDOR 'centos' 'rhel' $centos_version
elif [[ -f '/etc/SuSE-release' ]]; then
- local suse_distribution=`head -1 /etc/SuSE-release | awk ' { print $1 } '`
- local suse_version=`head -1 /etc/SuSE-release | awk ' { print $2 } '`
+ local suse_distribution="$(head -1 /etc/SuSE-release | awk ' { print $1 } ')"
+ local suse_version="$(head -1 /etc/SuSE-release | awk ' { print $2 } ')"
set_VENDOR 'suse' $suse_distribution $suse_version
elif [[ -f '/etc/redhat-release' ]]; then
- local rhel_version=`cat /etc/redhat-release | awk ' { print $7 } '`
- local _vendor=`rpm -qf /etc/redhat-release`
+ local rhel_version="$(awk ' { print $7 } ' < /etc/redhat-release)"
+ local _vendor="$(rpm -qf /etc/redhat-release)"
set_VENDOR $_vendor 'rhel' $rhel_version
elif [[ -f '/etc/os-release' ]]; then
source '/etc/os-release'
set_VENDOR $ID $ID $VERSION_ID
elif [[ -x '/usr/bin/lsb_release' ]]; then
- local _ID=`/usr/bin/lsb_release -s -i`
- local _VERSION=`/usr/bin/lsb_release -s -r`
+ local _ID="$(/usr/bin/lsb_release -s -i)"
+ local _VERSION="$(/usr/bin/lsb_release -s -r)"
set_VENDOR $_ID $_ID $_VERSION_ID
elif [[ -f '/etc/lsb-release' ]]; then
source '/etc/lsb-release'
rebuild_host_os
}
-function run_configure ()
+run_configure ()
{
# We will run autoreconf if we are required
run_autoreconf_if_required
# We always begin at the root of our build
- if [ ! popd ]; then
+ if [ ! $? ]; then
die "Programmer error, we entered run_configure with a stacked directory"
fi
if [[ -n "$BUILD_DIR" ]]; then
rm -r -f $BUILD_DIR
mkdir -p $BUILD_DIR
- safe_pushd $BUILD_DIR
fi
# Arguments for configure
- local BUILD_CONFIGURE_ARG=
+ local BUILD_CONFIGURE_ARG=''
- # If ENV DEBUG is set we enable both debug and asssert, otherwise we see if this is a VCS checkout and if so enable assert
- # Set ENV ASSERT in order to enable assert
- if $DEBUG; then
- BUILD_CONFIGURE_ARG+=' --enable-debug --enable-assert'
- elif [[ -n "$VCS_CHECKOUT" ]]; then
- BUILD_CONFIGURE_ARG+=' --enable-assert'
+ # If debug is set we enable both debug and asssert, otherwise we see if this is a VCS checkout and if so enable assert
+ # Set ENV ASSERT in order to enable assert.
+ # If we are doing a valgrind run, we always compile with assert disabled
+ if $valgrind_run; then
+ BUILD_CONFIGURE_ARG="--enable-assert=no $BUILD_CONFIGURE_ARG"
+ else
+ if $debug; then
+ BUILD_CONFIGURE_ARG="--enable-debug --enable-assert $BUILD_CONFIGURE_ARG"
+ elif [[ -n "$VCS_CHECKOUT" ]]; then
+ BUILD_CONFIGURE_ARG="--enable-assert $BUILD_CONFIGURE_ARG"
+ fi
fi
if [[ -n "$CONFIGURE_ARG" ]]; then
- BUILD_CONFIGURE_ARG+=" $CONFIGURE_ARG"
+ BUILD_CONFIGURE_ARG="$CONFIGURE_ARG $BUILD_CONFIGURE_ARG"
fi
if [[ -n "$PREFIX_ARG" ]]; then
- BUILD_CONFIGURE_ARG+=" $PREFIX_ARG"
+ BUILD_CONFIGURE_ARG="$PREFIX_ARG $BUILD_CONFIGURE_ARG"
fi
ret=1;
# If we are executing on OSX use CLANG, otherwise only use it if we find it in the ENV
case $HOST_OS in
*-darwin-*)
- CC=clang CXX=clang++ $top_srcdir/configure $BUILD_CONFIGURE_ARG || die "Cannot execute CC=clang CXX=clang++ configure $BUILD_CONFIGURE_ARG"
+ run CC=clang CXX=clang++ $CONFIGURE "$BUILD_CONFIGURE_ARG" || die "Cannot execute CC=clang CXX=clang++ configure $BUILD_CONFIGURE_ARG"
ret=$?
;;
rhel-5*)
command_exists 'gcc44' || die "Could not locate gcc44"
- CC=gcc44 CXX=gcc44 $top_srcdir/configure $BUILD_CONFIGURE_ARG || die "Cannot execute CC=gcc44 CXX=gcc44 configure $BUILD_CONFIGURE_ARG"
+ run CC=gcc44 CXX=gcc44 $top_srcdir/configure "$BUILD_CONFIGURE_ARG" || die "Cannot execute CC=gcc44 CXX=gcc44 configure $BUILD_CONFIGURE_ARG"
ret=$?
;;
*)
- $CONFIGURE $BUILD_CONFIGURE_ARG
+ run $CONFIGURE "$BUILD_CONFIGURE_ARG"
ret=$?
;;
esac
fi
}
-function setup_gdb_command () {
+setup_gdb_command ()
+{
GDB_TMPFILE=$(mktemp /tmp/gdb.XXXXXXXXXX)
- echo 'set logging overwrite on' > $GDB_TMPFILE
- echo 'set logging on' >> $GDB_TMPFILE
- echo 'set environment LIBTEST_IN_GDB=1' >> $GDB_TMPFILE
- echo 'run' >> $GDB_TMPFILE
- echo 'thread apply all bt' >> $GDB_TMPFILE
- echo 'quit' >> $GDB_TMPFILE
+ echo 'set logging overwrite on' > "$GDB_TMPFILE"
+ echo 'set logging on' >> "$GDB_TMPFILE"
+ echo 'set environment LIBTEST_IN_GDB=1' >> "$GDB_TMPFILE"
+ echo 'run' >> "$GDB_TMPFILE"
+ echo 'thread apply all bt' >> "$GDB_TMPFILE"
+ echo 'quit' >> "$GDB_TMPFILE"
GDB_COMMAND="gdb -f -batch -x $GDB_TMPFILE"
}
-function setup_valgrind_command () {
- VALGRIND_PROGRAM=`type -p valgrind`
+setup_valgrind_command ()
+{
+ VALGRIND_PROGRAM="$(type -p valgrind)"
if [[ -n "$VALGRIND_PROGRAM" ]]; then
- VALGRIND_COMMAND="$VALGRIND_PROGRAM --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE"
+ VALGRIND_COMMAND="$VALGRIND_PROGRAM --error-exitcode=1 --leak-check=yes --malloc-fill=A5 --free-fill=DE --xml=yes --xml-file=\"valgrind-%p.xml\""
fi
}
-function save_BUILD ()
+save_BUILD ()
{
if [[ -n "$OLD_CONFIGURE" ]]; then
die "OLD_CONFIGURE($OLD_CONFIGURE) was set on push, programmer error!"
fi
}
-function restore_BUILD ()
+restore_BUILD ()
{
if [[ -n "$OLD_CONFIGURE" ]]; then
CONFIGURE=$OLD_CONFIGURE
export -n CC CXX
}
-function safe_pushd ()
-{
- pushd $1 &> /dev/null ;
-
- if [ -n "$BUILD_DIR" ]; then
- if $VERBOSE; then
- echo "BUILD_DIR=$BUILD_DIR"
- fi
- fi
-}
-
-function safe_popd ()
+make_valgrind ()
{
- local directory_to_delete=`pwd`
- popd &> /dev/null ;
- if [ $? -eq 0 ]; then
- if [[ "$top_srcdir" == "$directory_to_delete" ]]; then
- die "We almost deleted top_srcdir($top_srcdir), programmer error"
- fi
-
- rm -r -f "$directory_to_delete"
- fi
-}
-
-function make_valgrind ()
-{
- if [[ "$VENDOR_DISTRIBUTION" == 'darwin' ]]; then
- make_darwin_malloc
- return
- fi
-
# If the env VALGRIND_COMMAND is set then we assume it is valid
local valgrind_was_set=false
if [[ -z "$VALGRIND_COMMAND" ]]; then
save_BUILD
+ valgrind_run=true
+
# If we are required to run configure, do so now
- run_configure_if_required
+ run_configure
# If we don't have a configure, then most likely we will be missing libtool
assert_file 'configure'
- if [[ -f 'libtool' ]]; then
+ if [[ -x 'libtool' ]]; then
TESTS_ENVIRONMENT="./libtool --mode=execute $VALGRIND_COMMAND"
else
TESTS_ENVIRONMENT="$VALGRIND_COMMAND"
fi
- make_target 'check' || return 1
+ make_target 'all'
+ make_target 'check'
+ ret=$?
+
+ valgrind_run=false
restore_BUILD
+
+ if [ "$ret" -ne 0 ]; then
+ return 1
+ fi
}
-function make_install_system ()
+make_install_system ()
{
- local INSTALL_LOCATION=$(mktemp -d /tmp/XXXXXXXXXX)
+ local INSTALL_LOCATION="$(mktemp -d /tmp/XXXXXXXXXX)"
save_BUILD
PREFIX_ARG="--prefix=$INSTALL_LOCATION"
fi
restore_BUILD
- safe_popd
}
-function make_darwin_malloc ()
+make_darwin_malloc ()
{
run_configure_if_required
MallocScribble=$old_MallocScribble
}
-function snapshot_check ()
-{
- if [ ! -f "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
- make_for_snapshot
- fi
-
- if [ -n "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
- assert_file "$BOOTSTRAP_SNAPSHOT_CHECK" 'snapshot check failed'
- fi
-}
-
# This will reset our environment, and make sure built files are available.
-function make_for_snapshot ()
+make_for_snapshot ()
{
- # Make sure it is clean
- make_maintainer_clean
+ # Lets make sure we have a clean environment
+ assert_no_file 'Makefile'
+ assert_no_file 'configure'
+ assert_no_directory 'autom4te.cache'
run_configure
- make_target 'dist'
+ make_target 'all'
make_target 'distclean'
# We should have a configure, but no Makefile at the end of this exercise
assert_no_file 'Makefile'
assert_exec_file 'configure'
-
- snapshot_check
}
-function check_mingw ()
+check_mingw ()
{
command_exists 'mingw64-configure'
ret=$?
return 0
}
-function check_clang ()
+check_clang ()
{
command_exists 'clang'
ret=$?
return 0
}
-function check_clang_analyzer ()
+check_clang_analyzer ()
{
command_exists 'scan-build'
ret=$?
return 0
}
-function make_skeleton ()
+make_skeleton ()
{
run_configure
ret=$?
return $ret
}
-function make_for_mingw ()
+make_for_mingw ()
{
if ! check_mingw; then
return 1
return $ret
}
-function make_for_clang ()
+make_for_clang ()
{
if ! check_clang; then
return 1
return $ret
}
-function make_for_clang_analyzer ()
+make_for_clang_analyzer ()
{
if ! check_clang; then
return 1
CC=clang CXX=clang++
export CC CXX
+ CONFIGURE='scan-build ./configure'
CONFIGURE_ARGS='--enable-debug'
- make_skeleton
- ret=$?
-
- make_target 'clean' 'warn'
+ run_configure
scan-build -o clang-html make -j4 -k
restore_BUILD
-
- return $ret
}
# If we are locally testing, we should make sure the environment is setup correctly
-function check_for_jenkins ()
+check_for_jenkins ()
{
if ! $jenkins_build_environment; then
- echo "Not inside of jenkins"
+ echo "Not inside of jenkins, simulating environment"
if [ -f 'configure' ]; then
make_maintainer_clean
fi
}
-function make_universe ()
+make_universe ()
{
+ use_banner 'make maintainer-clean'
+ make_maintainer_clean
+
+ use_banner 'snapshot'
make_for_snapshot
+
+ use_banner 'valgrind'
make_valgrind
+
+ use_banner 'gdb'
make_gdb
+
+ use_banner 'rpm'
make_rpm
+
+ use_banner 'clang'
make_for_clang
+
+ use_banner 'clang analyzer'
make_for_clang_analyzer
- if [ check_mingw -eq 0 ]; then
+ use_banner 'mingw'
+ check_mingw
+ if [ $? -eq 0 ]; then
make_for_mingw
fi
+ use_banner 'make distcheck'
make_distcheck
+
+ use_banner 'make install'
make_install_system
}
-function make_for_continuus_integration ()
+check_snapshot ()
+{
+ if [ -n "$BOOTSTRAP_SNAPSHOT_CHECK" ]; then
+ assert_file "$BOOTSTRAP_SNAPSHOT_CHECK" 'snapshot check failed'
+ fi
+}
+
+make_for_continuus_integration ()
{
# Setup the environment if we are local
check_for_jenkins
# Platforms which require bootstrap should have some setup done before we hit this stage.
# If we are building locally, skip this step, unless we are just testing locally.
if $BOOTSTRAP_SNAPSHOT; then
- snapshot_check
+ if $BOOTSTRAP_SNAPSHOT; then
+ assert_file 'configure'
+ fi
+
+ check_snapshot
else
# If we didn't require a snapshot, then we should not have a configure
assert_no_file 'configure'
assert_no_file 'Makefile' 'Programmer error, Makefile existed where build state should have been clean'
case $HOST_OS in
- *-fedora-*)
- run_configure
-
- assert_exec_file 'configure'
- assert_file 'Makefile'
-
- make_target 'all'
-
- # make rpm includes "make distcheck"
- if [[ -f rpm.am ]]; then
- make_rpm
- elif [[ -d rpm ]]; then
- make_rpm
- else
- make_distcheck
- fi
-
- assert_exec_file 'configure'
- assert_file 'Makefile'
-
- make_install_system
- ;;
- *-precise-*)
- run_configure
-
- assert_exec_file 'configure'
- assert_file 'Makefile'
-
- make_target 'all'
-
- make_distcheck
-
- assert_exec_file 'configure'
- assert_file 'Makefile'
-
- make_valgrind
-
- assert_exec_file 'configure'
- assert_file 'Makefile'
-
- make_install_system
- ;;
*)
make_jenkins_default
;;
esac
make_maintainer_clean
-
- safe_popd
}
# The point to this test is to test bootstrap.sh itself
-function self_test ()
+self_test ()
{
# We start off with a clean env
make_maintainer_clean
- eval "./bootstrap.sh jenkins" || die "failed 'jenkins'"
- eval "./bootstrap.sh all" || die "failed 'all'"
- eval "./bootstrap.sh gdb" || die "failed 'gdb'"
- eval "./bootstrap.sh maintainer-clean" || die "failed 'maintainer-clean'"
+# eval "./bootstrap.sh jenkins" || die "failed 'jenkins'"
+# eval "./bootstrap.sh all" || die "failed 'all'"
+# eval "./bootstrap.sh gdb" || die "failed 'gdb'"
+# eval "./bootstrap.sh maintainer-clean" || die "failed 'maintainer-clean'"
}
-function make_install_html ()
+make_install_html ()
{
run_configure_if_required
assert_file 'configure'
make_target 'install-html'
}
-function make_gdb ()
+make_gdb ()
{
save_BUILD
# $1 target to compile
# $2 to die, or not to die, based on contents
-function make_target ()
+make_target ()
{
if [ -z "$1" ]; then
die "Programmer error, no target provided for make"
fi
if [ -n "$TESTS_ENVIRONMENT" ]; then
- if $VERBOSE; then
+ if $verbose; then
echo "TESTS_ENVIRONMENT=$TESTS_ENVIRONMENT"
fi
fi
fi
# $2 represents error or warn
- run $MAKE $1
+ run "$MAKE" "$1"
ret=$?
if [ $ret -ne 0 ]; then
if [ -n "$2" ]; then
warn "Failed to execute $MAKE $1: $ret"
+ elif [ $ret -eq 2 ]; then
+ die "Failed to execute $MAKE $1"
else
die "Failed to execute $MAKE $1: $ret"
fi
return $ret
}
-function make_distcheck ()
+make_distcheck ()
{
make_target 'distcheck'
}
-function make_rpm ()
+make_rpm ()
{
if command_exists 'rpmbuild'; then
if [ -f 'rpm.am' -o -d 'rpm' ]; then
+ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
+ mkdir -p ~/rpmbuild/RPMS/{i386,i486,i586,i686,noarch,athlon}
+
run_configure_if_required
make_target 'rpm'
fi
}
-function make_maintainer_clean ()
+make_maintainer_clean ()
{
run_configure_if_required
make_target 'maintainer-clean' 'no_error'
assert_no_directory 'autom4te.cache'
}
-function make_check ()
+make_distclean ()
+{
+ run_configure_if_required
+ make_target 'distclean' 'no_error'
+
+ # Lets make sure we really cleaned up the environment
+ assert_no_file 'Makefile'
+ assert_file 'configure'
+}
+
+make_check ()
{
make_target 'check'
}
-function make_jenkins_default ()
+make_jenkins_default ()
{
run_configure
make_target 'all'
}
-function make_default ()
+make_default ()
{
run_configure_if_required
make_target 'all'
}
-function run_configure_if_required ()
+run_configure_if_required ()
{
run_autoreconf_if_required
assert_file 'Makefile' 'configure did not produce a Makefile'
}
-function run_autoreconf_if_required ()
+run_make_maintainer_clean_if_possible ()
+{
+ if [ -f 'Makefile' ]; then
+ make_maintainer_clean
+ fi
+}
+
+run_autoreconf_if_required ()
{
if [ ! -x 'configure' ]; then
run_autoreconf
bash -n configure
}
-function run_autoreconf ()
+run_autoreconf ()
{
if [[ -z "$AUTORECONF" ]]; then
die "Programmer error, tried to call run_autoreconf () but AUTORECONF was not set"
fi
- if test $use_libtool = 1; then
+ if $use_libtool; then
assert $BOOTSTRAP_LIBTOOLIZE
- run $BOOTSTRAP_LIBTOOLIZE '--copy' '--install' '--force' || die "Cannot execute $BOOTSTRAP_LIBTOOLIZE"
+ run "$BOOTSTRAP_LIBTOOLIZE" '--copy' '--install' '--force' || die "Cannot execute $BOOTSTRAP_LIBTOOLIZE"
fi
- run $AUTORECONF || die "Cannot execute $AUTORECONF"
+ run "$AUTORECONF" "$AUTORECONF_ARGS" || die "Cannot execute $AUTORECONF"
eval 'bash -n configure' || die "autoreconf generated a malformed configure"
}
-function run ()
+run ()
{
- if $VERBOSE; then
+ if $verbose; then
echo "\`$@' $ARGS"
fi
return 127;
fi
- eval $@ $ARGS
+ eval "$@" "$ARGS"
}
-function parse_command_line_options ()
+parse_command_line_options ()
{
local SHORTOPTS=':apcmt:dvh'
- nassert MAKE_TARGET
+ nassert OPT_TARGET
while getopts "$SHORTOPTS" opt; do
case $opt in
a) #--autoreconf
AUTORECONF_OPTION=true
- MAKE_TARGET='autoreconf'
+ OPT_TARGET+='autoreconf'
;;
p) #--print-env
- PRINT_SETUP_OPTION=true
+ print_setup_opt=true
;;
c) # --configure
CONFIGURE_OPTION=true
- MAKE_TARGET='configure'
+ OPT_TARGET+='configure'
;;
m) # maintainer-clean
CLEAN_OPTION=true
- MAKE_TARGET='clean_op'
+ ;;
+ o) # target
+ CONFIGURE_ARG="$OPTARG"
;;
t) # target
TARGET_OPTION=true
TARGET_OPTION_ARG="$OPTARG"
- MAKE_TARGET="$OPTARG"
+ OPT_TARGET+="$OPTARG"
;;
d) # debug
- DEBUG_OPTION=true
+ opt_debug=true
enable_debug
;;
h) # help
echo " -p # Print ENV";
echo " -c # Just run configure";
echo " -m # Just run maintainer-clean";
+ echo " -o # Specify configure arguments";
echo " -t # Make target";
echo " -d # Enable debug";
echo " -h # Show help";
exit
;;
v) # verbose
- VERBOSE_OPTION=true
- VERBOSE=true
+ opt_verbose=true
+ verbose=true
;;
:)
echo "Option -$OPTARG requires an argument." >&2
shift $((OPTIND-1))
if [ -n "$1" ]; then
- MAKE_TARGET="$@"
+ OPT_TARGET="$@"
fi
}
-function determine_vcs ()
+determine_vcs ()
{
if [[ -d '.git' ]]; then
VCS_CHECKOUT=git
fi
if [[ -n "$VCS_CHECKOUT" ]]; then
- VERBOSE=true
+ verbose=true
fi
}
-function require_libtoolise ()
+require_libtoolise ()
{
- use_libtool=0
grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
- && use_libtool=1
+ && use_libtool=true
grep '^[ ]*LT_INIT' configure.ac >/dev/null \
- && use_libtool=1
+ && use_libtool=true
}
-function autoreconf_setup ()
+autoreconf_setup ()
{
# Set ENV MAKE in order to override "make"
if [[ -z "$MAKE" ]]; then
if command_exists 'gmake'; then
- MAKE=`type -p gmake`
+ MAKE="$(type -p gmake)"
else
if command_exists 'make'; then
- MAKE=`type -p make`
+ MAKE="$(type -p make)"
fi
fi
if [ "$VCS_CHECKOUT" ]; then
- if $DEBUG; then
+ if $debug; then
MAKE="$MAKE --warn-undefined-variables"
fi
fi
- if $DEBUG; then
+ if $debug; then
MAKE="$MAKE -d"
fi
fi
GNU_BUILD_FLAGS="--install --force"
fi
- if $VERBOSE; then
+ if $verbose; then
GNU_BUILD_FLAGS="$GNU_BUILD_FLAGS --verbose"
fi
fi
fi
- if test $use_libtool = 1; then
+ if $use_libtool; then
if [[ -n "$LIBTOOLIZE" ]]; then
- BOOTSTRAP_LIBTOOLIZE=`type -p $LIBTOOLIZE`
+ BOOTSTRAP_LIBTOOLIZE="$(type -p $LIBTOOLIZE)"
if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
echo "Couldn't find user supplied libtoolize, it is required"
else
# If we are using OSX, we first check to see glibtoolize is available
if [[ "$VENDOR_DISTRIBUTION" == "darwin" ]]; then
- BOOTSTRAP_LIBTOOLIZE=`type -p glibtoolize`
+ BOOTSTRAP_LIBTOOLIZE="$(type -p glibtoolize)"
if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
echo "Couldn't find glibtoolize, it is required on OSX"
return 1
fi
else
- BOOTSTRAP_LIBTOOLIZE=`type -p libtoolize`
+ BOOTSTRAP_LIBTOOLIZE="$(type -p libtoolize)"
if [[ -z "$BOOTSTRAP_LIBTOOLIZE" ]]; then
echo "Couldn't find libtoolize, it is required"
fi
fi
fi
- if $VERBOSE; then
+
+ if $verbose; then
LIBTOOLIZE_OPTIONS="--verbose $BOOTSTRAP_LIBTOOLIZE_OPTIONS"
fi
- if $DEBUG; then
+
+ if $debug; then
LIBTOOLIZE_OPTIONS="--debug $BOOTSTRAP_LIBTOOLIZE_OPTIONS"
fi
+
+ # Here we set LIBTOOLIZE to true since we are going to invoke it via BOOTSTRAP_LIBTOOLIZE
LIBTOOLIZE=true
fi
# Test the ENV AUTOMAKE if it exists
if [[ -n "$AUTOMAKE" ]]; then
- run $AUTOMAKE '--help' &> /dev/null || die "Failed to run AUTOMAKE:$AUTOMAKE"
+ run "$AUTOMAKE" '--help' &> /dev/null || die "Failed to run AUTOMAKE:$AUTOMAKE"
fi
# Test the ENV AUTOCONF if it exists
if [[ -n "$AUTOCONF" ]]; then
- run $AUTOCONF '--help' &> /dev/null || die "Failed to run AUTOCONF:$AUTOCONF"
+ run "$AUTOCONF" '--help' &> /dev/null || die "Failed to run AUTOCONF:$AUTOCONF"
fi
# Test the ENV AUTOHEADER if it exists
if [[ -n "$AUTOHEADER" ]]; then
- run $AUTOHEADER '--help' &> /dev/null || die "Failed to run AUTOHEADER:$AUTOHEADER"
+ run "$AUTOHEADER" '--help' &> /dev/null || die "Failed to run AUTOHEADER:$AUTOHEADER"
fi
# Test the ENV AUTOM4TE if it exists
if [[ -n "$AUTOM4TE" ]]; then
- run $AUTOM4TE '--help' &> /dev/null || die "Failed to run AUTOM4TE:$AUTOM4TE"
+ run "$AUTOM4TE" '--help' &> /dev/null || die "Failed to run AUTOM4TE:$AUTOM4TE"
fi
# Test the ENV AUTOHEADER if it exists, if not we add one and add --install
if [[ -z "$ACLOCAL" ]]; then
ACLOCAL="aclocal --install"
fi
- run $ACLOCAL '--help' &> /dev/null || die "Failed to run ACLOCAL:$ACLOCAL"
+ run "$ACLOCAL" '--help' &> /dev/null || die "Failed to run ACLOCAL:$ACLOCAL"
if [[ -z "$AUTORECONF" ]]; then
- AUTORECONF=`type -p autoreconf`
+ AUTORECONF="$(type -p autoreconf)"
if [[ -z "$AUTORECONF" ]]; then
die "Couldn't find autoreconf"
fi
if [[ -n "$GNU_BUILD_FLAGS" ]]; then
- AUTORECONF="$AUTORECONF $GNU_BUILD_FLAGS"
+ AUTORECONF_ARGS="$GNU_BUILD_FLAGS"
fi
fi
- run $AUTORECONF '--help' &> /dev/null || die "Failed to run AUTORECONF:$AUTORECONF"
+ run "$AUTORECONF" '--help' &> /dev/null || die "Failed to run AUTORECONF:$AUTORECONF"
}
-function print_setup ()
+print_setup ()
{
- saved_debug_status=$DEBUG
- if $DEBUG; then
+ local saved_debug_status=$debug
+ if $debug; then
disable_debug
fi
echo "--configure"
fi
- if $DEBUG_OPTION; then
+ if $opt_debug; then
echo "--debug"
fi
- if $PRINT_SETUP_OPTION; then
+ if $print_setup_opt; then
echo "--print-env"
fi
echo "--target=$TARGET_OPTION_ARG"
fi
- if $VERBOSE_OPTION; then
+ if $opt_verbose; then
echo "--verbose"
fi
echo "VCS_CHECKOUT=$VCS_CHECKOUT"
fi
- if $VERBOSE; then
- echo "VERBOSE=true"
- fi
-
- if $DEBUG; then
- echo "DEBUG=true"
+ if $debug; then
+ echo "debug=true"
fi
if [[ -n "$WARNINGS" ]]; then
echo "WARNINGS=$WARNINGS"
fi
+
+ if $saved_debug_status; then
+ echo "DEBUG=true"
+ fi
+
echo '----------------------------------------------'
if $saved_debug_status; then
fi
}
-function make_clean_option ()
+make_clean_option ()
{
run_configure_if_required
fi
}
-function make_for_autoreconf ()
+make_for_autoreconf ()
{
if [ -f 'Makefile' ]; then
make_maintainer_clean
assert_no_file 'Makefile'
}
-function check_make_target()
+check_make_target()
{
+ local ret=0
case $1 in
'self')
;;
;;
'clang-analyzer')
;;
- 'test-*')
+ test-*)
;;
- 'valgrind-*')
+ valgrind-*)
;;
- 'gdb-*')
+ gdb-*)
;;
'dist')
;;
*)
- die "Unknown MAKE_TARGET option: $1"
+ echo "Matched default"
+ ret=1
;;
esac
+
+ return $ret
}
-function bootstrap ()
+execute_job ()
{
+ # We should always have a target by this point
+ assert MAKE_TARGET
+
determine_target_platform
determine_vcs
# Set up whatever we need to do to use autoreconf later
+ use_libtool=false
require_libtoolise
if ! autoreconf_setup; then
return 1
fi
- if [ -z "$MAKE_TARGET" ]; then
- MAKE_TARGET="make_default"
- fi
-
- if $PRINT_SETUP_OPTION -o $DEBUG; then
+ if $print_setup_opt -o $debug; then
echo
print_setup
echo
# Exit if all we were looking for were the currently used options
- if $PRINT_SETUP_OPTION; then
+ if $print_setup_opt; then
exit
fi
fi
PREFIX_ARG="--prefix=$PREFIX"
fi
- # We should always have a target by this point
- assert MAKE_TARGET
+ if $CLEAN_OPTION; then
+ make_maintainer_clean
+ fi
- local MAKE_TARGET_ARRAY=($MAKE_TARGET)
+ local MAKE_TARGET_ARRAY
+ MAKE_TARGET_ARRAY=( $MAKE_TARGET )
for target in "${MAKE_TARGET_ARRAY[@]}"
do
# If we are running inside of Jenkins, we want to only run some of the possible tests
if $jenkins_build_environment; then
check_make_target $target
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ die "Unknown MAKE_TARGET option: $target"
+ fi
+ fi
+
+ if $jenkins_build_environment; then
+ use_banner $target
fi
+ local snapshot_run=false
+ local valgrind_run=false
+
case $target in
'self')
self_test
make_default
;;
'clang')
+ make_distclean
if ! check_clang; then
die "clang was not found"
fi
fi
;;
'clang-analyzer')
+ make_distclean
if ! check_clang_analyzer; then
die "clang-analyzer was not found"
fi
fi
;;
'mingw')
- if ! check_mingw; then
- die "mingw was not found"
- fi
-
+ make_distclean
if ! make_for_mingw; then
die "Failed to build mingw: $?"
fi
;;
'snapshot')
make_for_snapshot
+ snapshot_run=true
+ check_snapshot
;;
'rpm')
make_rpm
;;
+ 'darwin_malloc')
+ make_darwin_malloc
+ ;;
'valgrind')
make_valgrind
;;
done
}
-function main ()
+main ()
{
+ # Are we running inside of Jenkins?
+ if [[ -n "$JENKINS_HOME" ]]; then
+ declare -r jenkins_build_environment=true
+ else
+ declare -r jenkins_build_environment=false
+ fi
+
# Variables we export
declare -x VCS_CHECKOUT=
# Variables we control globally
- local MAKE_TARGET=
+ local -a MAKE_TARGET=
local CONFIGURE=
+ local use_libtool=false
+ local verbose=false
+
+ #getop variables
+ local opt_debug=false
+ local opt_verbose=false
+
+ if [[ -n "$VERBOSE" ]]; then
+ verbose=true
+ fi
# Options for getopt
local AUTORECONF_OPTION=false
local CLEAN_OPTION=false
local CONFIGURE_OPTION=false
- local DEBUG_OPTION=false
- local PRINT_SETUP_OPTION=false
+ local print_setup_opt=false
local TARGET_OPTION=false
local TARGET_OPTION_ARG=
- local VERBOSE_OPTION=false
local OLD_CONFIGURE=
local OLD_CONFIGURE_ARG=
local AUTORECONF_REBUILD_HOST=false
local AUTORECONF_REBUILD=false
- local -r top_srcdir=`pwd`
+ local -r top_srcdir="$(pwd)"
# Default configure
if [ -z "$CONFIGURE" ]; then
rebuild_host_os no_output
- parse_command_line_options $@
+ local OPT_TARGET=
+ parse_command_line_options "$@"
+
+ nassert MAKE_TARGET
+
+ if [ -n "$OPT_TARGET" ]; then
+ MAKE_TARGET="$OPT_TARGET"
+ fi
# If we are running under Jenkins we predetermine what tests we will run against
# This MAKE_TARGET can be overridden by parse_command_line_options based MAKE_TARGET changes.
# We don't want Jenkins overriding other variables, so we NULL them.
if [ -z "$MAKE_TARGET" ]; then
if $jenkins_build_environment; then
- MAKE_TARGET='jenkins'
+ if [[ -n "$JENKINS_TARGET" ]]; then
+ MAKE_TARGET="$JENKINS_TARGET"
+ else
+ if [[ -n "$label" ]]; then
+ check_make_target $label
+ if [ $? -eq 0 ]; then
+ MAKE_TARGET="$label"
+ fi
+ fi
+
+ if [[ -n "$LABEL" ]]; then
+ check_make_target $LABEL
+ if [ $? -eq 0 ]; then
+ MAKE_TARGET="$LABEL"
+ fi
+ fi
+
+ if [ -z "$MAKE_TARGET" ]; then
+ MAKE_TARGET='jenkins'
+ fi
+ fi
fi
fi
- bootstrap
+ if [ -z "$MAKE_TARGET" ]; then
+ MAKE_TARGET="make_default"
+ fi
+
+ # We should always have a target by this point
+ assert MAKE_TARGET
+
+ execute_job
+ local ret=$?
jobs -l
wait
- exit 0
+ exit $ret
}
-function set_branch ()
+set_branch ()
{
if [ -z "$BRANCH" ]; then
if [ -z "$CI_PROJECT_TEAM" ]; then
fi
}
-function merge ()
+merge ()
{
if [ -z "$VCS_CHECKOUT" ]; then
die "Merges require VCS_CHECKOUT."
fi
}
-function enable_debug ()
+enable_debug ()
{
- if ! $DEBUG; then
- local caller_loc=`caller`
- if [ -n $1 ]; then
+ if ! $debug; then
+ local caller_loc="$(caller)"
+ if [[ -n "$1" ]]; then
echo "$caller_loc Enabling debug: $1"
else
echo "$caller_loc Enabling debug"
fi
set -x
- DEBUG=true
+ debug=true
fi
}
-function usage ()
+usage ()
{
cat << EOF
Usage: $program_name [OPTION]..
EOF
}
-function disable_debug ()
+disable_debug ()
{
set +x
- DEBUG=true
+ debug=false
}
-# Script begins here
+check_shell ()
+{
+ if [ -x '/usr/local/bin/shellcheck' ]; then
+ /usr/local/bin/shellcheck "$1"
+ local ret=$?
+
+ if [ "$ret" -ne 0 ]; then
+ die "$1 failed shellcheck"
+ fi
+ fi
+}
+
+bootstrap ()
+{
+ check_shell 'bootstrap.sh'
+ local env_debug_enabled=false
+ local debug=false
+
+ export ACLOCAL
+ export AUTOCONF
+ export AUTOHEADER
+ export AUTOM4TE
+ export AUTOMAKE
+ export AUTORECONF
+ export CONFIGURE_ARG
+ export DEBUG
+ export GNU_BUILD_FLAGS
+ export LIBTOOLIZE
+ export LIBTOOLIZE_OPTIONS
+ export MAKE
+ export PREFIX_ARG
+ export TESTS_ENVIRONMENT
+ export VERBOSE
+ export WARNINGS
+
+ case $OSTYPE in
+ darwin*)
+ export MallocGuardEdges
+ export MallocErrorAbort
+ export MallocScribble
+ ;;
+ esac
-program_name=$0
-
-env_debug_enabled=false
-if [[ -n "$JENKINS_HOME" ]]; then
- declare -r jenkins_build_environment=true
-else
- declare -r jenkins_build_environment=false
-fi
-
-export ACLOCAL
-export AUTOCONF
-export AUTOHEADER
-export AUTOM4TE
-export AUTOMAKE
-export AUTORECONF
-export CONFIGURE_ARG
-export DEBUG
-export GNU_BUILD_FLAGS
-export LIBTOOLIZE
-export LIBTOOLIZE_OPTIONS
-export MAKE
-export PREFIX_ARG
-export TESTS_ENVIRONMENT
-export VERBOSE
-export WARNINGS
-
-case $OSTYPE in
- darwin*)
- export MallocGuardEdges
- export MallocErrorAbort
- export MallocScribble
- ;;
-esac
-
-# We check for DEBUG twice, once before we source the config file, and once afterward
-env_debug_enabled=false
-if [[ -n "$DEBUG" ]]; then
- env_debug_enabled=true
- enable_debug
- print_setup
-fi
-
-# Variables which only can be set by .bootstrap
-BOOTSTRAP_SNAPSHOT=false
-BOOTSTRAP_SNAPSHOT_CHECK=
-
-if [ -f '.bootstrap' ]; then
- source '.bootstrap'
-fi
-
-if $env_debug_enabled; then
- enable_debug
-else
+ # We check for DEBUG twice, once before we source the config file, and once afterward
if [[ -n "$DEBUG" ]]; then
+ env_debug_enabled=true
+ fi
+
+ # Variables which only can be set by .bootstrap
+ BOOTSTRAP_SNAPSHOT=false
+ BOOTSTRAP_SNAPSHOT_CHECK=
+
+ if [ -f '.bootstrap' ]; then
+ source '.bootstrap'
+ fi
+
+ # We do this in order to protect the case where DEBUG that came from the ENV (i.e. it overrides what is found in .bootstrap
+ if $env_debug_enabled; then
+ enable_debug
+ elif [[ -n "$DEBUG" ]]; then
enable_debug "Enabling DEBUG from '.bootstrap'"
+ fi
+
+ if $env_debug_enabled; then
print_setup
fi
-fi
-# We do this in order to protect the case where DEBUG
-if ! $env_debug_enabled; then
- DEBUG=false
-fi
-main $@
+ main "$@"
+}
+
+# Script begins here
+declare -r program_name="$0"
+bootstrap "$@"
#include "clients/generator.h"
+#define KEY_BYTES 20
+
/* Use this for string generation */
static const char ALPHANUMERICS[]=
"0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz";
for (uint64_t x= 0; x < number_of; x++)
{
- pairs[x].key= (char *)calloc(100, sizeof(char));
+ pairs[x].key= (char *)calloc(KEY_BYTES, sizeof(char));
if (pairs[x].key == NULL)
goto error;
- get_random_string(pairs[x].key, 100);
- pairs[x].key_length= 100;
+ get_random_string(pairs[x].key, KEY_BYTES);
+ pairs[x].key_length= KEY_BYTES;
if (value_length)
{
if (error != 0)
{
if (error != EAI_SYSTEM)
+ {
fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(error));
+ }
else
+ {
perror("getaddrinfo()");
+ }
}
return ai;
}
}
else
- fprintf(stderr, "Failed to create socket: %s\n",
- strerror(get_socket_errno()));
+ {
+ fprintf(stderr, "Failed to create socket: %s\n", strerror(get_socket_errno()));
+ }
freeaddrinfo(ai);
}
{
if (verbose)
{
- fprintf(stderr, "\n%s:%d: %s", file, line, expression);
+ fprintf(stdout, "\n%s:%d: %s", file, line, expression);
}
if (do_core)
ssize_t nr= timeout_io_op(sock, POLLIN, ((char*) buf) + offset, len - offset);
switch (nr) {
case -1 :
- fprintf(stderr, "Errno: %d %s\n", get_socket_errno(), strerror(errno));
+ fprintf(stderr, "Errno: %d %s\n", get_socket_errno(), strerror(errno));
verify(get_socket_errno() == EINTR || get_socket_errno() == EAGAIN);
break;
struct test_type_st tests= { true, true };
int total= 0;
int failed= 0;
- const char *hostname= "localhost";
- const char *port= "11211";
+ const char *hostname= NULL;
+ const char *port= MEMCACHED_DEFAULT_PORT_STRING;
int cmd;
bool prompt= false;
const char *testname= NULL;
}
}
+ if (hostname)
+ {
+ fprintf(stderr, "No hostname was provided.\n");
+ return EXIT_FAILURE;
+ }
+
initialize_sockets();
sock= connect_server(hostname, port);
if (sock == INVALID_SOCKET)
reconnect= true;
++failed;
if (verbose)
+ {
fprintf(stderr, "\n");
+ }
}
else if (ret == TEST_PASS_RECONNECT)
+ {
reconnect= true;
+ }
+
+ if (ret == TEST_FAIL)
+ {
+ fprintf(stderr, "%s\n", status_msg[ret]);
+ }
+ else
+ {
+ fprintf(stdout, "%s\n", status_msg[ret]);
+ }
- fprintf(stderr, "%s\n", status_msg[ret]);
if (reconnect)
{
closesocket(sock);
/* LibMemcached
- * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
* Copyright (C) 2006-2009 Brian Aker
* All rights reserved.
*
{
options_parse(argc, argv);
+
+ if (optind >= argc)
+ {
+ fprintf(stderr, "Expected argument after options\n");
+ exit(EXIT_FAILURE);
+ }
+
initialize_sockets();
memcached_st *memc= memcached_create(NULL);
{
opt_servers= strdup(temp);
}
+#if 0
else if (argc >= 1 and argv[--argc])
{
- opt_servers= strdup(argv[--argc]);
+ opt_servers= strdup(argv[argc]);
}
+#endif
if (opt_servers == NULL)
{
}
struct stat sbuf;
- (void)fstat(fd, &sbuf);
+ if (fstat(fd, &sbuf) == -1)
+ {
+ std::cerr << "memcp " << argv[optind] << " " << strerror(errno) << std::endl;
+ optind++;
+ exit_code= EXIT_FAILURE;
+ continue;
+ }
char *ptr= rindex(argv[optind], '/');
if (ptr)
ptr, opt_flags, (unsigned long)opt_expires);
}
- char *file_buffer_ptr;
- if ((file_buffer_ptr= (char *)malloc(sizeof(char) * (size_t)sbuf.st_size)) == NULL)
+ // The file may be empty
+ char *file_buffer_ptr= NULL;
+ if (sbuf.st_size > 0)
{
- std::cerr << "Error allocating file buffer(" << strerror(errno) << ")" << std::endl;
- close(fd);
- exit(EXIT_FAILURE);
- }
+ if ((file_buffer_ptr= (char *)malloc(sizeof(char) * (size_t)sbuf.st_size)) == NULL)
+ {
+ std::cerr << "Error allocating file buffer(" << strerror(errno) << ")" << std::endl;
+ close(fd);
+ exit(EXIT_FAILURE);
+ }
- ssize_t read_length;
- if ((read_length= ::read(fd, file_buffer_ptr, (size_t)sbuf.st_size)) == -1)
- {
- std::cerr << "Error while reading file " << file_buffer_ptr << " (" << strerror(errno) << ")" << std::endl;
- close(fd);
- exit(EXIT_FAILURE);
- }
+ ssize_t read_length;
+ if ((read_length= ::read(fd, file_buffer_ptr, (size_t)sbuf.st_size)) == -1)
+ {
+ std::cerr << "Error while reading file " << file_buffer_ptr << " (" << strerror(errno) << ")" << std::endl;
+ close(fd);
+ free(file_buffer_ptr);
+ exit(EXIT_FAILURE);
+ }
- if (read_length != sbuf.st_size)
- {
- std::cerr << "Failure while reading file. Read length was not equal to stat() length" << std::endl;
- close(fd);
- exit(EXIT_FAILURE);
+ if (read_length != sbuf.st_size)
+ {
+ std::cerr << "Failure while reading file. Read length was not equal to stat() length" << std::endl;
+ close(fd);
+ free(file_buffer_ptr);
+ exit(EXIT_FAILURE);
+ }
}
memcached_return_t rc;
if (memcached_failed(rc))
{
std::cerr << "Error occrrured during memcached_set(): " << memcached_last_error_message(memc) << std::endl;
- ::close(fd);
exit_code= EXIT_FAILURE;
}
}
else if (argc >= 1 and argv[--argc])
{
- opt_servers= strdup(argv[--argc]);
+ opt_servers= strdup(argv[argc]);
}
if (opt_servers == NULL)
#define DEFAULT_EXECUTE_NUMBER 10000
#define DEFAULT_CONCURRENCY 1
+#define VALUE_BYTES 4096
+
#define PROGRAM_NAME "memslap"
#define PROGRAM_DESCRIPTION "Generates a load against a memcached custer of servers."
if (opt_test == SET_TEST)
{
- context->execute_pairs= pairs_generate(opt_execute_number, 400);
+ context->execute_pairs= pairs_generate(opt_execute_number, VALUE_BYTES);
context->execute_number= opt_execute_number;
}
break;
case OPT_DEBUG: /* --debug or -d */
- opt_verbose = OPT_DEBUG;
+ opt_verbose= OPT_DEBUG;
break;
case OPT_VERSION: /* --version or -V */
/* We always used non-blocking IO for load since it is faster */
memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NO_BLOCK, 0);
- pairs_st *pairs= pairs_generate(number_of, 400);
+ pairs_st *pairs= pairs_generate(number_of, VALUE_BYTES);
*actual_loaded= execute_set(memc_clone, pairs, number_of);
memcached_free(memc_clone);
#include "utilities.h"
#define PROGRAM_NAME "memtouch"
-#define PROGRAM_DESCRIPTION "Update the expiration value of an alreasy existing value in the sever"
+#define PROGRAM_DESCRIPTION "Update the expiration value of an already existing value in the server"
/* Prototypes */
#define MAX_TOKENS 10
/* server information */
-typedef struct mcd_sever
+typedef struct mcd_server
{
char srv_host_name[MCD_HOST_LENGTH]; /* host name of server */
int srv_port; /* server port */
# Use and distribution licensed under the BSD license. See
# the COPYING file in this directory for full text.
-AC_INIT([libmemcached],[1.0.17],[http://libmemcached.org/])
+m4_include([version.m4])
+AC_INIT([libmemcached],VERSION_NUMBER,[http://libmemcached.org/])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
LT_LANG([C++])
LT_LIB_M
+AC_PROG_CC_C99
+AS_IF([test "x${ac_cv_prog_cc_c99}" == "xno"],[AC_MSG_ERROR([No c99 compatible compiler found])])
+
AX_ASSERT
AX_PLATFORM
ENABLE_DEPRECATED
# Checks for programs.
+AC_CHECK_PROGS([DPKG_GENSYMBOLS],[dpkg-gensymbols])
+AC_CHECK_PROGS([LEX],['flex'],[:])
+AC_CHECK_PROGS([PERL],[perl])
+AC_CHECK_PROGS([VALGRIND],['valgrind'])
+AC_CHECK_PROGS([WINE],['wine'])
+AC_CHECK_PROGS([YACC],['bison --warnings=all'],[:])
AC_PROG_AWK
-AC_PROG_SED
AC_PROG_MKDIR_P
-AC_CHECK_PROGS([LEX],['flex'],[:])
-AC_CHECK_PROGS([YACC],['bison'],[:])
-AX_PROG_SPHINX_BUILD
+AC_PROG_SED
AX_PROG_MEMCACHED
+AX_PROG_SPHINX_BUILD(,[AC_MSG_WARN([sphinx-build version 1.0 or greater is required to build man pages])])
+AX_WITH_PROG([LCOV],[lcov])
+AX_WITH_PROG([LCOV_GENHTML],[genhtml])
+AC_DEFINE([HAVE_MEMCACHED_SASL_BINARY],[0],[If Memcached binary with sasl support is available])
# Checks for libraries.
AC_SEARCH_LIBS([getopt_long],[gnugetopt])
-rm -rf docs/_build docs/doctrees man/.doctrees/
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest
-if HAVE_SPHINX
sphinx-help:
@echo "Please use \`make <target>' where <target> is one of"
text: docs/conf.py
@PYTHONPATH=${top_srcdir}/docs $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(SPHINX_BUILDDIR)/text
-if HAVE_RECENT_SPHINX
man:
@PYTHONPATH=$(SPHINX_BUILDDIR)/docs $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) ${top_builddir}/man
-else
-
-man:
-
-endif
changes: docs/conf.py
@PYTHONPATH=${top_srcdir}/docs $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(SPHINX_BUILDDIR)/changes
PYTHONPATH=${top_srcdir}/docs $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(SPHINX_BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(SPHINX_BUILDDIR)/doctest/output.txt."
-
-else
-
-man:
-
-endif
expiration values, the operation will succeed by seeding the value for that
key with a initial value to expire with the provided expiration time. The
flags will be set to zero.The value is then returned via the uint32_t
-value pointer you pass to it.
+value pointer you pass to it. memcached_increment_with_initial is only available
+when using the binary protocol.
memcached_decrement_with_initial takes a key and keylength and decrements
the value by the offset passed to it. If the object specified by key does
expiration values, the operation will succeed by seeding the value for that
key with a initial value to expire with the provided expiration time. The
flags will be set to zero.The value is then returned via the uint32_t
-value pointer you pass to it.
+value pointer you pass to it. memcached_decrement_with_initial is only available
+when using the binary protocol.
:c:func:`memcached_increment_by_key`, :c:func:`memcached_decrement_by_key`,
:c:func:`memcached_increment_with_initial_by_key`, and
aes_key_t* aes_create_key(const char *key, const size_t key_length)
{
- aes_key_t* _aes_key= (aes_key_t*)calloc(1, sizeof(aes_key_t));
+ aes_key_t* _aes_key= (aes_key_t*)(calloc(1, sizeof(aes_key_t)));
if (_aes_key)
{
uint8_t rkey[AES_KEY_LENGTH/8];
{
ptr= rkey; /* Just loop over tmp_key until we used all key */
}
- *ptr^= (uint8_t) *sptr;
+ *ptr^= (uint8_t)(*sptr);
}
_aes_key->decode_key.nr= rijndaelKeySetupDec(_aes_key->decode_key.rk, rkey, AES_KEY_LENGTH);
return NULL;
}
- aes_key_t* _aes_clone_key= (aes_key_t*)calloc(1, sizeof(aes_key_t));
+ aes_key_t* _aes_clone_key= (aes_key_t*)(calloc(1, sizeof(aes_key_t)));
if (_aes_clone_key)
{
memcpy(_aes_clone_key, _aes_key, sizeof(aes_key_t));
for (size_t x= num_blocks; x > 0; x--) /* Encode complete blocks */
{
- rijndaelEncrypt(_aes_key->encode_key.rk, _aes_key->encode_key.nr, (const uint8_t*) source,
- (uint8_t*) dest);
+ rijndaelEncrypt(_aes_key->encode_key.rk, _aes_key->encode_key.nr, (const uint8_t*)(source),
+ (uint8_t*) (dest));
source+= AES_BLOCK_SIZE;
dest+= AES_BLOCK_SIZE;
}
char pad_len= AES_BLOCK_SIZE - (source_length - AES_BLOCK_SIZE*num_blocks);
memcpy(block, source, 16 -pad_len);
memset(block + AES_BLOCK_SIZE -pad_len, pad_len, pad_len);
- rijndaelEncrypt(_aes_key->encode_key.rk, _aes_key->encode_key.nr, block, (uint8_t*) dest);
+ rijndaelEncrypt(_aes_key->encode_key.rk, _aes_key->encode_key.nr, block, (uint8_t*) (dest));
hashkit_string_set_length(destination, AES_BLOCK_SIZE*(num_blocks + 1));
}
for (size_t x = num_blocks-1; x > 0; x--)
{
- rijndaelDecrypt(_aes_key->decode_key.rk, _aes_key->decode_key.nr, (const uint8_t*) source, (uint8_t*) dest);
+ rijndaelDecrypt(_aes_key->decode_key.rk, _aes_key->decode_key.nr, (const uint8_t*) (source), (uint8_t*)(dest));
source+= AES_BLOCK_SIZE;
dest+= AES_BLOCK_SIZE;
}
uint8_t block[AES_BLOCK_SIZE];
- rijndaelDecrypt(_aes_key->decode_key.rk, _aes_key->decode_key.nr, (const uint8_t*) source, block);
+ rijndaelDecrypt(_aes_key->decode_key.rk, _aes_key->decode_key.nr, (const uint8_t*)(source), block);
/* Use last char in the block as size */
- unsigned int pad_len= (unsigned int) (unsigned char) block[AES_BLOCK_SIZE-1];
+ unsigned int pad_len= (unsigned int) (unsigned char)(block[AES_BLOCK_SIZE-1]);
if (pad_len > AES_BLOCK_SIZE)
{
hashkit_string_free(destination);
/* Public defines */
#define MEMCACHED_DEFAULT_PORT 11211
+#define MEMCACHED_DEFAULT_PORT_STRING "11211"
#define MEMCACHED_POINTS_PER_SERVER 100
#define MEMCACHED_POINTS_PER_SERVER_KETAMA 160
#define MEMCACHED_CONTINUUM_SIZE MEMCACHED_POINTS_PER_SERVER*100 /* This would then set max hosts to 100 */
typedef memcached_trigger_key_fn memcached_trigger_key;
typedef memcached_trigger_delete_key_fn memcached_trigger_delete_key;
typedef memcached_dump_fn memcached_dump_func;
+typedef memcached_instance_st *memcached_server_instance_st;
assert(memcached_last_error(instance->root) != MEMCACHED_SUCCESS);
*value= UINT64_MAX;
}
+ else if (memcached_failed(rc))
+ {
+ *value= UINT64_MAX;
+ }
else
{
+ assert(memcached_last_error(instance->root) != MEMCACHED_NOTFOUND);
*value= instance->root->result.numeric_value;
}
}
if (server->root->poll_timeout == 0)
{
return memcached_set_error(*server, MEMCACHED_TIMEOUT, MEMCACHED_AT,
- memcached_literal_param("The time to wait for a connection to be established was set to zero, which means it will always timeout (MEMCACHED_TIMEOUT)."));
+ memcached_literal_param("The time to wait for a connection to be established was set to zero which produces a timeout to every call to poll()."));
}
while (--loop_max) // Should only loop on cases of ERESTART or EINTR
case MEMCACHED_CONNECTION_TCP:
rc= network_connect(server);
-#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
+#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT)
if (LIBMEMCACHED_WITH_SASL_SUPPORT)
{
if (server->fd != INVALID_SOCKET and server->root->sasl.callbacks)
*/
#include <libmemcached/common.h>
+
+#include "libmemcached/assert.hpp"
+
#include <cerrno>
#include <cstdarg>
#include <cstdio>
memcached_error_free(memc);
}
- // For memory allocation we use our error since it is a bit more specific
- if (local_errno == ENOMEM and rc == MEMCACHED_ERRNO)
+ if (memcached_fatal(rc) or rc == MEMCACHED_CLIENT_ERROR)
{
- rc= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
- }
+ // For memory allocation we use our error since it is a bit more specific
+ if (local_errno == ENOMEM and rc == MEMCACHED_ERRNO)
+ {
+ rc= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+ }
- if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE)
- {
- local_errno= ENOMEM;
- }
+ if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE)
+ {
+ local_errno= ENOMEM;
+ }
- if (rc == MEMCACHED_ERRNO and not local_errno)
- {
- local_errno= errno;
- rc= MEMCACHED_ERRNO;
- }
+ if (rc == MEMCACHED_ERRNO and not local_errno)
+ {
+ local_errno= errno;
+ rc= MEMCACHED_ERRNO;
+ }
- if (rc == MEMCACHED_ERRNO and local_errno == ENOTCONN)
- {
- rc= MEMCACHED_CONNECTION_FAILURE;
- }
+ if (rc == MEMCACHED_ERRNO and local_errno == ENOTCONN)
+ {
+ rc= MEMCACHED_CONNECTION_FAILURE;
+ }
- if (rc == MEMCACHED_ERRNO and local_errno == ECONNRESET)
- {
- rc= MEMCACHED_CONNECTION_FAILURE;
- }
+ if (rc == MEMCACHED_ERRNO and local_errno == ECONNRESET)
+ {
+ rc= MEMCACHED_CONNECTION_FAILURE;
+ }
- if (local_errno == EINVAL)
- {
- rc= MEMCACHED_INVALID_ARGUMENTS;
- }
+ if (local_errno == EINVAL)
+ {
+ rc= MEMCACHED_INVALID_ARGUMENTS;
+ }
- if (local_errno == ECONNREFUSED)
- {
- rc= MEMCACHED_CONNECTION_FAILURE;
- }
+ if (local_errno == ECONNREFUSED)
+ {
+ rc= MEMCACHED_CONNECTION_FAILURE;
+ }
- memcached_error_t *error= libmemcached_xmalloc(&memc, memcached_error_t);
- if (error == NULL) // Bad business if this happens
- {
- return;
- }
+ if (rc == MEMCACHED_TIMEOUT)
+ {
+ }
- error->root= &memc;
- error->query_id= memc.query_id;
- error->rc= rc;
- error->local_errno= local_errno;
+ memcached_error_t *error= libmemcached_xmalloc(&memc, memcached_error_t);
+ if (error == NULL) // Bad business if this happens
+ {
+ assert_msg(error, "libmemcached_xmalloc() failed to allocate a memcached_error_t");
+ return;
+ }
- const char *errmsg_ptr;
- char errmsg[MAX_ERROR_LENGTH];
- errmsg[0]= 0;
- errmsg_ptr= errmsg;
+ error->root= &memc;
+ error->query_id= memc.query_id;
+ error->rc= rc;
+ error->local_errno= local_errno;
+
+ // MEMCACHED_CLIENT_ERROR is a special case because it is an error coming from the server
+ if (rc == MEMCACHED_CLIENT_ERROR)
+ {
+ assert(str);
+ assert(str->size);
+ if (str and str->size)
+ {
+ assert(error->local_errno == 0);
+ error->local_errno= 0;
+
+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %.*s",
+ error->root,
+ int(str->size), str->c_str);
+ }
+ }
+ else if (local_errno)
+ {
+ const char *errmsg_ptr;
+ char errmsg[MAX_ERROR_LENGTH];
+ errmsg[0]= 0;
+ errmsg_ptr= errmsg;
- if (local_errno)
- {
#if defined(STRERROR_R_CHAR_P) && STRERROR_R_CHAR_P
- errmsg_ptr= strerror_r(local_errno, errmsg, sizeof(errmsg));
+ errmsg_ptr= strerror_r(local_errno, errmsg, sizeof(errmsg));
#elif defined(HAVE_STRERROR_R) && HAVE_STRERROR_R
- strerror_r(local_errno, errmsg, sizeof(errmsg));
- errmsg_ptr= errmsg;
+ strerror_r(local_errno, errmsg, sizeof(errmsg));
+ errmsg_ptr= errmsg;
#elif defined(HAVE_STRERROR) && HAVE_STRERROR
- snprintf(errmsg, sizeof(errmsg), "%s", strerror(local_errno));
- errmsg_ptr= errmsg;
+ snprintf(errmsg, sizeof(errmsg), "%s", strerror(local_errno));
+ errmsg_ptr= errmsg;
#endif
- }
+ if (str and str->size and local_errno)
+ {
+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s), %.*s -> %s",
+ error->root,
+ memcached_strerror(&memc, rc),
+ errmsg_ptr,
+ memcached_string_printf(*str), at);
+ }
+ else
+ {
+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s) -> %s",
+ error->root,
+ memcached_strerror(&memc, rc),
+ errmsg_ptr,
+ at);
+ }
+ }
+ else if (rc == MEMCACHED_PARSE_ERROR and str and str->size)
+ {
+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %.*s -> %s",
+ error->root,
+ int(str->size), str->c_str, at);
+ }
+ else if (str and str->size)
+ {
+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s, %.*s -> %s",
+ error->root,
+ memcached_strerror(&memc, rc),
+ int(str->size), str->c_str, at);
+ }
+ else
+ {
+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s -> %s",
+ error->root,
+ memcached_strerror(&memc, rc), at);
+ }
- if (str and str->size and local_errno)
- {
- error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s), %.*s -> %s",
- error->root,
- memcached_strerror(&memc, rc),
- errmsg_ptr,
- memcached_string_printf(*str), at);
- }
- else if (local_errno)
- {
- error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s(%s) -> %s",
- error->root,
- memcached_strerror(&memc, rc),
- errmsg_ptr,
- at);
- }
- else if (rc == MEMCACHED_PARSE_ERROR and str and str->size)
- {
- error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %.*s -> %s",
- error->root,
- int(str->size), str->c_str, at);
- }
- else if (str and str->size)
- {
- error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s, %.*s -> %s",
- error->root,
- memcached_strerror(&memc, rc),
- int(str->size), str->c_str, at);
- }
- else
- {
- error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "(%p) %s -> %s",
- error->root,
- memcached_strerror(&memc, rc), at);
+ error->next= memc.error_messages;
+ memc.error_messages= error;
}
- error->next= memc.error_messages;
- memc.error_messages= error;
-
#if 0
if (error_log_fd == -1)
{
memcached_return_t memcached_set_error(Memcached& memc, memcached_return_t rc, const char *at, memcached_string_t& str)
{
assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client");
- if (memcached_fatal(rc) == false)
+ if (memcached_fatal(rc))
{
- return rc;
+ _set(memc, &str, rc, at);
}
- _set(memc, &str, rc, at);
-
return rc;
}
memcached_string_t error_host= { hostname_port_message, size_t(size) };
assert_msg(self.root, "Programmer error, root was not set on instance");
- if (self.root == NULL)
+ if (self.root)
{
- return rc;
+ _set(*self.root, &error_host, rc, at);
+ _set(self, (*self.root));
+ assert(self.error_messages);
+ assert(self.root->error_messages);
+ assert(self.error_messages->rc == self.root->error_messages->rc);
}
- _set(*self.root, &error_host, rc, at);
- _set(self, (*self.root));
- assert(self.root->error_messages);
- assert(self.error_messages);
- assert(self.error_messages->rc == self.root->error_messages->rc);
-
return rc;
}
memcached_string_t error_host= { hostname_port, size};
- if (self.root == NULL)
+ if (self.root)
{
- return rc;
+ _set(*self.root, &error_host, rc, at);
+ _set(self, *self.root);
}
- _set(*self.root, &error_host, rc, at);
- _set(self, *self.root);
-
return rc;
}
{
if (memc->error_messages)
{
- if (memc->error_messages->size == 0)
+ if (memc->error_messages->size and memc->error_messages->message[0])
{
return memc->error_messages->message;
}
{
*error= MEMCACHED_NOTFOUND;
}
-
if (value == NULL)
{
if (ptr->get_key_failure and *error == MEMCACHED_NOTFOUND)
if (number_of_keys == 0)
{
- return memcached_set_error(*ptr, MEMCACHED_NOTFOUND, MEMCACHED_AT, memcached_literal_param("number_of_keys was zero"));
+ return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Numbers of keys provided was zero"));
}
- if (memcached_failed(memcached_key_test(*ptr, keys, key_length, number_of_keys)))
+ if (memcached_failed((rc= memcached_key_test(*ptr, keys, key_length, number_of_keys))))
{
- return memcached_last_error(ptr);
+ assert(memcached_last_error(ptr) == rc);
+
+ return rc;
}
bool is_group_key_set= false;
bool flush= (number_of_keys == 1);
+ if (memcached_failed(rc= memcached_key_test(*ptr, keys, key_length, number_of_keys)))
+ {
+ return rc;
+ }
+
/*
If a server fails we warn about errors and start all over with sending keys
to the server.
request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK;
}
+#if 0
{
memcached_return_t vk= memcached_validate_key_length(key_length[x], ptr->flags.binary_protocol);
- if (vk != MEMCACHED_SUCCESS)
+ if (memcached_failed(rc= memcached_key_test(*memc, (const char **)&key, &key_length, 1)))
{
+ memcached_set_error(ptr, vk, MEMCACHED_AT, memcached_literal_param("Key was too long."));
+
if (x > 0)
{
memcached_io_reset(instance);
return vk;
}
}
+#endif
request.message.header.request.keylen= htons((uint16_t)(key_length[x] + memcached_array_size(ptr->_namespace)));
request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
in_port_t port,
uint32_t weight)
{
- char buffer[MEMCACHED_NI_MAXHOST];
+ char buffer[MEMCACHED_NI_MAXHOST]= { 0 };
memcpy(buffer, hostname, hostname_length);
buffer[hostname_length]= 0;
case EWOULDBLOCK:
#endif
case EAGAIN:
-#ifdef TARGET_OS_LINUX
+#ifdef __linux
case ERESTART:
#endif
break; // No IO is fine, we can just move on
assert_msg(active_fd == -1 , "poll() returned an unexpected value");
switch (local_errno)
{
-#ifdef TARGET_OS_LINUX
+#ifdef __linux
case ERESTART:
#endif
case EINTR:
return io_wait(instance, MEM_WRITE);
}
+memcached_return_t memcached_io_wait_for_read(memcached_instance_st* instance)
+{
+ return io_wait(instance, MEM_READ);
+}
+
static memcached_return_t _io_fill(memcached_instance_st* instance)
{
ssize_t data_read;
case EWOULDBLOCK:
#endif
case EAGAIN:
-#ifdef TARGET_OS_LINUX
+#ifdef __linux
case ERESTART:
#endif
{
case EWOULDBLOCK:
#endif
case EAGAIN:
-#ifdef TARGET_OS_LINUX
+#ifdef __linux
case ERESTART:
#endif
if (memcached_success(io_wait(instance, MEM_READ)))
libmemcached_io_vector_st vector[],
const size_t number_of, const bool with_flush);
-memcached_return_t memcached_io_wait_for_write(memcached_instance_st* ptr);
+memcached_return_t memcached_io_wait_for_write(memcached_instance_st*);
+memcached_return_t memcached_io_wait_for_read(memcached_instance_st*);
void memcached_io_reset(memcached_instance_st* ptr);
#include <libmemcached/common.h>
+static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool)
+{
+ if (key_length == 0)
+ {
+ return MEMCACHED_BAD_KEY_PROVIDED;
+ }
+
+ // No one ever reimplemented MEMCACHED to use keys longer then the original ascii length
+#if 0
+ if (binary)
+ {
+ if (key_length > 0xffff)
+ {
+ return MEMCACHED_BAD_KEY_PROVIDED;
+ }
+ }
+ else
+#endif
+ {
+ if (key_length >= MEMCACHED_MAX_KEY)
+ {
+ return MEMCACHED_BAD_KEY_PROVIDED;
+ }
+ }
+
+ return MEMCACHED_SUCCESS;
+}
+
memcached_return_t memcached_key_test(memcached_st &memc,
const char * const *keys,
const size_t *key_length,
size_t number_of_keys)
{
+ if (number_of_keys == 0)
+ {
+ return memcached_set_error(memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Numbers of keys provided was zero"));
+ }
+
if (keys == NULL or key_length == NULL)
{
return memcached_set_error(memc, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("Key was NULL or length of key was zero."));
}
+ const bool is_binary= memcached_flag(memc, MEMCACHED_FLAG_BINARY_PROTOCOL);
+
// If we don't need to verify the key, or we are using the binary protoocol,
// we just check the size of the key
- if (memc.flags.verify_key == false or memc.flags.binary_protocol == true)
- {
- 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.
- memcached_return_t rc= memcached_validate_key_length(*(key_length +x), false /* memc.flags.binary_protocol */);
- if (memcached_failed(rc))
- {
- return memcached_set_error(memc, rc, MEMCACHED_AT, memcached_literal_param("Key provided was too long."));
- }
- }
-
- return MEMCACHED_SUCCESS;
- }
-
- for (size_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);
+ // We should set binary key, but the memcached server is broken for
+ // longer keys at the moment.
+ memcached_return_t rc= memcached_validate_key_length(*(key_length +x), false /* memc.flags.binary_protocol */);
if (memcached_failed(rc))
{
return memcached_set_error(memc, rc, MEMCACHED_AT, memcached_literal_param("Key provided was too long."));
}
-
- for (size_t y= 0; y < *(key_length + x); y++)
+
+ if (memc.flags.verify_key and is_binary == false)
{
- if ((isgraph(keys[x][y])) == 0)
+ for (size_t y= 0; y < *(key_length +x); ++y)
{
- return memcached_set_error(memc, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("Key provided had invalid character."));
+ if ((isgraph(keys[x][y])) == 0)
+ {
+ return memcached_set_error(memc, MEMCACHED_BAD_KEY_PROVIDED, MEMCACHED_AT, memcached_literal_param("Key provided had invalid character."));
+ }
}
}
}
const size_t *key_length,
size_t number_of_keys);
-static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool binary)
-{
- if (key_length == 0)
- {
- return MEMCACHED_BAD_KEY_PROVIDED;
- }
-
- if (binary)
- {
- if (key_length > 0xffff)
- {
- return MEMCACHED_BAD_KEY_PROVIDED;
- }
- }
- else
- {
- if (key_length >= MEMCACHED_MAX_KEY)
- {
- return MEMCACHED_BAD_KEY_PROVIDED;
- }
- }
-
- return MEMCACHED_SUCCESS;
-}
memcached_return_t rc;
protocol_binary_response_header header;
+ assert(memcached_is_binary(instance->root));
+
if ((rc= memcached_safe_read(instance, &header.bytes, sizeof(header.bytes))) != MEMCACHED_SUCCESS)
{
WATCHPOINT_ERROR(rc);
return memcached_set_error(*instance, MEMCACHED_NOT_SUPPORTED, MEMCACHED_AT);
}
- /* We may have old commands in the buffer not set, first purge */
+ /* We may have old commands in the buffer not sent, first purge */
if ((instance->root->flags.no_block) and (memcached_is_processing_input(instance->root) == false))
{
(void)memcached_io_write(instance);
}
+ /* Before going into loop wait to see if we have any IO waiting for us */
+ if (0)
+ {
+ memcached_return_t read_rc= memcached_io_wait_for_read(instance);
+ fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, memcached_strerror(NULL, read_rc));
+ }
+
/*
* The previous implementation purged all pending requests and just
* returned the last one. Purge all pending messages to ensure backwards
return MEMCACHED_SUCCESS;
}
-char *memcached_stat_get_value(const memcached_st *, memcached_stat_st *memc_stat,
+char *memcached_stat_get_value(const memcached_st* shell, memcached_stat_st *memc_stat,
const char *key, memcached_return_t *error)
{
memcached_return_t not_used;
}
else
{
- *error= MEMCACHED_NOTFOUND;
+ Memcached* memc= (Memcached*)memcached2Memcached(shell);
+ *error= memcached_set_error(*memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid key provided"));
return NULL;
}
if (length >= SMALL_STRING_LEN || length < 0)
{
- *error= MEMCACHED_FAILURE;
+ Memcached* memc= (Memcached*)memcached2Memcached(shell);
+ *error= memcached_set_error(*memc, MEMCACHED_FAILURE, MEMCACHED_AT, memcached_literal_param("Internal failure occured with buffer, please report this bug."));
return NULL;
}
if (args)
{
args_length= strlen(args);
- rc= memcached_validate_key_length(args_length, self->flags.binary_protocol);
- if (memcached_failed(rc))
+ if (memcached_failed(rc= memcached_key_test(*self, (const char **)&args, &args_length, 1)))
{
*error= memcached_set_error(*self, rc, MEMCACHED_AT);
return NULL;
if (args)
{
args_length= strlen(args);
- rc= memcached_validate_key_length(args_length, memc.flags.binary_protocol);
+ rc= memcached_key_test(*memc_ptr, (const char **)&args, &args_length, 1);
}
if (memcached_success(rc))
{
char* value= NULL;
- if (memcached_string_length(self))
+ assert_msg(self, "Invalid memcached_string_st");
+ if (self)
{
- assert_msg(self, "Invalid memcached_string_st");
- // If we fail at adding the null, we copy and move on
- if (memcached_success(memcached_string_append_null(self)))
+ if (memcached_string_length(self))
{
- return memcached_string_c_copy(self);
+ // If we fail at adding the null, we copy and move on
+ if (memcached_failed(memcached_string_append_null(self)))
+ {
+ return NULL;
+ }
+
+ value= self->string;
+ _init_string(self);
}
-
- value= self->string;
-
- _init_string(self);
}
return value;
return rc;
}
- if (memcached_failed(rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol)))
+ if (memcached_failed(rc= memcached_key_test(*ptr, (const char **)&key, &key_length, 1)))
{
- return rc;
+ return memcached_set_error(*ptr, rc, MEMCACHED_AT);
}
uint32_t server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length);
*
* Data Differential YATL (i.e. libtest) library
*
- * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2012-2013 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
#include <unistd.h>
#include <algorithm>
+#include <stdexcept>
#ifndef __USE_GNU
static char **environ= NULL;
int error;
switch ((error= errno))
{
-#ifdef TARGET_OS_LINUX
+#ifdef __linux
case ERESTART:
#endif
case EINTR:
Application::error_t Application::join()
{
- pid_t waited_pid= waitpid(_pid, &_status, 0);
+ pid_t waited_pid= waitpid(_pid, &_status, WUNTRACED);
slurp();
if (waited_pid == _pid and WIFEXITED(_status) == false)
{
-
/*
What we are looking for here is how the exit status happened.
- 127 means that posix_spawn() itself had an error.
{
if (WTERMSIG(_status) != SIGTERM and WTERMSIG(_status) != SIGHUP)
{
+ slurp();
_app_exit_state= Application::INVALID_POSIX_SPAWN;
std::string error_string(print_argv(built_argv));
error_string+= " was killed by signal ";
error_string+= strsignal(WTERMSIG(_status));
+
if (stdout_result_length())
{
error_string+= " stdout: ";
error_string+= stdout_c_str();
}
+
if (stderr_result_length())
{
error_string+= " stderr: ";
}
else if (waited_pid == -1)
{
+ std::string error_string;
+ if (stdout_result_length())
+ {
+ error_string+= " stdout: ";
+ error_string+= stdout_c_str();
+ }
+
+ if (stderr_result_length())
+ {
+ error_string+= " stderr: ";
+ error_string+= stderr_c_str();
+ }
+ Error << "waitpid() returned errno:" << strerror(errno) << " " << error_string;
_app_exit_state= Application::UNKNOWN;
- Error << "waitpid() returned errno:" << strerror(errno);
}
else
{
void Application::Pipe::nonblock()
{
int flags;
+ do
{
flags= fcntl(_pipe_fd[READ], F_GETFL, 0);
} while (flags == -1 and (errno == EINTR or errno == EAGAIN));
close(READ);
close(WRITE);
-#if defined(HAVE_PIPE2) && HAVE_PIPE2
+#ifdef HAVE_PIPE2
if (pipe2(_pipe_fd, O_NONBLOCK|O_CLOEXEC) == -1)
-#else
- if (pipe(_pipe_fd) == -1)
#endif
{
- FATAL(strerror(errno));
- }
- _open[0]= true;
- _open[1]= true;
+ if (pipe(_pipe_fd) == -1)
+ {
+ FATAL(strerror(errno));
+ }
-#if defined(HAVE_PIPE2) && HAVE_PIPE2
- {
+ // Since either pipe2() was not found/called we set the pipe directly
nonblock();
cloexec();
}
-#endif
+ _open[0]= true;
+ _open[1]= true;
}
void Application::Pipe::cloexec()
return int(app.join());
}
-const char *gearmand_binary()
-{
- return GEARMAND_BINARY;
-}
-
-const char *drizzled_binary()
-{
- return DRIZZLED_BINARY;
-}
-
} // namespace exec_cmdline
int exec_cmdline(const std::string& executable, const char *args[], bool use_libtool= false);
-const char *gearmand_binary();
-const char *drizzled_binary();
-
}
try
{
_timer.reset();
+ assert(frame);
+ assert(frame->runner());
+ assert(run->test_fn);
return_code= frame->runner()->main(run->test_fn, frame->creators_ptr());
}
// Special case where check for the testing of the exception
# include <arpa/inet.h>
#endif
-#if defined(_WIN32)
+#if defined(WIN32)
# include "win32/wrappers.h"
# define get_socket_errno() WSAGetLastError()
#else
void create_core(void)
{
-#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
- if (TARGET_OS_OSX)
+#if defined(__APPLE__) && __APPLE__
+ if (__APPLE__)
{
return;
}
size_t number_of_cpus()
{
size_t number_of_cpu= 1;
-#if defined(TARGET_OS_LINUX) && TARGET_OS_LINUX
+#if defined(__linux) && __linux
number_of_cpu= sysconf(_SC_NPROCESSORS_ONLN);
#elif defined(HAVE_SYS_SYSCTL_H) && defined(CTL_HW) && defined(HW_NCPU) && defined(HW_AVAILCPU) && defined(HW_NCPU)
int mib[4];
bool lookup(const char* host)
{
bool success= false;
- if (host)
+ assert(host and host[0]);
+ if (host and host[0])
{
- assert(host);
struct addrinfo *addrinfo= NULL;
+ struct addrinfo hints;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_socktype= SOCK_STREAM;
+ hints.ai_protocol= IPPROTO_TCP;
int limit= 5;
while (--limit and success == false)
}
int ret;
- if ((ret= getaddrinfo(host, NULL, NULL, &addrinfo)) == 0)
+ if ((ret= getaddrinfo(host, "echo", &hints, &addrinfo)) == 0)
{
success= true;
break;
bool check_dns()
{
+ if (valgrind_is_caller())
+ {
+ return false;
+ }
+
if (lookup("exist.gearman.info") == false)
{
return false;
void dream(time_t tv_sec, long tv_nsec)
{
-#if defined(_WIN32)
+#if defined(WIN32)
if (tv_sec == 0 and tv_nsec)
{
tv_sec++;
#if defined(HAVE_LIBDRIZZLE) && HAVE_LIBDRIZZLE
if (HAVE_LIBDRIZZLE)
{
- drizzle_st *drizzle= drizzle_create_tcp(getenv("MYSQL_SERVER"),
- getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
- getenv("MYSQL_USER"),
- getenv("MYSQL_PASSWORD"),
- getenv("MYSQL_SCHEMA"), drizzle_options_t());
+ drizzle_st *drizzle= drizzle_create(getenv("MYSQL_SERVER"),
+ getenv("MYSQL_PORT") ? atoi("MYSQL_PORT") : DRIZZLE_DEFAULT_TCP_PORT,
+ getenv("MYSQL_USER"),
+ getenv("MYSQL_PASSWORD"),
+ getenv("MYSQL_SCHEMA"), 0);
if (drizzle == NULL)
{
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Data Differential YATL (i.e. libtest) library
+ *
+ * Copyright (C) 2012-2013 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 "libtest/yatlcon.h"
+#include <libtest/common.h>
+#include <cstdarg>
+
+namespace libtest {
+
+exception::exception(const char *file_arg, int line_arg, const char *func_arg):
+ std::exception(),
+ _line(line_arg),
+ _file(file_arg),
+ _func(func_arg),
+ _error_message(NULL),
+ _error_message_size(0)
+{
+}
+
+#ifndef __INTEL_COMPILER
+# pragma GCC diagnostic ignored "-Wformat-nonliteral"
+#endif
+void exception::init(va_list args_)
+{
+ const char *format= va_arg(args_, const char *);
+ int error_message_length= vasprintf(&_error_message, format, args_);
+ assert(error_message_length != -1);
+ if (error_message_length > 0)
+ {
+ _error_message_size= error_message_length +1;
+ }
+}
+
+exception::~exception() throw()
+{
+ if (_error_message)
+ {
+ free(_error_message);
+ }
+}
+
+void exception::what(size_t length_, const char* message_)
+{
+ if (length_ > 0 and message_)
+ {
+ char *ptr= (char*) realloc(_error_message, length_ +1);
+ if (ptr)
+ {
+ _error_message= ptr;
+ memcpy(_error_message, message_, length_);
+ _error_message[length_]= 0;
+ }
+ }
+}
+
+exception::exception(const exception& other) :
+ std::exception(),
+ _line(other._line),
+ _file(other._file),
+ _func(other._func),
+ _error_message_size(0)
+{
+ if (other.length() > 0)
+ {
+ _error_message= (char*) malloc(other.length() +1);
+ if (_error_message)
+ {
+ memcpy(_error_message, other._error_message, other.length());
+ _error_message_size= other.length();
+ }
+ }
+}
+
+} // namespace libtest
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Data Differential YATL (i.e. libtest) library
+ *
+ * Copyright (C) 2012-2013 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
+
+namespace libtest {
+
+class exception : public std::exception
+{
+public:
+ exception(const char *file, int line, const char *func);
+
+ exception( const exception& );
+
+ virtual ~exception() throw();
+
+ virtual const char* what() const throw()
+ {
+ if (_error_message)
+ {
+ return _error_message;
+ }
+
+ return "";
+ }
+
+ void what(size_t, const char*);
+
+ size_t length() const
+ {
+ return _error_message_size;
+ }
+
+ int line() const
+ {
+ return _line;
+ }
+
+ const char* file() const
+ {
+ return _file;
+ }
+
+ const char* func() const
+ {
+ return _func;
+ }
+
+protected:
+ void init(va_list);
+
+private:
+ int _line;
+ const char* _file;
+ const char* _func;
+ char* _error_message;
+ size_t _error_message_size;
+};
+
+} // namespace libtest
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Data Differential YATL (i.e. libtest) library
+ *
+ * Copyright (C) 2012-2013 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
+
+#include "libtest/exception.hpp"
+
+namespace libtest {
+
+class disconnected : public libtest::exception
+{
+public:
+ disconnected(const char *file, int line, const char *func, const std::string&, const in_port_t port, ...);
+
+ disconnected(const disconnected&);
+
+ // The following are just for unittesting the exception class
+ static bool is_disabled();
+ static void disable();
+ static void enable();
+ static uint32_t disabled_counter();
+ static void increment_disabled_counter();
+
+private:
+ in_port_t _port;
+ char _instance[BUFSIZ];
+};
+
+} // namespace libtest
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Data Differential YATL (i.e. libtest) 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 "libtest/yatlcon.h"
+#include <libtest/common.h>
+#include "libtest/exception.hpp"
+#include <cstdarg>
+
+namespace libtest {
+
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
+fatal::fatal(const char *file_arg, int line_arg, const char *func_arg, ...) :
+ libtest::exception(file_arg, line_arg, func_arg)
+{
+ va_list args;
+ va_start(args, func_arg);
+ init(args);
+ va_end(args);
+}
+
+fatal::fatal( const fatal& other ) :
+ libtest::exception(other)
+{
+}
+
+static bool _disabled= false;
+static uint32_t _counter= 0;
+
+bool fatal::is_disabled() throw()
+{
+ return _disabled;
+}
+
+void fatal::disable() throw()
+{
+ _counter= 0;
+ _disabled= true;
+}
+
+void fatal::enable() throw()
+{
+ _counter= 0;
+ _disabled= false;
+}
+
+uint32_t fatal::disabled_counter() throw()
+{
+ return _counter;
+}
+
+void fatal::increment_disabled_counter() throw()
+{
+ _counter++;
+}
+
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+disconnected::disconnected(const char *file_arg, int line_arg, const char *func_arg,
+ const std::string& instance, const in_port_t port, ...) :
+ libtest::exception(file_arg, line_arg, func_arg),
+ _port(port)
+{
+ va_list args;
+ va_start(args, port);
+ const char *format= va_arg(args, const char *);
+ char last_error[BUFSIZ];
+ (void)vsnprintf(last_error, sizeof(last_error), format, args);
+ va_end(args);
+
+ char buffer_error[BUFSIZ];
+ int error_length= snprintf(buffer_error, sizeof(buffer_error), "%s:%u %s", instance.c_str(), uint32_t(port), last_error);
+
+ if (error_length > 0)
+ {
+ what(size_t(error_length), buffer_error);
+ }
+}
+
+disconnected::disconnected(const disconnected& other):
+ libtest::exception(other),
+ _port(other._port)
+{
+ strncpy(_instance, other._instance, BUFSIZ);
+}
+
+} // namespace libtest
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Data Differential YATL (i.e. libtest) 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
+
+namespace libtest {
+
+class fatal : public libtest::exception
+{
+public:
+ fatal(const char *file, int line, const char *func, ...);
+
+ fatal(const fatal&);
+
+ // The following are just for unittesting the exception class
+ static bool is_disabled() throw();
+ static void disable() throw();
+ static void enable() throw();
+ static uint32_t disabled_counter() throw();
+ static void increment_disabled_counter() throw();
+
+ test_return_t return_code() const
+ {
+ return TEST_SKIPPED;
+ }
+
+private:
+};
+
+} // namespace libtest
+
+#define FATAL(...) \
+do \
+{ \
+ throw libtest::fatal(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \
+} while (0)
+
+#define FATAL_IF(__expression, ...) \
+do \
+{ \
+ if ((__expression)) { \
+ throw libtest::fatal(LIBYATL_DEFAULT_PARAM, (#__expression)); \
+ } \
+} while (0)
+
+#define FATAL_IF_(__expression, ...) \
+do \
+{ \
+ if ((__expression)) { \
+ throw libtest::fatal(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \
+ } \
+} while (0)
+
+#define fatal_assert(__assert) if((__assert)) {} else { throw libtest::fatal(LIBYATL_DEFAULT_PARAM, #__assert); }
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Data Differential YATL (i.e. libtest) 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
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-LIBTEST_INTERNAL_API
- void push_failed_test(const char *collection, const char *test);
-
-LIBTEST_INTERNAL_API
- void print_failed_test(void);
-
-#ifdef __cplusplus
-}
-#endif
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Data Differential YATL (i.e. libtest) 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 "libtest/yatlcon.h"
-#include <libtest/common.h>
-#include <cstdarg>
-
-namespace libtest {
-
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
-
-fatal::fatal(const char *file_arg, int line_arg, const char *func_arg, ...) :
- __test_result(file_arg, line_arg, func_arg)
-{
- va_list args;
- va_start(args, func_arg);
- init(args);
- va_end(args);
-}
-
-fatal::fatal( const fatal& other ) :
- __test_result(other)
-{
-}
-
-static bool _disabled= false;
-static uint32_t _counter= 0;
-
-bool fatal::is_disabled() throw()
-{
- return _disabled;
-}
-
-void fatal::disable() throw()
-{
- _counter= 0;
- _disabled= true;
-}
-
-void fatal::enable() throw()
-{
- _counter= 0;
- _disabled= false;
-}
-
-uint32_t fatal::disabled_counter() throw()
-{
- return _counter;
-}
-
-void fatal::increment_disabled_counter() throw()
-{
- _counter++;
-}
-
-#pragma GCC diagnostic ignored "-Wformat-nonliteral"
-disconnected::disconnected(const char *file_arg, int line_arg, const char *func_arg,
- const std::string& instance, const in_port_t port, ...) :
- std::runtime_error(func_arg),
- _port(port),
- _line(line_arg),
- _file(file_arg),
- _func(func_arg)
-{
- va_list args;
- va_start(args, port);
- const char *format= va_arg(args, const char *);
- char last_error[BUFSIZ];
- (void)vsnprintf(last_error, sizeof(last_error), format, args);
- va_end(args);
-
- snprintf(_error_message, sizeof(_error_message), "%s:%u %s", instance.c_str(), uint32_t(port), last_error);
-}
-
-disconnected::disconnected(const disconnected& other):
- std::runtime_error(other._func),
- _port(other._port),
- _line(other._line),
- _file(other._file),
- _func(other._func)
-{
- strncpy(_error_message, other._error_message, BUFSIZ);
- strncpy(_instance, other._instance, BUFSIZ);
-}
-
-} // namespace libtest
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Data Differential YATL (i.e. libtest) 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
-
-#include <stdexcept>
-
-namespace libtest {
-
-class disconnected : public std::runtime_error
-{
-public:
- disconnected(const char *file, int line, const char *func, const std::string&, const in_port_t port, ...);
-
- const char* what() const throw()
- {
- return _error_message;
- }
-
- disconnected(const disconnected&);
-
- // The following are just for unittesting the exception class
- static bool is_disabled();
- static void disable();
- static void enable();
- static uint32_t disabled_counter();
- static void increment_disabled_counter();
-
- int line() const
- {
- return _line;
- }
-
- const char* file() const
- {
- return _file;
- }
-
- const char* func() const
- {
- return _func;
- }
-
-private:
- char _error_message[BUFSIZ];
- in_port_t _port;
- char _instance[BUFSIZ];
- int _line;
- const char* _file;
- const char* _func;
-};
-
-} // namespace libtest
get_world(this);
}
-void Framework::collections(collection_st* collections_)
+void Framework::collections(collection_st collections_[])
{
for (collection_st *next= collections_; next and next->name; next++)
{
iter != _collection.end() and (_signal.is_shutdown() == false);
++iter)
{
- if (_only_run.empty() == false and
- fnmatch(_only_run.c_str(), (*iter)->name(), 0))
+ if (*iter)
{
- continue;
- }
-
- _total++;
+ if (_only_run.empty() == false and
+ fnmatch(_only_run.c_str(), (*iter)->name(), 0))
+ {
+ continue;
+ }
- try {
- switch ((*iter)->exec())
+ _total++;
+
+ try {
+ switch ((*iter)->exec())
+ {
+ case TEST_FAILURE:
+ _failed++;
+ break;
+
+ case TEST_SKIPPED:
+ _skipped++;
+ break;
+
+ // exec() can return SUCCESS, but that doesn't mean that some tests did
+ // not fail or get skipped.
+ case TEST_SUCCESS:
+ _success++;
+ break;
+ }
+ }
+ catch (const libtest::fatal& e)
{
- case TEST_FAILURE:
_failed++;
- break;
-
- case TEST_SKIPPED:
- _skipped++;
- break;
-
- // exec() can return SUCCESS, but that doesn't mean that some tests did
- // not fail or get skipped.
- case TEST_SUCCESS:
- _success++;
- break;
+ stream::cerr(e.file(), e.line(), e.func()) << e.what();
+ }
+ catch (const libtest::disconnected& e)
+ {
+ _failed++;
+ Error << "Unhandled disconnection occurred:" << e.what();
+ throw;
+ }
+ catch (...)
+ {
+ _failed++;
+ throw;
}
- }
- catch (const libtest::fatal& e)
- {
- _failed++;
- stream::cerr(e.file(), e.line(), e.func()) << e.what();
- }
- catch (const libtest::disconnected& e)
- {
- _failed++;
- Error << "Unhandled disconnection occurred:" << e.what();
- throw;
- }
- catch (...)
- {
- _failed++;
- throw;
}
}
_destroy= arg;
}
- void collections(collection_st* arg);
+ void collections(collection_st arg[]);
void set_on_error(test_callback_error_fn *arg)
{
*
* Data Differential YATL (i.e. libtest) library
*
- * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2012-2013 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
#include "libtest/yatlcon.h"
#include <libtest/common.h>
+#include <cstdio>
#include <cstdlib>
#include <unistd.h>
namespace libtest {
+bool has_libmemcached_sasl(void)
+{
+ return false;
+}
+
bool has_libmemcached(void)
{
#if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED
bool has_gearmand()
{
-#if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
+#if defined(GEARMAND_BINARY) && defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
if (HAVE_GEARMAND_BINARY)
{
std::stringstream arg_buffer;
bool has_drizzled()
{
-#if defined(HAVE_DRIZZLED_BINARY) && HAVE_DRIZZLED_BINARY
+#if defined(DRIZZLED_BINARY) && defined(HAVE_DRIZZLED_BINARY) && HAVE_DRIZZLED_BINARY
if (HAVE_DRIZZLED_BINARY)
{
if (access(DRIZZLED_BINARY, X_OK) == 0)
bool has_mysqld()
{
-#if defined(HAVE_MYSQLD_BUILD) && HAVE_MYSQLD_BUILD
+#if defined(MYSQLD_BINARY) && defined(HAVE_MYSQLD_BUILD) && HAVE_MYSQLD_BUILD
if (HAVE_MYSQLD_BUILD)
{
if (access(MYSQLD_BINARY, X_OK) == 0)
return false;
}
-bool has_memcached()
+static char memcached_binary_path[FILENAME_MAX];
+
+static void initialize_memcached_binary_path()
{
-#if defined(HAVE_MEMCACHED_BINARY) && HAVE_MEMCACHED_BINARY
+ memcached_binary_path[0]= 0;
+
+#if defined(MEMCACHED_BINARY) && defined(HAVE_MEMCACHED_BINARY) && HAVE_MEMCACHED_BINARY
if (HAVE_MEMCACHED_BINARY)
{
std::stringstream arg_buffer;
-
char *getenv_ptr;
if (bool((getenv_ptr= getenv("PWD"))) and strcmp(MEMCACHED_BINARY, "memcached/memcached") == 0)
{
if (access(arg_buffer.str().c_str(), X_OK) == 0)
{
- return true;
+ strncpy(memcached_binary_path, arg_buffer.str().c_str(), FILENAME_MAX);
}
}
#endif
+}
+
+static pthread_once_t memcached_binary_once= PTHREAD_ONCE_INIT;
+static void initialize_memcached_binary(void)
+{
+ int ret;
+ if ((ret= pthread_once(&memcached_binary_once, initialize_memcached_binary_path)) != 0)
+ {
+ FATAL(strerror(ret));
+ }
+}
+
+bool has_memcached()
+{
+ initialize_memcached_binary();
+
+ if (memcached_binary_path[0] and (strlen(memcached_binary_path) > 0))
+ {
+ return true;
+ }
return false;
}
-bool has_memcached_sasl()
+const char* memcached_binary()
{
-#if defined(HAVE_MEMCACHED_SASL_BINARY) && HAVE_MEMCACHED_SASL_BINARY
- if (HAVE_MEMCACHED_SASL_BINARY)
+ initialize_memcached_binary();
+
+ if (memcached_binary_path[0])
{
- if (access(MEMCACHED_SASL_BINARY, X_OK) == 0)
- {
- return true;
- }
+ return memcached_binary_path;
}
+
+ return NULL;
+}
+
+const char *gearmand_binary()
+{
+#if defined(GEARMAND_BINARY)
+ return GEARMAND_BINARY;
+#else
+ return NULL;
#endif
+}
- return false;
+const char *drizzled_binary()
+{
+#if defined(DRIZZLED_BINARY)
+ return DRIZZLED_BINARY;
+#else
+ return NULL;
+#endif
}
} // namespace libtest
*
* Data Differential YATL (i.e. libtest) library
*
- * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2012-2013 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
namespace libtest {
+LIBTEST_API
+bool has_libmemcached_sasl(void);
+
LIBTEST_API
bool has_libmemcached();
LIBTEST_API
bool has_mysqld();
+LIBTEST_API
+const char* memcached_binary();
+
+LIBTEST_API
+const char *gearmand_binary();
+
+LIBTEST_API
+const char *drizzled_binary();
} // namespace libtest
(void)http_get_result_callback;
(void)curl;
(void)url;
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
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
}
+#endif
}
HTTP::HTTP(const std::string& url_arg) :
{
(void)init;
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
if (HAVE_LIBCURL)
{
-#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
CURL *curl= curl_easy_init();
init(curl, url());
curl_easy_cleanup(curl);
return bool(retref == CURLE_OK);
-#endif
}
+#endif
return false;
}
bool POST::execute()
{
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
if (HAVE_LIBCURL)
{
-#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
CURL *curl= curl_easy_init();;
init(curl, url());
curl_easy_cleanup(curl);
return bool(retref == CURLE_OK);
-#endif
}
+#endif
return false;
}
bool TRACE::execute()
{
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
if (HAVE_LIBCURL)
{
-#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
CURL *curl= curl_easy_init();;
init(curl, url());
curl_easy_cleanup(curl);
return retref == CURLE_OK;
-#endif
}
+#endif
return false;
}
bool HEAD::execute()
{
+#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
if (HAVE_LIBCURL)
{
-#if defined(HAVE_LIBCURL) && HAVE_LIBCURL
- CURL *curl= curl_easy_init();;
+ CURL *curl= curl_easy_init();
init(curl, url());
curl_easy_cleanup(curl);
return retref == CURLE_OK;
-#endif
}
+#endif
return false;
}
#
LIBTOOL_COMMAND= ${abs_top_builddir}/libtool --mode=execute
-VALGRIND_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --error-exitcode=1 --leak-check=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE
+VALGRIND_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=memcheck --error-exitcode=1 --leak-check=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE
+SGCHECK_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=exp-sgcheck --error-exitcode=1
VALGRIND_COMMAND= TESTS_ENVIRONMENT="valgrind" $(VALGRIND_EXEC_COMMAND)
HELGRIND_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=helgrind --read-var-info=yes --error-exitcode=1 --read-var-info=yes
-DRD_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=drd
+DRD_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=drd --free-is-write=yes --error-exitcode=1
+SGCHECK_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=exp-sgcheck --error-exitcode=1
MASSIF_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=massif
GDB_COMMAND= $(LIBTOOL_COMMAND) gdb -f -x libtest/run.gdb
PTRCHECK_COMMAND= $(LIBTOOL_COMMAND) valgrind --tool=exp-ptrcheck --error-exitcode=1
export VALGRIND_COMMAND
export HELGRIND_COMMAND
export DRD_COMMAND
+export SGCHECK_COMMAND
export GDB_COMMAND
valgrind:
@echo make check TESTS_ENVIRONMENT="\"$(VALGRIND_EXEC_COMMAND)\""
+sgcheck:
+ @echo make check TESTS_ENVIRONMENT="\"$(SGCHECK_EXEC_COMMAND)\""
+
valgrind-supressions:
@echo make check TESTS_ENVIRONMENT="\"$(VALGRIND_SUPRESSION)\""
noinst_HEADERS+= libtest/core.h
noinst_HEADERS+= libtest/dream.h
noinst_HEADERS+= libtest/error.h
-noinst_HEADERS+= libtest/failed.h
-noinst_HEADERS+= libtest/fatal.hpp
+noinst_HEADERS+= libtest/exception.hpp
+noinst_HEADERS+= libtest/exception/disconnected.hpp
+noinst_HEADERS+= libtest/exception/fatal.hpp
noinst_HEADERS+= libtest/framework.h
noinst_HEADERS+= libtest/gearmand.h
noinst_HEADERS+= libtest/drizzled.h
noinst_HEADERS+= libtest/result.hpp
noinst_HEADERS+= libtest/result/base.hpp
noinst_HEADERS+= libtest/result/fail.hpp
-noinst_HEADERS+= libtest/result/fatal.hpp
noinst_HEADERS+= libtest/result/skip.hpp
noinst_HEADERS+= libtest/result/success.hpp
noinst_HEADERS+= libtest/runner.h
noinst_HEADERS+= libtest/thread.hpp
noinst_HEADERS+= libtest/tmpfile.hpp
noinst_HEADERS+= libtest/lite.h
+noinst_HEADERS+= libtest/valgrind.h
noinst_HEADERS+= libtest/vchar.hpp
noinst_HEADERS+= libtest/version.h
noinst_HEADERS+= libtest/visibility.h
noinst_HEADERS+= libtest/wait.h
noinst_HEADERS+= libtest/yatl.h
-noinst_LTLIBRARIES+= libtest/libtest.la
+check_LTLIBRARIES+= libtest/libtest.la
libtest_libtest_la_CXXFLAGS=
EXTRA_libtest_libtest_la_DEPENDENCIES=
libtest_libtest_la_LIBADD=
libtest_libtest_la_SOURCES=
-if BUILDING_LIBMEMCACHED
-libtest_libtest_la_LIBADD+= libmemcached/libmemcached.la
-else
-libtest_libtest_la_CXXFLAGS+= @LIBMEMCACHED_CFLAGS@
-libtest_libtest_la_LIBADD+= @LIBMEMCACHED_LIB@
-endif
libtest_libtest_la_SOURCES+= libtest/alarm.cc
libtest_libtest_la_SOURCES+= libtest/binaries.cc
libtest_libtest_la_SOURCES+= libtest/dns.cc
libtest_libtest_la_SOURCES+= libtest/dream.cc
libtest_libtest_la_SOURCES+= libtest/drizzled.cc
-libtest_libtest_la_SOURCES+= libtest/fatal.cc
+libtest_libtest_la_SOURCES+= libtest/exception.cc
+libtest_libtest_la_SOURCES+= libtest/exception/fatal.cc
libtest_libtest_la_SOURCES+= libtest/formatter.cc
libtest_libtest_la_SOURCES+= libtest/client.cc
libtest_libtest_la_SOURCES+= libtest/framework.cc
drd-unittest: libtest/unittest
@$(DRD_COMMAND) libtest/unittest
+sgcheck-unittest: libtest/unittest
+ echo $(SGCHECK_COMMAND)
+ @$(SGCHECK_COMMAND) libtest/unittest
+
libtest_skiptest_LDADD= libtest/libtest.la
libtest_skiptest_SOURCES= libtest/skiptest.cc
check_PROGRAMS+= libtest/skiptest
noinst_PROGRAMS+= libtest/skiptest
+test-skiptest: libtest/skiptest
+ @libtest/skiptest
+
+valgrind-skiptest: libtest/skiptest
+ @$(VALGRIND_COMMAND) libtest/skiptest
+
+helgrind-skiptest: libtest/skiptest
+ @$(HELGRIND_COMMAND) libtest/skiptest
+
+drd-skiptest: libtest/skiptest
+ @$(DRD_COMMAND) libtest/skiptest
+
libtest_wait_SOURCES=
libtest_wait_SOURCES+= libtest/wait.cc
libtest_wait_SOURCES+= libtest/dream.cc
# include <string.h>
#endif
-#if defined(_WIN32)
+#if defined(WIN32)
# include <malloc.h>
#else
# include <alloca.h>
# define SKIP(__message_format, ...)
#endif
-static inline bool valgrind_is_caller(void)
-{
- if (getenv("TESTS_ENVIRONMENT") && strstr(getenv("TESTS_ENVIRONMENT"), "valgrind"))
- {
- return true;
- }
-
- return false;
-}
+#include <libtest/valgrind.h>
static inline size_t yatl_strlen(const char *s)
{
} \
} while (0)
+#define SKIP_UNLESS(__expression) \
+do \
+{ \
+ if (! (__expression)) { \
+ if (YATL_FULL) { \
+ SKIP(#__expression); \
+ } \
+ fprintf(stdout, "\n%s:%d: %s SKIP '(%s)'\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #__expression); \
+ exit(EXIT_SKIP); \
+ } \
+} while (0)
+
+#define SKIP_UNLESS_(__expression, ...) \
+do \
+{ \
+ if (! (__expression)) { \
+ size_t ask= snprintf(0, 0, __VA_ARGS__); \
+ ask++; \
+ char *buffer= (char*)alloca(sizeof(char) * ask); \
+ snprintf(buffer, ask, __VA_ARGS__); \
+ if (YATL_FULL) { \
+ SKIP(#__expression, buffer); \
+ } \
+ fprintf(stdout, "\n%s:%d: %s SKIP '%s' [ %s ]\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, #__expression, buffer); \
+ exit(EXIT_SKIP); \
+ } \
+} while (0)
+
#define ASSERT_TRUE(__expression) \
do \
{ \
*
* Data Differential YATL (i.e. libtest) library
*
- * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2012-2013 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
#include <ctime>
#include <fnmatch.h>
#include <iostream>
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
#include <fstream>
#include <memory>
#include <sys/stat.h>
Valgrind does not currently work reliably, or sometimes at all, on OSX
- Fri Jun 15 11:24:07 EDT 2012
*/
-#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+#if defined(__APPLE__) && __APPLE__
if (valgrind_is_caller())
{
return EXIT_SKIP;
Error << "unknown value passed to --repeat: `" << optarg << "`";
exit(EXIT_FAILURE);
}
-
break;
case OPT_LIBYATL_MATCH_COLLECTION:
std::auto_ptr<libtest::Framework> frame(new libtest::Framework(signal, binary_name, collection_to_run, wildcard));
// Run create(), bail on error.
- try
{
switch (frame->create())
{
break;
case TEST_SKIPPED:
- return EXIT_SKIP;
+ SKIP("SKIP was returned from framework create()");
+ break;
case TEST_FAILURE:
std::cerr << "Could not call frame->create()" << std::endl;
return EXIT_FAILURE;
}
}
- catch (const libtest::__skipped& e)
- {
- return EXIT_SKIP;
- }
frame->exec();
std::cerr << "std::exception:" << e.what() << std::endl;
exit_code= EXIT_FAILURE;
}
- catch (char const*)
+ catch (char const* s)
{
- std::cerr << "Exception:" << std::endl;
+ std::cerr << "Exception:" << s << std::endl;
exit_code= EXIT_FAILURE;
}
catch (...)
const std::string& username_arg,
const std::string& password_arg) :
libtest::Server(host_arg, port_arg,
- MEMCACHED_BINARY, false, is_socket_arg),
+ memcached_binary(), false, is_socket_arg),
_username(username_arg),
_password(password_arg)
{ }
Memcached(const std::string& host_arg, const in_port_t port_arg, const bool is_socket_arg) :
libtest::Server(host_arg, port_arg,
- MEMCACHED_BINARY, false, is_socket_arg)
+ memcached_binary(), false, is_socket_arg)
{
set_pid_file();
}
const char *executable()
{
- return MEMCACHED_BINARY;
+ return memcached_binary();
}
bool is_libtool()
libtest::Server *build_memcached(const std::string& hostname, const in_port_t try_port)
{
- if (HAVE_MEMCACHED_BINARY)
+ if (has_memcached())
{
return new Memcached(hostname, try_port, false);
}
libtest::Server *build_memcached_socket(const std::string& socket_file, const in_port_t try_port)
{
- if (HAVE_MEMCACHED_BINARY)
+ if (has_memcached())
{
return new Memcached(socket_file, try_port, true);
}
#if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED
inline bool operator== (const memcached_st& memc, const memcached_return_t rc)
{
- if (memcached_last_error(&memc) == rc)
+ if (memcached_last_error(const_cast<memcached_st *>(&memc)) == rc)
{
return true;
}
namespace libtest {
__test_result::__test_result(const char *file_arg, int line_arg, const char *func_arg):
- _line(line_arg),
- _file(file_arg),
- _func(func_arg),
- _error_message(NULL),
- _error_message_size(0)
-{
-}
-
-#ifndef __INTEL_COMPILER
-# pragma GCC diagnostic ignored "-Wformat-nonliteral"
-#endif
-void __test_result::init(va_list args_)
-{
- const char *format= va_arg(args_, const char *);
- _error_message_size= vasprintf(&_error_message, format, args_);
- assert(_error_message_size != -1);
- if (_error_message_size > 0)
+ libtest::exception(file_arg, line_arg, func_arg)
{
- _error_message_size++;
}
-}
-
-__test_result::~__test_result() throw()
-{
- free(_error_message);
-}
-
-__test_result::__test_result(const __test_result& other) :
- _line(other._line),
- _file(other._file),
- _func(other._func),
- _error_message_size(other._error_message_size)
-{
- if (_error_message_size > 0)
- {
- _error_message= (char*) malloc(_error_message_size);
- if (_error_message)
- {
- memcpy(_error_message, other._error_message, _error_message_size);
- }
- else
- {
- _error_message_size= -1;
- }
- }
-}
__success::__success(const char *file_arg, int line_arg, const char *func_arg):
__test_result(file_arg, line_arg, func_arg)
#pragma once
-#include <libtest/fatal.hpp>
#include <libtest/result/base.hpp>
#include <libtest/result/fail.hpp>
-#include <libtest/result/fatal.hpp>
#include <libtest/result/skip.hpp>
#include <libtest/result/success.hpp>
{ \
throw libtest::__failure(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \
} while (0)
-
-#define FATAL(...) \
-do \
-{ \
- throw libtest::fatal(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \
-} while (0)
-
-#define FATAL_IF(__expression, ...) \
-do \
-{ \
- if ((__expression)) { \
- throw libtest::fatal(LIBYATL_DEFAULT_PARAM, (#__expression)); \
- } \
-} while (0)
-
-#define FATAL_IF_(__expression, ...) \
-do \
-{ \
- if ((__expression)) { \
- throw libtest::fatal(LIBYATL_DEFAULT_PARAM, __VA_ARGS__); \
- } \
-} while (0)
-
-#define fatal_assert(__assert) if((__assert)) {} else { throw libtest::fatal(LIBYATL_DEFAULT_PARAM, #__assert); }
#pragma once
+#include "libtest/exception.hpp"
+#include "libtest/error.h"
+
namespace libtest {
-class __test_result : public std::exception
+class __test_result : public libtest::exception
{
public:
__test_result(const char *file, int line, const char *func);
- __test_result( const __test_result& );
-
- virtual ~__test_result() throw();
-
- virtual const char* what() const throw()
- {
- if (_error_message)
- {
- return _error_message;
- }
-
- return "";
- }
-
- int line() const
- {
- return _line;
- }
-
- const char* file() const
- {
- return _file;
- }
-
- const char* func() const
- {
- return _func;
- }
-
-protected:
- void init(va_list);
+ virtual test_return_t return_code() const= 0;
private:
- int _line;
- const char* _file;
- const char* _func;
- char* _error_message;
- int _error_message_size;
};
} // namespace libtest
__failure(const __failure&);
+ test_return_t return_code() const
+ {
+ return TEST_FAILURE;
+ }
+
private:
};
+++ /dev/null
-/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * Data Differential YATL (i.e. libtest) 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
-
-namespace libtest {
-
-class fatal : public __test_result
-{
-public:
- fatal(const char *file, int line, const char *func, ...);
-
- fatal(const fatal&);
-
- // The following are just for unittesting the exception class
- static bool is_disabled() throw();
- static void disable() throw();
- static void enable() throw();
- static uint32_t disabled_counter() throw();
- static void increment_disabled_counter() throw();
-
-private:
-};
-
-} // namespace libtest
__skipped(const char *file, int line, const char *func, ...);
__skipped(const __skipped&);
+
+ test_return_t return_code() const
+ {
+ return TEST_SKIPPED;
+ }
};
} // namespace libtest
return "SUCCESS";
}
+ test_return_t return_code() const
+ {
+ return TEST_SUCCESS;
+ }
+
private:
};
set logging on
set logging overwrite on
set environment LIBTEST_IN_GDB=1
-set ASAN_OPTIONS=abort_on_error=1
+#set ASAN_OPTIONS=abort_on_error=1
+handle SIGVTALRM stop
run
thread apply all bt
}
else if (server_type.compare("drizzled") == 0)
{
- if (DRIZZLED_BINARY)
+ if (has_drizzled())
{
- if (HAVE_LIBDRIZZLE)
+ if (has_libdrizzle())
{
server= build_drizzled("localhost", try_port);
}
}
else if (server_type.compare("blobslap_worker") == 0)
{
- if (GEARMAND_BINARY)
+ if (has_gearmand())
{
+#ifdef GEARMAND_BLOBSLAP_WORKER
if (GEARMAND_BLOBSLAP_WORKER)
{
if (HAVE_LIBGEARMAN)
server= build_blobslap_worker(try_port);
}
}
+#endif // GEARMAND_BLOBSLAP_WORKER
}
}
else if (server_type.compare("memcached") == 0)
{
- if (HAVE_MEMCACHED_BINARY)
+ if (has_memcached())
{
server= build_memcached("localhost", try_port);
}
else
{
{
-#if defined(DEBUG)
+#ifdef DEBUG
if (DEBUG)
{
Outn();
switch (sig)
{
case SIGALRM:
- Error << "SIGALRM";
+ case SIGVTALRM:
+ Error << strsignal(sig);
if (gdb_is_caller())
{
abort();
}
- exit(EXIT_SKIP);
-
- case SIGVTALRM:
- Error << "SIGVTALRM was called";
- context->unblock();
- raise(SIGVTALRM);
+ exit(EXIT_FAILURE);
case SIGABRT:
case SIGUSR2:
#include <libtest/version.h>
#include <libtest/vchar.hpp>
-#include <libtest/fatal.hpp>
+#include <libtest/error.h>
+#include <libtest/exception.hpp>
+#include <libtest/exception/disconnected.hpp>
+#include <libtest/exception/fatal.hpp>
#include <libtest/result.hpp>
#include <libtest/has.hpp>
namespace libtest {
-std::string create_tmpfile(const std::string& name)
+std::string create_tmpfile(const std::string& name, int& fd)
{
libtest::vchar_t file_buffer;
file_buffer.resize(FILENAME_MAX);
int length= snprintf(&file_buffer[0], file_buffer.size(), "var/tmp/%s.XXXXXX", name.c_str());
fatal_assert(length > 0);
- int fd;
if ((fd= mkstemp(&file_buffer[0])) == -1)
{
throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "mkstemp() failed on %s with %s", &file_buffer[0], strerror(errno));
}
- close(fd);
- unlink(&file_buffer[0]);
return &file_buffer[0];
}
+std::string create_tmpfile(const std::string& name)
+{
+ int fd;
+ std::string ret_file= create_tmpfile(name, fd);
+ close(fd);
+ unlink(ret_file.c_str());
+
+ return ret_file.c_str();
+}
+
} // namespace libtest
namespace libtest {
+std::string create_tmpfile(const std::string&, int&);
std::string create_tmpfile(const std::string&);
} // namespace libtest
return TEST_FAILURE;
}
+static test_return_t test_throw_skip_unless_macro_TEST(void *)
+{
+ try {
+ SKIP_UNLESS(false);
+ }
+ catch (const libtest::__skipped&)
+ {
+ return TEST_SUCCESS;
+ }
+ catch (...)
+ {
+ FAIL("SLIP_UNLESS() failed to throw libtest::_skipped");
+ }
+
+ FAIL("SLIP_UNLESS() failed to throw");
+
+ return TEST_FAILURE;
+}
+
static test_return_t test_throw_skip_TEST(void *)
{
try {
}
#pragma GCC diagnostic ignored "-Wstack-protector"
+#ifdef __clang__
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wformat-security"
+#endif
+
static test_return_t ASSERT_FALSE__TEST(void *)
{
try {
return TEST_FAILURE;
}
+#ifdef __clang__
+# pragma GCC diagnostic pop
+#endif
+
static test_return_t ASSERT_NEQ_FAIL_TEST(void *)
{
try {
true_app.will_fail();
const char *args[]= { "--fubar", 0 };
-#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
+#if defined(__APPLE__) && __APPLE__
ASSERT_EQ(Application::INVALID_POSIX_SPAWN, true_app.run(args));
-#elif defined(TARGET_OS_FREEBSD) && TARGET_OS_FREEBSD
+#elif defined(__FreeBSD__) && __FreeBSD__
ASSERT_EQ(Application::INVALID_POSIX_SPAWN, true_app.run(args));
#else
ASSERT_EQ(Application::SUCCESS, true_app.run(args));
static test_return_t gdb_wait_services_appliction_TEST(void *)
{
test_skip(true, false);
-#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
- test_skip(0, TARGET_OS_OSX);
+#if defined(__APPLE__) && __APPLE__
+ test_skip(0, __APPLE__);
#endif
test_skip(0, access("/etc/services", R_OK ));
test_skip(0, access("libtest/abort", X_OK ));
test_skip(true, false);
-#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
- test_skip(0, TARGET_OS_OSX);
+#if defined(__APPLE__) && __APPLE__
+ test_skip(0, __APPLE__);
#endif
libtest::Application abort_app("libtest/abort", true);
return TEST_SUCCESS;
}
+static test_return_t check_for_VALGRIND(void *)
+{
+ test_skip_valgrind();
+ return TEST_SUCCESS;
+}
+
static test_return_t check_for_gearman(void *)
{
test_skip(true, HAVE_LIBGEARMAN);
{"SUCCESS", false, test_throw_success_TEST },
{"libtest::__skipped", false, test_throw_skip_TEST },
{"SKIP_IF", false, test_throw_skip_macro_TEST },
+ {"SKIP_UNLESS", false, test_throw_skip_unless_macro_TEST },
{"FAIL", false, test_throw_fail_TEST },
{"ASSERT_FALSE_", false, ASSERT_FALSE__TEST },
{"ASSERT_FALSE", false, ASSERT_FALSE_TEST },
{"fatal", disable_fatal_exception, enable_fatal_exception, fatal_message_TESTS },
{"number_of_cpus()", 0, 0, number_of_cpus_TESTS },
{"create_tmpfile()", 0, 0, create_tmpfile_TESTS },
- {"dns", 0, 0, dns_TESTS },
+ {"dns", check_for_VALGRIND, 0, dns_TESTS },
{"libtest::Timer", 0, 0, timer_TESTS },
{0, 0, 0, 0}
};
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Data Differential YATL (i.e. libtest) library
+ *
+ * Copyright (C) 2012-2013 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
+
+static inline bool valgrind_is_caller(void)
+{
+ if (getenv("TESTS_ENVIRONMENT") && strstr(getenv("TESTS_ENVIRONMENT"), "valgrind"))
+ {
+ if (strstr(getenv("TESTS_ENVIRONMENT"), "--tool") == NULL)
+ {
+ return true;
+ }
+
+ if (strstr(getenv("TESTS_ENVIRONMENT"), "--tool=memcheck"))
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
namespace libtest {
+int random_alpha_num(void)
+{
+ return ALPHANUMERICS[get_alpha_num()];
+}
+
static std::string printer(const char *str, size_t length)
{
std::ostringstream buf;
namespace libtest {
+int random_alpha_num(void);
+
typedef std::vector<char*> vchar_ptr_t;
typedef std::vector<char> vchar_t;
} // namespace vchar
#define vchar_param(__arg) (&__arg[0]), (__arg.size())
+#define vchar_printf(__arg) int(__arg.size()), (&__arg[0])
std::ostream& operator<<(std::ostream& output, const libtest::vchar_t& arg);
AC_CONFIG_FILES([libtest/version.h])
m4_include([libtest/m4/mysql.m4])
-AC_DEFINE([HAVE_MEMCACHED_SASL_BINARY],[0],[If Memcached binary with sasl support is available])
YATL_MYSQL
# and this notice are preserved. This file is offered as-is, without any
# warranty.
-#serial 7
+#serial 8
AC_DEFUN([AX_APPEND_TO_FILE],[
AC_REQUIRE([AX_FILE_ESCAPES])
-printf "$2" >> "$1"
+printf "$2\n" >> "$1"
])
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#serial 5
+#serial 6
AC_DEFUN([AX_DEBUG],
[AC_PREREQ([2.63])dnl
[Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],
[ax_enable_debug=yes
AC_DEFINE([DEBUG],[1],[Define to 1 to enable debugging code.])
- AX_CHECK_LIBRARY([MCHECK],[mcheck.h],[mcheck],[AX_APPEND_LINK_FLAGS([-lmcheck])])],
+ AX_CHECK_LIBRARY([MCHECK],[mcheck.h],[mcheck],[AX_APPEND_LINK_FLAGS([-lmcheck])])
+ AX_ADD_AM_MACRO([--debug],[AM_YFLAGS])
+ AX_ADD_AM_MACRO([-D_GLIBCXX_DEBUG],[AM_CPPFLAGS])],
[ax_enable_debug=no
AC_SUBST([MCHECK])
AC_DEFINE([DEBUG],[0],[Define to 1 to enable debugging code.])])
#
# LICENSE
#
-# Copyright (C) 2012 Brian Aker
+# Copyright (C) 2012-2013 Brian Aker
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# 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.
+#
+# Notes:
+# We do not test for c99 or c++11, that is out of scope.
# The Following flags are not checked for
# -Wdeclaration-after-statement is counter to C99
-# _APPEND_COMPILE_FLAGS_ERROR([-std=c++11]) -- Not ready yet
-# _APPEND_COMPILE_FLAGS_ERROR([-pedantic]) --
-# ? _APPEND_COMPILE_FLAGS_ERROR([-Wlong-long]) -- Don't turn on for
-# compatibility issues memcached_stat_st
+# _APPEND_COMPILE_FLAGS_ERROR([-pedantic])
+
+#serial 13
-#serial 9
+AC_DEFUN([_SET_SANITIZE_FLAGS],
+ [AS_IF([test "x$MINGW" != xyes],[
+ AS_IF([test "x$enable_shared" = "xyes"],
+ [AS_CASE([$ax_harden_sanitize],
+ [thread],[
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=thread])],
+ [address],[
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=address])],
+ [rest],[
+ _APPEND_COMPILE_FLAGS_ERROR([-fno-omit-frame-pointer])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=memory])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=alignment])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bool])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bounds])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=enum])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-cast-overflow])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-divide-by-zero])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer-divide-by-zero])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=null])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=object-size])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=return])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=shift])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=signed-integer-overflow])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unreachable])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unsigned-integer-overflow])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vla-bound])
+ _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vptr])])
+ ])
+ ])
+ ])
AC_DEFUN([_WARNINGS_AS_ERRORS],
[AC_CACHE_CHECK([if all warnings into errors],[ac_cv_warnings_as_errors],
# Note: Should this be LIBS or LDFLAGS?
AC_DEFUN([_APPEND_LINK_FLAGS_ERROR],
- [AC_REQUIRE([AX_APPEND_LINK_FLAGS])
- AX_APPEND_LINK_FLAGS([$1],[LDFLAGS],[-Werror])
+ [AX_APPEND_LINK_FLAGS([$1],[LDFLAGS],[-Werror])
])
AC_DEFUN([_APPEND_COMPILE_FLAGS_ERROR],
- [AC_REQUIRE([AX_APPEND_COMPILE_FLAGS])
- AX_APPEND_COMPILE_FLAGS([$1],,[-Werror])
+ [AX_APPEND_COMPILE_FLAGS([$1],,[-Werror])
])
# Everything above this does the heavy lifting, while what follows does the specifics.
AC_DEFUN([_HARDEN_LINKER_FLAGS],
- [
- AS_IF([test "$CC" != "clang"],
- [_APPEND_LINK_FLAGS_ERROR([-z relro -z now])
-#_APPEND_LINK_FLAGS_ERROR([-pie])
- AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],
- [AX_APPEND_LINK_FLAGS([-Werror])])])
+ [AS_IF([test "$CC" != "clang"],
+ [_APPEND_LINK_FLAGS_ERROR([-z relro -z now])
+ AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],[AX_APPEND_LINK_FLAGS([-Werror])])
+ AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
+ [_APPEND_LINK_FLAGS_ERROR([-rdynamic])
+# AX_APPEND_LINK_FLAGS([--coverage])])
+ ])
+ ])
+
+AC_DEFUN([_AX_HARDEN_SANITIZE],
+ [AC_REQUIRE([AX_DEBUG])
+ AC_ARG_WITH([sanitize],
+ [AS_HELP_STRING([--with-sanitize],
+ [Enable sanitize flag for compiler if it supports them @<:@default=no@:>@])],
+ [AS_CASE([$with_sanitize],
+ [thread],[
+ ax_harden_sanitize='thread'],
+ [address],[
+ ax_harden_sanitize='address'],
+ [ax_harden_sanitize='rest'])
+ ],
+ [AS_IF([test "x$ax_enable_debug" = xyes],[ax_harden_sanitize='rest'])])
])
AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
AS_IF([test "x$ax_enable_debug" = xyes],
[CFLAGS=''
_APPEND_COMPILE_FLAGS_ERROR([-H])
- _APPEND_COMPILE_FLAGS_ERROR([-ggdb])
_APPEND_COMPILE_FLAGS_ERROR([-g])
- _APPEND_COMPILE_FLAGS_ERROR([-O0]),
+ _APPEND_COMPILE_FLAGS_ERROR([-g3])
+ _APPEND_COMPILE_FLAGS_ERROR([-fmudflapth])
+ _APPEND_COMPILE_FLAGS_ERROR([-fno-eliminate-unused-debug-types])
_APPEND_COMPILE_FLAGS_ERROR([-fno-omit-frame-pointer])
],[
_APPEND_COMPILE_FLAGS_ERROR([-g])
AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
[_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
+# _APPEND_COMPILE_FLAGS_ERROR([--coverage])
_APPEND_COMPILE_FLAGS_ERROR([-Wpragmas])
_APPEND_COMPILE_FLAGS_ERROR([-Wunknown-pragmas])],
[_APPEND_COMPILE_FLAGS_ERROR([-Wno-unknown-pragmas])
_APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
- AS_IF([test "$CC" = "clang"],
- [_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
+ AS_IF([test "$CC" = "clang"],[_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
_APPEND_COMPILE_FLAGS_ERROR([-Wall])
_APPEND_COMPILE_FLAGS_ERROR([-Wextra])
+ _APPEND_COMPILE_FLAGS_ERROR([-Weverything])
_APPEND_COMPILE_FLAGS_ERROR([-Wthis-test-should-fail])
- _APPEND_COMPILE_FLAGS_ERROR([-std=c99])
# Anything below this comment please keep sorted.
# _APPEND_COMPILE_FLAGS_ERROR([-Wmissing-format-attribute])
_APPEND_COMPILE_FLAGS_ERROR([-Wunsuffixed-float-constants])
_APPEND_COMPILE_FLAGS_ERROR([-Wno-suggest-attribute=pure])
_APPEND_COMPILE_FLAGS_ERROR([-Wno-redundant-decls])],
[_APPEND_COMPILE_FLAGS_ERROR([-Wredundant-decls])])
-
_APPEND_COMPILE_FLAGS_ERROR([-Wshadow])
_APPEND_COMPILE_FLAGS_ERROR([-Wshorten-64-to-32])
_APPEND_COMPILE_FLAGS_ERROR([-Wsign-compare])
_APPEND_COMPILE_FLAGS_ERROR([-Wundef])
_APPEND_COMPILE_FLAGS_ERROR([-Wunsafe-loop-optimizations])
_APPEND_COMPILE_FLAGS_ERROR([-funsafe-loop-optimizations])
- AS_IF([test "x$ac_cv_vcs_checkout" = xyes],[
- _APPEND_COMPILE_FLAGS_ERROR([-fno-omit-frame-pointer])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=address])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer])
- AS_IF([test "x$enable_shared" = "xyes"],[
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=thread])
- ])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=memory])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=alignment])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bool])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bounds])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=enum])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-cast-overflow])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-divide-by-zero])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer-divide-by-zero])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=null])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=object-size])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=return])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=shift])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=signed-integer-overflow])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unreachable])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unsigned-integer-overflow])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vla-bound])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vptr])
- ])
+
_APPEND_COMPILE_FLAGS_ERROR([-Wclobbered])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused-result])
_APPEND_COMPILE_FLAGS_ERROR([-fwrapv])
_APPEND_COMPILE_FLAGS_ERROR([-fmudflapt])
_APPEND_COMPILE_FLAGS_ERROR([-pipe])
+ _APPEND_COMPILE_FLAGS_ERROR([-fPIE -pie])
_APPEND_COMPILE_FLAGS_ERROR([-Wsizeof-pointer-memaccess])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wpacked])
+# _APPEND_COMPILE_FLAGS_ERROR([-Wlong-long])
+# GCC 4.5 removed this.
+# _APPEND_COMPILE_FLAGS_ERROR([-Wunreachable-code])
+
+ _SET_SANITIZE_FLAGS
AS_IF([test "x$ax_enable_debug" = xno],
[AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
- [AS_IF([test "x${target_os}" != "xmingw"],
+ [AS_IF([test "x${host_os}" != "xmingw"],
[AS_IF([test "x$ac_c_gcc_recent" = xyes],
[_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
#_APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
- #_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
- #_APPEND_COMPILE_FLAGS_ERROR([--param=ssp-buffer-size=1])
+ #_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector --param=ssp-buffer-size=4])
_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
])])])])
AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
[AC_LANG_PUSH([C++])
- AC_REQUIRE([_APPEND_COMPILE_FLAGS_ERROR])
-
AS_IF([test "x$ax_enable_debug" = xyes],
[CXXFLAGS=''
_APPEND_COMPILE_FLAGS_ERROR([-H])
- _APPEND_COMPILE_FLAGS_ERROR([-ggdb])
_APPEND_COMPILE_FLAGS_ERROR([-g])
- _APPEND_COMPILE_FLAGS_ERROR([-O0]),
+ _APPEND_COMPILE_FLAGS_ERROR([-g3])
+ _APPEND_COMPILE_FLAGS_ERROR([-fmudflapth])
+ _APPEND_COMPILE_FLAGS_ERROR([-fno-inline])
+ _APPEND_COMPILE_FLAGS_ERROR([-fno-eliminate-unused-debug-types])
_APPEND_COMPILE_FLAGS_ERROR([-fno-omit-frame-pointer])
],[
_APPEND_COMPILE_FLAGS_ERROR([-g])
AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
[_APPEND_COMPILE_FLAGS_ERROR([-fstack-check])
+# _APPEND_COMPILE_FLAGS_ERROR([--coverage])
_APPEND_COMPILE_FLAGS_ERROR([-Wpragmas])
_APPEND_COMPILE_FLAGS_ERROR([-Wunknown-pragmas])],
[_APPEND_COMPILE_FLAGS_ERROR([-Wno-unknown-pragmas])
_APPEND_COMPILE_FLAGS_ERROR([-Wno-pragmas])])
- AS_IF([test "$CXX" = "clang++"],
- [_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
+ AS_IF([test "$CXX" = "clang++"],[_APPEND_COMPILE_FLAGS_ERROR([-Qunused-arguments])])
_APPEND_COMPILE_FLAGS_ERROR([-Wall])
_APPEND_COMPILE_FLAGS_ERROR([-Wextra])
+ _APPEND_COMPILE_FLAGS_ERROR([-Weverything])
_APPEND_COMPILE_FLAGS_ERROR([-Wthis-test-should-fail])
# Anything below this comment please keep sorted.
# _APPEND_COMPILE_FLAGS_ERROR([-Wmissing-format-attribute])
_APPEND_COMPILE_FLAGS_ERROR([-funsafe-loop-optimizations])
_APPEND_COMPILE_FLAGS_ERROR([-Wc++11-compat])
# _APPEND_COMPILE_FLAGS_ERROR([-Weffc++])
- AS_IF([test "x$ac_cv_vcs_checkout" = xyes],[
- _APPEND_COMPILE_FLAGS_ERROR([-fno-omit-frame-pointer])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=address])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer])
- AS_IF([test "x$enable_shared" = "xyes"],[
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=thread])
- ])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=memory])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=alignment])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bool])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=bounds])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=enum])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-cast-overflow])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=float-divide-by-zero])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=integer-divide-by-zero])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=null])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=object-size])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=return])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=shift])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=signed-integer-overflow])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unreachable])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=unsigned-integer-overflow])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vla-bound])
- _APPEND_COMPILE_FLAGS_ERROR([-fsanitize=vptr])
- ])
# _APPEND_COMPILE_FLAGS_ERROR([-Wold-style-cast])
_APPEND_COMPILE_FLAGS_ERROR([-Wclobbered])
_APPEND_COMPILE_FLAGS_ERROR([-Wunused])
_APPEND_COMPILE_FLAGS_ERROR([-fwrapv])
_APPEND_COMPILE_FLAGS_ERROR([-fmudflapt])
_APPEND_COMPILE_FLAGS_ERROR([-pipe])
+ _APPEND_COMPILE_FLAGS_ERROR([-fPIE -pie])
_APPEND_COMPILE_FLAGS_ERROR([-Wsizeof-pointer-memaccess])
+ _APPEND_COMPILE_FLAGS_ERROR([-Wpacked])
+# _APPEND_COMPILE_FLAGS_ERROR([-Wlong-long])
+# GCC 4.5 removed this.
+# _APPEND_COMPILE_FLAGS_ERROR([-Wunreachable-code])
AS_IF([test "x$ax_enable_debug" = xno],
[AS_IF([test "x$ac_cv_vcs_checkout" = xyes],
- [AS_IF([test "x${target_os}" != "xmingw"],
+ [AS_IF([test "x${host_os}" != "xmingw"],
[AS_IF([test "x$ac_c_gcc_recent" = xyes],
[_APPEND_COMPILE_FLAGS_ERROR([-D_FORTIFY_SOURCE=2])
#_APPEND_COMPILE_FLAGS_ERROR([-Wstack-protector])
- #_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector])
- #_APPEND_COMPILE_FLAGS_ERROR([--param=ssp-buffer-size=1])
+ #_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector --param=ssp-buffer-size=4])
_APPEND_COMPILE_FLAGS_ERROR([-fstack-protector-all])
])])])])
+ _SET_SANITIZE_FLAGS
+
AS_IF([test "x$ac_cv_warnings_as_errors" = xyes],
[AX_APPEND_FLAG([-Werror])])
AC_LANG_POP([C++])
# _HARDEN_CC_COMPILER_FLAGS, _HARDEN_CXX_COMPILER_FLAGS
AC_DEFUN([AX_HARDEN_COMPILER_FLAGS],
[AC_PREREQ([2.63])dnl
- AC_REQUIRE([_WARNINGS_AS_ERRORS])
- AC_REQUIRE([AX_APPEND_LINK_FLAGS])
+ AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([AX_COMPILER_VERSION])
- AC_REQUIRE([AX_DEBUG])
- AC_REQUIRE([AX_VCS_CHECKOUT])
+ AC_REQUIRE([AX_ASSERT])
+ _WARNINGS_AS_ERRORS
+ _AX_HARDEN_SANITIZE
AC_REQUIRE([gl_VISIBILITY])
AS_IF([test -n "$CFLAG_VISIBILITY"],[CPPFLAGS="$CPPFLAGS $CFLAG_VISIBILITY"])
- AC_REQUIRE([_HARDEN_LINKER_FLAGS])
- AC_REQUIRE([_HARDEN_CC_COMPILER_FLAGS])
- AC_REQUIRE([_HARDEN_CXX_COMPILER_FLAGS])
+ _WARNINGS_AS_ERRORS
+ _HARDEN_LINKER_FLAGS
+ _HARDEN_CC_COMPILER_FLAGS
+ _HARDEN_CXX_COMPILER_FLAGS
])
+
#
# LICENSE
#
-# Copyright (c) 2012 Brian Aker <brian@tangent.org>
+# Copyright (c) 2012-2013 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 3
+#serial 4
#
AC_DEFUN([AX_PLATFORM],
[AC_REQUIRE([AC_CANONICAL_HOST])
- AC_REQUIRE([AC_CANONICAL_TARGET])
AC_DEFINE_UNQUOTED([HOST_VENDOR],["$host_vendor"],[Vendor of Build System])
AC_DEFINE_UNQUOTED([HOST_OS],["$host_os"], [OS of Build System])
AC_DEFINE_UNQUOTED([HOST_CPU],["$host_cpu"], [CPU of Build System])
- AC_DEFINE_UNQUOTED([TARGET_VENDOR],["$target_vendor"],[Vendor of Target System])
- AC_DEFINE_UNQUOTED([TARGET_OS],["$target_os"], [OS of Target System])
- AC_DEFINE_UNQUOTED([TARGET_CPU],["$target_cpu"], [CPU of Target System])
-
- AS_CASE([$target_os],
+ AS_CASE([$host_os],
[*mingw*],
- [TARGET_WINDOWS="true"
- AC_DEFINE([TARGET_OS_WINDOWS], [1], [Whether we are building for Windows])
+ [HOST_WINDOWS="true"
+ AC_DEFINE([HOST_OS_WINDOWS], [1], [Whether we are building for Windows])
AC_DEFINE([EAI_SYSTEM], [11], [Another magical number])
AH_BOTTOM([
#ifndef HAVE_SYS_SOCKET_H
# define SHUT_RDWR SD_BOTH
#endif
])],
- [*freebsd*],[AC_DEFINE([TARGET_OS_FREEBSD],[1],[Whether we are building for FreeBSD])
+ [*freebsd*],[AC_DEFINE([HOST_OS_FREEBSD],[1],[Whether we are building for FreeBSD])
AC_DEFINE([__APPLE_CC__],[1],[Workaround for bug in FreeBSD headers])],
- [*solaris*],[AC_DEFINE([TARGET_OS_SOLARIS],[1],[Whether we are building for Solaris])],
+ [*solaris*],[AC_DEFINE([HOST_OS_SOLARIS],[1],[Whether we are building for Solaris])],
[*darwin*],
- [TARGET_OSX="true"],
+ [HOST_OSX="true"],
[*linux*],
- [TARGET_LINUX="true"
- AC_DEFINE([TARGET_OS_LINUX],[1],[Whether we build for Linux])])
+ [HOST_LINUX="true"
+ AC_DEFINE([HOST_OS_LINUX],[1],[Whether we build for Linux])])
- AM_CONDITIONAL([BUILD_WIN32],[test "x${TARGET_WINDOWS}" = "xtrue"])
- AM_CONDITIONAL([TARGET_OSX],[test "x${TARGET_OSX}" = "xtrue"])
- AM_CONDITIONAL([TARGET_LINUX],[test "x${TARGET_LINUX}" = "xtrue"])
+ AM_CONDITIONAL([BUILD_WIN32],[test "x${HOST_WINDOWS}" = "xtrue"])
+ AM_CONDITIONAL([HOST_OSX],[test "x${HOST_OSX}" = "xtrue"])
+ AM_CONDITIONAL([HOST_LINUX],[test "x${HOST_LINUX}" = "xtrue"])
+ AM_CONDITIONAL([HOST_FREEBSD],[test "x${HOST_OS_FREEBSD}" = "xtrue"])
])
#
# SYNOPSIS
#
-# AX_PROG_SPHINX_BUILD()
+# AX_PROG_SPHINX_BUILD([ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND])
#
# DESCRIPTION
#
-# Look for sphinx-build
+# Look for sphinx-build and make sure it is a recent version of it.
#
# LICENSE
#
-# Copyright (c) 2012 Brian Aker <brian@tangent.org>
+# Copyright (c) 2012-2013 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 2
+#serial 5
AC_DEFUN([AX_PROG_SPHINX_BUILD],
- [AC_PREREQ([2.63])dnl
- AC_CHECK_PROGS([PERL], [perl])
- AC_CHECK_PROGS([DPKG_GENSYMBOLS], [dpkg-gensymbols], [:])
- AC_CHECK_PROGS([LCOV], [lcov], [echo lcov not found])
- AC_CHECK_PROGS([LCOV_GENHTML], [genhtml], [echo genhtml not found])
+ [AX_WITH_PROG([SPHINXBUILD],[sphinx-build],[:])
+ AS_IF([test x"SPHINXBUILD" = x":"],
+ [SPHINXBUILD=],
+ [AS_IF([test -x "$SPHINXBUILD"],
+ [AC_MSG_CHECKING([Checking to see if $SPHINXBUILD is recent])
+ junk=`$SPHINXBUILD --version &> version_file`
+ AS_IF([test $? -eq 0],
+ [ax_sphinx_build_version=`head -1 version_file`],
+ [junk=`$SPHINXBUILD &> version_file`
+ ax_sphinx_build_version=`head -1 version_file`
+ rm version_file
+ AC_MSG_RESULT([$SPHINXBUILD is version "$ax_sphinx_build_version"])
+ $SPHINXBUILD -Q -C -b man -d conftest.d . . >/dev/null 2>&1
+ AS_IF([test $? -eq 0], ,[SPHINXBUILD=])
+ rm -rf conftest.d ])
+ ])
+ rm -f version_file
+ ])
- AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build], [:])
- AS_IF([test "x${SPHINXBUILD}" != "x:"],[
- AC_CACHE_CHECK([if sphinx is new enough],[ac_cv_recent_sphinx],[
-
- ${SPHINXBUILD} -Q -C -b man -d conftest.d . . >/dev/null 2>&1
- AS_IF([test $? -eq 0],[ac_cv_recent_sphinx=yes],
- [ac_cv_recent_sphinx=no])
- rm -rf conftest.d
- ])
- ])
-
- AM_CONDITIONAL([HAVE_DPKG_GENSYMBOLS],[test "x${DPKG_GENSYMBOLS}" != "x:"])
- AM_CONDITIONAL([HAVE_SPHINX],[test "x${SPHINXBUILD}" != "x:"])
- AM_CONDITIONAL([HAVE_RECENT_SPHINX],[test "x${ac_cv_recent_sphinx}" = "xyes"])
-])
+ AS_IF([test -n "${SPHINXBUILD}"],
+ [AC_SUBST([SPHINXBUILD])
+ ifelse([$1], , :, [$1])],
+ [ifelse([$2], , :, [$2])])
+ ])
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
-#serial 19
+#serial 20
AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD])
AC_DEFUN([AX_PTHREAD], [
ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags"
;;
- darwin12*)
- ax_pthread_flags="$ax_pthread_flags"
- ;;
-
darwin*)
ax_pthread_flags="-pthread $ax_pthread_flags"
;;
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
- # More AIX lossage: must compile with xlc_r or cc_r
- if test x"$GCC" != xyes; then
- AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
- else
- PTHREAD_CC=$CC
+ # More AIX lossage: compile with *_r variant
+ if test "x$GCC" != xyes; then
+ case $host_os in
+ aix*)
+ AS_CASE(["x/$CC"],
+ [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6],
+ [#handle absolute path differently from PATH based program lookup
+ AS_CASE(["x$CC"],
+ [x/*],
+ [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])],
+ [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])])
+ ;;
+ esac
fi
-else
- PTHREAD_CC="$CC"
fi
+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"
+
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_CC)
# SYNOPSIS
#
# AX_UUID()
+# AX_UUID_GENERATE_TIME()
# AX_UUID_GENERATE_TIME_SAFE()
#
# DESCRIPTION
#
-# Check for uuid, and uuid_generate_time_safe support.
+# Check for uuid, uuid_generate_time, and uuid_generate_time_safe support.
#
# LICENSE
#
-# Copyright (c) 2012 Brian Aker <brian@tangent.org>
+# Copyright (c) 2012-2013 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 6
+#serial 7
AC_DEFUN([AX_UUID],
[AC_PREREQ([2.63])dnl
AM_CONDITIONAL([HAVE_LIBUUID],[test "x$ax_libuuid" = xyes])
])
+ AC_DEFUN([AX_UUID_GENERATE_TIME],
+ [AC_PREREQ([2.63])dnl
+ AC_REQUIRE([AX_UUID])dnl
+ AC_CACHE_CHECK([for uuid_generate_time],
+ [ax_cv_uuid_generate_time],
+ [AX_SAVE_FLAGS
+ LIBS="$LIBUUID_LIB $LIBS"
+ AC_LANG_PUSH([C])
+ AC_RUN_IFELSE([
+ AC_LANG_PROGRAM([#include <uuid/uuid.h>],[
+ uuid_t out;
+ uuid_generate_time(out);
+ ])],
+ [ax_cv_uuid_generate_time=yes],
+ [ax_cv_uuid_generate_time=no],
+ [AC_MSG_WARN([test program execution failed])])
+ AC_LANG_POP
+ AX_RESTORE_FLAGS
+ ])
+
+ AS_IF([test "$ax_cv_uuid_generate_time" = yes],
+ [AC_DEFINE([HAVE_UUID_GENERATE_TIME],[1],[Define if uuid_generate_time is present in uuid/uuid.h.])],
+ [AC_DEFINE([HAVE_UUID_GENERATE_TIME],[0],[Define if uuid_generate_time is present in uuid/uuid.h.])])
+ ])
+
AC_DEFUN([AX_UUID_GENERATE_TIME_SAFE],
[AC_PREREQ([2.63])dnl
AC_REQUIRE([AX_UUID])dnl
-dnl Copyright (C) 2011 Brian Aker (brian@tangent.org)
+# Copyright (C) 2011 Brian Aker (brian@tangent.org)
+#
+# serial 2
-AC_DEFUN([_SEARCH_LIBHIREDIS],[
- AC_REQUIRE([AX_CHECK_LIBRARY])
+AC_DEFUN([_SEARCH_HIREDIS],
+ [AC_REQUIRE([AX_CHECK_LIBRARY])
- AS_IF([test "x$ac_enable_hires" = "xyes"],[
- AX_CHECK_LIBRARY([LIBHIREDIS], [hiredis/hiredis.h], [hiredis],
- [
- LIBHIREDIS_LDFLAGS="-lhiredis"
- AC_DEFINE([HAVE_HIREDIS], [1], [If Hiredis available])
- ],
- [
- AC_DEFINE([HAVE_HIREDIS], [0], [If Hiredis is available])
- ac_enable_hires="no"
- ])
+ AS_IF([test "x$ac_enable_hiredis" = "xyes"],
+ [hiredis_header="hiredis/hiredis.h"],
+ [hiredis_header="does_not_exist"])
- ],
- [
- AC_DEFINE([HAVE_HIREDIS], [0], [If Hiredis is available])
- ])
+ AX_CHECK_LIBRARY([HIREDIS],[$hiredis_header],[hiredis],,
+ [AC_DEFINE([HAVE_HIREDIS],[0],[Define to 1 if HIREDIS is found])])
- AM_CONDITIONAL(HAVE_HIREDIS, [test "x$ac_cv_lib_hiredis_main" = "xyes"])
- ])
+ AS_IF([test "x$ax_cv_have_HIREDIS" = xno],[ac_enable_hiredis="no"])
+ ])
-AC_DEFUN([AX_HAVE_LIBHIREDIS],[
+ AC_DEFUN([AX_ENABLE_LIBHIREDIS],
+ [AC_ARG_ENABLE([hiredis],
+ [AS_HELP_STRING([--disable-hiredis],
+ [Build with hiredis support @<:@default=on@:>@])],
+ [ac_enable_hiredis="$enableval"],
+ [ac_enable_hiredis="yes"])
- AC_ARG_ENABLE([hires],
- [AS_HELP_STRING([--disable-hires],
- [Build with hires support @<:@default=on@:>@])],
- [ac_enable_hires="$enableval"],
- [ac_enable_hires="yes"])
-
- _SEARCH_LIBHIREDIS
-])
+ _SEARCH_HIREDIS
+ ])
# included from Top Level Makefile.am
# All paths should be given relative to the root
-if HAVE_RECENT_SPHINX
-if IS_VCS_CHECKOUT
-
-dist-hook: man
-
# Build rule for documentation
-$(dist_man_MANS): man
-
-BUILT_SOURCES+= $(dist_man_MANS)
+$(dist_man_MANS): $(top_srcdir)/configure.ac
+ $(MAKE) $(AM_MAKEFLAGS) man
-endif
-endif
+.NOTPARALLEL: $(dist_man_MANS)
dist_man_MANS+= man/memaslap.1
dist_man_MANS+= man/memcapable.1
check_PROGRAMS+= tests/memdump
noinst_PROGRAMS+= tests/memdump
+test-memcp: tests/memcp
+ tests/memcp
+
+gdb-memcp: tests/memcp
+ @$(GDB_COMMAND) tests/memcp
+
test-memstat: tests/memstat
tests/memstat
valgrind-memtouch: tests/memtouch
@$(VALGRIND_COMMAND) tests/memtouch
+
+test-memdump: tests/memdump
+ tests/memdump
+
+gdb-memdump: tests/memdump
+ @$(GDB_COMMAND) tests/memdump
+
+valgrind-memdump: tests/memdump
+ @$(VALGRIND_COMMAND) tests/memdump
pahole-mem: tests/testapp
@$(PAHOLE_COMMAND) tests/testapp
+pahole-hash: tests/testhashkit
+ @$(PAHOLE_COMMAND) tests/testhashkit
+
gdb-mem: tests/libmemcached-1.0/testapp
@$(GDB_COMMAND) tests/libmemcached-1.0/testapp
helgrind-hashplus: tests/hash_plus
@$(HELGRIND_COMMAND) tests/hash_plus
+
+drd-mem: tests/libmemcached-1.0/testapp
+ @$(DRD_COMMAND) tests/libmemcached-1.0/testapp
+
+drd-cycle: tests/cycle
+ @$(DRD_COMMAND) tests/cycle
*
* Libmemcached library
*
- * Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ * Copyright (C) 2012-2013 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
key_buffer.resize(padding +1);
memset(&key_buffer[0], 'x', padding);
-#ifdef HAVE_UUID_UUID_H
+#if defined(HAVE_UUID_UUID_H) && HAVE_UUID_UUID_H
if (HAVE_UUID_UUID_H)
{
uuid_t out;
{"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 },
+ {"memcached_increment_with_initial(0)", true, (test_callback_fn*)increment_with_initial_test },
+ {"memcached_increment_with_initial(999)", true, (test_callback_fn*)increment_with_initial_999_test },
{"decrement", false, (test_callback_fn*)decrement_test },
- {"decrement_with_initial", true, (test_callback_fn*)decrement_with_initial_test },
+ {"memcached_decrement_with_initial(3)", true, (test_callback_fn*)decrement_with_initial_test },
+ {"memcached_decrement_with_initial(999)", true, (test_callback_fn*)decrement_with_initial_999_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 },
test_compare(MEMCACHED_SUCCESS,
memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY, true));
test_compare(query_id, memcached_query_id(memc_clone)); // We should not increase the query_id for memcached_behavior_set()
+ ASSERT_TRUE(memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_VERIFY_KEY));
/* All keys are valid in the binary protocol (except for length) */
if (memcached_behavior_get(memc_clone, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) == false)
return TEST_SUCCESS;
}
-test_return_t increment_with_initial_test(memcached_st *memc)
+static test_return_t __increment_with_initial_test(memcached_st *memc, uint64_t initial)
{
- test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
-
uint64_t new_number;
- uint64_t initial= 0;
test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
- test_compare(MEMCACHED_SUCCESS,
- memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
- test_compare(new_number, initial);
+ if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
+ {
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
+ test_compare(new_number, initial);
- test_compare(MEMCACHED_SUCCESS,
- memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
- test_compare(new_number, (initial +1));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
+ test_compare(new_number, (initial +1));
+ }
+ else
+ {
+ test_compare(MEMCACHED_INVALID_ARGUMENTS,
+ memcached_increment_with_initial(memc, test_literal_param("number"), 1, initial, 0, &new_number));
+ }
return TEST_SUCCESS;
}
+test_return_t increment_with_initial_test(memcached_st *memc)
+{
+ return __increment_with_initial_test(memc, 0);
+}
+
+test_return_t increment_with_initial_999_test(memcached_st *memc)
+{
+ return __increment_with_initial_test(memc, 999);
+}
+
test_return_t decrement_test(memcached_st *memc)
{
test_compare(return_value_based_on_buffering(memc),
return TEST_SUCCESS;
}
-test_return_t decrement_with_initial_test(memcached_st *memc)
+static test_return_t __decrement_with_initial_test(memcached_st *memc, uint64_t initial)
{
test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
- uint64_t initial= 3;
-
test_compare(MEMCACHED_SUCCESS, memcached_flush_buffers(memc));
uint64_t new_number;
return TEST_SUCCESS;
}
+test_return_t decrement_with_initial_test(memcached_st *memc)
+{
+ return __decrement_with_initial_test(memc, 3);
+}
+
+test_return_t decrement_with_initial_999_test(memcached_st *memc)
+{
+ return __decrement_with_initial_test(memc, 999);
+}
+
test_return_t increment_by_key_test(memcached_st *memc)
{
const char *master_key= "foo";
test_return_t increment_with_initial_by_key_test(memcached_st *memc)
{
- test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
-
uint64_t new_number;
const char *master_key= "foo";
const char *key= "number";
uint64_t initial= 0;
- test_compare(MEMCACHED_SUCCESS,
- memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
- key, strlen(key),
- 1, initial, 0, &new_number));
- test_compare(new_number, initial);
+ if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
+ {
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
+ key, strlen(key),
+ 1, initial, 0, &new_number));
+ test_compare(new_number, initial);
- test_compare(MEMCACHED_SUCCESS,
- memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
- key, strlen(key),
- 1, initial, 0, &new_number));
- test_compare(new_number, (initial +1));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
+ key, strlen(key),
+ 1, initial, 0, &new_number));
+ test_compare(new_number, (initial +1));
+ }
+ else
+ {
+ test_compare(MEMCACHED_INVALID_ARGUMENTS,
+ memcached_increment_with_initial_by_key(memc, master_key, strlen(master_key),
+ key, strlen(key),
+ 1, initial, 0, &new_number));
+ }
return TEST_SUCCESS;
}
uint64_t new_number;
uint64_t initial= 3;
- test_compare(MEMCACHED_SUCCESS,
- memcached_decrement_with_initial_by_key(memc,
- test_literal_param("foo"),
- test_literal_param("number"),
- 1, initial, 0, &new_number));
- test_compare(new_number, initial);
+ if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL))
+ {
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_decrement_with_initial_by_key(memc,
+ test_literal_param("foo"),
+ test_literal_param("number"),
+ 1, initial, 0, &new_number));
+ test_compare(new_number, initial);
- test_compare(MEMCACHED_SUCCESS,
- memcached_decrement_with_initial_by_key(memc,
- test_literal_param("foo"),
- test_literal_param("number"),
- 1, initial, 0, &new_number));
- test_compare(new_number, (initial - 1));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_decrement_with_initial_by_key(memc,
+ test_literal_param("foo"),
+ test_literal_param("number"),
+ 1, initial, 0, &new_number));
+ test_compare(new_number, (initial - 1));
+ }
+ else
+ {
+ test_compare(MEMCACHED_INVALID_ARGUMENTS,
+ memcached_decrement_with_initial_by_key(memc,
+ test_literal_param("foo"),
+ test_literal_param("number"),
+ 1, initial, 0, &new_number));
+ }
return TEST_SUCCESS;
}
test_compare(memcached_behavior_set(&memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5), MEMCACHED_SUCCESS);
- test_compare(memcached_behavior_get(&memc, MEMCACHED_BEHAVIOR_KETAMA_HASH), MEMCACHED_HASH_MD5);
+ test_compare(memcached_hash_t(memcached_behavior_get(&memc, MEMCACHED_BEHAVIOR_KETAMA_HASH)), MEMCACHED_HASH_MD5);
test_compare(memcached_behavior_set_distribution(&memc, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY), MEMCACHED_SUCCESS);
const char *key= "mine";
char *value;
- /* Make sure be default none exists */
+ /* Make sure by default none exists */
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
test_null(value);
test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
test_true(value);
- test_memcmp(value, key, 4);
+ test_memcmp(value, key, strlen(key));
test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
/* Test that we can turn it off */
value= (char *)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
test_true(value);
test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
- test_memcmp(value, key, 4);
+ test_memcmp(value, key, strlen(key));
/* Set to Zero, and then Set to something too large */
{
test_compare(MEMCACHED_SUCCESS,
memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, NULL));
- value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
- test_null(value);
- test_compare(MEMCACHED_SUCCESS, rc);
+ ASSERT_NULL_(memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc), "Setting namespace to NULL did not work");
/* Test a long key for failure */
/* TODO, extend test to determine based on setting, what result should be */
{
memcached_return_t rc;
const char *key= "mine";
- char *value;
// Make sure we default to a null namespace
- value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
- test_null(value);
+ char* value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
+ ASSERT_NULL_(value, "memc had a value for namespace when none should exist");
test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
/* Test a clean set */
memcached_callback_set(memc, MEMCACHED_CALLBACK_NAMESPACE, (void *)key));
value= (char*)memcached_callback_get(memc, MEMCACHED_CALLBACK_NAMESPACE, &rc);
- test_true(value);
- test_memcmp(value, key, 4);
+ ASSERT_TRUE(value);
+ test_memcmp(value, key, strlen(key));
test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
return TEST_SUCCESS;
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 decrement_with_initial_999_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 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 increment_with_initial_999_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);
vector<char> return_value;
/* We need to empty the server before we continue the test */
+ bool flush_res= memc.flush();
+ if (flush_res == false)
+ {
+ std::string error_string;
+ ASSERT_TRUE(memc.error(error_string));
+ Error << error_string;
+ }
test_true(memc.flush());
test_true(memc.mget(keys));
static void *world_create(libtest::server_startup_st& servers, test_return_t& error)
{
- if (libtest::has_memcached() == false)
- {
- error= TEST_SKIPPED;
- return NULL;
- }
+ SKIP_UNLESS(libtest::has_libmemcached());
if (servers.sasl())
{
- if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
- {
- error= TEST_SKIPPED;
- return NULL;
- }
+ SKIP_UNLESS(libtest::has_libmemcached_sasl());
- if (HAVE_MEMCACHED_SASL_BINARY == 0)
- {
- error= TEST_SKIPPED;
- return NULL;
- }
-
// Assume we are running under valgrind, and bail
if (getenv("TESTS_ENVIRONMENT"))
{
static bool world_destroy(void *object)
{
libmemcached_test_container_st *container= (libmemcached_test_container_st *)object;
+#if 0
#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
if (LIBMEMCACHED_WITH_SASL_SUPPORT)
{
sasl_done();
}
+#endif
#endif
delete container;
static bool world_destroy(void *object)
{
libmemcached_test_container_st *container= (libmemcached_test_container_st *)object;
+
+#if 0
#if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT
if (LIBMEMCACHED_WITH_SASL_SUPPORT)
{
sasl_done();
}
+#endif
#endif
delete container;
using namespace libtest;
#ifndef __INTEL_COMPILER
-#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+# pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
static std::string executable;
static test_return_t quiet_test(void *)
{
- const char *args[]= { "-q", 0 };
+ char buffer[1024];
+ snprintf(buffer, sizeof(buffer), "%d", int(get_free_port()));
+ const char *args[]= { "-p", buffer, "-q", 0 };
test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "%d", int(default_port()));
- const char *args[]= { "-p", buffer, " -a ", 0 };
+ const char *args[]= { "-p", buffer, "-a", 0 };
test_true(exec_cmdline(executable, args, true) <= EXIT_FAILURE);
{
char buffer[1024];
snprintf(buffer, sizeof(buffer), "%d", int(default_port()));
- const char *args[]= { "-p", buffer, " -b ", 0 };
+ const char *args[]= { "-p", buffer, "-b", 0 };
test_true(exec_cmdline(executable, args, true) <= EXIT_FAILURE);
{0, 0, 0, 0}
};
-static void *world_create(server_startup_st& servers, test_return_t& error)
+static void *world_create(server_startup_st& servers, test_return_t&)
{
- if (libtest::has_memcached() == false)
- {
- error= TEST_SKIPPED;
- return NULL;
- }
-
- if (server_startup(servers, "memcached", libtest::default_port(), NULL) == false)
- {
- error= TEST_SKIPPED;
- }
+ SKIP_UNLESS(libtest::has_memcached());
+
+ SKIP_UNLESS(server_startup(servers, "memcached", libtest::default_port(), NULL));
return &servers;
}
static test_return_t cat_test(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
const char *args[]= { buffer, "foo", 0 };
- memcached_st *memc= memcached(buffer, strlen(buffer));
+ memcached_st *memc= memcached(buffer, length);
test_true(memc);
test_compare(MEMCACHED_SUCCESS,
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
+ snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
static test_return_t NOT_FOUND_test(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
const char *args[]= { buffer, "foo", 0 };
- memcached_st *memc= memcached(buffer, strlen(buffer));
- test_true(memc);
+ memcached_st *memc= memcached(buffer, length);
+ ASSERT_TRUE(memc);
test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0));
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_NOTFOUND, rc);
+ snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
#include <libtest/test.hpp>
#include <libmemcached-1.0/memcached.h>
+#include <sys/stat.h>
+
using namespace libtest;
#ifndef __INTEL_COMPILER
return TEST_SUCCESS;
}
+#if 0
static test_return_t server_test(void *)
{
+ int fd;
+ std::string tmp_file= create_tmpfile("memcp", fd);
+ ASSERT_TRUE(tmp_file.c_str());
+ struct stat buf;
+ ASSERT_EQ(fstat(fd, &buf), 0);
+ ASSERT_EQ(buf.st_size, 0);
+
char buffer[1024];
snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
- const char *args[]= { buffer, 0 };
+ const char *args[]= { buffer, tmp_file.c_str(), 0 };
test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
+ close(fd);
+ unlink(tmp_file.c_str());
return TEST_SUCCESS;
}
+#endif
test_st memcp_tests[] ={
{"--help", true, help_test },
+#if 0
{"--server_test", true, server_test },
+#endif
{0, 0, 0}
};
static test_return_t FOUND_test(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
const char *args[]= { buffer, 0 };
- memcached_st *memc= memcached(buffer, strlen(buffer));
+ memcached_st *memc= memcached(buffer, length);
test_true(memc);
test_compare(MEMCACHED_SUCCESS,
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
+ length= snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
test_true(exec_cmdline(executable, args, true) <= EXIT_FAILURE);
memcached_free(memc);
{0, 0, 0, 0}
};
-static void *world_create(server_startup_st& servers, test_return_t& error)
+static void *world_create(server_startup_st& servers, test_return_t&)
{
- if (libtest::has_memcached() == false)
- {
- error= TEST_SKIPPED;
- return NULL;
- }
-
- if (server_startup(servers, "memcached", libtest::default_port(), NULL) == false)
- {
- error= TEST_FAILURE;
- return NULL;
- }
+ SKIP_UNLESS(libtest::has_memcached());
+
+ ASSERT_TRUE(server_startup(servers, "memcached", libtest::default_port(), NULL));
return &servers;
}
static test_return_t exist_test(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
const char *args[]= { buffer, "foo", 0 };
- memcached_st *memc= memcached(buffer, strlen(buffer));
+ memcached_st *memc= memcached(buffer, length);
test_true(memc);
test_compare(MEMCACHED_SUCCESS,
static test_return_t NOT_FOUND_test(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
const char *args[]= { buffer, "foo", 0 };
- memcached_st *memc= memcached(buffer, strlen(buffer));
- test_true(memc);
+ memcached_st *memc= memcached(buffer, length);
+ ASSERT_TRUE(memc);
test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0));
static test_return_t check_version(void*)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- memcached_st *memc= memcached(buffer, strlen(buffer));
- test_true(memc);
+ int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ memcached_st *memc= memcached(buffer, length);
+ ASSERT_TRUE(memc);
test_return_t result= TEST_SUCCESS;
if (libmemcached_util_version_check(memc, 1, 4, 8) == false)
static test_return_t ping_TEST(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
const char *args[]= { buffer, 0 };
test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
static test_return_t NOT_FOUND_TEST(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=nonexist.libmemcached.org:%d", int(default_port()));
+ snprintf(buffer, sizeof(buffer), "--servers=nonexist.libmemcached.org:%d", int(default_port()));
const char *args[]= { buffer, 0 };
test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
test_null(memcached_get(memc, test_literal_param("foo"), 0, 0, &rc));
test_compare(MEMCACHED_SUCCESS, rc);
+ char memrm_buffer[1024];
+ snprintf(memrm_buffer, sizeof(memrm_buffer), "--servers=localhost:%d", int(default_port()));
const char *args[]= { buffer, "foo", 0 };
test_compare(EXIT_SUCCESS, exec_cmdline(executable, args, true));
static test_return_t multiple_NOT_FOUND_TEST(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
const char *args[]= { buffer, "protocols", "foo", "mine", "bar", "dog", "cat", "foo", "mine",
"eye", "for", "the", "to", "not", "know", "what", "I", "should", "be", "doing", 0 };
static test_return_t touch_test(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- memcached_st *memc= memcached(buffer, strlen(buffer));
+ memcached_st *memc= memcached(buffer, length);
test_true(memc);
test_compare(MEMCACHED_SUCCESS,
static test_return_t NOT_FOUND_test(void *)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- memcached_st *memc= memcached(buffer, strlen(buffer));
+ int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ memcached_st *memc= memcached(buffer, length);
test_true(memc);
test_compare(MEMCACHED_SUCCESS, memcached_flush(memc, 0));
test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("foo")));
- snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
+ length= snprintf(buffer, sizeof(buffer), "--servers=localhost:%d", int(default_port()));
const char *args[]= { "--expire=30", buffer, "foo", 0 };
test_compare(EXIT_FAILURE, exec_cmdline(executable, args, true));
static test_return_t check_version(void*)
{
char buffer[1024];
- snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
- memcached_st *memc= memcached(buffer, strlen(buffer));
+ int length= snprintf(buffer, sizeof(buffer), "--server=localhost:%d", int(default_port()));
+ memcached_st *memc= memcached(buffer, length);
test_true(memc);
test_return_t result= TEST_SUCCESS;
--- /dev/null
+m4_define([VERSION_NUMBER], [1.0.18])