tests/var/
tmp_chroot
unittests/unittests
+venv/
include(Include.cmake)
find_package(Threads REQUIRED)
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+
find_library(HAVE_LIBSASL NAMES sasl sasl2)
check_header(sasl/sasl.h)
check_header(sys/time.h)
check_header(sys/types.h)
check_header(sys/un.h)
+check_header(sys/wait.h)
check_header(time.h)
check_header(umem.h)
check_header(unistd.h)
check_debug()
include_directories(${CMAKE_BINARY_DIR})
+set(AUTOHEADER_FILE mem_config.h)
+
+set(CLIENTS
+ memcapable
+ memcat
+ memcp
+ memdump
+ memerror
+ memexist
+ memflush
+ memparse
+ memping
+ memrm
+ memslap
+ memstat
+ memtouch
+ )
add_subdirectory(clients)
add_subdirectory(libhashkit)
add_subdirectory(libmemcached-1.0)
add_subdirectory(libmemcachedutil)
+
+include(CTest)
+enable_testing()
+add_subdirectory(libtest)
+add_subdirectory(tests)
+
add_subdirectory(docs)
# keep last
-configure_file(mem_config.h.in ${CMAKE_BINARY_DIR}/mem_config.h @ONLY)
+configure_file(mem_config.h.in ${CMAKE_BINARY_DIR}/${AUTOHEADER_FILE} @ONLY)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake)
+function(set_test_target TARGET2)
+ foreach(TEST IN LISTS TESTS)
+ add_custom_command(TARGET ${TARGET2} POST_BUILD COMMAND ${TEST})
+ endforeach()
+endfunction()
+
include(CheckTypeSize)
include(CheckCSourceRuns)
include(CheckIncludeFileCXX)
-set(CLIENTS
- memcapable
- memcat
- memcp
- memdump
- memerror
- memexist
- memflush
- memparse
- memping
- memrm
- memslap
- memstat
- memtouch)
-
-add_library(libclient_utilities STATIC utilities.cc)
+add_library(libclient_utilities STATIC utilities.cc generator.cc execute.cc)
add_library(client_utilities ALIAS libclient_utilities)
target_include_directories(libclient_utilities PRIVATE ..)
target_link_libraries(libclient_utilities libmemcachedinternal)
-add_library(libclient_slap STATIC generator.cc execute.cc)
-add_library(client_slap ALIAS libclient_slap)
-target_include_directories(libclient_slap PRIVATE ..)
-target_link_libraries(libclient_slap libmemcachedinternal)
-
foreach(CLIENT IN LISTS CLIENTS)
add_executable(${CLIENT} ${CLIENT}.cc)
target_include_directories(${CLIENT} PRIVATE ..)
# extra libs
-target_link_libraries(memcapable ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(memcapable Threads::Threads)
target_link_libraries(memping libmemcachedutil)
-target_link_libraries(memslap libclient_slap ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(memslap Threads::Threads)
# memaslap is special
add_executable(memaslap memaslap.c
ms_conn.c ms_setting.c ms_sigsegv.c ms_stats.c ms_task.c ms_thread.c)
target_include_directories(memaslap PRIVATE ..)
- target_link_libraries(memaslap libclient_slap libclient_utilities ${LIBEVENT} ${CMAKE_THREAD_LIBS_INIT})
+ target_link_libraries(memaslap libclient_utilities ${LIBEVENT} Threads::Threads)
endif()
"${SPHINX_BUILD_DIR}/conf.py"
@ONLY)
- add_custom_target("docs"
+ add_custom_target(html
${SPHINX_EXECUTABLE}
-q -a -b html
-c "${SPHINX_BUILD_DIR}"
"${SPHINX_HTML_DIR}"
BYPRODUCTS ${SPHINX_HTML_DIR}
COMMENT "Build HTML documentation with Sphinx")
- #list(APPEND ADDITIONAL_CLEAN_FILES ${SPHINX_CACHE_DIR} ${SPHINX_HTML_DIR})
add_custom_target(man
${SPHINX_EXECUTABLE}
-q -a -b man
"${SPHINX_MAN_DIR}"
BYPRODUCTS ${SPHINX_MAN_DIR}
COMMENT "Build manpage documentation with Sphinx")
- #list(APPEND ADDITIONAL_CLEAN_FILES ${SPHINX_CACHE_DIR} ${SPHINX_MAN_DIR})
endif()
target_include_directories(libhashkit PRIVATE ..)
target_compile_options(libhashkit PRIVATE -DBUILDING_HASHKIT)
-set(AUTOHEADER_FILE mem_config.h)
configure_file(hashkitcon.h.in hashkitcon.h @ONLY)
${LIBMEMCACHED_SOURCES})
add_library(memcached ALIAS libmemcached)
set_target_properties(libmemcached PROPERTIES LIBRARY_OUTPUT_NAME memcached)
-target_link_libraries(libmemcached libhashkit ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
+target_link_libraries(libmemcached libhashkit Threads::Threads ${CMAKE_DL_LIBS})
target_include_directories(libmemcached PRIVATE ..)
target_compile_definitions(libmemcached PRIVATE -DBUILDING_LIBMEMCACHED)
${LIBMEMCACHED_SOURCES})
add_library(memcachedinternal ALIAS libmemcachedinternal)
set_target_properties(libmemcachedinternal PROPERTIES LIBRARY_OUTPUT_NAME memcachedinternal)
-target_link_libraries(libmemcachedinternal libhashkit ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
+target_link_libraries(libmemcachedinternal libhashkit Threads::Threads ${CMAKE_DL_LIBS})
target_include_directories(libmemcachedinternal PRIVATE ..)
target_compile_definitions(libmemcachedinternal PRIVATE -DBUILDING_LIBMEMCACHEDINTERNAL)
-find_package(Threads)
-
add_library(libmemcachedutil SHARED
../libmemcached/backtrace.cc
flush.cc
set_target_properties(libmemcachedutil PROPERTIES LIBRARY_OUTPUT_NAME memcachedutil)
target_include_directories(libmemcachedutil PRIVATE ..)
target_compile_definitions(libmemcachedutil PRIVATE -DBUILDING_LIBMEMCACHED)
-target_link_libraries(libmemcachedutil libmemcached ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(libmemcachedutil libmemcached Threads::Threads)
--- /dev/null
+
+file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/tmp_chroot)
+file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/libtool CONTENT
+"#!/bin/bash
+shift
+exec $@
+")
+if(UNIX)
+ execute_process(COMMAND chmod +x ${CMAKE_BINARY_DIR}/libtool)
+endif()
+
+add_library(libtest STATIC
+ alarm.cc
+ binaries.cc
+ client.cc
+ cmdline.cc
+ collection.cc
+ comparison.cc
+ core.cc
+ cpu.cc
+ dns.cc
+ dream.cc
+ drizzled.cc
+ exception.cc
+ exception/fatal.cc
+ formatter.cc
+ framework.cc
+ gearmand.cc
+ has.cc
+ http.cc
+ is_local.cc
+ killpid.cc
+ libtool.cc
+ main.cc
+ memcached.cc
+ port.cc
+ result.cc
+ runner.cc
+ server.cc
+ server_container.cc
+ signal.cc
+ socket.cc
+ strerror.cc
+ timer.cc
+ tmpfile.cc
+ vchar.cc
+ )
+set_target_properties(libtest PROPERTIES LIBRARY_OUTPUT_NAME test)
+target_compile_definitions(libtest PRIVATE
+ BUILDING_LIBTEST=1
+ LIBTEST_TEMP=\"${CMAKE_BINARY_DIR}/tmp_chroot\"
+
+ DRIZZLED_BINARY=\"drizzled\"
+ GEARMAND_BINARY=\"gearmand\"
+ MEMCACHED_BINARY=\"/usr/bin/memcached\"
+ HAVE_MEMCACHED_BINARY=1
+ )
+target_link_libraries(libtest PRIVATE Threads::Threads ${CMAKE_DL_LIBS})
+target_include_directories(libtest PRIVATE ..)
+
+add_executable(wait wait.cc dream.cc)
+target_include_directories(wait PRIVATE ..)
+
+add_executable(core_count core_count.cc cpu.cc)
+target_include_directories(core_count PRIVATE ..)
+
+add_executable(abort abort.cc)
+add_executable(backtrace backtrace_test.cc ../libmemcached/backtrace.cc)
+target_link_libraries(backtrace PRIVATE ${CMAKE_DL_LIBS})
+target_include_directories(backtrace PRIVATE ..)
+
+configure_file(yatlcon.h.in yatlcon.h @ONLY)
+configure_file(version.h.in version.h @ONLY)
{
if (libtool() == NULL)
{
- FATAL("libtool requested, but know libtool was found");
+ FATAL("libtool requested, but no libtool was found");
}
}
{
if (_will_fail == false)
{
- Error << strerror(spawn_ret) << "(" << spawn_ret << ")";
+ std::string sb;
+ char buf[1024];
+
+ std::for_each(built_argv.begin(), built_argv.end()-1, [&sb](const char *a) {
+ if (sb.size()) {
+ sb.append(" ");
+ }
+ sb.append(a);
+ });
+ Error << strerror(spawn_ret) << "(" << spawn_ret << "): " << sb << " cwd:" << getcwd(buf, sizeof(buf)-1);
}
_pid= -1;
return Application::INVALID_POSIX_SPAWN;
return data_was_read;
}
+std::pair<std::string, std::string> Application::output()
+{
+ slurp();
+ return {
+ std::string {
+ stdout_result().data(),
+ stdout_result().size()
+ },
+ std::string {
+ stderr_result().data(),
+ stderr_result().size()
+ }
+ };
+
+}
+
Application::error_t Application::join()
{
pid_t waited_pid= waitpid(_pid, &_status, WUNTRACED);
Application::error_t ret= app.run(args);
+ if (Application::SUCCESS == ret) {
+ ret = app.join();
+ }
+
if (ret != Application::SUCCESS)
{
- return int(ret);
+ auto out = app.output();
+ Error << command << " stdout: " << out.first;
+ Error << command << " stderr: " << out.second;
}
- return int(app.join());
+ return int(ret);
}
} // namespace exec_cmdline
bool check() const;
bool slurp();
+ std::pair<std::string, std::string> output();
void murder();
void clear()
bool has_postgres_support(void)
{
char *getenv_ptr;
- if (bool((getenv_ptr= getenv("POSTGES_IS_RUNNING_AND_SETUP"))))
+ if (bool((getenv_ptr= getenv("POSTGRES_IS_RUNNING_AND_SETUP"))))
{
(void)(getenv_ptr);
+#if defined(HAVE_LIBPQ) && HAVE_LIBPQ
if (HAVE_LIBPQ)
{
return true;
}
+#endif
}
return false;
return EXIT_FAILURE;
}
- if (libtest::libtool() == NULL)
- {
- Error << "Failed to locate libtool";
- return EXIT_FAILURE;
- }
-
if (getenv("YATL_COLLECTION_TO_RUN"))
{
if (strlen(getenv("YATL_COLLECTION_TO_RUN")))
add_option(sasl());
}
- add_option("-vv");
+ //add_option("-vv");
return true;
}
return false;
}
-std::pair<std::string, std::string> Server::output()
-{
- _app.slurp();
- return {
- std::string {
- _app.stdout_result().data(),
- _app.stdout_result().size()
- },
- std::string {
- _app.stderr_result().data(),
- _app.stderr_result().size()
- }
- };
-}
-
-
} // namespace libtest
_log_file.clear();
}
- std::pair<std::string, std::string> output();
+ std::pair<std::string, std::string> output()
+ {
+ return _app.output();
+ }
pid_t pid() const;
#pragma once
#include "@AUTOHEADER_FILE@"
+
+#ifndef LIBTEST_TEMP
+# define LIBTEST_TEMP "/tmp"
+#endif
+
+#define HAVE_LIBMEMCACHED 1
--- /dev/null
+
+add_subdirectory(libmemcached-1.0)
+
+add_executable(cycle cycle.cc)
+target_link_libraries(cycle PRIVATE libtest Threads::Threads)
+target_include_directories(cycle PRIVATE ..)
+add_test(cycle cycle)
+
+add_executable(parser parser.cc)
+target_link_libraries(parser PRIVATE libtest libmemcached)
+target_include_directories(parser PRIVATE ..)
+add_test(parser parser)
+
+add_executable(failure failure.cc)
+add_executable(testudp mem_udp.cc)
+
+foreach(TEST IN ITEMS failure testudp)
+ target_sources(${TEST} PRIVATE
+ libmemcached-1.0/callback_counter.cc
+ libmemcached-1.0/fetch_all_results.cc
+ libmemcached-1.0/generate.cc
+ libmemcached-1.0/print.cc
+ )
+ target_link_libraries(${TEST} PRIVATE
+ libclient_utilities
+ libmemcached
+ libmemcachedutil
+ libtest
+ )
+ target_include_directories(${TEST} PRIVATE ..)
+ add_test(${TEST} ${TEST})
+endforeach()
+
+add_executable(testhashkit hashkit_functions.cc)
+target_link_libraries(testhashkit PRIVATE libtest libhashkit)
+target_include_directories(testhashkit PRIVATE ..)
+add_test(hashkit testhashkit)
+
+add_executable(hash_plus hash_plus.cc)
+target_link_libraries(hash_plus PRIVATE libtest libhashkit)
+target_include_directories(hash_plus PRIVATE ..)
+add_test(hashplus hash_plus)
+
+foreach(CLIENT IN LISTS CLIENTS)
+ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${CLIENT}.cc)
+ add_executable(test${CLIENT} ${CLIENT}.cc)
+ target_link_libraries(test${CLIENT} PRIVATE
+ libmemcached
+ libmemcachedutil
+ libtest
+ )
+ target_include_directories(test${CLIENT} PRIVATE ..)
+ add_test(test${CLIENT} test${CLIENT})
+ endif()
+endforeach()
--- /dev/null
+
+add_executable(internals internals.cc string.cc)
+target_link_libraries(internals PRIVATE libtest libmemcachedinternal Threads::Threads)
+target_include_directories(internals PRIVATE ../..)
+add_test(internals internals)
+
+add_executable(sasl
+ basic.cc
+ debug.cc
+ deprecated.cc
+ error_conditions.cc
+ ketama.cc
+ namespace.cc
+ parser.cc
+ pool.cc
+ print.cc
+ replication.cc
+ sasl.cc
+ virtual_buckets.cc
+ callback_counter.cc
+ fetch_all_results.cc
+ generate.cc
+ )
+target_link_libraries(sasl PRIVATE
+ libclient_utilities
+ libhashkit
+ libmemcached
+ libmemcachedutil
+ libtest
+ Threads::Threads
+ )
+target_include_directories(sasl PRIVATE ../..)
+add_test(sasl sasl)
+
+add_executable(atomsmasher atomsmasher.cc)
+add_executable(testplus plus.cpp)
+
+foreach(TEST IN ITEMS atomsmasher testplus)
+ target_sources(${TEST} PRIVATE
+ callback_counter.cc
+ debug.cc
+ fetch_all_results.cc
+ generate.cc
+ print.cc
+ )
+ target_link_libraries(${TEST} PRIVATE
+ libclient_utilities
+ libhashkit
+ libmemcached
+ libmemcachedutil
+ libtest
+ )
+ target_include_directories(${TEST} PRIVATE ../..)
+ add_test(${TEST} ${TEST})
+endforeach()
+
+
+find_library(LIBUUID uuid REQUIRED)
+
+add_executable(testapp all_tests.cc)
+add_executable(testsocket all_tests_socket.cc)
+
+foreach(TEST IN ITEMS testapp testsocket)
+ target_sources(${TEST} PRIVATE
+ basic.cc
+ callback_counter.cc
+ callbacks.cc
+ debug.cc
+ deprecated.cc
+ dump.cc
+ encoding_key.cc
+ error_conditions.cc
+ exist.cc
+ fetch_all_results.cc
+ generate.cc
+ haldenbrand.cc
+ ketama.cc
+ mem_functions.cc
+ memcached_get.cc
+ namespace.cc
+ parser.cc
+ pool.cc
+ print.cc
+ replication.cc
+ server_add.cc
+ setup_and_teardowns.cc
+ stat.cc
+ touch.cc
+ virtual_buckets.cc
+ )
+ target_link_libraries(${TEST} PRIVATE
+ libclient_utilities
+ libhashkit
+ libmemcached
+ libmemcachedutil
+ libtest
+ Threads::Threads
+ ${LIBUUID}
+ )
+ target_include_directories(${TEST} PRIVATE ../..)
+ add_test(${TEST} ${TEST})
+endforeach()
#include <mem_config.h>
#include <libtest/test.hpp>
-
+#include "libmemcached-1.0/memcached.h"
#include "tests/basic.h"
#include "tests/debug.h"
#include "tests/deprecated.h"
#include <mem_config.h>
#include <libtest/test.hpp>
-
+#include "libmemcached-1.0/memcached.h"
#include "tests/basic.h"
#include "tests/debug.h"
#include "tests/deprecated.h"
#include <mem_config.h>
#include <libtest/test.hpp>
-
+#include <libmemcached-1.0/memcached.h>
#include "tests/libmemcached-1.0/callback_counter.h"
memcached_return_t callback_counter(const memcached_st*, memcached_result_st*, void *context)
#include <mem_config.h>
#include <libtest/test.hpp>
-
+#include "libmemcached-1.0/memcached.h"
#include <tests/callbacks.h>
using namespace libtest;
#include <mem_config.h>
#include <libtest/test.hpp>
-
+#include "libmemcached-1.0/memcached.h"
#include <tests/exist.h>
using namespace libtest;
#include <mem_config.h>
#include <libtest/test.hpp>
-
+#include <libmemcached-1.0/memcached.h>
#include <tests/libmemcached-1.0/fetch_all_results.h>
test_return_t fetch_all_results(memcached_st *memc, unsigned int &keys_returned, memcached_return_t& rc)
#include <mem_config.h>
#include <libtest/test.hpp>
-
+#include "libmemcached-1.0/memcached.h"
#include "tests/libmemcached-1.0/haldenbrand.h"
#include "tests/libmemcached-1.0/fetch_all_results.h"