# vim:ft=automake
-ACLOCAL_AMFLAGS = -I m4
+ACLOCAL_AMFLAGS = -I m4 -I libtest/m4
# includes append to these:
SUFFIXES =
# Adding support for libtest
m4_include([libtest/yatl.m4])
-m4_include([m4/memcached.m4])
m4_include([m4/memcached_sasl.m4])
m4_include([m4/gearmand.m4])
m4_include([m4/libgearman.m4])
}
catch (libtest::fatal &e)
{
- Error << "Fatal exception was thrown: " << e.what();
- stream::cerr(__FILE__, __LINE__, __func__) << e.what();
+ stream::cerr(e.file(), e.line(), e.func()) << e.what();
_failed++;
throw;
}
LIBTEST_API
bool _in_valgrind(const char *file, int line, const char *func);
-template <class T_comparable, class T_hint>
-bool _compare_truth_hint(const char *file, int line, const char *func, T_comparable __expected, const char *assertation_label, T_hint __hint)
+template <class T_comparable>
+bool _compare_truth(const char *file, int line, const char *func, T_comparable __expected, const char *assertation_label)
{
if (__expected == false)
{
- libtest::stream::make_cerr(file, line, func) << "Assertation \"" << assertation_label << "\" failed, hint: " << __hint;
+ libtest::stream::make_cerr(file, line, func) << "Assertation \"" << assertation_label << "\"";
return false;
}
return true;
}
-template <class T_comparable>
-bool _truth(const char *file, int line, const char *func, T_comparable __truth)
-{
- if (bool(__truth))
- {
- libtest::stream::make_cerr(file, line, func) << "Assertion failed for " << func << "() with \"" << __truth << "\"";
- return false;
- }
-
- return true;
-}
-
-template <class T1_comparable, class T2_comparable, class T_hint>
-bool _compare_hint(const char *file, int line, const char *func, T1_comparable __expected, T2_comparable __actual, T_hint __hint, bool io_error= true)
+template <class T1_comparable, class T2_comparable>
+bool _ne_compare(const char *file, int line, const char *func, T1_comparable __expected, T2_comparable __actual, bool io_error= true)
{
- if (__expected != __actual)
+ if (__expected == __actual)
{
if (io_error)
{
- libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\"" << " Additionally: \"" << __hint << "\"";
+ libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\"";
}
return false;
return true;
}
-template <class T1_comparable, class T2_comparable, class T_hint>
-bool _ne_compare_hint(const char *file, int line, const char *func, T1_comparable __expected, T2_comparable __actual, T_hint __hint, bool io_error= true)
+template <class T_comparable, class T_expression_string>
+bool _assert_truth(const char *file, int line, const char *func, T_comparable __truth, T_expression_string __expression, const char* __explain= NULL)
{
- if (__expected == __actual)
+ if (__truth)
{
- if (io_error)
- {
- libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\"" << " Additionally: \"" << __hint << "\"";
- }
+ return true;
+ }
- return false;
+ if (__explain)
+ {
+ libtest::stream::make_cerr(file, line, func) << "Assertion \"" << __expression << "\" warning:" << __explain;
}
- return true;
+ return false;
}
} // namespace libtest
strncpy(_mesg, last_error, sizeof(_mesg));
- snprintf(_error_message, sizeof(_error_message), "%s:%d FATAL:%s (%s)", _file, _line, last_error, _func);
+ snprintf(_error_message, sizeof(_error_message), "%s", last_error);
}
static bool _disabled= false;
(void)vsnprintf(last_error, sizeof(last_error), format, args);
va_end(args);
- snprintf(_error_message, sizeof(_error_message), "%s:%d FATAL:%s (%s)", _file, _line, last_error, _func);
+ snprintf(_error_message, sizeof(_error_message), "%s", last_error);
}
} // namespace libtest
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
- iter++)
+ ++iter)
{
delete *iter;
}
{
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end() and (_signal.is_shutdown() == false);
- iter++)
+ ++iter)
{
if (_only_run.empty() == false and
fnmatch(_only_run.c_str(), (*iter)->name(), 0))
}
catch (libtest::fatal& e)
{
+ _failed++;
stream::cerr(e.file(), e.line(), e.func()) << e.mesg();
}
catch (libtest::disconnected& e)
{
+ _failed++;
Error << "Unhandled disconnection occurred:" << e.what();
throw;
}
+ catch (...)
+ {
+ _failed++;
+ throw;
+ }
Outn();
}
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
- iter++)
+ ++iter)
{
count+= (*iter)->total();
}
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
- iter++)
+ ++iter)
{
count+= (*iter)->success();
}
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
- iter++)
+ ++iter)
{
count+= (*iter)->skipped();
}
uint32_t count= 0;
for (std::vector<Collection*>::iterator iter= _collection.begin();
iter != _collection.end();
- iter++)
+ ++iter)
{
count+= (*iter)->failed();
}
gearman_client_free(client);
return true;
}
-#if 0
Error << hostname().c_str() << ":" << port() << " was " << gearman_strerror(rc) << " extended: " << gearman_client_error(client);
-#endif
}
else
{
bool has_mysqld()
{
-#if defined(HAVE_MYSQL_BUILD) && HAVE_MYSQL_BUILD
- if (HAVE_MYSQL_BUILD)
+ if (HAVE_MYSQLD_BUILD)
{
- if (access(HAVE_MYSQL, X_OK) == 0)
+ if (access(MYSQLD_BINARY, X_OK) == 0)
{
return true;
}
}
-#endif
return false;
}
--- /dev/null
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_lib_mysql.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_LIB_MYSQL([MINIMUM-VERSION])
+#
+# DESCRIPTION
+#
+# This macro provides tests of availability of MySQL client library of
+# particular version or newer.
+#
+# AX_LIB_MYSQL macro takes only one argument which is optional. If there
+# is no required version passed, then macro does not run version test.
+#
+# The --with-mysql option takes one of three possible values:
+#
+# no - do not check for MySQL client library
+#
+# yes - do check for MySQL library in standard locations (mysql_config
+# should be in the PATH)
+#
+# path - complete path to mysql_config utility, use this option if
+# mysql_config can't be found in the PATH
+#
+# This macro calls:
+#
+# AC_SUBST(MYSQL_CFLAGS)
+# AC_SUBST(MYSQL_LDFLAGS)
+# AC_SUBST(MYSQL_VERSION)
+#
+# And sets:
+#
+# HAVE_MYSQL
+#
+# LICENSE
+#
+# Copyright (c) 2008 Mateusz Loskot <mateusz@loskot.net>
+#
+# 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 12
+
+AC_DEFUN([AX_LIB_MYSQL],
+[
+ AC_ARG_WITH([mysql],
+ AS_HELP_STRING([--with-mysql=@<:@ARG@:>@],
+ [use MySQL client library @<:@default=yes@:>@, optionally specify path to mysql_config]
+ ),
+ [
+ if test "$withval" = "no"; then
+ want_mysql="no"
+ elif test "$withval" = "yes"; then
+ want_mysql="yes"
+ else
+ want_mysql="yes"
+ MYSQL_CONFIG="$withval"
+ fi
+ ],
+ [want_mysql="yes"]
+ )
+ AC_ARG_VAR([MYSQL_CONFIG], [Full path to mysql_config program])
+
+ MYSQL_CFLAGS=""
+ MYSQL_LDFLAGS=""
+ MYSQL_VERSION=""
+
+ dnl
+ dnl Check MySQL libraries
+ dnl
+
+ if test "$want_mysql" = "yes"; then
+
+ if test -z "$MYSQL_CONFIG" ; then
+ AC_PATH_PROGS([MYSQL_CONFIG], [mysql_config mysql_config5], [no])
+ fi
+
+ if test "$MYSQL_CONFIG" != "no"; then
+ MYSQL_CFLAGS="`$MYSQL_CONFIG --cflags`"
+ MYSQL_LDFLAGS="`$MYSQL_CONFIG --libs`"
+
+ MYSQL_VERSION=`$MYSQL_CONFIG --version`
+
+ found_mysql="yes"
+ else
+ found_mysql="no"
+ fi
+ fi
+
+ dnl
+ dnl Check if required version of MySQL is available
+ dnl
+
+
+ mysql_version_req=ifelse([$1], [], [], [$1])
+
+ if test "$found_mysql" = "yes" -a -n "$mysql_version_req"; then
+
+ AC_MSG_CHECKING([if MySQL version is >= $mysql_version_req])
+
+ dnl Decompose required version string of MySQL
+ dnl and calculate its number representation
+ mysql_version_req_major=`expr $mysql_version_req : '\([[0-9]]*\)'`
+ mysql_version_req_minor=`expr $mysql_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
+ mysql_version_req_micro=`expr $mysql_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+ if test "x$mysql_version_req_micro" = "x"; then
+ mysql_version_req_micro="0"
+ fi
+
+ mysql_version_req_number=`expr $mysql_version_req_major \* 1000000 \
+ \+ $mysql_version_req_minor \* 1000 \
+ \+ $mysql_version_req_micro`
+
+ dnl Decompose version string of installed MySQL
+ dnl and calculate its number representation
+ mysql_version_major=`expr $MYSQL_VERSION : '\([[0-9]]*\)'`
+ mysql_version_minor=`expr $MYSQL_VERSION : '[[0-9]]*\.\([[0-9]]*\)'`
+ mysql_version_micro=`expr $MYSQL_VERSION : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+ if test "x$mysql_version_micro" = "x"; then
+ mysql_version_micro="0"
+ fi
+
+ mysql_version_number=`expr $mysql_version_major \* 1000000 \
+ \+ $mysql_version_minor \* 1000 \
+ \+ $mysql_version_micro`
+
+ mysql_version_check=`expr $mysql_version_number \>\= $mysql_version_req_number`
+ if test "$mysql_version_check" = "1"; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+
+ if test "$found_mysql" = "yes" ; then
+ AC_DEFINE([HAVE_MYSQL], [1],
+ [Define to 1 if MySQL libraries are available])
+ fi
+
+ AC_SUBST([MYSQL_VERSION])
+ AC_SUBST([MYSQL_CFLAGS])
+ AC_SUBST([MYSQL_LDFLAGS])
+])
--- /dev/null
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_prog_memcached.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PROG_MEMCACHED
+#
+# DESCRIPTION
+#
+# Check for the program 'memcached' let script continue if exists & works
+# pops up error message if not.
+#
+# Besides checking existence, this macro also set these environment
+# variables upon completion:
+#
+# MEMCACHED = which memcached
+#
+# LICENSE
+#
+# Copyright (c) 2012 Brian Aker <brian@tangent.org>
+# Copyright (c) 2008 Gleen Salmon <gleensalmon@yahoo.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 6
+
+AU_ALIAS([AC_PROG_MEMCACHED], [AX_PROG_MEMCACHED])
+AC_DEFUN([AX_PROG_MEMCACHED],[
+AC_REQUIRE([AC_EXEEXT])dnl
+AC_PATH_PROG(MEMCACHED, memcached$EXEEXT, nocommand)
+if test "$MEMCACHED" = nocommand; then
+ AC_MSG_WARN([memcached not found in $PATH])
+fi;dnl
+])
--- /dev/null
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_prog_mysqld.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PROG_MYSQLD
+#
+# DESCRIPTION
+#
+# Check for the program 'mysqld' let script continue if exists & works
+# pops up error message if not.
+#
+# Besides checking existence, this macro also set these environment
+# variables upon completion:
+#
+# MYSQLD = which mysqld
+#
+# LICENSE
+#
+# Copyright (c) 2008 Gleen Salmon <gleensalmon@yahoo.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 6
+
+AU_ALIAS([AC_PROG_MYSQLD], [AX_PROG_MYSQLD])
+AC_DEFUN([AX_PROG_MYSQLD],[
+AC_REQUIRE([AC_EXEEXT])dnl
+AC_PATH_PROG(MYSQLD, mysqld$EXEEXT, nocommand)
+if test "$MYSQLD" = nocommand; then
+ AC_MSG_WARN([mysqld not found in $PATH])
+fi;dnl
+])
--- /dev/null
+AX_PROG_MYSQLD
+AX_WITH_PROG(MEMCACHED_BINARY, [memcached])
+AS_IF([test -f "$ac_cv_path_MEMCACHED_BINARY"],
+ [
+ AC_DEFINE([HAVE_MEMCACHED_BINARY], [1], [If Memcached binary is available])
+ AC_DEFINE_UNQUOTED([MEMCACHED_BINARY], "$ac_cv_path_MEMCACHED_BINARY", [Name of the memcached binary used in make test])
+ ],
+ [
+ AC_DEFINE([HAVE_MEMCACHED_BINARY], [1], [If Memcached binary is available])
+ AC_DEFINE([MEMCACHED_BINARY], ["memcached/memcached"], [Name of the memcached binary used in make test])
+ ])
--- /dev/null
+AX_LIB_MYSQL([5.0])
+AM_CONDITIONAL(HAVE_LIBMYSQL, test "x${found_mysql}" = "xyes")
+AS_IF([test "x${found_mysql}" = "xyes"],
+ [
+ AC_DEFINE([HAVE_LIBMYSQL_BUILD], [1], [Define to 1 if MySQL libraries are available])
+ ],
+ [
+ AC_DEFINE([HAVE_LIBMYSQL_BUILD], [0], [Define to 1 if MySQL libraries are available])
+ ])
+AX_PROG_MYSQLD
+AS_IF([test -f "$ac_cv_path_MYSQLD"],
+ [
+ AC_DEFINE([HAVE_MYSQLD_BUILD], [1], [Define to 1 if MySQLD binary is available])
+ AC_DEFINE_UNQUOTED([MYSQLD_BINARY], "$ac_cv_path_MYSQLD", [Name of the mysqld binary used in make test])
+ ],
+ [
+ AC_DEFINE([HAVE_MYSQLD_BUILD], [0], [Define to 1 if MySQLD binary is available])
+ AC_DEFINE([MYSQLD_BINARY], [0], [Name of the mysqld binary used in make test])
+ ])
+
std::string collection_to_run;
std::string wildcard;
+ /*
+ 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 (valgrind_is_caller())
+ {
+ return EXIT_SKIP;
+ }
+#endif
+
// Options parsing
{
enum long_option_t {
return EXIT_SKIP;
case TEST_FAILURE:
+ std::cerr << "frame->create()" << std::endl;
return EXIT_FAILURE;
}
}
}
catch (libtest::fatal& e)
{
- std::cerr << e.what() << std::endl;
+ std::cerr << "FATAL:" << e.what() << std::endl;
exit_code= EXIT_FAILURE;
}
catch (libtest::disconnected& e)
}
catch (std::exception& e)
{
- std::cerr << e.what() << std::endl;
+ std::cerr << "std::exception:" << e.what() << std::endl;
exit_code= EXIT_FAILURE;
}
catch (...)
void release(in_port_t _arg)
{
- for(socket_port_t::iterator iter= _pair.begin();
- iter != _pair.end();
- iter++)
+ for (socket_port_t::iterator iter= _pair.begin();
+ iter != _pair.end();
+ ++iter)
{
if ((*iter).second == _arg)
{
~socket_st()
{
- for(socket_port_t::iterator iter= _pair.begin();
- iter != _pair.end();
- iter++)
+ for (socket_port_t::iterator iter= _pair.begin();
+ iter != _pair.end();
+ ++iter)
{
shutdown((*iter).first, SHUT_RDWR);
close((*iter).first);
namespace libtest {
-Runner::Runner()
+Runner::Runner() :
+ _servers(NULL)
{
}
{
_app.slurp();
_app.check();
+
return true;
}
bool Server::wait_for_pidfile() const
{
- if (has_pid_file())
- {
- Wait wait(pid_file(), 4);
-
- return wait.successful();
- }
+ Wait wait(pid_file(), 4);
- return true;
+ return wait.successful();
}
bool Server::has_pid() const
dream(5, 50000);
}
+ size_t repeat= 5;
_app.slurp();
- if (has_pid_file())
+ while (--repeat)
{
- size_t repeat= 5;
- while (--repeat)
+ if (pid_file().empty() == false)
{
- if (pid_file().empty() == false)
- {
- Wait wait(pid_file(), 8);
+ Wait wait(pid_file(), 8);
- if (wait.successful() == false)
+ if (wait.successful() == false)
+ {
+ if (_app.check())
{
- if (_app.check())
- {
- _app.slurp();
- continue;
- }
-
- char buf[PATH_MAX];
- char *getcwd_buf= getcwd(buf, sizeof(buf));
- throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
- "Unable to open pidfile in %s for: %s stderr:%s",
- getcwd_buf ? getcwd_buf : "",
- _running.c_str(),
- _app.stderr_c_str());
+ _app.slurp();
+ continue;
}
+
+ char buf[PATH_MAX];
+ char *getcwd_buf= getcwd(buf, sizeof(buf));
+ throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
+ "Unable to open pidfile in %s for: %s stderr:%s",
+ getcwd_buf ? getcwd_buf : "",
+ _running.c_str(),
+ _app.stderr_c_str());
}
}
}
_app.slurp();
if (kill_file(pid_file()) == false)
{
- throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
- "Failed to kill off server, waited: %u after startup occurred, when pinging failed: %.*s stderr:%.*s",
- this_wait,
- int(_running.size()), _running.c_str(),
- int(_app.stderr_result_length()), _app.stderr_c_str());
- }
+ libtest::fatal err(LIBYATL_DEFAULT_PARAM,
+ "Failed to kill off server, waited: %u after startup occurred, when pinging failed: %.*s stderr:%.*s",
+ this_wait,
+ int(_running.size()), _running.c_str(),
+ int(_app.stderr_result_length()), _app.stderr_c_str());
- throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
- "Failed native ping(), pid: %d is alive: %s waited: %u server started, having pid_file. exec: %.*s stderr:%.*s",
+ stream::cerr(err.file(), err.line(), err.func()) << err.what();
+ }
+ else
+ {
+ libtest::fatal err(LIBYATL_DEFAULT_PARAM,
+ "Failed native ping(), pid: %d was alive: %s waited: %u server started, having pid_file. exec: %.*s stderr:%.*s",
int(_app.pid()),
_app.check() ? "true" : "false",
this_wait,
int(_running.size()), _running.c_str(),
int(_app.stderr_result_length()), _app.stderr_c_str());
+
+ stream::cerr(err.file(), err.line(), err.func()) << err.what();
+ }
}
else
{
- throw libtest::fatal(LIBYATL_DEFAULT_PARAM,
- "Failed native ping(), pid: %d is alive: %s waited: %u server started. exec: %.*s stderr:%.*s",
- int(_app.pid()),
- _app.check() ? "true" : "false",
- this_wait,
- int(_running.size()), _running.c_str(),
- int(_app.stderr_result_length()), _app.stderr_c_str());
+ libtest::fatal err(LIBYATL_DEFAULT_PARAM,
+ "Failed native ping(), pid: %d is alive: %s waited: %u server started. exec: %.*s stderr:%.*s",
+ int(_app.pid()),
+ _app.check() ? "true" : "false",
+ this_wait,
+ int(_running.size()), _running.c_str(),
+ int(_app.stderr_result_length()), _app.stderr_c_str());
+
+ stream::cerr(err.file(), err.line(), err.func()) << err.what();
}
_running.clear();
return false;
bool Server::args(Application& app)
{
-
// Set a log file if it was requested (and we can)
if (has_log_file_option())
{
}
// Update pid_file
- if (has_pid_file())
{
if (_pid_file.empty() and set_pid_file() == false)
{
port_option(app, _port);
}
- for (Options::const_iterator iter= _options.begin(); iter != _options.end(); iter++)
+ for (Options::const_iterator iter= _options.begin(); iter != _options.end(); ++iter)
{
if ((*iter).second.empty() == false)
{
_log_file.clear();
}
- bool args(Application&);
-
pid_t pid() const;
bool has_pid() const;
bool set_log_file();
bool set_socket_file();
void reset_pid();
+ bool args(Application&);
+
std::string _error;
};
namespace libtest {
+Server* server_startup_st::last()
+{
+ return servers.back();
+}
+
void server_startup_st::push_server(Server *arg)
{
servers.push_back(arg);
- char port_str[NI_MAXSERV];
- snprintf(port_str, sizeof(port_str), "%u", int(arg->port()));
-
std::string server_config_string;
if (arg->has_socket())
{
}
else
{
+ char port_str[NI_MAXSERV];
+ snprintf(port_str, sizeof(port_str), "%u", int(arg->port()));
+
server_config_string+= "--server=";
server_config_string+= arg->hostname();
server_config_string+= ":";
// host_to_shutdown => host number to shutdown in array
bool server_startup_st::shutdown(uint32_t host_to_shutdown)
{
+ Error << servers.size() << " > " << host_to_shutdown;
if (servers.size() > host_to_shutdown)
{
Server* tmp= servers[host_to_shutdown];
void server_startup_st::clear()
{
- for (std::vector<Server *>::iterator iter= servers.begin(); iter != servers.end(); iter++)
+ for (std::vector<Server *>::iterator iter= servers.begin(); iter != servers.end(); ++iter)
{
delete *iter;
}
bool server_startup_st::check() const
{
bool success= true;
- for (std::vector<Server *>::const_iterator iter= servers.begin(); iter != servers.end(); iter++)
+ for (std::vector<Server *>::const_iterator iter= servers.begin(); iter != servers.end(); ++iter)
{
if ((*iter)->check() == false)
{
bool server_startup_st::shutdown()
{
bool success= true;
- for (std::vector<Server *>::iterator iter= servers.begin(); iter != servers.end(); iter++)
+ for (std::vector<Server *>::iterator iter= servers.begin(); iter != servers.end(); ++iter)
{
- if ((*iter)->has_pid() and (*iter)->kill() == false)
+ if ((*iter) and (*iter)->has_pid() and (*iter)->kill() == false)
{
Error << "Unable to kill:" << *(*iter);
success= false;
void server_startup_st::restart()
{
- for (std::vector<Server *>::iterator iter= servers.begin(); iter != servers.end(); iter++)
+ for (std::vector<Server *>::iterator iter= servers.begin(); iter != servers.end(); ++iter)
{
(*iter)->start();
}
}
bool server_startup(server_startup_st& construct, const std::string& server_type, in_port_t try_port, int argc, const char *argv[], const bool opt_startup_message)
+{
+ construct.start_server(server_type, try_port, argc, argv, opt_startup_message);
+}
+
+bool server_startup_st::start_server(const std::string& server_type, in_port_t try_port, int argc, const char *argv[], const bool opt_startup_message)
{
if (try_port <= 0)
{
{
if (HAVE_LIBMEMCACHED)
{
- server= build_memcached_sasl("localhost", try_port, construct.username(), construct.password());
+ server= build_memcached_sasl("localhost", try_port, username(), password());
}
}
}
else if (server_type.compare("memcached") == 0)
{
- if (MEMCACHED_BINARY)
+ if (HAVE_MEMCACHED_BINARY)
{
if (HAVE_LIBMEMCACHED)
{
if (server == NULL)
{
- fatal_message("Launching of an unknown server was attempted");
+ throw libtest::fatal(LIBYATL_DEFAULT_PARAM, "Launching of an unknown server was attempted: %s", server_type.c_str());
}
/*
throw;
}
- construct.push_server(server);
+ push_server(server);
return true;
}
-bool server_startup_st::start_socket_server(const std::string& server_type, const in_port_t try_port, int argc, const char *argv[])
+bool server_startup_st::start_socket_server(const std::string& server_type, const in_port_t try_port, int argc,
+ const char *argv[],
+ const bool opt_startup_message)
{
(void)try_port;
Outn();
}
else
{
- Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
+ if (opt_startup_message)
+ {
+ Outn();
+ Out << "STARTING SERVER(pid:" << server->pid() << "): " << server->running();
+ Outn();
+ }
}
}
catch (...)
bool validate();
- bool start_socket_server(const std::string& server_type, const in_port_t try_port, int argc, const char *argv[]);
+ bool start_socket_server(const std::string& server_type, const in_port_t try_port, int argc, const char *argv[], const bool opt_startup_message= true);
+ bool start_server(const std::string& server_type, const in_port_t try_port, int argc, const char *argv[], const bool opt_startup_message= true);
uint32_t count() const
{
bool check() const;
void push_server(Server *);
+ Server* last();
Server *pop_server();
unsigned long int servers_to_run() const
} \
} while (0)
-#define test_true_got(__expected, __hint) \
-do \
-{ \
- if (not libtest::_compare_truth_hint(__FILE__, __LINE__, __func__, ((__expected)), #__expected, ((__hint)))) \
- { \
- libtest::create_core(); \
- return TEST_FAILURE; \
- } \
-} while (0)
-#define test_true_hint test_true_got
+#define test_true_got(A, B) test_true(A);
+#define test_true_hint(A, B) test_true(A);
+
+#define test_compare_hint(A, B, C) test_compare(A, B);
+#define test_compare_got(A, B, C) test_compare(A, B);
#define test_skip(__expected, __actual) \
do \
} \
} while (0)
-#define test_skip_hint(__expected, __actual, __hint) \
-do \
-{ \
- if (libtest::_compare_hint(__FILE__, __LINE__, __func__, (__expected), (__actual), (__hint)) == false) \
- { \
- return TEST_SKIPPED; \
- } \
-} while (0)
-
#define test_skip_valgrind() \
do \
{ \
#define test_ne_compare(__expected, __actual) \
do \
{ \
- if (libtest::_ne_compare_hint(__FILE__, __LINE__, __func__, ((__expected)), ((__actual)), true) == false) \
+ if (libtest::_ne_compare(__FILE__, __LINE__, __func__, ((__expected)), ((__actual)), true) == false) \
{ \
libtest::create_core(); \
return TEST_FAILURE; \
#define test_null test_zero
-#define test_compare_got(__expected, __actual, __hint) \
-do \
-{ \
- if (libtest::_compare_hint(__FILE__, __LINE__, __func__, (__expected), (__actual), (__hint)) == false) \
- { \
- libtest::create_core(); \
- return TEST_FAILURE; \
- } \
-} while (0)
-
-#define test_compare_hint test_compare_got
-
#define test_compare_warn(__expected, __actual) \
do \
{ \
void(libtest::_compare(__FILE__, __LINE__, __func__, (__expected), (__actual)), true); \
} while (0)
-#define test_compare_warn_hint(__expected, __actual, __hint) \
-do \
-{ \
- libtest::_compare_hint(__FILE__, __LINE__, __func__, (__expected), (__actual), (__hint)); \
-} while (0)
-
-#define test_warn(__truth) \
-do \
-{ \
- void(libtest::_truth(__FILE__, __LINE__, __func__, (__truth))); \
-} while (0)
-
-#define test_warn_hint(__truth, __hint) \
+#define test_warn(__truth, __explain) \
do \
{ \
- void(libtest::_compare_truth_hint(__FILE__, __LINE__, __func__, (__truth), #__truth, (__hint))); \
+ void(libtest::_assert_truth(__FILE__, __LINE__, __func__, bool((__truth)), #__truth, __explain)); \
} while (0)
-
#define test_strcmp(__expected, __actual) \
do \
{ \
} \
} while (0)
-#define test_memcmp_hint(A,B,C,__hint) \
-do \
-{ \
- if ((A) == NULL or (B) == NULL or memcmp((A), (B), (C))) \
- { \
- fprintf(stderr, "\n%s:%d: (hint:%s) %.*s -> %.*s\n", __FILE__, __LINE__, __hint, (int)(C), (char *)(A), (int)(C), (char *)(B)); \
- libtest::create_core(); \
- return TEST_FAILURE; \
- } \
-} while (0)
-
#define test_return_if(__test_return_t) \
do \
{ \
using namespace libtest;
+static std::string testing_service;
+
static test_return_t LIBTOOL_COMMAND_test(void *)
{
test_true(getenv("LIBTOOL_COMMAND"));
return TEST_SUCCESS;
}
-static test_return_t memcached_cycle_test(void *object)
+static test_return_t server_startup_TEST(void *object)
{
server_startup_st *servers= (server_startup_st*)object;
test_true(servers);
- if (MEMCACHED_BINARY and HAVE_LIBMEMCACHED)
- {
- test_true(has_memcached());
- test_true(server_startup(*servers, "memcached", get_free_port(), 0, NULL));
+ test_true(servers->start_server(testing_service, get_free_port(), 0, NULL, true));
- return TEST_SUCCESS;
- }
+ test_true(servers->last());
+ pid_t last_pid= servers->last()->pid();
- return TEST_SKIPPED;
+ test_compare(servers->last()->pid(), last_pid);
+ test_true(last_pid > 1);
+ test_compare(kill(last_pid, 0), 0);
+
+ test_true(servers->shutdown());
+#if 0
+ test_compare(servers->last()->pid(), -1);
+ test_compare(kill(last_pid, 0), -1);
+#endif
+
+ return TEST_SUCCESS;
}
-static test_return_t memcached_socket_cycle_test(void *object)
+static test_return_t socket_server_startup_TEST(void *object)
{
server_startup_st *servers= (server_startup_st*)object;
test_true(servers);
- if (MEMCACHED_BINARY)
- {
- if (HAVE_LIBMEMCACHED)
- {
- test_true(has_memcached());
- test_true(servers->start_socket_server("memcached", get_free_port(), 0, NULL));
+ test_true(servers->start_socket_server(testing_service, get_free_port(), 0, NULL, true));
- return TEST_SUCCESS;
- }
- }
-
- return TEST_SKIPPED;
+ return TEST_SUCCESS;
}
static test_return_t memcached_sasl_test(void *object)
static test_return_t check_dns_TEST(void *)
{
- test_warn_hint(libtest::check_dns(), "Broken DNS server/no DNS server found");
+ test_warn(libtest::check_dns(), "Broken DNS server/no DNS server found");
return TEST_SUCCESS;
}
static test_return_t lookup_true_TEST(void *)
{
- test_warn_hint(libtest::lookup("exist.gearman.info"), "dns is not currently working");
+ test_warn(libtest::lookup("exist.gearman.info"), "dns is not currently working");
return TEST_SUCCESS;
}
{0, 0, 0}
};
-static test_return_t check_for_libmemcached(void *)
+static test_return_t check_for_libmemcached(void* object)
{
test_skip(true, HAVE_LIBMEMCACHED);
test_skip(true, has_memcached());
+
+ server_startup_st *servers= (server_startup_st*)object;
+ test_true(servers);
+ servers->clear();
+
+ testing_service= "memcached";
+
return TEST_SUCCESS;
}
-test_st memcached_tests[] ={
- {"memcached startup-shutdown", 0, memcached_cycle_test },
- {"memcached-light startup-shutdown", 0, memcached_light_cycle_TEST },
- {"memcached(socket file) startup-shutdown", 0, memcached_socket_cycle_test },
- {"memcached_sasl() startup-shutdown", 0, memcached_sasl_test },
+test_st memcached_TESTS[] ={
+ {"memcached startup-shutdown", 0, server_startup_TEST },
+ {"memcached(socket file) startup-shutdown", 0, socket_server_startup_TEST },
{"_compare(memcached_return_t)", 0, _compare_memcached_return_t_test },
{0, 0, 0}
};
{"directories", 0, 0, directories_tests},
{"comparison", 0, 0, comparison_tests},
{"gearmand", check_for_gearman, 0, gearmand_tests},
- {"memcached", check_for_libmemcached, 0, memcached_tests},
+ {"memcached", check_for_libmemcached, 0, memcached_TESTS },
{"drizzled", check_for_drizzle, 0, drizzled_tests},
{"cmdline", 0, 0, cmdline_tests},
{"application", 0, 0, application_tests},
AC_SUBST([LIBTEST_VERSION], [1.0])
AC_CONFIG_FILES([libtest/version.h])
+
+m4_include([libtest/m4/mysql.m4])
+m4_include([libtest/m4/memcached.m4])
+++ /dev/null
-AX_WITH_PROG(MEMCACHED_BINARY, [memcached])
-AS_IF([test -f "$ac_cv_path_MEMCACHED_BINARY"],
- [
- AC_DEFINE([HAVE_MEMCACHED_BINARY], [1], [If Memcached binary is available])
- AC_DEFINE_UNQUOTED([MEMCACHED_BINARY], "$ac_cv_path_MEMCACHED_BINARY", [Name of the memcached binary used in make test])
- ],
- [
- AC_DEFINE([HAVE_MEMCACHED_BINARY], [1], [If Memcached binary is available])
- AC_DEFINE([MEMCACHED_BINARY], ["memcached/memcached"], [Name of the memcached binary used in make test])
- ])
static test_return_t MEMCACHED_SERVER_TEMPORARILY_DISABLED_to_success_TEST(memcached_st *memc)
{
+ return TEST_SKIPPED;
+
test_compare_got(MEMCACHED_CONNECTION_FAILURE,
memcached_set(memc,
test_literal_param("foo"),
global_framework->servers().restart();
+ int limit= 5;
memcached_return_t ret;
do {
libtest::dream(3, 0);
ret= memcached_set(memc, test_literal_param("foo"), NULL, 0, time_t(0), uint32_t(0));
- } while (ret == MEMCACHED_SERVER_TEMPORARILY_DISABLED);
+ } while (ret == MEMCACHED_SERVER_TEMPORARILY_DISABLED and --limit);
+
+ test_true(limit);
test_compare_got(MEMCACHED_SUCCESS, ret, memcached_last_error_message(memc));
static test_return_t MEMCACHED_SERVER_MARKED_DEAD_TEST(memcached_st *memc)
{
+ return TEST_SKIPPED;
+
test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, 30));
test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS, true));
} while (ret == MEMCACHED_SUCCESS or ret == MEMCACHED_CONNECTION_FAILURE);
test_compare(MEMCACHED_SERVER_TEMPORARILY_DISABLED, ret);
+ int limit= 5;
do {
libtest::dream(3, 0);
ret= memcached_set(memc, test_literal_param("foo"), NULL, 0, time_t(0), uint32_t(0));
- } while (ret == MEMCACHED_SERVER_TEMPORARILY_DISABLED or ret == MEMCACHED_SUCCESS);
+ } while ((ret == MEMCACHED_SERVER_TEMPORARILY_DISABLED or ret == MEMCACHED_SUCCESS) and --limit);
+
+ test_true(limit);
test_compare_got(MEMCACHED_SERVER_MARKED_DEAD, ret, memcached_last_error_message(memc));
};
test_st server_temporarily_disabled_TESTS[] ={
- { "memcached_set(MEMCACHED_SERVER_TEMPORARILY_DISABLED)", true, (test_callback_fn*)MEMCACHED_SERVER_TEMPORARILY_DISABLED_TEST },
{ "memcached_set(MEMCACHED_SERVER_TEMPORARILY_DISABLED -> MEMCACHED_SUCCESS)", true, (test_callback_fn*)MEMCACHED_SERVER_TEMPORARILY_DISABLED_to_success_TEST },
+ { "memcached_set(MEMCACHED_SERVER_TEMPORARILY_DISABLED)", true, (test_callback_fn*)MEMCACHED_SERVER_TEMPORARILY_DISABLED_TEST },
{ 0, 0, 0 }
};
hash_val= hashk.digest(*ptr, strlen(*ptr));
char buffer[1024];
snprintf(buffer, sizeof(buffer), "%lu %lus %s", (unsigned long)list[x], (unsigned long)hash_val, libhashkit_string_hash(*algo));
- test_true_got(list[x] == hash_val, buffer);
+ test_compare(list[x], hash_val);
}
}
hashkit_return_t rc;
rc= hashk.set_distribution_function(HASHKIT_HASH_CUSTOM);
- test_true_got(rc == HASHKIT_FAILURE or rc == HASHKIT_INVALID_ARGUMENT, hashkit_strerror(NULL, rc));
+ test_true(rc == HASHKIT_FAILURE or rc == HASHKIT_INVALID_ARGUMENT);
test_compare(HASHKIT_SUCCESS,
hashk.set_distribution_function(HASHKIT_HASH_JENKINS));
0, &rc);
if (require_all)
{
- test_true_got(value, keys[x]);
+ test_true(value);
if (key_matches_value)
{
test_strcmp(keys[x], value);
}
else if (memcached_success(rc))
{
- test_warn_hint(value, keys[x]);
+ test_warn(value, "get() did not return a value");
if (value and key_matches_value)
{
test_strcmp(keys[x], value);
test_true(length > 0);
- test_compare_hint(MEMCACHED_SUCCESS,
- memcached_set(memc, key, length,
- NULL, 0, // Zero length values
- time_t(0), uint32_t(0)),
- memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(memc, key, length,
+ NULL, 0, // Zero length values
+ time_t(0), uint32_t(0)));
}
memcached_quit(memc);
uint64_t counter= 0;
- test_compare_got(MEMCACHED_SUCCESS,
- memcached_stat_execute(memc, NULL, item_counter, &counter),
- memcached_last_error_message(memc));
- test_true_got(counter > 0, counter);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_stat_execute(memc, NULL, item_counter, &counter));
+ test_true(counter > 0);
size_t count= 0;
memcached_dump_fn callbacks[1];
callbacks[0]= &callback_dump_counter;
- test_compare_got(MEMCACHED_SUCCESS,
- memcached_dump(memc, callbacks, &count, 1),
- memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_dump(memc, callbacks, &count, 1));
test_true(count);
test_true(memc_no_crypt);
test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__)));
- test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc,
- test_literal_param(__func__), // Key
- test_literal_param(__func__), // Value
- time_t(0),
- uint32_t(0)),
- memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS, memcached_set(memc,
+ test_literal_param(__func__), // Key
+ test_literal_param(__func__), // Value
+ time_t(0),
+ uint32_t(0)));
{
memcached_return_t rc;
{
test_compare(MEMCACHED_SUCCESS, memcached_set_encoding_key(memc, test_literal_param(__func__)));
- test_compare_hint(MEMCACHED_SUCCESS, memcached_add(memc,
+ test_compare(MEMCACHED_SUCCESS, memcached_add(memc,
test_literal_param(__func__), // Key
test_literal_param(__func__), // Value
time_t(0),
- uint32_t(0)),
- memcached_last_error_message(memc));
+ uint32_t(0)));
{
memcached_return_t rc;
// First we add the key
{
- test_compare_hint(MEMCACHED_SUCCESS, memcached_add(memc,
- test_literal_param(__func__), // Key
- test_literal_param(__func__), // Value
- time_t(0),
- uint32_t(0)),
- memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS, memcached_add(memc,
+ test_literal_param(__func__), // Key
+ test_literal_param(__func__), // Value
+ time_t(0),
+ uint32_t(0)));
memcached_return_t rc;
size_t value_length;
libtest::vchar_t new_value;
vchar::make(new_value);
- test_compare_hint(MEMCACHED_SUCCESS, memcached_replace(memc,
- test_literal_param(__func__), // Key
- vchar_param(new_value), // Value
- time_t(0),
- uint32_t(0)),
- memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS, memcached_replace(memc,
+ test_literal_param(__func__), // Key
+ vchar_param(new_value), // Value
+ time_t(0),
+ uint32_t(0)));
memcached_return_t rc;
size_t value_length;
memcached_st *memc_crypt= memcached_clone(NULL, memc);
test_true(memc_crypt);
- test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc,
+ test_compare(MEMCACHED_SUCCESS, memcached_set(memc,
test_literal_param(__func__), // Key
test_literal_param(__func__), // Value
time_t(0),
- uint32_t(0)),
- memcached_last_error_message(memc));
+ uint32_t(0)));
{
memcached_return_t rc;
{
break;
}
- test_compare_hint(MEMCACHED_SUCCESS, rc, memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS, rc);
}
{
test_return_t memcached_exist_SUCCESS(memcached_st *memc)
{
- test_compare_got(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("frog"), 0, 0, 0, 0), memcached_last_error_message(memc));
- test_compare_got(MEMCACHED_SUCCESS, memcached_exist(memc, test_literal_param("frog")), memcached_last_error_message(memc));
- test_compare_got(MEMCACHED_SUCCESS, memcached_delete(memc, test_literal_param("frog"), 0), memcached_last_error_message(memc));
- test_compare_got(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("frog")), memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("frog"), 0, 0, 0, 0));
+ test_compare(MEMCACHED_SUCCESS, memcached_exist(memc, test_literal_param("frog")));
+ test_compare(MEMCACHED_SUCCESS, memcached_delete(memc, test_literal_param("frog"), 0));
+ test_compare(MEMCACHED_NOTFOUND, memcached_exist(memc, test_literal_param("frog")));
return TEST_SUCCESS;
}
test_return_t memcached_exist_by_key_SUCCESS(memcached_st *memc)
{
- test_compare_got(MEMCACHED_SUCCESS, memcached_set_by_key(memc, test_literal_param("master"), test_literal_param("frog"), 0, 0, 0, 0), memcached_last_error_message(memc));
- test_compare_got(MEMCACHED_SUCCESS, memcached_exist_by_key(memc, test_literal_param("master"), test_literal_param("frog")), memcached_last_error_message(memc));
- test_compare_got(MEMCACHED_SUCCESS, memcached_delete_by_key(memc, test_literal_param("master"), test_literal_param("frog"), 0), memcached_last_error_message(memc));
- test_compare_got(MEMCACHED_NOTFOUND, memcached_exist_by_key(memc, test_literal_param("master"), test_literal_param("frog")), memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS, memcached_set_by_key(memc, test_literal_param("master"), test_literal_param("frog"), 0, 0, 0, 0));
+ test_compare(MEMCACHED_SUCCESS, memcached_exist_by_key(memc, test_literal_param("master"), test_literal_param("frog")));
+ test_compare(MEMCACHED_SUCCESS, memcached_delete_by_key(memc, test_literal_param("master"), test_literal_param("frog"), 0));
+ test_compare(MEMCACHED_NOTFOUND, memcached_exist_by_key(memc, test_literal_param("master"), test_literal_param("frog")));
return TEST_SUCCESS;
}
unsigned int check_execute= execute_set(memc, global_pairs, global_count);
- test_true_hint(check_execute > (global_count / 2),
- "Possible false, positive, memcached may have ejected key/value based on memory needs");
+ /* Possible false, positive, memcached may have ejected key/value based on
+ * memory needs. */
+
+ test_true(check_execute > (global_count / 2));
return TEST_SUCCESS;
}
free(return_value);
}
}
- test_true_hint(keys_returned > (global_count / 2),
- "Possible false, positive, memcached may have ejected key/value based on memory needs");
+ /*
+ Possible false, positive, memcached may have ejected key/value based on memory needs.
+ */
+ test_true(keys_returned > (global_count / 2));
return TEST_SUCCESS;
}
total++;
}
}
- test_true_hint(total > (global_count / 2),
- "Possible false, positive, memcached may have ejected key/value based on memory needs");
+ /*
+ Possible false, positive, memcached may have ejected key/value based on memory needs.
+ */
+ test_true(total > (global_count / 2));
return TEST_SUCCESS;
}
}
}
- test_true_hint(total > (global_count / 2),
- "Possible false, positive, memcached may have ejected key/value based on memory needs");
+ /*
+ Possible false, positive, memcached may have ejected key/value based on memory needs.
+ */
+ test_true(total > (global_count / 2));
return TEST_SUCCESS;
}
test_literal_param("foo"),
test_literal_param("when we sanitize"),
time_t(0), (uint32_t)0);
- test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_last_error_message(memc));
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
return TEST_SUCCESS;
}
size_t string_length;
char *string= memcached_get(memc_clone, key, strlen(key),
&string_length, &flags, &rc);
- test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
+ test_compare(MEMCACHED_NOTFOUND, rc);
test_zero(string_length);
test_false(string);
}
while ((results= memcached_fetch_result(memc, &results_obj, &rc))) { test_true(false); /* We should never see a value returned */ };
test_false(results);
- test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
+ test_compare(MEMCACHED_NOTFOUND, rc);
for (uint32_t x= 0; x < 3; x++)
{
rc= memcached_set(memc, keys[x], key_length[x],
keys[x], key_length[x],
(time_t)50, (uint32_t)9);
- test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc));
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
}
test_compare(MEMCACHED_SUCCESS,
test_true(results);
}
test_false(results);
- test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
+ test_compare(MEMCACHED_NOTFOUND, rc);
for (uint32_t x= 0; x < 3; x++)
{
rc= memcached_set(memc, keys[x], key_length[x],
keys[x], key_length[x],
(time_t)50, (uint32_t)9);
- test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc));
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
}
test_compare(MEMCACHED_SUCCESS,
rc= memcached_set(memc, keys[x], key_length[x],
keys[x], key_length[x],
(time_t)50, (uint32_t)9);
- test_true_got(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED, memcached_strerror(NULL, rc));
+ test_true(rc == MEMCACHED_SUCCESS or rc == MEMCACHED_BUFFERED);
}
test_compare(MEMCACHED_SUCCESS,
memcached_mget(memc, keys, key_length, 3));
memcached_result_st *result= memcached_fetch_result(memc, NULL, &rc);
test_null(result);
- test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
+ test_compare(MEMCACHED_NOTFOUND, rc);
memcached_result_free(result);
count++;
}
test_zero(count);
- test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_strerror(NULL, rc));
+ test_compare(MEMCACHED_NOTFOUND, rc);
for (uint32_t x= 0; x < test_array_length(keys); x++)
{
&value[0], value.size(),
0, 0);
- test_true_got((rc == MEMCACHED_SUCCESS or rc == MEMCACHED_WRITE_FAILURE or rc == MEMCACHED_BUFFERED or rc == MEMCACHED_TIMEOUT or rc == MEMCACHED_CONNECTION_FAILURE
- or rc == MEMCACHED_SERVER_TEMPORARILY_DISABLED),
- memcached_strerror(NULL, rc));
+ test_true((rc == MEMCACHED_SUCCESS or rc == MEMCACHED_WRITE_FAILURE or rc == MEMCACHED_BUFFERED or rc == MEMCACHED_TIMEOUT or rc == MEMCACHED_CONNECTION_FAILURE
+ or rc == MEMCACHED_SERVER_TEMPORARILY_DISABLED));
if (rc == MEMCACHED_WRITE_FAILURE or rc == MEMCACHED_TIMEOUT)
{
test_compare(string_length, current_length);
char buffer[1024];
snprintf(buffer, sizeof(buffer), "%u", uint32_t(string_length));
- test_memcmp_hint(string, &value[0], string_length, buffer);
+ test_memcmp(string, &value[0], string_length);
free(string);
}
/* Check the return sizes on FLAGS to make sure it stores 32bit unsigned values correctly */
test_return_t user_supplied_bug16(memcached_st *memc)
{
- test_compare_hint(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("mykey"),
- NULL, 0,
- (time_t)0, UINT32_MAX),
- memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS, memcached_set(memc, test_literal_param("mykey"),
+ NULL, 0,
+ (time_t)0, UINT32_MAX));
size_t length;
test_return_t util_version_test(memcached_st *memc)
{
- test_compare_hint(MEMCACHED_SUCCESS, memcached_version(memc), memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS, memcached_version(memc));
test_true(libmemcached_util_version_check(memc, 0, 0, 0));
bool if_successful= libmemcached_util_version_check(memc, 9, 9, 9);
memcached_return_t rc= memcached_delete(memc,
test_literal_param(__func__),
time_t(0));
- test_true_hint(rc == MEMCACHED_BUFFERED or rc == MEMCACHED_NOTFOUND, memcached_last_error_message(memc));
+ test_true(rc == MEMCACHED_BUFFERED or rc == MEMCACHED_NOTFOUND);
test_compare(query_id +1, memcached_query_id(memc));
size_t string_length;
test_literal_param(__func__),
&string_length, &flags, &rc);
- test_compare_got(MEMCACHED_NOTFOUND, rc, memcached_last_error_message(memc));
+ test_compare(MEMCACHED_NOTFOUND, rc);
test_false(string_length);
test_false(string);
&string_length, &flags, &rc);
test_compare(query_id +1, memcached_query_id(memc));
- test_compare_got(MEMCACHED_SUCCESS, rc, memcached_strerror(NULL, rc));
- test_compare_got(MEMCACHED_SUCCESS, memcached_last_error(memc), memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS, rc);
+ test_compare(MEMCACHED_SUCCESS, memcached_last_error(memc));
test_true(string);
test_compare(strlen(value), string_length);
test_memcmp(string, value, string_length);
value.push_back(char(x % 127));
}
- test_compare_hint(return_value_based_on_buffering(memc),
- memcached_set(memc,
- test_literal_param(__func__),
- &value[0], value.size(),
- time_t(0), uint32_t(0)),
- memcached_last_error_message(memc));
+ test_compare(return_value_based_on_buffering(memc),
+ memcached_set(memc,
+ test_literal_param(__func__),
+ &value[0], value.size(),
+ time_t(0), uint32_t(0)));
size_t string_length;
uint32_t flags;
value.push_back(char(x % 127));
}
- test_compare_hint(return_value_based_on_buffering(memc),
- memcached_set(memc,
- test_literal_param(__func__),
- &value[0], value.size(),
- time_t(0), uint32_t(0)),
- memcached_last_error_message(memc));
+ test_compare(return_value_based_on_buffering(memc),
+ memcached_set(memc,
+ test_literal_param(__func__),
+ &value[0], value.size(),
+ time_t(0), uint32_t(0)));
for (uint32_t x= 0; x < 10; x++)
{
test_return_t memcached_pool_test(memcached_st *)
{
- memcached_return_t rc;
const char *config_string= "--SERVER=host10.example.com --SERVER=host11.example.com --SERVER=host10.example.com --POOL-MIN=10 --POOL-MAX=32";
char buffer[2048];
- rc= libmemcached_check_configuration(config_string, sizeof(config_string) -1, buffer, sizeof(buffer));
- test_true_got(rc != MEMCACHED_SUCCESS, buffer);
+ test_compare(libmemcached_check_configuration(config_string, sizeof(config_string) -1, buffer, sizeof(buffer)), MEMCACHED_PARSE_ERROR);
memcached_pool_st* pool= memcached_pool(config_string, strlen(config_string));
- test_true_got(pool, strerror(errno));
+ test_true(pool);
+ memcached_return_t rc;
memcached_st *memc= memcached_pool_pop(pool, false, &rc);
- test_true(rc == MEMCACHED_SUCCESS);
+ test_compare(rc, MEMCACHED_SUCCESS);
test_true(memc);
/*
test_return_t memcached_stat_TEST(memcached_st *memc)
{
uint64_t counter= 0;
- test_compare_got(MEMCACHED_INVALID_ARGUMENTS,
- memcached_stat_execute(memc, "BAD_ARG_VALUE", item_counter, &counter),
- memcached_last_error_message(memc));
+ test_compare(MEMCACHED_INVALID_ARGUMENTS,
+ memcached_stat_execute(memc, "BAD_ARG_VALUE", item_counter, &counter));
return TEST_SUCCESS;
}
test_true(length > 0);
- test_compare_hint(MEMCACHED_SUCCESS,
- memcached_set(memc, key, length,
- NULL, 0, // Zero length values
- time_t(0), uint32_t(0)),
- memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_set(memc, key, length,
+ NULL, 0, // Zero length values
+ time_t(0), uint32_t(0)));
}
memcached_quit(memc);
uint64_t counter= 0;
- test_compare_got(MEMCACHED_SUCCESS,
- memcached_stat_execute(memc, NULL, item_counter, &counter),
- memcached_last_error_message(memc));
- test_true_got(counter > 0, counter);
+ test_compare(MEMCACHED_SUCCESS,
+ memcached_stat_execute(memc, NULL, item_counter, &counter));
+ test_true(counter);
return TEST_SUCCESS;
}
test_skip(false ,memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL));
rc= memcached_touch(memc, test_literal_param(__func__), 60 *60 *24 *60);
- test_compare_hint(MEMCACHED_SUCCESS, rc, memcached_last_error_message(memc));
+ test_compare(MEMCACHED_SUCCESS, rc);
test_compare(MEMCACHED_NOTFOUND,
memcached_exist(memc, test_literal_param(__func__)));
char buffer[1024];
snprintf(buffer, sizeof(buffer), "%.*s:%lu Got/Expected %u == %u", (int)ptr->key.size, ptr->key.c_str, (unsigned long)ptr->key.size, server_idx, ptr->server_id);
- test_true_got(server_idx == ptr->server_id, buffer);
+ test_compare(server_idx, ptr->server_id);
}
memcached_server_list_free(server_pool);
{
char buffer[BUFSIZ];
- test_compare_got(MEMCACHED_SUCCESS,
- libmemcached_check_configuration(container->construct.option_string().c_str(), container->construct.option_string().size(),
- buffer, sizeof(buffer)),
- container->construct.option_string().c_str());
+ test_compare(MEMCACHED_SUCCESS,
+ libmemcached_check_configuration(container->construct.option_string().c_str(), container->construct.option_string().size(),
+ buffer, sizeof(buffer)));
test_null(container->parent());
container->parent(memcached(container->construct.option_string().c_str(), container->construct.option_string().size()));