summaryrefslogtreecommitdiffstats
path: root/.gitlab
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-06-07 18:30:08 (GMT)
committerBrad King <brad.king@kitware.com>2021-06-08 13:54:08 (GMT)
commit20bc209a0c61ec59912b0c2b082ed43a080905bc (patch)
tree245c08ac3ba827556be39aea30b77fe23a4362b0 /.gitlab
parent19d831b03d2c3921c19f07a94fce4f7b678f0afa (diff)
downloadCMake-20bc209a0c61ec59912b0c2b082ed43a080905bc.zip
CMake-20bc209a0c61ec59912b0c2b082ed43a080905bc.tar.gz
CMake-20bc209a0c61ec59912b0c2b082ed43a080905bc.tar.bz2
gitlab-ci: add clang asan job
Diffstat (limited to '.gitlab')
-rw-r--r--.gitlab/ci/configure_fedora34_asan.cmake4
-rw-r--r--.gitlab/ci/ctest_exclusions.cmake7
-rw-r--r--.gitlab/ci/ctest_memcheck.cmake45
-rw-r--r--.gitlab/ci/ctest_memcheck_fedora34_asan.lsan.supp1
-rw-r--r--.gitlab/ci/env_fedora34_asan.sh2
-rw-r--r--.gitlab/os-linux.yml30
6 files changed, 89 insertions, 0 deletions
diff --git a/.gitlab/ci/configure_fedora34_asan.cmake b/.gitlab/ci/configure_fedora34_asan.cmake
new file mode 100644
index 0000000..c22cdb7
--- /dev/null
+++ b/.gitlab/ci/configure_fedora34_asan.cmake
@@ -0,0 +1,4 @@
+set(CMAKE_C_FLAGS "-fsanitize=address" CACHE STRING "")
+set(CMAKE_CXX_FLAGS "-fsanitize=address" CACHE STRING "")
+
+include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora34_common.cmake")
diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake
index b885a6a..3460d48 100644
--- a/.gitlab/ci/ctest_exclusions.cmake
+++ b/.gitlab/ci/ctest_exclusions.cmake
@@ -13,6 +13,13 @@ if (CTEST_CMAKE_GENERATOR MATCHES "Visual Studio")
"^ExternalProjectUpdateSetup$")
endif ()
+if ("$ENV{CMAKE_CONFIGURATION}" MATCHES "_asan")
+ list(APPEND test_exclusions
+ CTestTest2 # crashes on purpose
+ BootstrapTest # no need to cover this for asan
+ )
+endif()
+
string(REPLACE ";" "|" test_exclusions "${test_exclusions}")
if (test_exclusions)
set(test_exclusions "(${test_exclusions})")
diff --git a/.gitlab/ci/ctest_memcheck.cmake b/.gitlab/ci/ctest_memcheck.cmake
new file mode 100644
index 0000000..dac907c
--- /dev/null
+++ b/.gitlab/ci/ctest_memcheck.cmake
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.8)
+
+include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake")
+
+# Read the files from the build directory.
+ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
+
+# Pick up from where the configure left off.
+ctest_start(APPEND)
+
+include(ProcessorCount)
+ProcessorCount(nproc)
+if (NOT "$ENV{CTEST_MAX_PARALLELISM}" STREQUAL "")
+ if (nproc GREATER "$ENV{CTEST_MAX_PARALLELISM}")
+ set(nproc "$ENV{CTEST_MAX_PARALLELISM}")
+ endif ()
+endif ()
+
+set(CTEST_MEMORYCHECK_TYPE "$ENV{CTEST_MEMORYCHECK_TYPE}")
+set(CTEST_MEMORYCHECK_SANITIZER_OPTIONS "$ENV{CTEST_MEMORYCHECK_SANITIZER_OPTIONS}")
+
+set(lsan_suppressions "${CMAKE_CURRENT_LIST_DIR}/ctest_memcheck_$ENV{CMAKE_CONFIGURATION}.lsan.supp")
+if (EXISTS "${lsan_suppressions}")
+ set(ENV{LSAN_OPTIONS} "suppressions='${lsan_suppressions}'")
+endif ()
+
+include("${CMAKE_CURRENT_LIST_DIR}/ctest_exclusions.cmake")
+ctest_memcheck(
+ PARALLEL_LEVEL "${nproc}"
+ TEST_LOAD "${nproc}"
+ RETURN_VALUE test_result
+ EXCLUDE "${test_exclusions}"
+ DEFECT_COUNT defects)
+ctest_submit(PARTS Test)
+ctest_submit(PARTS Memcheck)
+
+if (test_result)
+ message(FATAL_ERROR
+ "Failed to test")
+endif ()
+
+if (defects)
+ message(FATAL_ERROR
+ "Found ${defects} memcheck defects")
+endif ()
diff --git a/.gitlab/ci/ctest_memcheck_fedora34_asan.lsan.supp b/.gitlab/ci/ctest_memcheck_fedora34_asan.lsan.supp
new file mode 100644
index 0000000..8ec1a03
--- /dev/null
+++ b/.gitlab/ci/ctest_memcheck_fedora34_asan.lsan.supp
@@ -0,0 +1 @@
+# Add 'leak:<pattern>' lines here to suppress known leaks.
diff --git a/.gitlab/ci/env_fedora34_asan.sh b/.gitlab/ci/env_fedora34_asan.sh
new file mode 100644
index 0000000..e976486
--- /dev/null
+++ b/.gitlab/ci/env_fedora34_asan.sh
@@ -0,0 +1,2 @@
+export CC=/usr/bin/clang
+export CXX=/usr/bin/clang++
diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml
index 17f51cf..997beab 100644
--- a/.gitlab/os-linux.yml
+++ b/.gitlab/os-linux.yml
@@ -158,6 +158,27 @@
CMAKE_CONFIGURATION: debian10_makefiles_clang
CMAKE_GENERATOR: "Unix Makefiles"
+### Sanitizers
+
+.fedora_memcheck:
+ variables:
+ CMAKE_BUILD_TYPE: RelWithDebInfo
+
+.fedora_asan_addon:
+ extends: .fedora_memcheck
+
+ variables:
+ CTEST_MEMORYCHECK_TYPE: AddressSanitizer
+ CTEST_MEMORYCHECK_SANITIZER_OPTIONS: ""
+
+.fedora34_asan:
+ extends:
+ - .fedora34
+ - .fedora_asan_addon
+
+ variables:
+ CMAKE_CONFIGURATION: fedora34_asan
+
### Intel Compiler
.intelcompiler:
@@ -306,6 +327,15 @@
interruptible: true
+.cmake_memcheck_linux:
+ stage: test
+
+ script:
+ - *before_script_linux
+ - "$LAUNCHER ctest --output-on-failure -V -S .gitlab/ci/ctest_memcheck.cmake"
+
+ interruptible: true
+
.cmake_build_linux_release:
stage: build