From 3e1aa956375eb1adf3ec6edd55615064cf45a17c Mon Sep 17 00:00:00 2001 From: FritzFlorian Date: Mon, 18 Mar 2019 12:58:57 +0100 Subject: [PATCH] Add thread sanitizer to CI. --- .gitlab-ci.yml | 13 +++++++++++-- build_cmake_release.sh | 9 --------- ci_scripts/build_cmake_release.sh | 9 +++++++++ ci_scripts/run_tests.sh | 9 +++++++++ ci_scripts/run_thread_sanitizer.sh | 9 +++++++++ cmake/SetupThreadSanitizer.cmake | 2 +- 6 files changed, 39 insertions(+), 12 deletions(-) delete mode 100755 build_cmake_release.sh create mode 100755 ci_scripts/build_cmake_release.sh create mode 100755 ci_scripts/run_tests.sh create mode 100755 ci_scripts/run_thread_sanitizer.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d82014b..e4fddcb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,6 +3,7 @@ image: "ubuntu:latest" stages: - build - test + - sanitizer before_script: - apt update; apt-get install --yes --force-yes build-essential cmake @@ -10,7 +11,7 @@ before_script: build_cmake: stage: build script: - ./build_cmake_release.sh + ./ci_scripts/build_cmake_release.sh artifacts: paths: - cmake-build-release/bin/ @@ -18,4 +19,12 @@ build_cmake: run_tests: stage: test script: - ./build_cmake_release.sh; ./cmake-build-release/bin/tests \ No newline at end of file + ./ci_scripts/run_tests.sh + +run_thread_sanitizer: + stage: sanitizer + script: + ./ci_scripts/run_thread_sanitizer.sh + artifacts: + paths: + - cmake-build-release/sanitizer.log.* \ No newline at end of file diff --git a/build_cmake_release.sh b/build_cmake_release.sh deleted file mode 100755 index 2be8977..0000000 --- a/build_cmake_release.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -mkdir cmake-build-release -cd cmake-build-release -cmake .. -DCMAKE_BUILD_TYPE=RELEASE -make - -# echo the result of make to show it in gitlab -exit $? diff --git a/ci_scripts/build_cmake_release.sh b/ci_scripts/build_cmake_release.sh new file mode 100755 index 0000000..d962672 --- /dev/null +++ b/ci_scripts/build_cmake_release.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +mkdir cmake-build-release +cd cmake-build-release +cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DTHREAD_SANITIZER=OFF +make + +# echo the result of make to show it in gitlab +exit $? diff --git a/ci_scripts/run_tests.sh b/ci_scripts/run_tests.sh new file mode 100755 index 0000000..5876b92 --- /dev/null +++ b/ci_scripts/run_tests.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +mkdir cmake-build-release +cd cmake-build-release +cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DTHREAD_SANITIZER=OFF +make + +# run the actual tests +./bin/tests diff --git a/ci_scripts/run_thread_sanitizer.sh b/ci_scripts/run_thread_sanitizer.sh new file mode 100755 index 0000000..453cfc8 --- /dev/null +++ b/ci_scripts/run_thread_sanitizer.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +mkdir cmake-build-release-thread-sunitizer +cd cmake-build-release +cmake .. -DCMAKE_BUILD_TYPE=RELEASE -DTHREAD_SANITIZER=ON +make + +# run the actual tests with sanitizer enabled, reporting the result +TSAN_OPTIONS="log_path=sanitizer.log exitcode=1" ./bin/tests \ No newline at end of file diff --git a/cmake/SetupThreadSanitizer.cmake b/cmake/SetupThreadSanitizer.cmake index 3854a46..4a5debd 100644 --- a/cmake/SetupThreadSanitizer.cmake +++ b/cmake/SetupThreadSanitizer.cmake @@ -5,6 +5,6 @@ option(THREAD_SANITIZER "Add thread sanitizer" OFF) if(THREAD_SANITIZER) add_compile_options(-fsanitize=thread -g) - add_link_options(-fsanitize=thread) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread") endif() message("-- Thread Sanitizer: ${THREAD_SANITIZER}") \ No newline at end of file -- libgit2 0.26.0