about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorFrank Busse <bb0xfb@gmail.com>2018-10-03 14:17:28 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2018-10-10 18:58:09 +0100
commit44892ef160e9a6cb471ecbf100d45cfc5e65f8e6 (patch)
treee366f701e98aad928c402e3a12325c0bda0a8b01
parent4feadfd9a3049cbfe2f986dc96b69dbe10bbf2ed (diff)
downloadklee-44892ef160e9a6cb471ecbf100d45cfc5e65f8e6.tar.gz
cmake/lit: add asan/non-asan, ubsan/non-ubsan flags
-rw-r--r--CMakeLists.txt16
-rw-r--r--test/lit.cfg4
-rw-r--r--test/lit.site.cfg.in2
3 files changed, 22 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2e894aec..b1830954 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -607,6 +607,22 @@ else()
 endif()
 
 ################################################################################
+# Sanitizer support
+################################################################################
+message(STATUS "${CMAKE_CXX_FLAGS}")
+set(IS_ASAN_BUILD 0)
+set(IS_UBSAN_BUILD 0)
+string(REPLACE " " ";" _flags ${CMAKE_CXX_FLAGS})
+foreach(arg IN ITEMS ${_flags})
+  if (${arg} STREQUAL -fsanitize=address)
+    set(IS_ASAN_BUILD 1)
+  elseif (${arg} STREQUAL -fsanitize=undefined)
+    set(IS_UBSAN_BUILD 1)
+  endif()
+endforeach()
+unset(_flags)
+
+################################################################################
 # Generate `config.h`
 ################################################################################
 configure_file(${CMAKE_SOURCE_DIR}/include/klee/Config/config.h.cmin
diff --git a/test/lit.cfg b/test/lit.cfg
index 780973d7..56fb6fdd 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -189,3 +189,7 @@ for target in supported_targets:
     config.available_features.add(target)
   else:
     config.available_features.add('not-{}'.format(target))
+
+# Sanitizer
+config.available_features.add('{}asan'.format('' if config.have_asan else 'not-'))
+config.available_features.add('{}ubsan'.format('' if config.have_ubsan else 'not-'))
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index 6a90bb4c..cea7ad26 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -27,6 +27,8 @@ config.enable_posix_runtime = True if @ENABLE_POSIX_RUNTIME@ == 1 else False
 config.have_selinux = True if @HAVE_SELINUX@ == 1 else False
 config.enable_stp = True if @ENABLE_STP@ == 1 else False
 config.enable_z3 = True if @ENABLE_Z3@ == 1 else False
+config.have_asan = True if @IS_ASAN_BUILD@ == 1 else False
+config.have_ubsan = True if @IS_UBSAN_BUILD@ == 1 else False
 
 # Add sanitizer list
 config.environment['LSAN_OPTIONS'] = "suppressions=@KLEE_UTILS_DIR@/sanitizers/lsan.txt"