Merging bzr://gaz.tangent.org/libmemcached/build/ to Build branch
authorContinuous Integration <ci@tangent.org>
Tue, 13 Mar 2012 16:06:21 +0000 (09:06 -0700)
committerContinuous Integration <ci@tangent.org>
Tue, 13 Mar 2012 16:06:21 +0000 (09:06 -0700)
37 files changed:
ChangeLog
configure.ac
libtest/binaries.cc
libtest/blobslap_worker.cc
libtest/cmdline.cc
libtest/common.h
libtest/comparison.cc [new file with mode: 0644]
libtest/comparison.hpp
libtest/core.cc
libtest/cpu.cc
libtest/dream.cc
libtest/failed.cc
libtest/fatal.cc
libtest/framework.cc
libtest/gearmand.cc
libtest/http.cc
libtest/http.hpp
libtest/include.am
libtest/is_local.cc
libtest/killpid.cc
libtest/libtool.cc
libtest/memcached.cc
libtest/port.cc
libtest/runner.cc
libtest/server.cc
libtest/server.h
libtest/server_container.cc
libtest/server_container.h
libtest/signal.cc
libtest/socket.cc
libtest/strerror.cc
libtest/test.cc
libtest/test.h
libtest/unittest.cc
libtest/vchar.cc
tests/libmemcached-1.0/generate.cc
tests/libmemcached-1.0/setup_and_teardowns.cc

index 7a60fb070f99c72e99f165007c41f63f2ab43789..cb1582811626e05fa8278c141b6bf55b7324dbdf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,8 @@
 1.0.5
-
-* Version is now parsed directly in the parser, which makes buffered
-operations now work with it..
-
-* memstat has been extended so that it can be used to find the version of the
-server.
+* Version is now parsed directly in the parser, which makes buffered operations now work with it..
+* memstat has been extended so that it can be used to find the version of the server.
+* Update documentation.
+* Fixes for compile issues on Debian and Ubuntu
 
 
 1.0.4 Thu Jan 26 22:33:54 PST 2012
index 1fe4f7749b29d97cf7e9431a54390fd91c8111be..965ad3bf163cba06e79609a1aafe1b46ea67a2c9 100644 (file)
@@ -7,7 +7,7 @@
 # Use and distribution licensed under the BSD license.  See
 # the COPYING file in this directory for full text.
 
-AC_INIT([libmemcached],[1.0.4],[http://libmemcached.org/])
+AC_INIT([libmemcached],[1.0.5],[http://libmemcached.org/])
 
 AC_CONFIG_AUX_DIR(config)
 
index 33cde3b74700b4544e5a748e227213d068532189..e437f96942cdc285232f992b6fca986134073b34 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 
 namespace libtest {
index fe1cdce31baeaa6f75b72fd1b5bd1596dbf93cc0..caddbdd764cc5d9944e30e94343a4ff5fade480f 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <libtest/blobslap_worker.h>
index efe03040e5088f1742ba95059830433ba077b305..e774113a87f75bc5f8635f1f3312bd02a075d7dc 100644 (file)
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 
 using namespace libtest;
 
 #include <cstdlib>
 #include <cstring>
+#include <cerrno>
 #include <fcntl.h>
 #include <fstream>
 #include <memory>
@@ -351,26 +353,24 @@ void Application::Pipe::reset()
   close(WRITE);
 
   int ret;
-  if ((ret= pipe(_fd)) < 0)
+  if (pipe(_fd) == -1)
   {
-    throw strerror(ret);
+    throw strerror(errno);
   }
   _open[0]= true;
   _open[1]= true;
 
   {
-    ret= fcntl(_fd[0], F_GETFL, 0);
-    if (ret == -1)
+    if ((ret= fcntl(_fd[0], F_GETFL, 0)) == -1)
     {
-      Error << "fcntl(F_GETFL) " << strerror(ret);
-      throw strerror(ret);
+      Error << "fcntl(F_GETFL) " << strerror(errno);
+      throw strerror(errno);
     }
 
-    ret= fcntl(_fd[0], F_SETFL, ret | O_NONBLOCK);
-    if (ret == -1)
+    if ((ret= fcntl(_fd[0], F_SETFL, ret | O_NONBLOCK)) == -1)
     {
-      Error << "fcntl(F_SETFL) " << strerror(ret);
-      throw strerror(ret);
+      Error << "fcntl(F_SETFL) " << strerror(errno);
+      throw strerror(errno);
     }
   }
 }
@@ -406,11 +406,12 @@ void Application::Pipe::close(const close_t& arg)
   if (_open[type])
   {
     int ret;
-    if ((ret= ::close(_fd[type])) < 0)
+    if (::close(_fd[type]) == -1)
     {
-      Error << "close(" << strerror(ret) << ")";
+      Error << "close(" << strerror(errno) << ")";
     }
     _open[type]= false;
+    _fd[type]= -1;
   }
 }
 
@@ -523,21 +524,19 @@ std::string Application::arguments()
 
 void Application::delete_argv()
 {
-  if (built_argv == NULL)
-  {
-    return;
-  }
-
-  for (size_t x= 0; x < _argc; x++)
+  if (built_argv)
   {
-    if (built_argv[x])
+    for (size_t x= 0; x < _argc; x++)
     {
-      ::free(built_argv[x]);
+      if (built_argv[x])
+      {
+        ::free(built_argv[x]);
+      }
     }
+    delete[] built_argv;
+    built_argv= NULL;
+    _argc= 0;
   }
-  delete[] built_argv;
-  built_argv= NULL;
-  _argc= 0;
 }
 
 
index 1e50bf08a203221f3cd5b33460946b53fea75c9e..05f273a72bf6102317533a32e341df1eecaf31e4 100644 (file)
@@ -25,8 +25,6 @@
 
 #pragma once
 
-#include <config.h>
-
 #include <cassert>
 #include <cerrno>
 #include <cstdlib>
diff --git a/libtest/comparison.cc b/libtest/comparison.cc
new file mode 100644 (file)
index 0000000..121df25
--- /dev/null
@@ -0,0 +1,37 @@
+/*  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ * 
+ *  libtest
+ *
+ *  Copyright (C) 2012 Data Differential, http://datadifferential.com/
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 3 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <config.h>
+#include <libtest/common.h>
+
+namespace libtest {
+
+bool _in_valgrind(const char*, int, const char*)
+{
+  if (bool(getenv("TESTS_ENVIRONMENT")) and strstr(getenv("TESTS_ENVIRONMENT"), "valgrind"))
+  {
+    return true;
+  }
+
+  return TEST_SUCCESS;
+}
+
+} // namespace libtest
index bcb7558e61cd907da977208989fa4185cd02fff5..98ea1c8b68f4620ba9a91e250b8351d595c66cb1 100644 (file)
@@ -34,6 +34,8 @@
 
 namespace libtest {
 
+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)
 {
@@ -47,11 +49,15 @@ bool _compare_truth_hint(const char *file, int line, const char *func, T_compara
 }
 
 template <class T1_comparable, class T2_comparable>
-bool _compare(const char *file, int line, const char *func, const T1_comparable& __expected, const T2_comparable& __actual)
+bool _compare(const char *file, int line, const char *func, const T1_comparable& __expected, const T2_comparable& __actual, bool use_io)
 {
   if (__expected != __actual)
   {
-    libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\"";
+    if (use_io)
+    {
+      libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\"";
+    }
+
     return false;
   }
 
@@ -83,11 +89,14 @@ bool _truth(const char *file, int line, const char *func, T_comparable __truth)
 }
 
 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 _compare_hint(const char *file, int line, const char *func, T1_comparable __expected, T2_comparable __actual, T_hint __hint, bool io_error= true)
 {
   if (__expected != __actual)
   {
-    libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\"" << " Additionally: \"" << __hint << "\"";
+    if (io_error)
+    {
+      libtest::stream::make_cerr(file, line, func) << "Expected \"" << __expected << "\" got \"" << __actual << "\"" << " Additionally: \"" << __hint << "\"";
+    }
 
     return false;
   }
index 3e30444a12eeb65fe701a94eae3d18bbea6f5d7b..fac66616eae4a45b3cb663af28299f0242889ddd 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 
 
index d75df955708d0da174ae7ff1f8b588657673bac4..10bb303c1c94e64dbb1f9c1f523f702fb33fb5f5 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <unistd.h>
index 32dece35d247cc542607efa32690061dc1c158eb..c03bd9027ebd10636e72c0e9cdb06dda0095a5fe 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 
 namespace libtest {
index 11e237dcf8220ff85a6b59f7dc2a0c692ba88208..88b84664219bf7fc03736f35d0d23c4bcb73d27a 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <libtest/failed.h>
index 36683a48ed51d69810a55093fb4a4a385206e624..4cef2047b5f4c06f0de5a61eca718871b903240d 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 #include <cstdarg>
 
index 1541e7da7a4b4578c4f9764d6f14c6466ee0d476..a9730a0e95d86294a7d20fd565f95dababf7fd3a 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 #include <iostream>
 
index 4a544f10b9671eeb35b5263e2ee4b069c40e440b..85307fcf0825b60a056fc41c46ba47d72fb2a77d 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <libtest/gearmand.h>
index 5309d50447a7dea2bdbadc047e2caea445917dc3..920fd021d647f34d1a01d257adcecad100b5b892 100644 (file)
@@ -19,6 +19,8 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
+
 #include <libtest/common.h>
 
 #if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
 class CURL;
 #endif
 
+
+static void cleanup_curl(void)
+{
+#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
+  curl_global_cleanup();
+#endif
+}
+
+static void initialize_curl_startup()
+{
+#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
+  if (curl_global_init(CURL_GLOBAL_ALL))
+  {
+    fatal_message("curl_global_init(CURL_GLOBAL_ALL) failed");
+  }
+#endif
+
+  if (atexit(cleanup_curl))
+  {
+    fatal_message("atexit() failed");
+  }
+}
+
+static pthread_once_t start_key_once= PTHREAD_ONCE_INIT;
+void initialize_curl(void)
+{
+  int ret;
+  if (pthread_once(&start_key_once, initialize_curl_startup) != 0)
+  {
+    fatal_message(strerror(ret));
+  }
+}
+
 namespace libtest {
 namespace http {
 
@@ -58,6 +93,13 @@ static void init(CURL *curl, const std::string& url)
   }
 }
 
+HTTP::HTTP(const std::string& url_arg) :
+  _url(url_arg),
+  _response(0)
+{
+  initialize_curl();
+}
+
 bool GET::execute()
 {
   if (HAVE_LIBCURL)
index 012d7a0708329cb35e0147d4204589566a55f164..bbc23b975ae31a88862d8207a9aa83c27b5bfcb6 100644 (file)
@@ -28,10 +28,7 @@ namespace http {
 class HTTP {
 public:
 
-  HTTP(const std::string& url_arg) :
-    _url(url_arg),
-    _response(0)
-  { }
+  HTTP(const std::string& url_arg);
 
   virtual bool execute()= 0;
 
index 92dc7d2776f61744852faafaf682619929a5b09d..accd98ae78e8e5f07e56abe2e3486acc66ecc914 100644 (file)
@@ -21,7 +21,8 @@
 # 
 
 LIBTOOL_COMMAND= ${abs_top_builddir}/libtool --mode=execute
-VALGRIND_COMMAND= $(LIBTOOL_COMMAND) valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE
+VALGRIND_EXEC_COMMAND= $(LIBTOOL_COMMAND) valgrind --error-exitcode=1 --leak-check=yes --show-reachable=yes --track-fds=yes --malloc-fill=A5 --free-fill=DE
+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
 GDB_COMMAND= $(LIBTOOL_COMMAND) gdb -f -x libtest/run.gdb
@@ -33,7 +34,7 @@ export DRD_COMMAND
 export GDB_COMMAND
 
 valgrind:
-       @echo make check TESTS_ENVIRONMENT="\"$(VALGRIND_COMMAND)\""
+       @echo make check TESTS_ENVIRONMENT="\"$(VALGRIND_EXEC_COMMAND)\""
 
 gdb:
        @echo make check TESTS_ENVIRONMENT="\"$(GDB_COMMAND)\""
@@ -100,6 +101,7 @@ noinst_LTLIBRARIES+= libtest/libtest.la
 libtest_libtest_la_SOURCES= \
                            libtest/binaries.cc \
                            libtest/cmdline.cc \
+                           libtest/comparison.cc \
                            libtest/core.cc \
                            libtest/cpu.cc \
                            libtest/dream.cc \
@@ -210,7 +212,7 @@ test-unittest: libtest/unittest
        @libtest/unittest
 
 valgrind-unittest: libtest/unittest
-       @$(VALGRIND_COMMAND) libtest/unittest
+       @$(VALGRIND_COMMAND) libtest/unittest TESTS_ENVIRONMENT="valgrind"
 
 gdb-unittest: libtest/unittest
        @$(GDB_COMMAND) libtest/unittest
index dfc303b23be6d103e0047be0f3901ab8aa48b8f6..ec3322af32a246fe60f7608cf4df4c9da7effde7 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 
 
index 79f6a3f81cb59f936717fcd4e6c704b7f3c268a4..cfc9316f34e2b02976060ffb09035077aa07fb5a 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <cstdlib>
index 90f0035e5a5ffdd9ff62a05c079f6a245e9102f2..5beea9b96ce448b8d4b66ef549471cd765fda5e0 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 #include <string>
 
index c5358bf53fa5da4bdf4b6b7c68f777bddd87c873..5327e9b8dbb971a1181cda97aaa175b48507fa13 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <libmemcached-1.0/memcached.h>
@@ -87,7 +88,8 @@ public:
     // Memcached is slow to start, so we need to do this
     if (pid_file().empty() == false)
     {
-      if (error_is_ok and not wait_for_pidfile())
+      if (error_is_ok and
+          wait_for_pidfile() == false)
       {
         Error << "Pidfile was not found:" << pid_file();
         return -1;
@@ -121,7 +123,7 @@ public:
   bool ping()
   {
     // Memcached is slow to start, so we need to do this
-    if (not pid_file().empty())
+    if (pid_file().empty() == false)
     {
       if (wait_for_pidfile() == false)
       {
@@ -135,7 +137,7 @@ public:
 
     if (has_socket())
     {
-        ret= libmemcached_util_ping(socket().c_str(), 0, &rc);
+      ret= libmemcached_util_ping(socket().c_str(), 0, &rc);
     }
     else
     {
@@ -235,9 +237,9 @@ public:
   pid_t get_pid(bool error_is_ok)
   {
     // Memcached is slow to start, so we need to do this
-    if (not pid_file().empty())
+    if (pid_file().empty() == false)
     {
-      if (error_is_ok and not wait_for_pidfile())
+      if (error_is_ok and wait_for_pidfile() == false)
       {
         Error << "Pidfile was not found:" << pid_file();
         return -1;
@@ -342,7 +344,11 @@ public:
 class MemcachedSaSL : public Memcached
 {
 public:
-  MemcachedSaSL(const std::string& host_arg, const in_port_t port_arg, const bool is_socket_arg, const std::string& username_arg, const std::string &password_arg) :
+  MemcachedSaSL(const std::string& host_arg,
+                const in_port_t port_arg, 
+                const bool is_socket_arg, 
+                const std::string& username_arg, 
+                const std::string &password_arg) :
     Memcached(host_arg, port_arg, is_socket_arg, username_arg, password_arg)
   { }
 
@@ -364,9 +370,10 @@ public:
   pid_t get_pid(bool error_is_ok)
   {
     // Memcached is slow to start, so we need to do this
-    if (not pid_file().empty())
+    if (pid_file().empty() == false)
     {
-      if (error_is_ok and not wait_for_pidfile())
+      if (error_is_ok and 
+          wait_for_pidfile() == false)
       {
         Error << "Pidfile was not found:" << pid_file();
         return -1;
@@ -457,7 +464,7 @@ bool Memcached::build(size_t argc, const char *argv[])
 
 bool MemcachedLight::build(size_t argc, const char *argv[])
 {
-  for (int x= 0 ; x < argc ; x++)
+  for (size_t x= 0 ; x < argc ; x++)
   {
     add_option(argv[x]);
   }
index b6820335f1c3d610874da501710c67c219fe5006..2561343dd987a279f6b389d60d2a67d45223b69c 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <cassert>
index b205b0e79e50622578f62d8761e5c264a1c65da6..6b8d0d483424fc7dc28940b0626ed4d2129743ab 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 
 namespace libtest {
index e554039a1c523d8dea88c4c869f89f067af85ed8..b6564b3aab38bd11d0b9d7e25fc8169144965d6f 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <cassert>
@@ -65,7 +66,7 @@ std::ostream& operator<<(std::ostream& output, const Server &arg)
     output << " Socket:" <<  arg.socket();
   }
 
-  if (not arg.running().empty())
+  if (arg.running().empty() == false)
   {
     output << " Exec:" <<  arg.running();
   }
@@ -73,7 +74,10 @@ std::ostream& operator<<(std::ostream& output, const Server &arg)
   return output;  // for multiple << operators
 }
 
+#define MAGIC_MEMORY 123570
+
 Server::Server(const std::string& host_arg, const in_port_t port_arg, bool is_socket_arg) :
+  _magic(MAGIC_MEMORY),
   _is_socket(is_socket_arg),
   _pid(-1),
   _port(port_arg),
@@ -89,6 +93,11 @@ Server::~Server()
   }
 }
 
+bool Server::validate()
+{
+  return _magic == MAGIC_MEMORY;
+}
+
 // If the server exists, kill it
 bool Server::cycle()
 {
@@ -96,7 +105,8 @@ bool Server::cycle()
 
   // Try to ping, and kill the server #limit number of times
   pid_t current_pid;
-  while (--limit and is_pid_valid(current_pid= get_pid()))
+  while (--limit and 
+         is_pid_valid(current_pid= get_pid()))
   {
     if (kill(current_pid))
     {
@@ -167,7 +177,7 @@ bool Server::start()
 
   if (Application::SUCCESS !=  (ret= app.wait()))
   {
-    Error << "Application::wait() " << app.print() << " " << ret;
+    Error << "Application::wait() " << _running << " " << ret;
     return false;
   }
 
@@ -180,9 +190,11 @@ bool Server::start()
   {
     Wait wait(pid_file(), 8);
 
-    if (not wait.successful())
+    if (wait.successful() == false)
     {
-      Error << "Unable to open pidfile for: " << _running;
+      libtest::fatal(LIBYATL_DEFAULT_PARAM,
+                     "Unable to open pidfile for: %s",
+                     _running.c_str());
     }
   }
 
index df2bbee814774d9ceb8146e0d5e1d97859f3794f..1b6841d55d38d57541679d0af66305f9060df58a 100644 (file)
@@ -39,6 +39,7 @@ private:
   typedef std::vector< std::pair<std::string, std::string> > Options;
 
 private:
+  uint64_t _magic;
   bool _is_socket;
   std::string _socket;
   std::string _sasl;
@@ -229,6 +230,8 @@ public:
   bool start();
   bool command(libtest::Application& app);
 
+  bool validate();
+
 protected:
   bool set_pid_file();
   Options _options;
index 6d0c785e7de5f20d5d2d06d549ed7545e5b749ff..579f901c0694c855237f78332496cd0849f5454a 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <cassert>
@@ -120,11 +121,26 @@ void server_startup_st::restart()
   }
 }
 
+#define MAGIC_MEMORY 123575
+server_startup_st::server_startup_st() :
+  _magic(MAGIC_MEMORY),
+  _socket(false),
+  _sasl(false),
+  _count(5),
+  udp(0)
+{ }
+
 server_startup_st::~server_startup_st()
 {
   shutdown_and_remove();
 }
 
+bool server_startup_st::validate()
+{
+  return _magic == MAGIC_MEMORY;
+}
+
+
 bool server_startup_st::is_debug() const
 {
   return bool(getenv("LIBTEST_MANUAL_GDB"));
@@ -235,7 +251,6 @@ bool server_startup(server_startup_st& construct, const std::string& server_type
   }
   else if (server->start() == false)
   {
-    Error << "Failed to start " << *server;
     delete server;
     return false;
   }
@@ -313,7 +328,7 @@ bool server_startup_st::start_socket_server(const std::string& server_type, cons
   /*
     We will now cycle the server we have created.
   */
-  if (not server->cycle())
+  if (server->cycle() == false)
   {
     Error << "Could not start up server " << *server;
     delete server;
index 4e81dafd27af310f22db1bf91ddd62160adebacb..29ecb97d689ecbaf34beae6bbd71b56c1375e865 100644 (file)
@@ -35,6 +35,7 @@ namespace libtest {
 class server_startup_st
 {
 private:
+  uint64_t _magic;
   std::string server_list;
   bool _socket;
   bool _sasl;
@@ -47,12 +48,10 @@ public:
   uint8_t udp;
   std::vector<Server *> servers;
 
-  server_startup_st() :
-    _socket(false),
-    _sasl(false),
-    _count(5),
-    udp(0)
-  { }
+  server_startup_st();
+  ~server_startup_st();
+
+  bool validate();
 
   bool start_socket_server(const std::string& server_type, const in_port_t try_port, int argc, const char *argv[]);
 
@@ -114,8 +113,6 @@ public:
 
   void push_server(Server *);
   Server *pop_server();
-
-  ~server_startup_st();
 };
 
 bool server_startup(server_startup_st&, const std::string&, in_port_t try_port, int argc, const char *argv[]);
index 42e6d78da39234032bb3736aa6df3ccfe22c5ad0..bc9da4bc33b7eebefd705bf43a0f508657848be8 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <csignal>
index 21fade0b305cfb8fa842984050c825558a2f4639..832f0c4a945f17b3081708533a58ef473ec35553 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 
 static char global_socket[1024]= { 0 };
index d081bafcd2d433af39afedb4d1ee399e5d16df32..0739d625f12d469ba7ffc34ea69a5ba0c3182aa4 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 
 namespace libtest { 
index 66d258a0b009094430793e268598203ee8a836b9..cafc48d4e45cfa9f2b41963ce73d3da0d15dab9b 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 
 #include <cassert>
 
 #include <signal.h>
 
-#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
-#include <curl/curl.h>
-#endif
-
 #ifndef __INTEL_COMPILER
 #pragma GCC diagnostic ignored "-Wold-style-cast"
 #endif
@@ -74,32 +71,11 @@ static long int timedif(struct timeval a, struct timeval b)
   return s + us;
 }
 
-static void cleanup_curl(void)
-{
-#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
-  curl_global_cleanup();
-#endif
-}
-
 #include <getopt.h>
 #include <unistd.h>
 
 int main(int argc, char *argv[])
 {
-#if defined(HAVE_CURL_CURL_H) && HAVE_CURL_CURL_H
-  if (curl_global_init(CURL_GLOBAL_ALL))
-  {
-    Error << "curl_global_init(CURL_GLOBAL_ALL) failed";
-    return EXIT_FAILURE;
-  }
-#endif
-
-  if (atexit(cleanup_curl))
-  {
-    Error << "atexit() failed";
-    return EXIT_FAILURE;
-  }
-
   bool opt_repeat= false;
   std::string collection_to_run;
 
@@ -192,15 +168,9 @@ int main(int argc, char *argv[])
   try {
     do {
       exit_code= EXIT_SUCCESS;
-      Framework *world= new Framework();
+      Framework world;
 
-      if (world == NULL)
-      {
-        Error << "Failed to create Framework()";
-        return EXIT_FAILURE;
-      }
-
-      assert(sigignore(SIGPIPE) == 0);
+      fatal_assert(sigignore(SIGPIPE) == 0);
 
       libtest::SignalThread signal;
       if (not signal.setup())
@@ -211,10 +181,10 @@ int main(int argc, char *argv[])
 
       Stats stats;
 
-      get_world(world);
+      get_world(&world);
 
       test_return_t error;
-      void *creators_ptr= world->create(error);
+      void *creators_ptr= world.create(error);
 
       switch (error)
       {
@@ -223,11 +193,9 @@ int main(int argc, char *argv[])
 
       case TEST_SKIPPED:
         Out << "SKIP " << argv[0];
-        delete world;
         return EXIT_SUCCESS;
 
       case TEST_FAILURE:
-        delete world;
         return EXIT_FAILURE;
       }
 
@@ -250,7 +218,7 @@ int main(int argc, char *argv[])
         wildcard= argv[2];
       }
 
-      for (collection_st *next= world->collections; next and next->name and (not signal.is_shutdown()); next++)
+      for (collection_st *next= world.collections; next and next->name and (not signal.is_shutdown()); next++)
       {
         bool failed= false;
         bool skipped= false;
@@ -262,11 +230,11 @@ int main(int argc, char *argv[])
 
         stats.collection_total++;
 
-        test_return_t collection_rc= world->startup(creators_ptr);
+        test_return_t collection_rc= world.startup(creators_ptr);
 
         if (collection_rc == TEST_SUCCESS and next->pre)
         {
-          collection_rc= world->runner()->pre(next->pre, creators_ptr);
+          collection_rc= world.runner()->pre(next->pre, creators_ptr);
         }
 
         switch (collection_rc)
@@ -303,20 +271,20 @@ int main(int argc, char *argv[])
 
           test_return_t return_code;
           try {
-            if (test_success(return_code= world->item.startup(creators_ptr)))
+            if (test_success(return_code= world.item.startup(creators_ptr)))
             {
-              if (test_success(return_code= world->item.flush(creators_ptr, run)))
+              if (test_success(return_code= world.item.flush(creators_ptr, run)))
               {
                 // @note pre will fail is SKIPPED is returned
-                if (test_success(return_code= world->item.pre(creators_ptr)))
+                if (test_success(return_code= world.item.pre(creators_ptr)))
                 {
                   { // Runner Code
                     gettimeofday(&start_time, NULL);
-                    assert(world->runner());
+                    assert(world.runner());
                     assert(run->test_fn);
                     try 
                     {
-                      return_code= world->runner()->run(run->test_fn, creators_ptr);
+                      return_code= world.runner()->run(run->test_fn, creators_ptr);
                     }
                     // Special case where check for the testing of the exception
                     // system.
@@ -339,7 +307,7 @@ int main(int argc, char *argv[])
                 }
 
                 // @todo do something if post fails
-                (void)world->item.post(creators_ptr);
+                (void)world.item.post(creators_ptr);
               }
               else if (return_code == TEST_SKIPPED)
               { }
@@ -394,7 +362,7 @@ int main(int argc, char *argv[])
             throw fatal_message("invalid return code");
           }
 
-          if (test_failed(world->on_error(return_code, creators_ptr)))
+          if (test_failed(world.on_error(return_code, creators_ptr)))
           {
             Error << "Failed while running on_error()";
             signal.set_shutdown(SHUTDOWN_GRACEFUL);
@@ -402,7 +370,7 @@ int main(int argc, char *argv[])
           }
         }
 
-        (void) world->runner()->post(next->post, creators_ptr);
+        (void) world.runner()->post(next->post, creators_ptr);
 
 cleanup:
         if (failed == false and skipped == false)
@@ -420,7 +388,7 @@ cleanup:
           stats.collection_skipped++;
         }
 
-        world->shutdown(creators_ptr);
+        world.shutdown(creators_ptr);
         Outn();
       }
 
@@ -451,8 +419,6 @@ cleanup:
 
       stats_print(&stats);
 
-      delete world;
-
       Outn(); // Generate a blank to break up the messages if make check/test has been run
     } while (exit_code == EXIT_SUCCESS and opt_repeat);
   }
@@ -460,13 +426,13 @@ cleanup:
   {
     std::cerr << e.what() << std::endl;
   }
-  catch (std::bad_alloc& e)
+  catch (std::exception& e)
   {
     std::cerr << e.what() << std::endl;
   }
   catch (...)
   {
-    std::cerr << "Unknown exception halted execution" << std::endl;
+    std::cerr << "Unknown exception halted execution." << std::endl;
   }
 
   return exit_code;
index abd4e2aa4184f2babd6abc9ea1f14d86de925db6..a79109f12f69ad298ae5ed7e4a1e6df9d48751a6 100644 (file)
@@ -89,10 +89,19 @@ do \
 } while (0)
 #define test_true_hint test_true_got
 
-#define test_skip(A,B) \
+#define test_skip(__expected, __actual) \
 do \
 { \
-  if ((A) != (B)) \
+  if (libtest::_compare(__FILE__, __LINE__, __func__, ((__expected)), ((__actual)), false) == false) \
+  { \
+    return TEST_SKIPPED; \
+  } \
+} while (0)
+
+#define test_skip_valgrind() \
+do \
+{ \
+  if (libtest::_in_valgrind(__FILE__, __LINE__, __func__)) \
   { \
     return TEST_SKIPPED; \
   } \
@@ -132,7 +141,7 @@ do \
 #define test_compare(__expected, __actual) \
 do \
 { \
-  if (not libtest::_compare(__FILE__, __LINE__, __func__, ((__expected)), ((__actual)))) \
+  if (libtest::_compare(__FILE__, __LINE__, __func__, ((__expected)), ((__actual)), true) == false) \
   { \
     libtest::create_core(); \
     return TEST_FAILURE; \
@@ -166,7 +175,7 @@ do \
 #define test_compare_warn(__expected, __actual) \
 do \
 { \
-  void(libtest::_compare(__FILE__, __LINE__, __func__, (__expected), (__actual))); \
+  void(libtest::_compare(__FILE__, __LINE__, __func__, (__expected), (__actual)), true); \
 } while (0)
 
 #define test_compare_warn_hint(__expected, __actual, __hint) \
index 7f0c7404fc2d5ca74997efaf1dc3a0bfcb281809..0f82a560a701f31e177cedb1850c2e5d9d5a5489 100644 (file)
@@ -63,7 +63,7 @@ static test_return_t GDB_COMMAND_test(void *)
 
 static test_return_t test_success_equals_one_test(void *)
 {
-  test_skip(HAVE_LIBMEMCACHED, true);
+  test_skip(HAVE_LIBMEMCACHED, 1);
 #if defined(HAVE_LIBMEMCACHED) && HAVE_LIBMEMCACHED 
   test_zero(MEMCACHED_SUCCESS);
 #endif
@@ -110,7 +110,7 @@ static test_return_t local_not_test(void *)
   }
 
   // unsetenv() will cause issues with valgrind
-  _compare(__FILE__, __LINE__, __func__, 0, unsetenv("LIBTEST_LOCAL"));
+  _compare(__FILE__, __LINE__, __func__, 0, unsetenv("LIBTEST_LOCAL"), true);
   test_compare(0, unsetenv("LIBTEST_LOCAL"));
   test_false(test_is_local());
 
@@ -228,14 +228,16 @@ static test_return_t _compare_gearman_return_t_test(void *)
 static test_return_t gearmand_cycle_test(void *object)
 {
   server_startup_st *servers= (server_startup_st*)object;
-  test_true(servers);
+  test_true(servers and servers->validate());
 
 #if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
   test_true(has_gearmand_binary());
-#else
-  test_skip(true, has_gearmand_binary());
 #endif
 
+  test_skip(true, has_gearmand_binary());
+
+  Error << " " << has_gearmand_binary();
+
   test_true(server_startup(*servers, "gearmand", get_free_port(), 0, NULL));
 
   return TEST_SUCCESS;
@@ -253,6 +255,29 @@ static test_return_t memcached_light_cycle_TEST(void *object)
   return TEST_SUCCESS;
 }
 
+static test_return_t skip_shim(bool a, bool b)
+{
+  test_skip(a, b);
+  return TEST_SUCCESS;
+}
+
+static test_return_t test_skip_true_TEST(void *object)
+{
+  test_compare(true, true);
+  test_compare(false, false);
+  test_compare(TEST_SUCCESS, skip_shim(true, true));
+  test_compare(TEST_SUCCESS, skip_shim(false, false));
+
+  return TEST_SUCCESS;
+}
+
+static test_return_t test_skip_false_TEST(void *object)
+{
+  test_compare(TEST_SKIPPED, skip_shim(true, false));
+  test_compare(TEST_SKIPPED, skip_shim(false, true));
+  return TEST_SUCCESS;
+}
+
 static test_return_t memcached_cycle_test(void *object)
 {
   server_startup_st *servers= (server_startup_st*)object;
@@ -293,10 +318,7 @@ static test_return_t memcached_sasl_test(void *object)
   server_startup_st *servers= (server_startup_st*)object;
   test_true(servers);
 
-  if (getenv("TESTS_ENVIRONMENT"))
-  {
-    return TEST_SKIPPED;
-  }
+  test_skip(false, bool(getenv("TESTS_ENVIRONMENT")));
 
   if (MEMCACHED_SASL_BINARY)
   {
@@ -361,27 +383,19 @@ static test_return_t application_true_fubar_BINARY(void *)
 
 static test_return_t application_doesnotexist_BINARY(void *)
 {
+  test_skip_valgrind();
+
   Application true_app("doesnotexist");
 
   const char *args[]= { "--fubar", 0 };
 #if defined(TARGET_OS_OSX) && TARGET_OS_OSX
   test_compare(Application::INVALID, true_app.run(args));
+  test_compare(Application::FAILURE, true_app.wait());
 #else
   test_compare(Application::SUCCESS, true_app.run(args));
+  test_compare(Application::INVALID, true_app.wait());
 #endif
-  // Behavior is different if we are running under valgrind
-  if (getenv("TESTS_ENVIRONMENT") and strstr(getenv("TESTS_ENVIRONMENT"), "valgrind"))
-  {
-    test_compare(Application::FAILURE, true_app.wait());
-  }
-  else
-  {
-#if defined(TARGET_OS_OSX) && TARGET_OS_OSX
-    test_compare(Application::FAILURE, true_app.wait());
-#else
-    test_compare(Application::INVALID, true_app.wait());
-#endif
-  }
+
   test_compare(0, true_app.stdout_result().size());
 
   return TEST_SUCCESS;
@@ -706,6 +720,12 @@ test_st memcached_tests[] ={
   {0, 0, 0}
 };
 
+test_st test_skip_TESTS[] ={
+  {"true, true", 0, test_skip_true_TEST },
+  {"true, false", 0, test_skip_false_TEST },
+  {0, 0, 0}
+};
+
 test_st environment_tests[] ={
   {"LIBTOOL_COMMAND", 0, LIBTOOL_COMMAND_test },
   {"VALGRIND_COMMAND", 0, VALGRIND_COMMAND_test },
@@ -825,6 +845,7 @@ test_st http_tests[] ={
 collection_st collection[] ={
   {"environment", 0, 0, environment_tests},
   {"return values", 0, 0, tests_log},
+  {"test_skip()", 0, 0, test_skip_TESTS },
   {"local", 0, 0, local_log},
   {"directories", 0, 0, directories_tests},
   {"comparison", 0, 0, comparison_tests},
index 779cfbba065cf810f6b7b403803ecfd1c76c2cc0..9e0b92a47f69fe326f5c65cb3899ffc581ca462d 100644 (file)
@@ -19,6 +19,7 @@
  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
+#include <config.h>
 #include <libtest/common.h>
 
 namespace libtest {
index 4411d77f22129ed07e8bef1accd197b186c7b4c7..da31fe0cefe680a31dbac985cab7f1fb80454586 100644 (file)
@@ -51,6 +51,8 @@
 #define GLOBAL_COUNT 10000
 #define GLOBAL2_COUNT 100
 
+using namespace libtest;
+
 static pairs_st *global_pairs;
 static const char *global_keys[GLOBAL_COUNT];
 static size_t global_keys_length[GLOBAL_COUNT];
index 9bf0e92a838fca9cbab14ac07fed51d20c322955..093be4906f2b3998c7ce211575dfbbda442939b7 100644 (file)
@@ -44,6 +44,7 @@
 
 #include <sys/stat.h>
 
+using namespace libtest;
 
 memcached_return_t return_value_based_on_buffering(memcached_st *memc)
 {