Skip to content

Commit

Permalink
Add sanitizers (#220)
Browse files Browse the repository at this point in the history
* Add sanitizers

* rev ci version

* fix job names

* revert version

* fix ubsan.  Use sanitizers cmake module
  • Loading branch information
Jason Gauci committed Aug 15, 2019
1 parent f176a24 commit 0ce6b1b
Show file tree
Hide file tree
Showing 20 changed files with 222 additions and 7,743 deletions.
54 changes: 48 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
- run:
name: Kill server
command: pkill etserver
build_linux:
linux_asan:
docker:
- image: ubuntu:bionic
steps:
Expand All @@ -51,11 +51,51 @@ jobs:
command: git submodule update --init
- run:
name: Build the project with test
command: mkdir build; cd build; cmake ../; make -j4
command: mkdir build; cd build; cmake -DASAN=ON ../; make -j4
- run:
name: Run tests
command: cd build; ./et-test
linux_tsan:
docker:
- image: ubuntu:bionic
steps:
- run:
name: Avoid hosts unknown for github
command: mkdir -p ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- run:
name: Install system dependencies
command: apt-get update; apt-get install -y git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
- checkout
- run:
name: Init submodules
command: git submodule update --init
- run:
name: Build the project with test
command: mkdir build; cd build; cmake -DTSAN=ON ../; make -j4
- run:
name: Run tests
command: cd build; ./et-test
build_mac:
linux_ubsan:
docker:
- image: ubuntu:bionic
steps:
- run:
name: Avoid hosts unknown for github
command: mkdir -p ~/.ssh/ && echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- run:
name: Install system dependencies
command: apt-get update; apt-get install -y git cmake protobuf-compiler libsodium-dev libgflags-dev libprotobuf-dev libutempter-dev g++
- checkout
- run:
name: Init submodules
command: git submodule update --init
- run:
name: Build the project with test
command: mkdir build; cd build; cmake -DUBSAN=ON ../; make -j4
- run:
name: Run tests
command: cd build; ./et-test
mac_tsan:
macos:
xcode: "10.2.1"
steps:
Expand All @@ -71,14 +111,16 @@ jobs:
command: git submodule update --init
- run:
name: Build the project with test
command: mkdir build; cd build; cmake ../; make -j4
command: mkdir build; cd build; cmake -DTSAN=ON ../; make -j4
- run:
name: Run tests
command: cd build; ./et-test
workflows:
version: 2
build_and_test:
jobs:
- build_linux
- build_mac
- linux_asan
- linux_tsan
- linux_ubsan
- mac_tsan
- connect_to_initial_version
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
deps
out
.vscode
*PVS-Studio*

# Code Coverage
code-coverage.info
Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
[submodule "external/ThreadPool"]
path = external/ThreadPool
url = https://github.com/progschj/ThreadPool.git
[submodule "external/easyloggingpp"]
path = external/easyloggingpp
url = https://github.com/zuhd-org/easyloggingpp.git
[submodule "external/sanitizers-cmake"]
path = external/sanitizers-cmake
url = git:https://github.com/arsenm/sanitizers-cmake.git
23 changes: 14 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
cmake_minimum_required (VERSION 3.0.2)
project (EternalTCP VERSION 6.0.0)

SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/external/sanitizers-cmake/cmake" ${CMAKE_MODULE_PATH})
FIND_PACKAGE(Sanitizers)

option(CODE_COVERAGE "Enable code coverage" OFF)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DET_VERSION='\"${PROJECT_VERSION}\"'")
Expand Down Expand Up @@ -87,7 +90,7 @@ ELSE()
ENDIF()

include_directories(
external
external/easyloggingpp/src
external/ThreadPool
external/Catch2/single_include
external/cxxopts/include
Expand All @@ -108,7 +111,7 @@ add_library(
et-lib
STATIC

external/easylogging++.cc
external/easyloggingpp/src/easylogging++.cc

src/base/BackedReader.cpp
src/base/BackedWriter.cpp
Expand All @@ -132,6 +135,7 @@ add_dependencies(
et-lib
generated-code
)
add_sanitizers(et-lib)

add_library(
TerminalCommon
Expand All @@ -153,12 +157,12 @@ add_dependencies(
TerminalCommon
generated-code
)
add_sanitizers(TerminalCommon)

add_executable (
etserver
src/terminal/TerminalServerMain.cpp
)

target_link_libraries (
etserver
LINK_PUBLIC
Expand All @@ -171,12 +175,12 @@ target_link_libraries (
${UTEMPTER_LIBRARIES}
${CORE_LIBRARIES}
)
add_sanitizers(etserver)

add_executable (
etterminal
src/terminal/TerminalMain.cpp
)

target_link_libraries (
etterminal
LINK_PUBLIC
Expand All @@ -189,12 +193,12 @@ target_link_libraries (
${UTEMPTER_LIBRARIES}
${CORE_LIBRARIES}
)
add_sanitizers(etterminal)

add_executable (
et
src/terminal/TerminalClientMain.cpp
)

target_link_libraries (
et
LINK_PUBLIC
Expand All @@ -206,6 +210,7 @@ target_link_libraries (
${UTEMPTER_LIBRARIES}
${CORE_LIBRARIES}
)
add_sanitizers(et)

add_library (
HtmCommon
Expand All @@ -223,13 +228,13 @@ add_dependencies(
HtmCommon
generated-code
)
add_sanitizers(HtmCommon)

add_executable (
htm

src/htm/HtmClientMain.cpp
)

target_link_libraries (
htm
LINK_PUBLIC
Expand All @@ -243,13 +248,13 @@ target_link_libraries (
${UTEMPTER_LIBRARIES}
${CORE_LIBRARIES}
)
add_sanitizers(htm)

add_executable (
htmd

src/htm/HtmServerMain.cpp
)

target_link_libraries (
htmd
LINK_PUBLIC
Expand All @@ -263,6 +268,7 @@ target_link_libraries (
${UTEMPTER_LIBRARIES}
${CORE_LIBRARIES}
)
add_sanitizers(htmd)

enable_testing()

Expand All @@ -273,12 +279,10 @@ add_executable(
${TEST_SRCS}
test/Main.cpp
)

add_dependencies(
et-test
TerminalCommon
et-lib)

target_link_libraries(
et-test
TerminalCommon
Expand All @@ -296,6 +300,7 @@ add_test(
et-test
et-test
)
add_sanitizers(et-test)

install(TARGETS etserver etterminal et htm htmd
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
Expand Down
Loading

0 comments on commit 0ce6b1b

Please sign in to comment.