Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | set(UBSAN_LIT_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 2 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 3 | set(UBSAN_TESTSUITES) |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 4 | set(UBSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) |
| 5 | |
| 6 | macro(add_ubsan_testsuite test_mode sanitizer arch) |
| 7 | set(UBSAN_LIT_TEST_MODE "${test_mode}") |
| 8 | set(CONFIG_NAME ${UBSAN_LIT_TEST_MODE}-${arch}) |
| 9 | configure_lit_site_cfg( |
| 10 | ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in |
| 11 | ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) |
| 12 | list(APPEND UBSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) |
| 13 | if(NOT COMPILER_RT_STANDALONE_BUILD) |
| 14 | list(APPEND UBSAN_TEST_DEPS ${sanitizer}) |
| 15 | endif() |
| 16 | endmacro() |
| 17 | |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 18 | foreach(arch ${UBSAN_SUPPORTED_ARCH}) |
| 19 | set(UBSAN_TEST_TARGET_ARCH ${arch}) |
| 20 | if(${arch} MATCHES "arm|aarch64") |
| 21 | # This is only true if we're cross-compiling. |
| 22 | set(UBSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS}) |
| 23 | else() |
| 24 | get_target_flags_for_arch(${arch} UBSAN_TEST_TARGET_CFLAGS) |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 25 | string(REPLACE ";" " " UBSAN_TEST_TARGET_CFLAGS "${UBSAN_TEST_TARGET_CFLAGS}") |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 26 | endif() |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 27 | add_ubsan_testsuite("Standalone" ubsan ${arch}) |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 28 | |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 29 | if(COMPILER_RT_HAS_ASAN AND ";${ASAN_SUPPORTED_ARCH};" MATCHES ";${arch};") |
| 30 | add_ubsan_testsuite("AddressSanitizer" asan ${arch}) |
| 31 | endif() |
| 32 | if(COMPILER_RT_HAS_MSAN AND ";${MSAN_SUPPORTED_ARCH};" MATCHES ";${arch};") |
| 33 | add_ubsan_testsuite("MemorySanitizer" msan ${arch}) |
| 34 | endif() |
| 35 | if(COMPILER_RT_HAS_TSAN AND ";${TSAN_SUPPORTED_ARCH};" MATCHES ";${arch};") |
| 36 | add_ubsan_testsuite("ThreadSanitizer" tsan ${arch}) |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 37 | endif() |
| 38 | endforeach() |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 39 | |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 40 | add_lit_testsuite(check-ubsan "Running UndefinedBehaviorSanitizer tests" |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 41 | ${UBSAN_TESTSUITES} |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 42 | DEPENDS ${UBSAN_TEST_DEPS}) |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 43 | set_target_properties(check-ubsan PROPERTIES FOLDER "UBSan tests") |