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)
+ __test_result(file_arg, line_arg, func_arg),
+ _error_message(NULL),
+ _error_message_size(0)
+{
+ va_list args;
+ va_start(args, func_arg);
+ 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)
+ {
+ _error_message_size++;
+ }
+ va_end(args);
+}
+
+fatal::fatal( const fatal& other ) :
+ __test_result(other),
+ _error_message_size(other._error_message_size)
+{
+ _error_message= (char*) malloc(_error_message_size);
+ if (_error_message)
+ {
+ memcpy(_error_message, other._error_message, _error_message_size);
+ }
+ else
{
- va_list args;
- va_start(args, func_arg);
- const char *format= va_arg(args, const char *);
- int last_error_length= vsnprintf(0, 0, format, args);
- _error_message.resize(last_error_length +1);
- last_error_length= vsnprintf(&_error_message[0], _error_message.size(), format, args);
- va_end(args);
+ _error_message_size= -1;
}
+}
+
+fatal::~fatal() throw()
+{
+ if ((_error_message_size > 0) and _error_message)
+ {
+ free(_error_message);
+ _error_message= NULL;
+ }
+}
static bool _disabled= false;
static uint32_t _counter= 0;
libtest_unittest_LDADD=
# We are either building in tree, or with
-if HAVE_MEMCACHED_BINARY
libtest_libtest_la_SOURCES+= libtest/memcached.cc
-endif
if HAVE_LIBDRIZZLE
+++ /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
-])
#serial 2
AC_DEFUN([YATL_MEMCACHED],
- [AC_REQUIRE([AX_ENABLE_LIBMEMCACHED])
-
- AX_WITH_PROG(MEMCACHED_BINARY, [memcached])
+ [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])
])
- AM_CONDITIONAL([HAVE_MEMCACHED_BINARY],[test -f "$ac_cv_path_MEMCACHED_BINARY"])
])
libtest::Server *build_memcached(const std::string& hostname, const in_port_t try_port)
{
- return new Memcached(hostname, try_port, false);
-}
+ if (HAVE_MEMCACHED_BINARY)
+ {
+ return new Memcached(hostname, try_port, false);
+ }
-libtest::Server *build_memcached_socket(const std::string& socket_file, const in_port_t try_port)
-{
- return new Memcached(socket_file, try_port, true);
+ return NULL;
}
-libtest::Server *build_memcached_sasl(const std::string& hostname, const in_port_t try_port, const std::string& username, const std::string &password)
+libtest::Server *build_memcached_socket(const std::string& socket_file, const in_port_t try_port)
{
- if (username.empty())
+ if (HAVE_MEMCACHED_BINARY)
{
- return new Memcached(hostname, try_port, false, "memcached", "memcached");
+ return new Memcached(socket_file, try_port, true);
}
- return new Memcached(hostname, try_port, false, username, password);
+ return NULL;
}
} // namespace libtest
-
libtest::Server *build_memcached(const std::string& hostname, const in_port_t try_port);
-libtest::Server *build_memcached_light(const std::string& socket_file, const in_port_t try_port);
-
libtest::Server *build_memcached_socket(const std::string& socket_file, const in_port_t try_port);
-libtest::Server *build_memcached_sasl(const std::string& hostname, const in_port_t try_port, const std::string& username, const std::string& password);
-
-libtest::Server *build_memcached_sasl_socket(const std::string& socket_file, const in_port_t try_port, const std::string& username, const std::string& password);
-
}
public:
fatal(const char *file, int line, const char *func, ...);
- ~fatal() throw()
- {
- }
+ fatal(const fatal&);
+
+ ~fatal() throw();
const char* what() const throw()
{
static void increment_disabled_counter();
private:
- vchar_t _error_message;
+ char* _error_message;
+ int _error_message_size;
};
} // namespace libtest
}
else if (server_type.compare("memcached") == 0)
{
- if (MEMCACHED_BINARY)
+ if (HAVE_MEMCACHED_BINARY)
{
server= build_memcached_socket("localhost", try_port);
}
static test_return_t test_throw_fail_TEST(void *)
{
try {
-#if 0
FAIL("test message!");
-#endif
- throw libtest::__failure(LIBYATL_DEFAULT_PARAM, "test message!");
}
catch (const libtest::__failure& e)
{
try {
ASSERT_FALSE_(true, __func__);
}
- catch (libtest::__failure e)
+ catch (const libtest::__failure& e)
{
- std::string compare_message(__func__);
- ASSERT_EQ(compare_message.compare(e.what()), -32);
+ ASSERT_STREQ(e.what(), "Assertion '!true' [ ASSERT_FALSE__TEST ]");
return TEST_SUCCESS;
}
catch (...)
try {
FAIL(__func__);
}
- catch (libtest::__failure e)
+ catch (const libtest::__failure& e)
{
- std::string compare_message(__func__);
- ASSERT_EQ(0, compare_message.compare(e.what()));
+ ASSERT_STREQ(e.what(), __func__);
return TEST_SUCCESS;
}
catch (...)