From: Michael Wallner Date: Mon, 12 Oct 2020 17:24:25 +0000 (+0200) Subject: testing: freebsd on cirrus X-Git-Tag: 1.1.0-beta1~236^2~11 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2224115a3a7017166591a9c628827771dd82e36d;p=m6w6%2Flibmemcached testing: freebsd on cirrus --- diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 00000000..c7fe30bc --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,51 @@ +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 diff --git a/.github/workflows/cmake-build-ci.gen b/.github/workflows/cmake-build-ci.gen index 0d1e1be0..c6bd81fb 100755 --- a/.github/workflows/cmake-build-ci.gen +++ b/.github/workflows/cmake-build-ci.gen @@ -191,6 +191,7 @@ on: paths-ignore: - "docs/**" - ".travis.yml" + - ".cirrus.yml" branches-ignore: - gh-pages - catch diff --git a/.github/workflows/cmake-build-ci.yml b/.github/workflows/cmake-build-ci.yml index 492c4d53..3209d0ad 100644 --- a/.github/workflows/cmake-build-ci.yml +++ b/.github/workflows/cmake-build-ci.yml @@ -5,6 +5,7 @@ on: paths-ignore: - "docs/**" - ".travis.yml" + - ".cirrus.yml" branches-ignore: - gh-pages - catch diff --git a/CMake/EnableDtrace.cmake b/CMake/EnableDtrace.cmake new file mode 100644 index 00000000..184a327a --- /dev/null +++ b/CMake/EnableDtrace.cmake @@ -0,0 +1,55 @@ +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() diff --git a/CMake/_Include.cmake b/CMake/_Include.cmake index a6b5463c..67fe16bf 100644 --- a/CMake/_Include.cmake +++ b/CMake/_Include.cmake @@ -6,6 +6,12 @@ endif() 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) @@ -34,6 +40,7 @@ if(ENABLE_MEMASLAP) endif() ## dtrace +include(EnableDtrace) if(ENABLE_DTRACE) find_package(DTrace) if(DTRACE_EXECUTABLE) @@ -69,10 +76,10 @@ endif() # 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) @@ -103,8 +110,13 @@ check_decl(setenv stdlib.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) diff --git a/src/bin/common/CMakeLists.txt b/src/bin/common/CMakeLists.txt index c452049a..d1fd699e 100644 --- a/src/bin/common/CMakeLists.txt +++ b/src/bin/common/CMakeLists.txt @@ -1,6 +1,6 @@ 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 diff --git a/src/libmemcached/CMakeLists.txt b/src/libmemcached/CMakeLists.txt index a029ac58..819a98f7 100644 --- a/src/libmemcached/CMakeLists.txt +++ b/src/libmemcached/CMakeLists.txt @@ -2,7 +2,7 @@ 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() @@ -18,27 +18,10 @@ flex_target(CSL_SCANNER csl/scanner.l ${CMAKE_CURRENT_BINARY_DIR}/csl/scanner.cc 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 @@ -97,17 +80,20 @@ set_target_properties(libmemcached PROPERTIES 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 $ $ $) +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::) @@ -126,17 +112,20 @@ add_library(libmemcachedinternal STATIC 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 $ $ $) +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) diff --git a/src/libmemcached/assert.hpp b/src/libmemcached/assert.hpp index a1526bab..de2283a7 100644 --- a/src/libmemcached/assert.hpp +++ b/src/libmemcached/assert.hpp @@ -1,5 +1,5 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * + * * libmcachedd client library. * * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/ @@ -50,7 +50,7 @@ # ifdef _WIN32 # include -# else +# elif HAVE_ALLOCA_H # include # endif diff --git a/src/libmemcached/backtrace.cc b/src/libmemcached/backtrace.cc index e171fbeb..8017f7a2 100644 --- a/src/libmemcached/backtrace.cc +++ b/src/libmemcached/backtrace.cc @@ -1,5 +1,5 @@ /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: - * + * * Libmemcached client library. * * Copyright (C) 2012 Data Differential, http://datadifferential.com/ @@ -43,13 +43,11 @@ #include #include -#if defined(HAVE_SHARED_ENABLED) && HAVE_SHARED_ENABLED +#if HAVE_BACKTRACE -#ifdef HAVE_EXECINFO_H -#include -#endif +#include BACKTRACE_HEADER -#ifdef HAVE_GCC_ABI_DEMANGLE +#if HAVE_ABI____CXA_DEMANGLE # include # define USE_DEMANGLE 1 #else @@ -58,13 +56,12 @@ #ifdef HAVE_DLFCN_H # include -#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); @@ -73,7 +70,7 @@ void custom_backtrace(void) 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; @@ -119,13 +116,12 @@ void custom_backtrace(void) ::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 diff --git a/src/libmemcachedutil/CMakeLists.txt b/src/libmemcachedutil/CMakeLists.txt index c1110b47..7e2a6e67 100644 --- a/src/libmemcachedutil/CMakeLists.txt +++ b/src/libmemcachedutil/CMakeLists.txt @@ -25,6 +25,7 @@ target_include_directories(libmemcachedutil PRIVATE ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR}/src ${CMAKE_BINARY_DIR}) +target_include_directories(libmemcachedutil PUBLIC ${LIBSASL_INCLUDEDIR}) target_include_directories(libmemcachedutil PUBLIC $ $ diff --git a/src/mem_config.h.in b/src/mem_config.h.in index 1d1d3d29..9609ab40 100644 --- a/src/mem_config.h.in +++ b/src/mem_config.h.in @@ -8,11 +8,13 @@ #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 @@ -54,8 +56,6 @@ #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 @@ -69,4 +69,8 @@ # include #endif +#if HAVE_BACKTRACE +# define BACKTRACE_HEADER <@Backtrace_HEADER@> +#endif + #define HAVE_LIBMEMCACHED 1 diff --git a/test/lib/Server.cpp b/test/lib/Server.cpp index af6e41ba..2744f3e1 100644 --- a/test/lib/Server.cpp +++ b/test/lib/Server.cpp @@ -67,7 +67,8 @@ vector Server::createArgv() { vector 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(*it)) { diff --git a/test/lib/random.hpp b/test/lib/random.hpp index 18e518c3..1984e89c 100644 --- a/test/lib/random.hpp +++ b/test/lib/random.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -17,9 +18,10 @@ enable_if_t, T> random_num(T min, T max) { using rnd = mt19937; using dst = uniform_int_distribution; - auto time = duration_cast(system_clock::now().time_since_epoch()); - auto seed = static_cast(time.count() % numeric_limits::max()); - auto rgen = rnd{seed}; + static auto time = duration_cast(system_clock::now().time_since_epoch()); + static auto seed = static_cast(time.count() % numeric_limits::max()); + static auto rgen = rnd{seed}; + return dst(min, max)(rgen); } diff --git a/test/tests/bin/memcp.cpp b/test/tests/bin/memcp.cpp index ef234cbe..83fe9749 100644 --- a/test/tests/bin/memcp.cpp +++ b/test/tests/bin/memcp.cpp @@ -63,7 +63,11 @@ TEST_CASE("bin/memcp") { 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") { diff --git a/test/tests/bin/memdump.cpp b/test/tests/bin/memdump.cpp index b2caa3d1..e16f5e3e 100644 --- a/test/tests/bin/memdump.cpp +++ b/test/tests/bin/memdump.cpp @@ -56,7 +56,11 @@ TEST_CASE("bin/memdump") { 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") { diff --git a/test/tests/bin/memflush.cpp b/test/tests/bin/memflush.cpp index 45246fa0..b512b8e2 100644 --- a/test/tests/bin/memflush.cpp +++ b/test/tests/bin/memflush.cpp @@ -62,7 +62,11 @@ TEST_CASE("bin/memflush") { 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")); } } } diff --git a/test/tests/bin/memping.cpp b/test/tests/bin/memping.cpp index ab56fa12..bd6b6ced 100644 --- a/test/tests/bin/memping.cpp +++ b/test/tests/bin/memping.cpp @@ -49,7 +49,11 @@ TEST_CASE("bin/memping") { 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")); } } } diff --git a/test/tests/bin/memrm.cpp b/test/tests/bin/memrm.cpp index b4a7fd01..d6a9f7d4 100644 --- a/test/tests/bin/memrm.cpp +++ b/test/tests/bin/memrm.cpp @@ -69,7 +69,11 @@ TEST_CASE("bin/memrm") { 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")); } } } diff --git a/test/tests/bin/memstat.cpp b/test/tests/bin/memstat.cpp index 87db31d4..431d1ce7 100644 --- a/test/tests/bin/memstat.cpp +++ b/test/tests/bin/memstat.cpp @@ -64,7 +64,11 @@ TEST_CASE("bin/memstat") { 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")); } } } diff --git a/test/tests/memcached/util.cpp b/test/tests/memcached/util.cpp index ae91ffa4..35a76b7e 100644 --- a/test/tests/memcached/util.cpp +++ b/test/tests/memcached/util.cpp @@ -53,7 +53,7 @@ TEST_CASE("memcached_util") { } REQUIRE(-1 == libmemcached_util_getpid("localhost", 1, &rc)); - REQUIRE_RC(MEMCACHED_CONNECTION_FAILURE, rc); + REQUIRE(memcached_fatal(rc)); } SECTION("ping") {