From: Brian Aker Date: Tue, 23 Aug 2011 07:39:02 +0000 (-0700) Subject: Update testing. X-Git-Tag: 0.52~11 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=9835056a5f5240281d13505f1f6fb70085b257b9;p=m6w6%2Flibmemcached Update testing. --- diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 00000000..e1c39ec8 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,8 @@ +#!/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 diff --git a/configure.ac b/configure.ac index a7590b05..045b562f 100644 --- a/configure.ac +++ b/configure.ac @@ -55,6 +55,7 @@ AC_SUBST(HASHKIT_LIBRARY_VERSION) 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) diff --git a/libtest/binaries.cc b/libtest/binaries.cc new file mode 100644 index 00000000..00a89766 --- /dev/null +++ b/libtest/binaries.cc @@ -0,0 +1,63 @@ +/* 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 + +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; +} + +} diff --git a/libtest/binaries.h b/libtest/binaries.h new file mode 100644 index 00000000..e071016c --- /dev/null +++ b/libtest/binaries.h @@ -0,0 +1,36 @@ +/* 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 + diff --git a/libtest/include.am b/libtest/include.am index 044ca4f8..d49e5acc 100644 --- a/libtest/include.am +++ b/libtest/include.am @@ -84,12 +84,13 @@ noinst_HEADERS+= \ 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 \ diff --git a/libtest/test.cc b/libtest/test.cc index 89e7c071..bae5c39f 100644 --- a/libtest/test.cc +++ b/libtest/test.cc @@ -170,7 +170,7 @@ int main(int argc, char *argv[]) world= new Framework(); - if (not world) + if (world == NULL) { Error << "Failed to create Framework()"; return EXIT_FAILURE; diff --git a/libtest/test.hpp b/libtest/test.hpp index 047dd8ce..db702943 100644 --- a/libtest/test.hpp +++ b/libtest/test.hpp @@ -49,6 +49,7 @@ #include #include #include +#include #pragma once diff --git a/libtest/unittest.cc b/libtest/unittest.cc index cee9b52e..3833a5bd 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -219,7 +219,7 @@ static test_return_t _compare_gearman_return_t_test(void *) { 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; @@ -230,8 +230,9 @@ static test_return_t gearmand_cycle_test(void *object) 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)); @@ -248,6 +249,7 @@ static test_return_t memcached_cycle_test(void *object) 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)); @@ -264,6 +266,7 @@ static test_return_t memcached_socket_cycle_test(void *object) 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)); @@ -285,6 +288,7 @@ static test_return_t memcached_sasl_test(void *object) 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)); diff --git a/m4/gearmand.m4 b/m4/gearmand.m4 new file mode 100644 index 00000000..7765acec --- /dev/null +++ b/m4/gearmand.m4 @@ -0,0 +1,11 @@ +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]) + ]) + diff --git a/m4/memcached.m4 b/m4/memcached.m4 index 0b8592fe..7d648bf2 100644 --- a/m4/memcached.m4 +++ b/m4/memcached.m4 @@ -1,8 +1,10 @@ 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]) ]) diff --git a/m4/memcached_sasl.m4 b/m4/memcached_sasl.m4 index 5983c112..a43e4533 100644 --- a/m4/memcached_sasl.m4 +++ b/m4/memcached_sasl.m4 @@ -1,8 +1,10 @@ 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]) ]) diff --git a/m4/pandora_with_memcached.m4 b/m4/pandora_with_memcached.m4 deleted file mode 100644 index 4ea906b6..00000000 --- a/m4/pandora_with_memcached.m4 +++ /dev/null @@ -1,41 +0,0 @@ -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"]) - ]) -]) - diff --git a/tests/libmemcached_world.h b/tests/libmemcached_world.h index 9f38c024..ecbb489e 100644 --- a/tests/libmemcached_world.h +++ b/tests/libmemcached_world.h @@ -29,7 +29,13 @@ struct libmemcached_test_container_st 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; @@ -67,7 +73,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) { if (not server_startup(servers, "memcached-sasl", port, 1, argv)) { - error= TEST_FAILURE; + error= TEST_FATAL; return NULL; } } @@ -75,7 +81,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) { if (not server_startup(servers, "memcached", port, 1, argv)) { - error= TEST_FAILURE; + error= TEST_FATAL; return NULL; } } @@ -88,7 +94,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) 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; } } @@ -97,7 +103,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) 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; } }