--- /dev/null
+#!/bin/bash
+
+if test -f configure; then make clean; make merge-clean; make distclean; fi;
+
+rm -r -f autom4te.cache
+./config/autorun.sh
+./configure
+make
LT_INIT
m4_include([m4/memcached.m4])
m4_include([m4/memcached_sasl.m4])
+m4_include([m4/gearmand.m4])
AM_CONDITIONAL(BUILDING_LIBMEMCACHED, true)
AM_CONDITIONAL(HAVE_LIBMEMCACHED, false)
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2011 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 <libtest/common.h>
+
+namespace libtest {
+
+bool has_gearmand_binary()
+{
+#if defined(HAVE_GEARMAND_BINARY) && HAVE_GEARMAND_BINARY
+ if (access(GEARMAND_BINARY,R_OK|X_OK) == 0)
+ {
+ return true;
+ }
+#endif
+
+ return false;
+}
+
+bool has_memcached_binary()
+{
+#if defined(HAVE_MEMCACHED_BINARY) && HAVE_MEMCACHED_BINARY
+ if (access(MEMCACHED_BINARY,R_OK|X_OK) == 0)
+ {
+ return true;
+ }
+#endif
+
+ return false;
+}
+
+bool has_memcached_sasl_binary()
+{
+#if defined(HAVE_MEMCACHED_SASL_BINARY) && HAVE_MEMCACHED_SASL_BINARY
+ if (access(MEMCACHED_SASL_BINARY, R_OK|X_OK) == 0)
+ {
+ return true;
+ }
+#endif
+
+ return false;
+}
+
+}
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * libtest
+ *
+ * Copyright (C) 2011 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
+ */
+
+#pragma once
+
+namespace libtest {
+
+LIBTEST_API
+bool has_memcached_binary();
+
+LIBTEST_API
+bool has_memcached_sasl_binary();
+
+LIBTEST_API
+bool has_gearmand_binary();
+
+} // namespace libtest
+
noinst_LTLIBRARIES+= libtest/libtest.la
libtest_libtest_la_SOURCES= \
+ libtest/binaries.cc \
libtest/cmdline.cc \
libtest/framework.cc \
libtest/killpid.cc \
libtest/libtool.cc \
- libtest/runner.cc \
libtest/port.cc \
+ libtest/runner.cc \
libtest/server.cc \
libtest/server_container.cc \
libtest/signal.cc \
world= new Framework();
- if (not world)
+ if (world == NULL)
{
Error << "Failed to create Framework()";
return EXIT_FAILURE;
#include <libtest/stream.h>
#include <libtest/cmdline.h>
#include <libtest/string.hpp>
+#include <libtest/binaries.h>
#pragma once
{
test_skip(HAVE_LIBGEARMAN, true);
#if defined(HAVE_LIBGEARMAN) && HAVE_LIBGEARMAN
- test_compare(GEARMAN_SUCCESS, GEARMAN_SUCCESS);
+ test_compare(GEARMAN_SUCCESS, GEARMAN_SUCCESS);
#endif
return TEST_SUCCESS;
server_startup_st *servers= (server_startup_st*)object;
test_true(servers);
- if (HAVE_LIBGEARMAN)
+ if (HAVE_LIBGEARMAN and GEARMAND_BINARY)
{
+ test_true(has_gearmand_binary());
const char *argv[1]= { "cycle_gearmand" };
test_true(server_startup(*servers, "gearmand", 9999, 1, argv));
if (MEMCACHED_BINARY and HAVE_LIBMEMCACHED)
{
+ test_true(has_memcached_binary());
const char *argv[1]= { "cycle_memcached" };
test_true(server_startup(*servers, "memcached", 9998, 1, argv));
if (MEMCACHED_BINARY and HAVE_LIBMEMCACHED)
{
+ test_true(has_memcached_binary());
const char *argv[1]= { "cycle_memcached" };
test_true(servers->start_socket_server("memcached", 9997, 1, argv));
if (MEMCACHED_SASL_BINARY and HAVE_LIBMEMCACHED)
{
+ test_true(has_memcached_sasl_binary());
const char *argv[1]= { "cycle_memcached_sasl" };
test_true(server_startup(*servers, "memcached-sasl", 9996, 1, argv));
--- /dev/null
+AX_WITH_PROG(GEARMAND_BINARY,gearmand)
+AS_IF([test -f "$ac_cv_path_GEARMAND_BINARY"],
+ [
+ AC_DEFINE([HAVE_GEARMAND_BINARY], [1], [If Gearmand binary is available])
+ AC_DEFINE_UNQUOTED([GEARMAND_BINARY], "$ac_cv_path_GEARMAND_BINARY", [Name of the gearmand binary used in make test])
+ ],
+ [
+ AC_DEFINE([HAVE_GEARMAND_BINARY], [0], [If Gearmand binary is available])
+ AC_DEFINE([GEARMAND_BINARY], [0], [Name of the gearmand binary used in make test])
+ ])
+
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], [0], [If Memcached binary is available])
AC_DEFINE([MEMCACHED_BINARY], [0], [Name of the memcached binary used in make test])
])
AX_WITH_PROG(MEMCACHED_SASL_BINARY,memcached_sasl)
AS_IF([test -f "$ac_cv_path_MEMCACHED_SASL_BINARY"],
[
+ AC_DEFINE([HAVE_MEMCACHED_SASL_BINARY], [1], [Name of the memcached_sasl binary used in make test])
AC_DEFINE_UNQUOTED([MEMCACHED_SASL_BINARY], "$ac_cv_path_MEMCACHED_SASL_BINARY", [Name of the memcached_sasl binary used in make test])
],
[
+ AC_DEFINE([HAVE_MEMCACHED_SASL_BINARY], [0], [Name of the memcached_sasl binary used in make test])
AC_DEFINE([MEMCACHED_SASL_BINARY], [0], [Name of the memcached_sasl binary used in make test])
])
+++ /dev/null
-dnl Copyright (C) 2009 Sun Microsystems, Inc.
-dnl This file is free software; Sun Microsystems, Inc.
-dnl gives unlimited permission to copy and/or distribute it,
-dnl with or without modifications, as long as this notice is preserved.
-
-AC_DEFUN([_PANDORA_SEARCH_MEMCACHED],[
-
- AC_ARG_WITH([memcached],
- [AS_HELP_STRING([--with-memcached],
- [Memcached binary to use for make test])],
- [ac_cv_with_memcached="$withval"],
- [ac_cv_with_memcached=memcached])
-
- # just ignore the user if --without-memcached is passed.. it is
- # only used by make test
- AS_IF([test "x$ac_cv_with_memcached" = "xno"],[
- ac_cv_with_memcached=memcached
- MEMCACHED_BINARY=memcached
- ],[
- AS_IF([test -f "$ac_cv_with_memcached"],[
- MEMCACHED_BINARY=$ac_cv_with_memcached
- ],[
- AC_PATH_PROG([MEMCACHED_BINARY], [$ac_cv_with_memcached], "no")
- ])
- ])
- AC_DEFINE_UNQUOTED([MEMCACHED_BINARY], "$MEMCACHED_BINARY",
- [Name of the memcached binary used in make test])
- AM_CONDITIONAL([HAVE_MEMCACHED],[test "x$MEMCACHED_BINARY" != "xno"])
-])
-
-AC_DEFUN([PANDORA_HAVE_MEMCACHED],[
- AC_REQUIRE([_PANDORA_SEARCH_MEMCACHED])
-])
-
-AC_DEFUN([PANDORA_REQUIRE_MEMCACHED],[
- AC_REQUIRE([PANDORA_HAVE_MEMCACHED])
- AS_IF([test "x$MEMCACHED_BINARY" = "xno"],[
- AC_MSG_ERROR(["could not find memcached binary"])
- ])
-])
-
static void *world_create(server_startup_st& servers, test_return_t& error)
{
- if (LIBMEMCACHED_WITH_SASL_SUPPORT == 0)
+ if (HAVE_MEMCACHED_BINARY == 0)
+ {
+ error= TEST_FATAL;
+ return NULL;
+ }
+
+ if (servers.sasl() and (LIBMEMCACHED_WITH_SASL_SUPPORT == 0 or MEMCACHED_SASL_BINARY == 0))
{
error= TEST_SKIPPED;
return NULL;
{
if (not server_startup(servers, "memcached-sasl", port, 1, argv))
{
- error= TEST_FAILURE;
+ error= TEST_FATAL;
return NULL;
}
}
{
if (not server_startup(servers, "memcached", port, 1, argv))
{
- error= TEST_FAILURE;
+ error= TEST_FATAL;
return NULL;
}
}
const char *argv[1]= { "memcached" };
if (not servers.start_socket_server("memcached-sasl", max_port +1, 1, argv))
{
- error= TEST_FAILURE;
+ error= TEST_FATAL;
return NULL;
}
}
const char *argv[1]= { "memcached" };
if (not servers.start_socket_server("memcached", max_port +1, 1, argv))
{
- error= TEST_FAILURE;
+ error= TEST_FATAL;
return NULL;
}
}
noinst_HEADERS+= \
util/daemon.hpp \
util/instance.hpp \
+ util/logfile.hpp \
util/operation.hpp \
util/signal.hpp \
util/string.hpp \
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * DataDifferential Utility Library
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "config.h"
+
+#include "util/logfile.hpp"
+
+#include <cerrno>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <fcntl.h>
+#include <fstream>
+#include <iostream>
+#include <sstream>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+namespace datadifferential {
+namespace util {
+
+Logfile::Logfile(const std::string &arg) :
+ _filename(arg)
+{
+ time_t tmp= time(NULL);
+ _log_file << "shutdown: " << ctime(&tmp) << std::endl;
+}
+
+Logfile::~Logfile()
+{
+ if (not _filename.empty())
+ {
+ _log_file.close();
+ if (access(_filename.c_str(), F_OK) == -1)
+ { }
+ else if (unlink(_filename.c_str()) == -1)
+ { }
+ }
+}
+
+bool Logfile::open()
+{
+ if (_filename.empty())
+ {
+ _log_file.open("/dev/stderr");
+ return true;
+ }
+
+ _log_file.open(_filename.c_str());
+ if (not _log_file.good())
+ {
+ return false;
+ }
+
+ time_t tmp= time(NULL);
+ _log_file << "startup: " << ctime(&tmp) << std::endl;
+
+ return true;
+}
+
+} /* namespace util */
+} /* namespace datadifferential */
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * DataDifferential Utility Library
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+#include <string>
+#include <fstream>
+
+namespace datadifferential {
+namespace util {
+
+class Logfile
+{
+public:
+ Logfile(const std::string &arg);
+
+ ~Logfile();
+
+ std::ofstream &log()
+ {
+ return _log_file;
+ }
+
+ bool open();
+
+private:
+ const std::string _filename;
+ std::ofstream _log_file;
+};
+
+} /* namespace util */
+} /* namespace datadifferential */