Merge lp:~brianaker/libmemcached/1164440 Build: jenkins-Libmemcached-371
authorContinuous Integration <ci@tangent.org>
Fri, 11 Oct 2013 11:47:41 +0000 (04:47 -0700)
committerContinuous Integration <ci@tangent.org>
Fri, 11 Oct 2013 11:47:41 +0000 (04:47 -0700)
102 files changed:
.bzrignore
ChangeLog
Makefile.am
bootstrap.sh
clients/generator.cc
clients/memcapable.cc
clients/memcp.cc
clients/memdump.cc
clients/memslap.cc
clients/memtouch.cc
clients/ms_setting.h
configure.ac
docs/include.am
docs/memcached_auto.rst
libhashkit/aes.cc
libmemcached-1.0/defaults.h
libmemcached-1.0/deprecated_types.h
libmemcached/auto.cc
libmemcached/connect.cc
libmemcached/error.cc
libmemcached/get.cc
libmemcached/hosts.cc
libmemcached/io.cc
libmemcached/io.hpp
libmemcached/key.cc
libmemcached/key.hpp
libmemcached/response.cc
libmemcached/stats.cc
libmemcached/string.cc
libmemcached/touch.cc
libtest/cmdline.cc
libtest/cmdline.h
libtest/collection.cc
libtest/common.h
libtest/core.cc
libtest/cpu.cc
libtest/dns.cc
libtest/dream.cc
libtest/drizzled.cc
libtest/exception.cc [new file with mode: 0644]
libtest/exception.hpp [new file with mode: 0644]
libtest/exception/disconnected.hpp [new file with mode: 0644]
libtest/exception/fatal.cc [new file with mode: 0644]
libtest/exception/fatal.hpp [new file with mode: 0644]
libtest/failed.h [deleted file]
libtest/fatal.cc [deleted file]
libtest/fatal.hpp [deleted file]
libtest/framework.cc
libtest/framework.h
libtest/has.cc
libtest/has.hpp
libtest/http.cc
libtest/include.am
libtest/lite.h
libtest/main.cc
libtest/memcached.cc
libtest/memcached.hpp
libtest/result.cc
libtest/result.hpp
libtest/result/base.hpp
libtest/result/fail.hpp
libtest/result/fatal.hpp [deleted file]
libtest/result/skip.hpp
libtest/result/success.hpp
libtest/run.gdb
libtest/server_container.cc
libtest/signal.cc
libtest/test.hpp
libtest/tmpfile.cc
libtest/tmpfile.hpp
libtest/unittest.cc
libtest/valgrind.h [new file with mode: 0644]
libtest/vchar.cc
libtest/vchar.hpp
libtest/yatl.m4
m4/ax_append_to_file.m4
m4/ax_debug.m4
m4/ax_harden_compiler_flags.m4
m4/ax_platform.m4
m4/ax_prog_sphinx_build.m4
m4/ax_pthread.m4
m4/ax_uuid.m4
m4/hiredis.m4
man/include.am
tests/cli.am
tests/include.am
tests/keys.hpp
tests/libmemcached-1.0/all_tests.h
tests/libmemcached-1.0/mem_functions.cc
tests/libmemcached-1.0/mem_functions.h
tests/libmemcached-1.0/plus.cpp
tests/libmemcached_world.h
tests/libmemcached_world_socket.h
tests/memcapable.cc
tests/memcat.cc
tests/memcp.cc
tests/memdump.cc
tests/memexist.cc
tests/memping.cc
tests/memrm.cc
tests/memtouch.cc
version.m4 [new file with mode: 0644]

index 23517686dc27da06f05f812792a28c34b03b8136..652e9d91312315becbd2101f7a2769ed3b7f736d 100644 (file)
@@ -1,3 +1,5 @@
+*.log
+*.trs
 *.exe
 *.gz
 *.lo
@@ -72,6 +74,7 @@ docs/text
 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
@@ -90,11 +93,13 @@ libmemcached/memcached_configure.h
 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 
@@ -142,6 +147,7 @@ tests/memdump
 tests/memerror
 tests/memexist
 tests/memflush
+tests/memping
 tests/memplus
 tests/memrm
 tests/memslap
@@ -158,5 +164,3 @@ tests/testudp
 tests/var/
 tmp_chroot
 unittests/unittests
-libhashkit/hashkitcon.h
-libtest/yatlcon.h
index 4d20c93c751f79a0cc66be68f7aa96e7ccfcad7d..5fbed1604d924502373be1e7b4c50f8d78f6d42b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+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.
index a359ac00d229e52e17889078206e76b86a410afd..cc65cb781bbbb5fbe9e9f1101397d99a8886eda2 100644 (file)
@@ -1,6 +1,7 @@
 # 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 =
@@ -18,6 +19,7 @@ noinst_PROGRAMS =
 include_HEADERS =
 nobase_include_HEADERS =
 check_PROGRAMS =
+check_LTLIBRARIES=
 EXTRA_HEADERS =
 BUILT_SOURCES=
 EXTRA_DIST=
@@ -140,6 +142,7 @@ maintainer-clean-local:
        -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
index 6dee9557d91616db2a5204ecbf2fc31f0b35c319..abb117f7a21f35d8a01e94049255030e96acd3c8 100755 (executable)
 #   WARNINGS
 #
 
+use_banner ()
+{
+  echo "#####################################################################################"
+  echo "#"
+  echo "#"
+  echo "#"
+  echo "#    TARGET:$1"
+  echo "#"
+  echo "#"
+  echo "#"
+  echo "#####################################################################################"
+}
+
 command_not_found_handle ()
 {
   warn "$@: command not found"
@@ -60,27 +73,27 @@ command_not_found_handle ()
   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
@@ -88,10 +101,10 @@ function nassert ()
   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
@@ -99,7 +112,7 @@ function assert ()
   fi
 }
 
-function assert_file ()
+assert_file ()
 {
   if [ ! -f "$1" ]; then
     echo "$BASH_SOURCE:$BASH_LINENO: assert($1) does not exist: $2" >&2
@@ -107,7 +120,7 @@ function assert_file ()
   fi
 }
 
-function assert_no_file ()
+assert_no_file ()
 {
   if [ -f "$1" ]; then
     echo "$BASH_SOURCE:$BASH_LINENO: assert($1) file exists: $2" >&2
@@ -115,7 +128,7 @@ function assert_no_file ()
   fi
 }
 
-function assert_no_directory ()
+assert_no_directory ()
 {
   if [ -d "$1" ]; then
     echo "$BASH_SOURCE:$BASH_LINENO: assert($1) directory exists: $2" >&2
@@ -123,7 +136,7 @@ function assert_no_directory ()
   fi
 }
 
-function assert_exec_file ()
+assert_exec_file ()
 {
   if [ ! -f "$1" ]; then
     echo "$BASH_SOURCE:$BASH_LINENO: assert($1) does not exist: $2" >&2
@@ -136,16 +149,16 @@ function assert_exec_file ()
   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
@@ -153,9 +166,9 @@ function rebuild_host_os ()
 
 # 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'
@@ -185,12 +198,18 @@ function set_VENDOR_DISTRIBUTION ()
 }
 
 # 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'
           ;;
@@ -200,10 +219,12 @@ function set_VENDOR_RELEASE ()
         mountain)
           VENDOR_RELEASE='mountain'
           ;;
-        10.8*)
+        10.8.*)
+          echo "mountain_lion"
           VENDOR_RELEASE='mountain_lion'
           ;;
         *)
+          echo $VENDOR_RELEASE
           VENDOR_RELEASE='unknown'
           ;;
       esac
@@ -217,12 +238,17 @@ function set_VENDOR_RELEASE ()
     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)
@@ -239,9 +265,9 @@ function set_VENDOR_RELEASE ()
 
 
 #  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)
@@ -282,8 +308,8 @@ function set_VENDOR ()
       ;;
   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
@@ -307,37 +333,37 @@ function set_VENDOR ()
 
 }
 
-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'
@@ -347,13 +373,13 @@ function determine_target_platform ()
   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
 
@@ -365,42 +391,46 @@ function run_configure ()
   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
@@ -414,25 +444,27 @@ function run_configure ()
   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!"
@@ -471,7 +503,7 @@ function save_BUILD ()
   fi
 }
 
-function restore_BUILD ()
+restore_BUILD ()
 {
   if [[ -n "$OLD_CONFIGURE" ]]; then
     CONFIGURE=$OLD_CONFIGURE
@@ -502,37 +534,8 @@ function restore_BUILD ()
   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
@@ -552,25 +555,35 @@ function make_valgrind ()
 
   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"
@@ -595,10 +608,9 @@ function make_install_system ()
   fi
 
   restore_BUILD
-  safe_popd
 }
 
-function make_darwin_malloc ()
+make_darwin_malloc ()
 {
   run_configure_if_required
 
@@ -616,35 +628,24 @@ function make_darwin_malloc ()
   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=$?
@@ -661,7 +662,7 @@ function check_mingw ()
   return 0
 }
 
-function check_clang ()
+check_clang ()
 {
   command_exists 'clang'
   ret=$?
@@ -672,7 +673,7 @@ function check_clang ()
   return 0
 }
 
-function check_clang_analyzer ()
+check_clang_analyzer ()
 {
   command_exists 'scan-build'
   ret=$?
@@ -683,7 +684,7 @@ function check_clang_analyzer ()
   return 0
 }
 
-function make_skeleton ()
+make_skeleton ()
 {
   run_configure
   ret=$?
@@ -716,7 +717,7 @@ function make_skeleton ()
   return $ret
 }
 
-function make_for_mingw ()
+make_for_mingw ()
 {
   if ! check_mingw; then
     return 1
@@ -743,7 +744,7 @@ function make_for_mingw ()
   return $ret
 }
 
-function make_for_clang ()
+make_for_clang ()
 {
   if ! check_clang; then
     return 1
@@ -771,7 +772,7 @@ function make_for_clang ()
   return $ret
 }
 
-function make_for_clang_analyzer ()
+make_for_clang_analyzer ()
 {
   if ! check_clang; then
     return 1
@@ -792,25 +793,21 @@ function make_for_clang_analyzer ()
 
   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
@@ -822,24 +819,50 @@ function check_for_jenkins ()
   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
@@ -850,7 +873,11 @@ function make_for_continuus_integration ()
   # 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'
@@ -861,71 +888,27 @@ function make_for_continuus_integration ()
   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'
@@ -933,7 +916,7 @@ function make_install_html ()
   make_target 'install-html'
 }
 
-function make_gdb ()
+make_gdb ()
 {
   save_BUILD
 
@@ -976,7 +959,7 @@ function make_gdb ()
 
 # $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"
@@ -988,7 +971,7 @@ function make_target ()
   fi
 
   if [ -n "$TESTS_ENVIRONMENT" ]; then
-    if $VERBOSE; then
+    if $verbose; then
       echo "TESTS_ENVIRONMENT=$TESTS_ENVIRONMENT"
     fi
   fi
@@ -998,12 +981,14 @@ function make_target ()
   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
@@ -1012,15 +997,18 @@ function make_target ()
   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'
 
@@ -1032,7 +1020,7 @@ function make_rpm ()
   fi
 }
 
-function make_maintainer_clean ()
+make_maintainer_clean ()
 {
   run_configure_if_required
   make_target 'maintainer-clean' 'no_error'
@@ -1043,24 +1031,34 @@ function make_maintainer_clean ()
   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
 
@@ -1071,7 +1069,14 @@ function run_configure_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
@@ -1081,25 +1086,25 @@ function run_autoreconf_if_required ()
   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
 
@@ -1107,39 +1112,41 @@ function run ()
     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
@@ -1148,6 +1155,7 @@ function parse_command_line_options ()
         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";
@@ -1155,8 +1163,8 @@ function parse_command_line_options ()
         exit
         ;;
       v) # verbose
-        VERBOSE_OPTION=true
-        VERBOSE=true
+        opt_verbose=true
+        verbose=true
         ;;
       :)
         echo "Option -$OPTARG requires an argument." >&2
@@ -1172,11 +1180,11 @@ function parse_command_line_options ()
   shift $((OPTIND-1))
 
   if [ -n "$1" ]; then
-    MAKE_TARGET="$@"
+    OPT_TARGET="$@"
   fi
 }
 
-function determine_vcs ()
+determine_vcs ()
 {
   if [[ -d '.git' ]]; then
     VCS_CHECKOUT=git
@@ -1191,38 +1199,37 @@ function determine_vcs ()
   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
@@ -1231,7 +1238,7 @@ function autoreconf_setup ()
     GNU_BUILD_FLAGS="--install --force"
   fi
 
-  if $VERBOSE; then
+  if $verbose; then
     GNU_BUILD_FLAGS="$GNU_BUILD_FLAGS --verbose"
   fi
 
@@ -1247,9 +1254,9 @@ function autoreconf_setup ()
     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"
@@ -1258,14 +1265,14 @@ function autoreconf_setup ()
     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"
@@ -1273,60 +1280,64 @@ function autoreconf_setup ()
         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
 
@@ -1351,11 +1362,11 @@ function print_setup ()
     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
 
@@ -1363,7 +1374,7 @@ function print_setup ()
     echo "--target=$TARGET_OPTION_ARG"
   fi
 
-  if $VERBOSE_OPTION; then
+  if $opt_verbose; then
     echo "--verbose"
   fi
 
@@ -1387,17 +1398,18 @@ function print_setup ()
     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
@@ -1405,7 +1417,7 @@ function print_setup ()
   fi
 }
 
-function make_clean_option ()
+make_clean_option ()
 {
   run_configure_if_required
 
@@ -1418,7 +1430,7 @@ function make_clean_option ()
   fi
 }
 
-function make_for_autoreconf ()
+make_for_autoreconf ()
 {
   if [ -f 'Makefile' ]; then
     make_maintainer_clean
@@ -1429,8 +1441,9 @@ function make_for_autoreconf ()
   assert_no_file 'Makefile'
 }
 
-function check_make_target()
+check_make_target()
 {
+  local ret=0
   case $1 in
     'self')
       ;;
@@ -1474,43 +1487,46 @@ function check_make_target()
       ;;
     '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
@@ -1523,18 +1539,31 @@ function bootstrap ()
     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
@@ -1561,6 +1590,7 @@ function bootstrap ()
         make_default
         ;;
       'clang')
+        make_distclean
         if ! check_clang; then
           die "clang was not found"
         fi
@@ -1570,6 +1600,7 @@ function bootstrap ()
         fi
         ;;
       'clang-analyzer')
+        make_distclean
         if ! check_clang_analyzer; then
           die "clang-analyzer was not found"
         fi
@@ -1582,20 +1613,22 @@ function bootstrap ()
         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
         ;;
@@ -1613,24 +1646,39 @@ function bootstrap ()
   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=
@@ -1642,7 +1690,7 @@ function main ()
   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
@@ -1671,26 +1719,61 @@ function main ()
 
   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 
@@ -1712,7 +1795,7 @@ function set_branch ()
   fi
 }
 
-function merge ()
+merge ()
 {
   if [ -z "$VCS_CHECKOUT" ]; then
     die "Merges require VCS_CHECKOUT."
@@ -1732,21 +1815,21 @@ function merge ()
   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]..
@@ -1758,76 +1841,83 @@ function usage ()
 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 "$@"
index df805153ce29327e51e93d73842fe0d66ba099b4..1f40daedbc6fd21a1b70fac8c6433d1c892d5ded 100644 (file)
@@ -22,6 +22,8 @@
 
 #include "clients/generator.h"
 
+#define KEY_BYTES 20
+
 /* Use this for string generation */
 static const char ALPHANUMERICS[]=
   "0123456789ABCDEFGHIJKLMNOPQRSTWXYZabcdefghijklmnopqrstuvwxyz";
@@ -75,13 +77,13 @@ pairs_st *pairs_generate(uint64_t number_of, size_t value_length)
 
   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)
     {
index b38cf311001cbae26ebe2f12a272fe507828181f..3e9bfabfbf2e9b63136353376b7e7b9359cef4d8 100644 (file)
@@ -110,9 +110,13 @@ static struct addrinfo *lookuphost(const char *hostname, const char *port)
   if (error != 0)
   {
     if (error != EAI_SYSTEM)
+    {
       fprintf(stderr, "getaddrinfo(): %s\n", gai_strerror(error));
+    }
     else
+    {
       perror("getaddrinfo()");
+    }
   }
 
   return ai;
@@ -182,8 +186,9 @@ static memcached_socket_t connect_server(const char *hostname, const char *port)
       }
     }
     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);
   }
@@ -249,7 +254,7 @@ static enum test_return ensure(bool val, const char *expression, const char *fil
   {
     if (verbose)
     {
-      fprintf(stderr, "\n%s:%d: %s", file, line, expression);
+      fprintf(stdout, "\n%s:%d: %s", file, line, expression);
     }
 
     if (do_core)
@@ -334,7 +339,7 @@ static enum test_return retry_read(void *buf, size_t len)
     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;
 
@@ -2074,8 +2079,8 @@ int main(int argc, char **argv)
   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;
@@ -2143,6 +2148,12 @@ int main(int argc, char **argv)
     }
   }
 
+  if (hostname)
+  {
+    fprintf(stderr, "No hostname was provided.\n");
+    return EXIT_FAILURE;
+  }
+
   initialize_sockets();
   sock= connect_server(hostname, port);
   if (sock == INVALID_SOCKET)
@@ -2197,12 +2208,24 @@ int main(int argc, char **argv)
       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);
index 7ae5a1f300126469239f22578f169fd3ea916f22..6c6d1e96fe6142bdac3186445787b3df720c9a49 100644 (file)
@@ -1,5 +1,5 @@
 /* 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.
  *
@@ -85,6 +85,13 @@ int main(int argc, char *argv[])
 {
 
   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);
@@ -129,10 +136,12 @@ int main(int argc, char *argv[])
     {
       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)
     {
@@ -185,7 +194,13 @@ int main(int argc, char *argv[])
     }
 
     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)
@@ -206,27 +221,33 @@ int main(int argc, char *argv[])
             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;
@@ -252,7 +273,6 @@ int main(int argc, char *argv[])
     if (memcached_failed(rc))
     {
       std::cerr << "Error occrrured during memcached_set(): " << memcached_last_error_message(memc) << std::endl;
-      ::close(fd);
       exit_code= EXIT_FAILURE;
     }
 
index 5c6fef29e81d91895528cc2db3a2078e6c3ea04d..48c35d3edf4e0b81e2419913bf32bf02a2d41d20 100644 (file)
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
     }
     else if (argc >= 1 and argv[--argc])
     {
-      opt_servers= strdup(argv[--argc]);
+      opt_servers= strdup(argv[argc]);
     }
 
     if (opt_servers == NULL)
index 05a491fbef9aec5d7a41c94abb69f85cfa64af28..9bc4f2385683583960aa12348c11ecf1633a224f 100644 (file)
@@ -66,6 +66,8 @@
 #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."
 
@@ -336,7 +338,7 @@ void scheduler(memcached_server_st *servers, conclusions_st *conclusion)
 
     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;
     }
 
@@ -432,7 +434,7 @@ void options_parse(int argc, char *argv[])
       break;
 
     case OPT_DEBUG: /* --debug or -d */
-      opt_verbose = OPT_DEBUG;
+      opt_verbose= OPT_DEBUG;
       break;
 
     case OPT_VERSION: /* --version or -V */
@@ -566,7 +568,7 @@ pairs_st *load_create_data(memcached_st *memc, unsigned int number_of,
   /* 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);
index bf68a3dbbebf5a8fed6ee018caf2e38469fe658e..09e0c92a2074fb87479960f81d44d1d25f4b48ac 100644 (file)
@@ -24,7 +24,7 @@
 #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 */
index ec060c4103d9a83930e5881f1cef1d2f29b38516..4bab2b99d259e3b1b15fb4431778a7ea4000a83a 100644 (file)
@@ -47,7 +47,7 @@ typedef struct token_s
 #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 */
index a70143abc8b8a3c51715e0462dc7c46897b11a94..b0870bbfc490758e6dc20372a07d63550379b03b 100644 (file)
@@ -6,7 +6,8 @@
 # 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])
 
@@ -50,6 +51,9 @@ LT_INIT
 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
@@ -100,13 +104,20 @@ PROTOCOL_BINARY_TEST
 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])
index b302681d5ba7aaa0c68d2c9c6c61e301d276b425..f28079f8d6745b36a2912d482b977a703a47ef27 100644 (file)
@@ -19,7 +19,6 @@ clean-docs-check:
        -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"
@@ -86,15 +85,9 @@ latexpdf: latex
 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
@@ -106,9 +99,3 @@ doctest: docs/conf.py
        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
index c3f4c7f5b8343bfe44d6a8e54e0ff78709c37177..0f78e6e7d8d1a7610a358293d81b7d6ad8049cbe 100644 (file)
@@ -53,7 +53,8 @@ MEMCACHED_EXPIRATION_NOT_ADD, the operation will fail. For all other
 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
@@ -62,7 +63,8 @@ MEMCACHED_EXPIRATION_NOT_ADD, the operation will fail. For all other
 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
index c7083a6e4adc3c83676195b59225770ac5876997..12adcae36a7f2b45281e5abe2d85c505284939ad 100644 (file)
@@ -62,7 +62,7 @@ struct aes_key_t {
 
 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];
@@ -79,7 +79,7 @@ aes_key_t* aes_create_key(const char *key, const size_t key_length)
       {
         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);
@@ -96,7 +96,7 @@ aes_key_t* aes_clone_key(aes_key_t *_aes_key)
     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));
@@ -122,8 +122,8 @@ hashkit_string_st* aes_encrypt(aes_key_t *_aes_key,
 
     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;
     }
@@ -132,7 +132,7 @@ hashkit_string_st* aes_encrypt(aes_key_t *_aes_key,
     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));
   }
 
@@ -160,15 +160,15 @@ hashkit_string_st* aes_decrypt(aes_key_t *_aes_key,
 
     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);
index 38c29ba38112a47aab62714e1271b0395e948825..177e18cf6b61ca91121e5ece1a2f5d37fe6ce97d 100644 (file)
@@ -40,6 +40,7 @@
 
 /* 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 */
index 716d3e440e77804ab6e288c532010f7dadf2ecab..0a6df6549b4a536ca4cf5fa0d9f72a939c9f036d 100644 (file)
@@ -57,4 +57,5 @@ typedef memcached_server_fn memcached_server_function;
 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;
 
index 685528f2fae41adc40e8924016fdd3d8b88601c1..eae44a9032f646284424cb7e2267924ab9dbc5e7 100644 (file)
@@ -57,8 +57,13 @@ static void auto_response(memcached_instance_st* instance, const bool reply,  me
     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;
   }
 }
index 659d34078ce2f168523186b447c4ba6db4775cba..b60bbd8ce61ae9768186988e6652d43743f2547d 100644 (file)
@@ -76,7 +76,7 @@ static memcached_return_t connect_poll(memcached_instance_st* server, const int
   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
@@ -760,7 +760,7 @@ static memcached_return_t _memcached_connect(memcached_instance_st* server, cons
   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)
index 266f78b55f16570f041fb27b86b8b51c8bb1fecb..ab17926e67cf27d3941fffd111eec606def06a29 100644 (file)
@@ -36,6 +36,9 @@
  */
 
 #include <libmemcached/common.h>
+
+#include "libmemcached/assert.hpp"
+
 #include <cerrno>
 #include <cstdarg>
 #include <cstdio>
@@ -87,112 +90,134 @@ static void _set(Memcached& memc, memcached_string_t *str, memcached_return_t &r
     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)
   {
@@ -231,13 +256,11 @@ memcached_return_t memcached_set_error(memcached_instance_st& self, memcached_re
 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;
 }
 
@@ -299,17 +322,15 @@ memcached_return_t memcached_set_error(memcached_instance_st& self, memcached_re
   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;
 }
 
@@ -326,14 +347,12 @@ memcached_return_t memcached_set_error(memcached_instance_st& self, memcached_re
 
   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;
 }
 
@@ -528,7 +547,7 @@ const char *memcached_last_error_message(const memcached_st *shell)
   {
     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;
       }
index 1f7e775c3cc57a258eb47d554b263782bf604e26..86d8cf2e13522b625cf35f4acd8a1de23636e733 100644 (file)
@@ -114,7 +114,6 @@ char *memcached_get_by_key(memcached_st *shell,
   {
     *error= MEMCACHED_NOTFOUND;
   }
-
   if (value == NULL)
   {
     if (ptr->get_key_failure and *error == MEMCACHED_NOTFOUND)
@@ -221,12 +220,14 @@ static memcached_return_t __mget_by_key_real(memcached_st *ptr,
 
   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;
@@ -463,6 +464,11 @@ static memcached_return_t simple_binary_mget(memcached_st *ptr,
 
   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.
@@ -502,10 +508,13 @@ static memcached_return_t simple_binary_mget(memcached_st *ptr,
       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);
@@ -514,6 +523,7 @@ static memcached_return_t simple_binary_mget(memcached_st *ptr,
         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;
index 121e8f7c5700b613b64eb217527589f7bce34b1a..75bfbee696875e6c22a7f74756d4a9e3005f3cca 100644 (file)
@@ -591,7 +591,7 @@ memcached_return_t memcached_server_add_parsed(memcached_st *ptr,
                                                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;
index cb8ed5c23199eac47b5665ca6733384216b4ffbb..ba4b347494a6e5261cafb68f7d9825a3e5ec0343 100644 (file)
@@ -99,7 +99,7 @@ static bool repack_input_buffer(memcached_instance_st* instance)
           case EWOULDBLOCK:
 #endif
           case EAGAIN:
-#ifdef TARGET_OS_LINUX
+#ifdef __linux
           case ERESTART:
 #endif
             break; // No IO is fine, we can just move on
@@ -265,7 +265,7 @@ static memcached_return_t io_wait(memcached_instance_st* instance,
     assert_msg(active_fd == -1 , "poll() returned an unexpected value");
     switch (local_errno)
     {
-#ifdef TARGET_OS_LINUX
+#ifdef __linux
     case ERESTART:
 #endif
     case EINTR:
@@ -412,6 +412,11 @@ memcached_return_t memcached_io_wait_for_write(memcached_instance_st* instance)
   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;
@@ -430,7 +435,7 @@ static memcached_return_t _io_fill(memcached_instance_st* instance)
       case EWOULDBLOCK:
 #endif
       case EAGAIN:
-#ifdef TARGET_OS_LINUX
+#ifdef __linux
       case ERESTART:
 #endif
         {
@@ -568,7 +573,7 @@ memcached_return_t memcached_io_slurp(memcached_instance_st* instance)
       case EWOULDBLOCK:
 #endif
       case EAGAIN:
-#ifdef TARGET_OS_LINUX
+#ifdef __linux
       case ERESTART:
 #endif
         if (memcached_success(io_wait(instance, MEM_READ)))
index f3fed3456593fc75230cd7d35753ed4fbb14897f..5480239f25e51313fab892b17f8ebd60f470737e 100644 (file)
@@ -49,7 +49,8 @@ bool memcached_io_writev(memcached_instance_st* ptr,
                          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);
 
index 19d1f957acefc01214ac2ffdaa2198e613d05093..cec0eece64400e83d3645234bca3bbc3e53e29ed 100644 (file)
 
 #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."));
+        }
       }
     }
   }
index ddd557d88aadb903b330ce55a0d03da093b456ce..811a4b7bbd447ca882c5a8cfdae4c8c503e1dc08 100644 (file)
@@ -41,27 +41,3 @@ memcached_return_t memcached_key_test(memcached_st& memc,
                                       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;
-}
index c01d508942ea8ddb199ff41f1f7c066d44066864..ad3c0785dfa24bed1e1bc2b09b1488e08d2f85ee 100644 (file)
@@ -500,6 +500,8 @@ static memcached_return_t binary_read_one_response(memcached_instance_st* instan
   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);
@@ -892,12 +894,19 @@ memcached_return_t memcached_response(memcached_instance_st* instance,
     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
index d70972efdeb52f6af83c3d70df6e56aa863cf5d3..180b0d982204c3e34b089d78c7428eba3dc8b292 100644 (file)
@@ -346,7 +346,7 @@ static memcached_return_t set_data(memcached_stat_st *memc_stat, const char *key
   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;
@@ -456,13 +456,15 @@ char *memcached_stat_get_value(const memcached_st *, memcached_stat_st *memc_sta
   }
   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;
   }
 
@@ -658,8 +660,7 @@ memcached_stat_st *memcached_stat(memcached_st *shell, char *args, memcached_ret
   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;
@@ -746,7 +747,7 @@ memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char
     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))
index ce96b98cba501ef57ff4552ae8045e44d11470ea..b821aca61edcb1de951774d4a81b2ca1f75b19e5 100644 (file)
@@ -281,18 +281,20 @@ char *memcached_string_take_value(memcached_string_st *self)
 {
   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;
index 1f793c5535bbb4854a49bc50c9e22f8c1c0a6b51..91d0825f09a8ab7f822cc6d0bfec9f4ba6880095 100644 (file)
@@ -124,9 +124,9 @@ memcached_return_t memcached_touch_by_key(memcached_st *shell,
     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);
index 741d18d7f7e480d9e3cf9e44c9cec60246d01807..e813eb592c4da4730350ff103ff1994b6bb1f213 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  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
@@ -59,6 +59,7 @@ using namespace libtest;
 #include <unistd.h>
 
 #include <algorithm>
+#include <stdexcept>
 
 #ifndef __USE_GNU
 static char **environ= NULL;
@@ -358,7 +359,7 @@ bool Application::slurp()
     int error;
     switch ((error= errno))
     {
-#ifdef TARGET_OS_LINUX
+#ifdef __linux
     case ERESTART:
 #endif
     case EINTR:
@@ -408,11 +409,10 @@ bool Application::slurp()
 
 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.
@@ -437,15 +437,18 @@ Application::error_t Application::join()
     {
       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: ";
@@ -479,8 +482,20 @@ Application::error_t Application::join()
   }
   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
   {
@@ -573,6 +588,7 @@ bool Application::Pipe::read(libtest::vchar_t& arg)
 void Application::Pipe::nonblock()
 {
   int flags;
+  do 
   {
     flags= fcntl(_pipe_fd[READ], F_GETFL, 0);
   } while (flags == -1 and (errno == EINTR or errno == EAGAIN));
@@ -601,23 +617,21 @@ void Application::Pipe::reset()
   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()
@@ -817,14 +831,4 @@ int exec_cmdline(const std::string& command, const char *args[], bool use_libtoo
   return int(app.join());
 }
 
-const char *gearmand_binary() 
-{
-  return GEARMAND_BINARY;
-}
-
-const char *drizzled_binary() 
-{
-  return DRIZZLED_BINARY;
-}
-
 } // namespace exec_cmdline
index 6bf71b644c6c842215892823e0030f3903868b71..368daaecbbbf2e18ab32b4e169ed7a9d429cc20d 100644 (file)
@@ -245,7 +245,4 @@ static inline std::ostream& operator<<(std::ostream& output, const enum Applicat
 
 int exec_cmdline(const std::string& executable, const char *args[], bool use_libtool= false);
 
-const char *gearmand_binary(); 
-const char *drizzled_binary();
-
 }
index 86e7f864a922c4034cf29f32b1495d660be9bcd0..2f1cba317857353ed5b18a116958a8dd765f5f7c 100644 (file)
@@ -51,6 +51,9 @@ static test_return_t runner_code(libtest::Framework* frame,
   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
index b611e1a9fcd18a7cae461a8e5b85162e767a465e..90d8b6a8def0594cef3663b9c7d83ebe4bca8b64 100644 (file)
@@ -69,7 +69,7 @@
 # include <arpa/inet.h>
 #endif
 
-#if defined(_WIN32)
+#if defined(WIN32)
 # include "win32/wrappers.h"
 # define get_socket_errno() WSAGetLastError()
 #else
index 8e8874717d609a46de1c97a5a7a2fbfe9d86e416..2542f43f5146dd45ec99bca783b37f0b17b84d8e 100644 (file)
@@ -42,8 +42,8 @@ namespace libtest {
 
 void create_core(void)
 {
-#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
-  if (TARGET_OS_OSX)
+#if defined(__APPLE__) && __APPLE__
+  if (__APPLE__)
   {
     return;
   }
index 838804d7fc3a29b10de248deaaca0fe75ce390bc..0ee8df600ff148c6a868913240fdc59fe2aae46f 100644 (file)
@@ -50,7 +50,7 @@ namespace libtest {
 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];
index 0becfc99107f22068e22d512ab9cc2e971989754..75a5bbfbf420352aacc907174a7eca932715c273 100644 (file)
@@ -46,10 +46,14 @@ namespace libtest {
 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)
@@ -61,7 +65,7 @@ bool lookup(const char* host)
       }
 
       int ret;
-      if ((ret= getaddrinfo(host, NULL, NULL, &addrinfo)) == 0)
+      if ((ret= getaddrinfo(host, "echo", &hints, &addrinfo)) == 0)
       {
         success= true;
         break;
@@ -92,6 +96,11 @@ bool lookup(const char* host)
 
 bool check_dns()
 {
+  if (valgrind_is_caller())
+  {
+    return false;
+  }
+
   if (lookup("exist.gearman.info") == false)
   {
     return false;
index cd7d6aa67e11e104567d8aacb0a44d53a2da4e83..42f9222dde6b12fb324f2a54c4adc9f911932abe 100644 (file)
@@ -41,7 +41,7 @@ namespace libtest {
 
 void dream(time_t tv_sec, long tv_nsec)
 {
-#if defined(_WIN32)
+#if defined(WIN32)
   if (tv_sec == 0 and tv_nsec)
   {
     tv_sec++;
index b8068ac89a310c98629609aec6a2ecfe9af4a366..3a93b6664817e6131349d88e72ce63b88719dc1b 100644 (file)
@@ -74,11 +74,11 @@ bool ping_drizzled(const in_port_t _port)
 #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)
     {
diff --git a/libtest/exception.cc b/libtest/exception.cc
new file mode 100644 (file)
index 0000000..0b18f77
--- /dev/null
@@ -0,0 +1,108 @@
+/*  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
+
diff --git a/libtest/exception.hpp b/libtest/exception.hpp
new file mode 100644 (file)
index 0000000..3d20e8b
--- /dev/null
@@ -0,0 +1,94 @@
+/*  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
+
diff --git a/libtest/exception/disconnected.hpp b/libtest/exception/disconnected.hpp
new file mode 100644 (file)
index 0000000..fb3a2ad
--- /dev/null
@@ -0,0 +1,62 @@
+/*  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
diff --git a/libtest/exception/fatal.cc b/libtest/exception/fatal.cc
new file mode 100644 (file)
index 0000000..21a8ca7
--- /dev/null
@@ -0,0 +1,119 @@
+/*  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
diff --git a/libtest/exception/fatal.hpp b/libtest/exception/fatal.hpp
new file mode 100644 (file)
index 0000000..5ee1aac
--- /dev/null
@@ -0,0 +1,87 @@
+/*  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); }
diff --git a/libtest/failed.h b/libtest/failed.h
deleted file mode 100644 (file)
index bc45966..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/*  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
diff --git a/libtest/fatal.cc b/libtest/fatal.cc
deleted file mode 100644 (file)
index 0ed06c2..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*  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
diff --git a/libtest/fatal.hpp b/libtest/fatal.hpp
deleted file mode 100644 (file)
index c679f9b..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*  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
index 30f511afdbf484850dc5cb18125888e8f332040d..2c9ba74b4aebc346b40856eb51b358a4263077a0 100644 (file)
@@ -68,7 +68,7 @@ Framework::Framework(libtest::SignalThread& signal_,
   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++)
   {
@@ -107,47 +107,50 @@ void Framework::exec()
        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;
     }
   }
 
index 7a24466a5ab9c7254d8f4b3a3db4de2155e98a98..361779db7387b5778ac2da80fdc5894738adff3e 100644 (file)
@@ -72,7 +72,7 @@ public:
     _destroy= arg;
   }
 
-  void collections(collection_st* arg);
+  void collections(collection_st arg[]);
 
   void set_on_error(test_callback_error_fn *arg)
   {
index 9b26b96b675dab7d2fef408cdcf99e276553758c..2d9abf6b4f26abd70a7a9920384caadc21128dda 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  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
@@ -84,7 +90,7 @@ bool has_postgres_support(void)
 
 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;
@@ -110,7 +116,7 @@ bool has_gearmand()
 
 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)
@@ -125,7 +131,7 @@ bool has_drizzled()
 
 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)
@@ -138,14 +144,17 @@ bool has_mysqld()
   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)
     {
@@ -156,27 +165,62 @@ bool has_memcached()
 
     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
index e6c9d4d51680cd54f6e9f05e3e3967041e677c04..59ee88f96716a94d1a70a1cda55afdac7d547490 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  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
@@ -38,6 +38,9 @@
 
 namespace libtest {
 
+LIBTEST_API
+bool has_libmemcached_sasl(void);
+
 LIBTEST_API
 bool has_libmemcached();
 
@@ -62,4 +65,12 @@ bool has_drizzled();
 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
index 621c714c2f1c616166a105d21b7c0fca90d6bdbd..29873dc67f5e959cbe1ab555bd91e7905f9aeb2b 100644 (file)
@@ -97,14 +97,14 @@ static void init(CURL *curl, const std::string& url)
   (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) :
@@ -118,9 +118,9 @@ bool GET::execute()
 {
   (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());
@@ -134,17 +134,17 @@ bool GET::execute()
     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());
@@ -158,17 +158,17 @@ bool POST::execute()
     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());
@@ -183,18 +183,18 @@ bool TRACE::execute()
     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());
 
@@ -207,8 +207,8 @@ bool HEAD::execute()
     curl_easy_cleanup(curl);
 
     return retref == CURLE_OK;
-#endif
   }
+#endif
 
   return false;
 }
index d1ede13b2a1bb4278c9a1cd0280b7158f8057c15..4d1d8428dc3e4d79b2cb27ea9ee2565d4754fe80 100644 (file)
@@ -5,10 +5,12 @@
 #
 
 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
@@ -19,11 +21,15 @@ export LIBTOOL_COMMAND
 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)\""
 
@@ -61,8 +67,9 @@ noinst_HEADERS+= libtest/comparison.hpp
 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
@@ -80,7 +87,6 @@ noinst_HEADERS+= libtest/port.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
@@ -96,24 +102,19 @@ noinst_HEADERS+= libtest/test.hpp
 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
@@ -125,7 +126,8 @@ libtest_libtest_la_SOURCES+= libtest/cpu.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
@@ -204,11 +206,27 @@ helgrind-unittest: libtest/unittest
 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
index 70aee2b00cc6336cc733fe036c54ebe7b73b103f..36f873e8be6649649e1da6db33003306f830b5bc 100644 (file)
@@ -51,7 +51,7 @@
 # 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)
 {
@@ -148,6 +140,34 @@ do \
   } \
 } 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 \
 { \
index 80ffa769344d5ac89c5d72283c0c37cfa3a23b1b..3084ca4b4c8d79771a00383ca128a973bd6b50fa 100644 (file)
@@ -2,7 +2,7 @@
  *
  *  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
@@ -43,6 +43,9 @@
 #include <ctime>
 #include <fnmatch.h>
 #include <iostream>
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
 #include <fstream>
 #include <memory>
 #include <sys/stat.h>
@@ -110,7 +113,7 @@ int main(int argc, char *argv[])
     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;
@@ -165,7 +168,6 @@ int main(int argc, char *argv[])
           Error << "unknown value passed to --repeat: `" << optarg << "`";
           exit(EXIT_FAILURE);
         }
-
         break;
 
       case OPT_LIBYATL_MATCH_COLLECTION:
@@ -298,7 +300,6 @@ int main(int argc, char *argv[])
       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())
         {
@@ -306,17 +307,14 @@ int main(int argc, char *argv[])
           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();
 
@@ -383,9 +381,9 @@ int main(int argc, char *argv[])
     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 (...)
index 24bc3b8d18352da7d19656678e1cd6ef79d62a57..15fcbffa834722fd09b093b59bc3dd79092e811b 100644 (file)
@@ -72,14 +72,14 @@ public:
             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();
   }
@@ -131,7 +131,7 @@ public:
 
   const char *executable()
   {
-    return MEMCACHED_BINARY;
+    return memcached_binary();
   }
 
   bool is_libtool()
@@ -218,7 +218,7 @@ bool Memcached::build()
 
 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);
   }
@@ -228,7 +228,7 @@ libtest::Server *build_memcached(const std::string& hostname, const in_port_t tr
 
 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);
   }
index 142f167c31398bec78d87e2272fbd43d65b93b86..5d010faf82704189f55d58dbcc8314495b71bfc3 100644 (file)
@@ -39,7 +39,7 @@
 #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;
   }
index 9a1c8fba4eae58f09b613faf0dcd01beaec187d1..3e4523d3b42b2dc36cc766e9929a02ee2d826643 100644 (file)
 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)
index 0c78b9980f5469eb2a31ac235b796c36237fe180..79acbb40ede8e6bed81bfbb55966802b4454b8f8 100644 (file)
 
 #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>
 
@@ -56,27 +54,3 @@ do \
 { \
   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); }
index 51ee995d4463cbf81a114cd817ff8d29c251a5d2..5f093f83c2ff747b1d6afea73d52befab9d153a3 100644 (file)
 
 #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
index fd8766a9a85a771b9fff5a83311e270d4c98995f..3aec9c1e9a6b5df43b99ab57827a2f0485b5a4f6 100644 (file)
@@ -45,6 +45,11 @@ public:
 
   __failure(const __failure&);
 
+  test_return_t return_code() const
+  {
+    return TEST_FAILURE;
+  }
+
 private:
 };
 
diff --git a/libtest/result/fatal.hpp b/libtest/result/fatal.hpp
deleted file mode 100644 (file)
index 8e6d134..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*  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
index d0226e9f82a942444897f53dce8bfd4abf349008..7409d71801649b53bef36c729e8fcf433240bdd2 100644 (file)
@@ -44,6 +44,11 @@ public:
   __skipped(const char *file, int line, const char *func, ...);
 
   __skipped(const __skipped&);
+
+  test_return_t return_code() const
+  {
+    return TEST_SKIPPED;
+  }
 };
 
 } // namespace libtest
index 2931f2d052944ef821310a03c3173bea458a916d..a34e677e57f12a98aeeca24f6136acfff6160b5c 100644 (file)
@@ -48,6 +48,11 @@ public:
     return "SUCCESS";
   }
 
+  test_return_t return_code() const
+  {
+    return TEST_SUCCESS;
+  }
+
 private:
 };
 
index 328ee8f0936cd9cd9ea369302ad2fb550c5e4f1f..c35ab7673fa4fc358356d9727d2a10e8ebb6c0b6 100644 (file)
@@ -1,6 +1,7 @@
 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
index 3a5a7a0e3eaf14eff0cb7da20c21384fb1b827ad..4e73a0e91d8344e3ba9a42b5edb81de4015ae954 100644 (file)
@@ -215,9 +215,9 @@ libtest::Server* server_startup_st::create(const std::string& server_type, in_po
   }
   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);
       }
@@ -225,8 +225,9 @@ libtest::Server* server_startup_st::create(const std::string& server_type, in_po
   }
   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)
@@ -234,11 +235,12 @@ libtest::Server* server_startup_st::create(const std::string& server_type, in_po
           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);
     }
@@ -327,7 +329,7 @@ bool server_startup_st::_start_server(const bool is_socket,
       else
       {
         {
-#if defined(DEBUG)
+#ifdef DEBUG
           if (DEBUG)
           {
             Outn();
index 51f42a4e1439ab29140bf9518f8970427ed59afb..70012f1d94ad672e8a01d036e7e491ccd4662b66 100644 (file)
@@ -153,17 +153,13 @@ static void *sig_thread(void *arg)
     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:
index 7c18d6bc448ce4eca07a71d84ee2927c775ca579..d904070008c8a64b3fe0586be8aa03490fa5d5d5 100644 (file)
 #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>
index a88c0edea95c2380e80b490bf8bd4b580ad61765..425a21e7b730fe15c3ae73c9041a17b5dcbc8992 100644 (file)
@@ -40,7 +40,7 @@
 
 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);
@@ -49,15 +49,22 @@ std::string create_tmpfile(const std::string& name)
   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
index 0eb8dca2f31ca752130c574cf15e273efe3b6fcd..9283b84ad1659b3091838e70fefc18204204354a 100644 (file)
@@ -40,6 +40,7 @@
 
 namespace libtest {
 
+std::string create_tmpfile(const std::string&, int&);
 std::string create_tmpfile(const std::string&);
 
 } // namespace libtest
index c7be63fa49c90a693e7110e8911b3788fea2cfac..c21438890c31760d13ae9ed14fc0fa3c4ab6644b 100644 (file)
@@ -142,6 +142,25 @@ static test_return_t test_throw_skip_macro_TEST(void *)
   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 {
@@ -181,6 +200,11 @@ static test_return_t test_throw_fail_TEST(void *)
 }
 #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 {
@@ -199,6 +223,10 @@ static test_return_t ASSERT_FALSE__TEST(void *)
   return TEST_FAILURE;
 }
 
+#ifdef __clang__
+# pragma GCC diagnostic pop
+#endif
+
 static test_return_t ASSERT_NEQ_FAIL_TEST(void *)
 {
   try {
@@ -590,9 +618,9 @@ static test_return_t application_doesnotexist_BINARY(void *)
   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));
@@ -790,8 +818,8 @@ static test_return_t wait_services_appliction_TEST(void *)
 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 ));
@@ -814,8 +842,8 @@ static test_return_t gdb_abort_services_appliction_TEST(void *)
   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);
@@ -932,6 +960,12 @@ static test_return_t default_port_TEST(void *)
   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);
@@ -1034,6 +1068,7 @@ test_st tests_log[] ={
   {"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 },
@@ -1177,7 +1212,7 @@ collection_st collection[] ={
   {"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}
 };
diff --git a/libtest/valgrind.h b/libtest/valgrind.h
new file mode 100644 (file)
index 0000000..9d9e8ba
--- /dev/null
@@ -0,0 +1,55 @@
+/*  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;
+}
index 9d2244b3c32c3646bf56d02893c3a42c135c8f14..4af110b40e800988eeac7854204f64eb0650d582 100644 (file)
@@ -50,6 +50,11 @@ static size_t get_alpha_num(void)
 
 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;
index 1cc45b44455861952ab400918b3ab2a562d0237a..541bb92fab468585967de0211a7963301999f412 100644 (file)
@@ -44,6 +44,8 @@
 
 namespace libtest {
 
+int random_alpha_num(void);
+
 typedef std::vector<char*> vchar_ptr_t;
 typedef std::vector<char> vchar_t;
 
@@ -61,6 +63,7 @@ void append(libtest::vchar_t& arg, const char*);
 } // 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);
 
index 61d1a2f0f4ecbbf3c0619a39025ac36b62d9ffe6..0e88425db8a7b61c92d2df8c937f6ad3de52bef1 100644 (file)
@@ -7,7 +7,6 @@ AC_SUBST([LIBTEST_VERSION],[1.0])
 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
 
index c88affb46caf15bfe110eff9f4dda7d41e2cd997..f9f54e088db1608746bfe926a7fd6b222e4ee549 100644 (file)
@@ -19,9 +19,9 @@
 #   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"
 ])
index 4c72f27689b25dcf484e1eff68881ab8ee26f414..5522d72152e3188df6fa749238563f21153ee2df 100644 (file)
@@ -43,7 +43,7 @@
 #  (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
@@ -52,7 +52,9 @@ AC_DEFUN([AX_DEBUG],
         [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.])])
index b3b939217ad9c6acafc82e05dbe89f5716046ad3..2be988a372ae751f2724c6c43320baacf669e222 100644 (file)
@@ -15,7 +15,7 @@
 #
 # 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],
@@ -64,24 +96,38 @@ AC_DEFUN([_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],
@@ -90,9 +136,10 @@ 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])
@@ -101,18 +148,18 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
 
          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])
@@ -147,7 +194,6 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
                 _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])
@@ -158,31 +204,7 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
           _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])
@@ -194,16 +216,22 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
           _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])
                   ])])])])
 
@@ -215,14 +243,14 @@ AC_DEFUN([_HARDEN_CC_COMPILER_FLAGS],
 
 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])
@@ -231,16 +259,17 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
 
          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])
@@ -280,31 +309,6 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
           _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])
@@ -318,19 +322,25 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
           _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++])
@@ -340,16 +350,18 @@ AC_DEFUN([_HARDEN_CXX_COMPILER_FLAGS],
 # _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
            ])
+
index 01ff25d90abd58f28cc055d3703fccae6af1dd3f..ba46a5402dd0860bb7a9579729bebf202c49f321 100644 (file)
 #
 # 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"])
   ])
index cbbf17239738e22278f14a3a039159de0ffa0d30..653c7bcec8eab47c32ede4095a1857203523e0d7 100644 (file)
@@ -4,42 +4,45 @@
 #
 # 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])])
+         ])
index 71b932e07da39281595fac5cbcbe10690b8412f7..6d400ed4e8e29dfc7a650e2ca704a228d0dc61ba 100644 (file)
@@ -82,7 +82,7 @@
 #   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], [
@@ -159,10 +159,6 @@ case ${host_os} in
         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"
         ;;
@@ -287,16 +283,24 @@ if test "x$ax_pthread_ok" = xyes; then
         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)
index 93c5f89f2367791683bccd039df80f09677a045f..293fdfc58a06c39a5a9f75fa2d8debc9176d7acc 100644 (file)
@@ -6,22 +6,23 @@
 # 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
@@ -72,6 +73,31 @@ AC_DEFUN([AX_UUID],
   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
index 068041780f617ed4a54621007b0f10c602ff3b73..6db092789ed24a51c20bbd491d47e8c882f5ca21 100644 (file)
@@ -1,34 +1,26 @@
-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
+      ])
index 3b68557a7937836efb7dd92770c4043742f099ee..602cfa9680852f0d9711a5078f30027823cd4560 100644 (file)
@@ -2,18 +2,11 @@
 # 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
index 573be2af0edaa17f213a9babf2c319e992a56d61..1bb9a6a9dcf187f5835644c356a1e8a7f53dab29 100644 (file)
@@ -99,6 +99,12 @@ tests_memdump_LDADD=  libtest/libtest.la $(TESTS_LDADDS)
 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
 
@@ -116,3 +122,12 @@ valgrind-memerror: tests/memerror
 
 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
index 44fdbfa3404c042bcd7a2a6793b02427f1050690..414b143b393c69039a5f652f81f9e430eb6dc516 100644 (file)
@@ -98,6 +98,9 @@ valgrind-memcapable: tests/memcapable
 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
 
@@ -148,3 +151,9 @@ helgrind-hash: tests/testhashkit
 
 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
index 37f7bafc1faac49e82627282ce7fcb2791ea2b9d..1034a672b0798b522e9c4baee5210e8e41c9a48e 100644 (file)
@@ -2,7 +2,7 @@
  * 
  *  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
@@ -62,7 +62,7 @@ public:
       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;
index 2012d477d37901901aa69665613c576dc06207ec..d748d39e7e31e31e04df94a1c9550716b2a5097c 100644 (file)
@@ -70,9 +70,11 @@ test_st tests[] ={
   {"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 },
index eb74f00e4e9e9f56f2d6aba7f256f882aeec75a9..a6c38c5b1a8c6a5b6ff7b6cd740fddf3889046c6 100644 (file)
@@ -993,6 +993,7 @@ test_return_t bad_key_test(memcached_st *memc)
   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)
@@ -1294,26 +1295,41 @@ test_return_t increment_test(memcached_st *memc)
   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),
@@ -1341,12 +1357,10 @@ test_return_t decrement_test(memcached_st *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;
@@ -1367,6 +1381,16 @@ test_return_t decrement_with_initial_test(memcached_st *memc)
   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";
@@ -1398,24 +1422,32 @@ test_return_t increment_by_key_test(memcached_st *memc)
 
 test_return_t increment_with_initial_by_key_test(memcached_st *memc)
 {
-  test_skip(true, memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
-
   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;
 }
@@ -1456,19 +1488,30 @@ test_return_t decrement_with_initial_by_key_test(memcached_st *memc)
   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;
 }
@@ -2838,7 +2881,7 @@ test_return_t ketama_TEST(memcached_st *)
 
   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);
 
@@ -3039,7 +3082,7 @@ test_return_t selection_of_namespace_tests(memcached_st *memc)
   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));
@@ -3050,7 +3093,7 @@ test_return_t selection_of_namespace_tests(memcached_st *memc)
 
   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 */
@@ -3068,7 +3111,7 @@ test_return_t selection_of_namespace_tests(memcached_st *memc)
   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 */
   {
@@ -3078,9 +3121,7 @@ test_return_t selection_of_namespace_tests(memcached_st *memc)
     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 */
@@ -3108,11 +3149,10 @@ test_return_t set_namespace(memcached_st *memc)
 {
   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 */
@@ -3120,8 +3160,8 @@ test_return_t set_namespace(memcached_st *memc)
                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;
index 9edc820ec1ae197b466b4480d3d67d89427dc938..757369316fbcfafccda44d9cecfadce089ae1f55 100644 (file)
@@ -67,6 +67,7 @@ test_return_t decrement_by_key_test(memcached_st *memc);
 test_return_t decrement_test(memcached_st *memc);
 test_return_t decrement_with_initial_by_key_test(memcached_st *memc);
 test_return_t decrement_with_initial_test(memcached_st *memc);
+test_return_t 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);
@@ -88,6 +89,7 @@ test_return_t increment_by_key_test(memcached_st *memc);
 test_return_t increment_test(memcached_st *memc);
 test_return_t increment_with_initial_by_key_test(memcached_st *memc);
 test_return_t increment_with_initial_test(memcached_st *memc);
+test_return_t 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);
index 145f979765a0612870fb00dcd97cb34d585cb3bd..5897dcb71338d6b81d9df67c5ea63181fda61814 100644 (file)
@@ -181,6 +181,13 @@ static test_return_t mget_test(memcached_st *original)
   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));
index 3dda2d8ada2a8c78624ed0b1a5601fc90c7ecbfb..4d4953ee724980a2261feaf4c3cfdb3d2396933e 100644 (file)
 
 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"))
     {
@@ -101,11 +87,13 @@ static void *world_create(libtest::server_startup_st& servers, test_return_t& er
 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;
index 64cf55e5cf5ba0f5d6ecb6c28d76177d322d22e6..69f0a91bced921b7df3a9433769f9ecc99096f3a 100644 (file)
@@ -75,11 +75,14 @@ static void *world_create(libtest::server_startup_st& servers, test_return_t& er
 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;
index 04a7b34259182ac643b556b452fc0ee3fa31e08c..4e7c957da441a8648b941a1a833a7c7ac35c2526 100644 (file)
 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));
 
@@ -74,7 +76,7 @@ static test_return_t ascii_test(void *)
 {
   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);
 
@@ -85,7 +87,7 @@ static test_return_t binary_test(void *)
 {
   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);
 
@@ -105,18 +107,11 @@ collection_st collection[] ={
   {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;
 }
index 2910e4b9be2635d05dbd1b4959aa19206dedd7c4..3b3b021fd1fa7453012b3c82da603f655d20ace5 100644 (file)
@@ -64,10 +64,10 @@ static test_return_t help_test(void *)
 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,
@@ -77,6 +77,7 @@ static test_return_t cat_test(void *)
   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));
@@ -90,11 +91,11 @@ static test_return_t cat_test(void *)
 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));
 
@@ -102,6 +103,7 @@ static test_return_t NOT_FOUND_test(void *)
   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));
index 440f1b1dec8a41a07a6ed1a15d05b7b037a3b75b..7ce5a493e9f3287b56033488b5aaf1fb86b839ac 100644 (file)
@@ -44,6 +44,8 @@
 #include <libtest/test.hpp>
 #include <libmemcached-1.0/memcached.h>
 
+#include <sys/stat.h>
+
 using namespace libtest;
 
 #ifndef __INTEL_COMPILER
@@ -61,20 +63,33 @@ static test_return_t help_test(void *)
   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}
 };
 
index a43a61240a0be4915d4de52219402415c24255f0..ab59c3ce245a594a535fb83dd44e7ae22e0216ca 100644 (file)
@@ -75,10 +75,10 @@ static test_return_t server_test(void *)
 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,
@@ -91,6 +91,7 @@ static test_return_t FOUND_test(void *)
   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);
@@ -110,19 +111,11 @@ collection_st collection[] ={
   {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;
 }
index 0c57c029b7144f013d2d72caaf331cabf5a8b158..41a4648dc36bdc8e629abda2b63f4a99a156c66b 100644 (file)
@@ -64,10 +64,10 @@ static test_return_t help_test(void *)
 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,
@@ -90,11 +90,11 @@ static test_return_t exist_test(void *)
 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));
 
@@ -115,9 +115,9 @@ static test_return_t NOT_FOUND_test(void *)
 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)
index 543efc7ccab0b32b4746c479de89faa361e770a5..af057defa7ad9e587f5055f4071c51d60870d83c 100644 (file)
@@ -64,7 +64,7 @@ static test_return_t help_test(void *)
 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));
@@ -75,7 +75,7 @@ static test_return_t ping_TEST(void *)
 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));
index 043e0ce50ef2a2d685efd03925765ad81d16b783..6955f1fa391003a72a9f470ef7bb596ed6b1d46d 100644 (file)
@@ -84,6 +84,8 @@ static test_return_t rm_test(void *)
   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));
 
@@ -121,7 +123,7 @@ static test_return_t NOT_FOUND_TEST(void *)
 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 };
 
index 5617fa2895683fc5d11143ad2f320af07c08f94f..761a70723c4b2e34145f7374a7e20906167c02ca 100644 (file)
@@ -65,9 +65,9 @@ static test_return_t help_test(void *)
 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,
@@ -89,15 +89,15 @@ static test_return_t touch_test(void *)
 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));
 
@@ -111,8 +111,8 @@ static test_return_t NOT_FOUND_test(void *)
 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;
diff --git a/version.m4 b/version.m4
new file mode 100644 (file)
index 0000000..759ba24
--- /dev/null
@@ -0,0 +1 @@
+m4_define([VERSION_NUMBER], [1.0.18])