Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | set(SANITIZER_COMMON_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 2 | |
| 3 | set(SANITIZER_COMMON_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) |
| 4 | set(SANITIZER_COMMON_TESTSUITES) |
| 5 | |
| 6 | set(SUPPORTED_TOOLS) |
| 7 | if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID) |
| 8 | list(APPEND SUPPORTED_TOOLS asan) |
| 9 | endif() |
| 10 | if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID) |
| 11 | list(APPEND SUPPORTED_TOOLS tsan) |
| 12 | list(APPEND SUPPORTED_TOOLS msan) |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 13 | list(APPEND SUPPORTED_TOOLS lsan) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 14 | endif() |
| 15 | |
| 16 | # Create a separate config for each tool we support. |
| 17 | foreach(tool ${SUPPORTED_TOOLS}) |
| 18 | string(TOUPPER ${tool} tool_toupper) |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 19 | if(${tool_toupper}_SUPPORTED_ARCH AND NOT COMPILER_RT_STANDALONE_BUILD) |
| 20 | list(APPEND SANITIZER_COMMON_TEST_DEPS ${tool}) |
| 21 | endif() |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 22 | set(TEST_ARCH ${${tool_toupper}_SUPPORTED_ARCH}) |
| 23 | if(APPLE) |
| 24 | darwin_filter_host_archs(${tool_toupper}_SUPPORTED_ARCH TEST_ARCH) |
| 25 | endif() |
| 26 | |
| 27 | foreach(arch ${TEST_ARCH}) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 28 | set(SANITIZER_COMMON_LIT_TEST_MODE ${tool}) |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 29 | set(SANITIZER_COMMON_TEST_TARGET_ARCH ${arch}) |
| 30 | if(${arch} MATCHES "arm|aarch64") |
| 31 | # This is only true if we're cross-compiling. |
| 32 | set(SANITIZER_COMMON_TEST_TARGET_CFLAGS |
| 33 | ${COMPILER_RT_TEST_COMPILER_CFLAGS}) |
| 34 | else() |
| 35 | get_target_flags_for_arch(${arch} SANITIZER_COMMON_TEST_TARGET_CFLAGS) |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 36 | string(REPLACE ";" " " SANITIZER_COMMON_TEST_TARGET_CFLAGS "${SANITIZER_COMMON_TEST_TARGET_CFLAGS}") |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 37 | endif() |
| 38 | set(CONFIG_NAME ${tool}-${arch}-${OS_NAME}) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 39 | configure_lit_site_cfg( |
| 40 | ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in |
Pirama Arumuga Nainar | 7c91505 | 2015-04-08 08:58:29 -0700 | [diff] [blame] | 41 | ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg) |
| 42 | list(APPEND SANITIZER_COMMON_TESTSUITES |
| 43 | ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}) |
| 44 | endforeach() |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 45 | endforeach() |
| 46 | |
| 47 | # Unit tests. |
| 48 | if(COMPILER_RT_INCLUDE_TESTS) |
| 49 | configure_lit_site_cfg( |
| 50 | ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in |
| 51 | ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg) |
| 52 | list(APPEND SANITIZER_COMMON_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit) |
| 53 | list(APPEND SANITIZER_COMMON_TEST_DEPS SanitizerUnitTests) |
| 54 | endif() |
| 55 | |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 56 | # FIXME: Re-enable on 64-bit Windows. |
| 57 | if(SANITIZER_COMMON_TESTSUITES AND |
| 58 | (NOT OS_NAME MATCHES "Windows" OR CMAKE_SIZEOF_VOID_P EQUAL 4)) |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 59 | add_lit_testsuite(check-sanitizer "Running sanitizer_common tests" |
| 60 | ${SANITIZER_COMMON_TESTSUITES} |
| 61 | DEPENDS ${SANITIZER_COMMON_TEST_DEPS}) |
| 62 | set_target_properties(check-sanitizer PROPERTIES FOLDER |
| 63 | "sanitizer_common tests") |
| 64 | endif() |