--- /dev/null
+env:
+ CMAKE_BUILD_TYPE: Debug
+ BUILD_TESTING: "ON"
+ ENABLE_SASL: "ON"
+ ENABLE_HASH_HSIEH: "ON"
+ ENABLE_DTRACE: "ON"
+ VERBOSE: "ON"
+ MEMCACHED_BINARY: "/usr/local/bin/memcached"
+
+task:
+ name: Freebsd
+ env:
+ ports: RELEASE_12_1_0
+ freebsd_instance:
+ image_family: freebsd-12-1
+ dependencies_script: |
+ pkg update
+ pkg upgrade -y
+ pkg install -y \
+ autotools \
+ bison \
+ cmake \
+ cyrus-sasl \
+ flex \
+ libevent \
+ pkgconf \
+ subversion \
+ sudo
+ memcached_script: |
+ svn co https://svn.freebsd.org/ports/tags/${ports}/databases/memcached memcached
+ svn co https://svn.freebsd.org/ports/tags/${ports}/Mk /usr/ports/Mk
+ svn co https://svn.freebsd.org/ports/tags/${ports}/Templates /usr/ports/Templates
+ cd memcached
+ echo bin/memcached > pkg-plist
+ make all install SASLPWDB_CONFIGURE_ENABLE=sasl-pwdb OPTIONS_SET="SASL SASLPWDB" OPTIONS_DEFINE="SASL SASLPWDB"
+ cd ..
+ prepare_script: |
+ mkdir build
+ chown nobody build
+ chsh -s /bin/sh nobody
+ configure_script: |
+ sudo -E -u nobody cmake -S . -B build
+ build_script: |
+ sudo -E -u nobody make -C build -j2 all
+ test_script: |
+ sudo -E -u nobody make -C build -j2 test/fast
+ install_script: |
+ sudo -E -u nobody make -C build install DESTDIR=/tmp
+ on_failure:
+ failed_script: |
+ cat build/Testing/Temporary/LastTest.log || true
paths-ignore:
- "docs/**"
- ".travis.yml"
+ - ".cirrus.yml"
branches-ignore:
- gh-pages
- catch
paths-ignore:
- "docs/**"
- ".travis.yml"
+ - ".cirrus.yml"
branches-ignore:
- gh-pages
- catch
--- /dev/null
+function(enable_dtrace_for TARGET PROBES_D PROBES_H)
+ if(HAVE_DTRACE AND NOT CMAKE_CROSSCOMPILING)
+ target_sources(${TARGET} PRIVATE ${PROBES_H})
+ add_custom_command(
+ OUTPUT
+ ${PROBES_H}
+ MAIN_DEPENDENCY
+ ${PROBES_D}
+ COMMAND
+ ${DTRACE_EXECUTABLE}
+ ARGS
+ -x nolibs -h
+ -s ${CMAKE_CURRENT_SOURCE_DIR}/${PROBES_D}
+ -o ${PROBES_H}
+ )
+ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
+ add_custom_command(
+ OUTPUT
+ ${TARGET}_probes.o
+ MAIN_DEPENDENCY
+ ${PROBES_H}
+ COMMAND
+ ${DTRACE_EXECUTABLE}
+ ARGS
+ -x nolibs -G
+ -s ${CMAKE_CURRENT_SOURCE_DIR}/${PROBES_D}
+ -o ${TARGET}_probes.o
+ )
+ target_sources(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_probes.o)
+ set_source_files_properties(${TARGET}_probes.o PROPERTIES
+ GENERATED true
+ EXTERNAL_OBJECT true)
+ else() # not Linux
+ set(PROBES_C ${TARGET}_probes.cc)
+ file(GENERATE
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PROBES_C}
+ CONTENT "#include \"${PROBES_H}\""
+ )
+ add_custom_command(
+ TARGET ${TARGET}
+ PRE_LINK
+ DEPENDS
+ ${PROBES_H}
+ COMMAND
+ rm -f ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir/${PROBES_C}.o
+ COMMAND
+ ${DTRACE_EXECUTABLE} -x nolibs -G
+ -s ${CMAKE_CURRENT_SOURCE_DIR}/${PROBES_D}
+ -o ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir/${PROBES_C}.o
+ ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir/*.o
+ )
+ target_sources(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${PROBES_C})
+ endif()
+ endif()
+endfunction()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
+if(CMAKE_HOST_SYSTEM_NAME STREQUAL "FreeBSD")
+ find_program(PKGCONF pkgconf)
+ if(PKGCONF)
+ set(PKG_CONFIG_EXECUTABLE ${PKGCONF})
+ endif()
+endif()
find_package(PkgConfig)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
endif()
## dtrace
+include(EnableDtrace)
if(ENABLE_DTRACE)
find_package(DTrace)
if(DTRACE_EXECUTABLE)
# system checks
+check_header(alloca.h)
check_header(arpa/inet.h)
check_header(dlfcn.h)
check_header(errno.h)
-check_header(execinfo.h)
check_header(fcntl.h)
check_header(io.h)
check_header(limits.h)
check_decl(strerror string.h)
check_decl(strerror_r string.h)
check_compiles(HAVE_STRERROR_R_CHAR_P "char x, y = *strerror_r(0,&x,1);" string.h)
+
check_decl(abi::__cxa_demangle cxxabi.h)
-set(HAVE_GCC_ABI_DEMANGLE ${HAVE_ABI____CXA_DEMANGLE})
+
+find_package(Backtrace)
+if(Backtrace_FOUND)
+ set(HAVE_BACKTRACE 1)
+endif()
check_type(in_port_t netinet/in.h)
add_library(libclient_common STATIC utilities.cc generator.cc execute.cc)
add_library(client_common ALIAS libclient_common)
-target_link_libraries(libclient_common PRIVATE libmemcachedinternal)
+target_link_libraries(libclient_common PUBLIC libmemcachedinternal)
target_include_directories(libclient_common PUBLIC
.
${CMAKE_SOURCE_DIR}/include
find_package(FLEX)
find_package(BISON 2.3)
-if(${BISON_VERSION} VERSION_GREATER_EQUAL 3.0)
+if("${BISON_VERSION}" VERSION_GREATER_EQUAL 3.0)
set(BISON_WARNINGS -Wno-deprecated)
endif()
set_source_files_properties(${FLEX_CSL_SCANNER_OUTPUTS} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
add_flex_bison_dependency(CSL_SCANNER CSL_PARSER)
-if(HAVE_DTRACE)
- add_custom_command(
- OUTPUT dtrace_probes.h
- COMMAND ${DTRACE_EXECUTABLE}
- ARGS -h -o dtrace_probes.h -s ${CMAKE_CURRENT_SOURCE_DIR}/libmemcached_probes.d
- MAIN_DEPENDENCY libmemcached_probes.d
- )
- add_custom_command(
- OUTPUT libmemcached_probes.o
- COMMAND ${DTRACE_EXECUTABLE}
- ARGS -o libmemcached_probes.o -G -s ${CMAKE_CURRENT_SOURCE_DIR}/libmemcached_probes.d
- MAIN_DEPENDENCY dtrace_probes.h
- )
- set(DTRACE_GENERATED_OUTPUT libmemcached_probes.o)
-endif()
-
set(LIBMEMCACHED_SOURCES
csl/context.cc
${BISON_CSL_PARSER_OUTPUTS}
${FLEX_CSL_SCANNER_OUTPUTS}
- ${DTRACE_GENERATED_OUTPUT}
allocators.cc
analyze.cc
array.c
SOVERSION ${LIBMEMCACHED_SO_VERSION}
VERSION v${LIBMEMCACHED_VERSION})
target_compile_definitions(libmemcached PRIVATE -DBUILDING_LIBMEMCACHED)
-target_link_libraries(libmemcached PUBLIC libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS})
-target_include_directories(libmemcached PRIVATE ${LIBSASL_INCLUDEDIR})
+target_link_libraries(libmemcached PUBLIC libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS} ${Backtrace_LIBRARIES})
+target_include_directories(libmemcached PRIVATE ${Backtrace_INCLUDE_DIR})
target_include_directories(libmemcached PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/src
${CMAKE_BINARY_DIR})
+target_include_directories(libmemcached PUBLIC ${LIBSASL_INCLUDEDIR})
target_include_directories(libmemcached PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
+enable_dtrace_for(libmemcached libmemcached_probes.d dtrace_probes.h)
+
install(TARGETS libmemcached EXPORT libmemcached-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
export(EXPORT libmemcached-targets NAMESPACE libmemcached::)
add_library(memcachedinternal ALIAS libmemcachedinternal)
set_target_properties(libmemcachedinternal PROPERTIES LIBRARY_OUTPUT_NAME memcachedinternal)
target_compile_definitions(libmemcachedinternal PRIVATE -DBUILDING_LIBMEMCACHEDINTERNAL)
-target_link_libraries(libmemcachedinternal PUBLIC libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS})
-target_include_directories(libmemcachedinternal PRIVATE ${LIBSASL_INCLUDEDIR})
+target_link_libraries(libmemcachedinternal PUBLIC libhashkit Threads::Threads ${LIBSASL_LIBRARIES} ${CMAKE_DL_LIBS} ${Backtrace_LIBRARIES})
+target_include_directories(libmemcachedinternal PRIVATE ${Backtrace_INCLUDE_DIR})
target_include_directories(libmemcachedinternal PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/src
${CMAKE_BINARY_DIR})
+target_include_directories(libmemcachedinternal PUBLIC ${LIBSASL_INCLUDEDIR})
target_include_directories(libmemcachedinternal PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
+enable_dtrace_for(libmemcachedinternal libmemcached_probes.d dtrace_probes.h)
+
# let libmemcached depend on libmemcachedinternal to ensure that they do not
# compete for the same generated dependencies
add_dependencies(libmemcached libmemcachedinternal)
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
+ *
* libmcachedd client library.
*
* Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/
# ifdef _WIN32
# include <malloc.h>
-# else
+# elif HAVE_ALLOCA_H
# include <alloca.h>
# endif
/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
+ *
* Libmemcached client library.
*
* Copyright (C) 2012 Data Differential, http://datadifferential.com/
#include <cstdlib>
#include <cstring>
-#if defined(HAVE_SHARED_ENABLED) && HAVE_SHARED_ENABLED
+#if HAVE_BACKTRACE
-#ifdef HAVE_EXECINFO_H
-#include <execinfo.h>
-#endif
+#include BACKTRACE_HEADER
-#ifdef HAVE_GCC_ABI_DEMANGLE
+#if HAVE_ABI____CXA_DEMANGLE
# include <cxxabi.h>
# define USE_DEMANGLE 1
#else
#ifdef HAVE_DLFCN_H
# include <dlfcn.h>
-#endif
+#endif
const int MAX_DEPTH= 50;
void custom_backtrace(void)
{
-#ifdef HAVE_EXECINFO_H
void *backtrace_buffer[MAX_DEPTH +1];
int stack_frames= backtrace(backtrace_buffer, MAX_DEPTH);
char **symbollist= backtrace_symbols(backtrace_buffer, stack_frames);
if (symbollist)
{
- for (int x= 0; x < stack_frames; x++)
+ for (int x= 0; x < stack_frames; x++)
{
bool was_demangled= false;
::free(symbollist);
}
}
-#endif // HAVE_EXECINFO_H
}
-#else // HAVE_SHARED_ENABLED
+#else // HAVE_BACKTRACE
void custom_backtrace(void)
{
fprintf(stderr, "Backtrace null function called\n");
}
-#endif // AX_ENABLE_BACKTRACE
+#endif // HAVE_BACKTRACE
${CMAKE_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/src
${CMAKE_BINARY_DIR})
+target_include_directories(libmemcachedutil PUBLIC ${LIBSASL_INCLUDEDIR})
target_include_directories(libmemcachedutil PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
#cmakedefine HAVE_C_STDATOMIC 1
#cmakedefine HAVE_CXX_STDATOMIC 1
+#cmakedefine HAVE_ABI____CXA_DEMANGLE 1
+#cmakedefine HAVE_BACKTRACE 1
+#cmakedefine HAVE_ALLOCA_H 1
#cmakedefine HAVE_ARPA_INET_H 1
#cmakedefine HAVE_DLFCN_H 1
#cmakedefine HAVE_DTRACE 1
#cmakedefine HAVE_ERRNO_H 1
-#cmakedefine HAVE_EXECINFO_H 1
#cmakedefine HAVE_FCNTL 1
#cmakedefine HAVE_FCNTL_H 1
#cmakedefine HAVE_FNV64_HASH 1
#cmakedefine HAVE_WINSOCK2_H 1
#cmakedefine HAVE_WS2TCPIP_H 1
-#cmakedefine HAVE_ABI____CXA_DEMANGLE 1
-#cmakedefine HAVE_GCC_ABI_DEMANGLE 1
#cmakedefine HAVE_CINTTYPES 1
#cmakedefine HAVE_CSTDINT 1
# include <inttypes.h>
#endif
+#if HAVE_BACKTRACE
+# define BACKTRACE_HEADER <@Backtrace_HEADER@>
+#endif
+
#define HAVE_LIBMEMCACHED 1
vector<char *> arr;
pushArg(arr, binary);
- //pushArg(arr, "-v");
+ pushArg(arr, "-u");
+ pushArg(arr, "nobody");
for (auto it = args.cbegin(); it != args.cend(); ++it) {
if (holds_alternative<arg_t>(*it)) {
#include <cstddef>
#include <chrono>
+#include <iostream>
#include <random>
#include <string>
#include <type_traits>
using rnd = mt19937;
using dst = uniform_int_distribution<T>;
- auto time = duration_cast<nanoseconds>(system_clock::now().time_since_epoch());
- auto seed = static_cast<rnd::result_type>(time.count() % numeric_limits<T>::max());
- auto rgen = rnd{seed};
+ static auto time = duration_cast<nanoseconds>(system_clock::now().time_since_epoch());
+ static auto seed = static_cast<rnd::result_type>(time.count() % numeric_limits<T>::max());
+ static auto rgen = rnd{seed};
+
return dst(min, max)(rgen);
}
string output;
REQUIRE_FALSE(sh.run(comm + temp.getFn(), output));
- REQUIRE_THAT(output, Contains("CONNECTION FAILURE"));
+ REQUIRE_THAT(output,
+ Contains("CONNECTION FAILURE")
+ || Contains("SERVER HAS FAILED")
+ || Contains("SYSTEM ERROR")
+ || Contains("TIMEOUT OCCURRED"));
}
SECTION("file not found") {
string output;
REQUIRE_FALSE(sh.run(comm + "-v", output));
- REQUIRE_THAT(output, Contains("CONNECTION FAILURE") || Contains("SERVER HAS FAILED"));
+ REQUIRE_THAT(output,
+ Contains("CONNECTION FAILURE")
+ || Contains("SERVER HAS FAILED")
+ || Contains("SYSTEM ERROR")
+ || Contains("TIMEOUT OCCURRED"));
}
SECTION("empty") {
string output;
REQUIRE_FALSE(sh.run(comm, output));
- REQUIRE_THAT(output, Contains("CONNECTION FAILURE") || Contains("SERVER HAS FAILED"));
+ REQUIRE_THAT(output,
+ Contains("CONNECTION FAILURE")
+ || Contains("SERVER HAS FAILED")
+ || Contains("SYSTEM ERROR")
+ || Contains("TIMEOUT OCCURRED"));
}
}
}
string output;
REQUIRE_FALSE(sh.run(comm, output));
- REQUIRE_THAT(output, Contains("CONNECTION FAILURE") || Contains("SERVER HAS FAILED"));
+ REQUIRE_THAT(output,
+ Contains("CONNECTION FAILURE")
+ || Contains("SERVER HAS FAILED")
+ || Contains("SYSTEM ERROR")
+ || Contains("TIMEOUT OCCURRED"));
}
}
}
string output;
REQUIRE_FALSE(sh.run(comm + " -v key2", output));
- REQUIRE_THAT(output, Contains("CONNECTION FAILURE") || Contains("SERVER HAS FAILED"));
+ REQUIRE_THAT(output,
+ Contains("CONNECTION FAILURE")
+ || Contains("SERVER HAS FAILED")
+ || Contains("SYSTEM ERROR")
+ || Contains("TIMEOUT OCCURRED"));
}
}
}
string output;
REQUIRE_FALSE(sh.run(comm + "--analyze", output));
- REQUIRE_THAT(output, Contains("CONNECTION FAILURE") || Contains("SERVER HAS FAILED"));
+ REQUIRE_THAT(output,
+ Contains("CONNECTION FAILURE")
+ || Contains("SERVER HAS FAILED")
+ || Contains("SYSTEM ERROR")
+ || Contains("TIMEOUT OCCURRED"));
}
}
}
}
REQUIRE(-1 == libmemcached_util_getpid("localhost", 1, &rc));
- REQUIRE_RC(MEMCACHED_CONNECTION_FAILURE, rc);
+ REQUIRE(memcached_fatal(rc));
}
SECTION("ping") {