diff --git a/.github/workflows/daily-ci.yaml b/.github/workflows/daily-ci.yaml index 587b457d262..8d6dd945675 100644 --- a/.github/workflows/daily-ci.yaml +++ b/.github/workflows/daily-ci.yaml @@ -64,8 +64,37 @@ jobs: run: | mkdir build && cd build cmake -DDISABLE_JEMALLOC=true -DCMAKE_BUILD_TYPE=Release .. + make -j4 + cd .. + + - name: Redis Tcl Test + run: | + sudo apt-get install tcl8.5 + cd tests/tcl && sh runtest && cd - + + build-on-ubuntu-with-sanitizers: + strategy: + matrix: + os: [ubuntu-18.04] + sanitizer: [ENABLE_ASAN=ON, ENABLE_TSAN=ON] + + runs-on: ${{ matrix.os }} + steps: + - name: Checkout Code Base + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 64 + + - name: Build + run: | + mkdir build && cd build + cmake -D${{ matrix.sanitizer }} .. make -j4 kvrocks kvrocks2redis cd .. + + - name: Unit Test + run: | + ./build/unittest - name: Redis Tcl Test run: | diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ea4878e119..00a68db39b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,9 +21,15 @@ project(kvrocks LANGUAGES CXX) option(DISABLE_JEMALLOC "disable use of the jemalloc library" OFF) -option(ENABLE_ASAN "enable ASAN santinizer" OFF) +option(ENABLE_ASAN "enable address santinizer" OFF) +option(ENABLE_TSAN "enable thread santinizer" OFF) +option(ASAN_WITH_LSAN "enable leak santinizer while address santinizer is enabled" ON) option(ENABLE_STATIC_LIBSTDCXX "link kvrocks with static library of libstd++ instead of shared library" ON) +if(ENABLE_ASAN AND ENABLE_TSAN) + message(FATAL_ERROR "ASan and TSan cannot be used at the same time") +endif() + # GLIBC < 2.17 should explict specify the real time library when use clock_* find_library(REALTIME_LIB rt) if (REALTIME_LIB) @@ -94,9 +100,20 @@ target_compile_features(kvrocks_objs PUBLIC cxx_std_11) target_compile_options(kvrocks_objs PUBLIC ${WARNING_FLAGS} -fno-omit-frame-pointer) target_link_libraries(kvrocks_objs PUBLIC -fno-omit-frame-pointer) if(ENABLE_ASAN) + if(ASAN_WITH_LSAN) + if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5")) + message(FATAL_ERROR "leak sanitizer is not supported until gcc 5") + endif() + target_compile_options(kvrocks_objs PUBLIC -fsanitize=leak) + target_link_libraries(kvrocks_objs PUBLIC -fsanitize=leak) + endif() target_compile_options(kvrocks_objs PUBLIC -fsanitize=address) target_link_libraries(kvrocks_objs PUBLIC -fsanitize=address) endif() +if(ENABLE_TSAN) + target_compile_options(kvrocks_objs PUBLIC -fsanitize=thread) + target_link_libraries(kvrocks_objs PUBLIC -fsanitize=thread) +endif() target_link_libraries(kvrocks_objs PUBLIC ${EXTERNAL_LIBS}) if(FOUND_UNWIND_LIB) target_link_libraries(kvrocks_objs PUBLIC ${FOUND_UNWIND_LIB})