1set(SANITIZER_COMMON_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 2 3set(SANITIZER_COMMON_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) 4set(SANITIZER_COMMON_TESTSUITES) 5 6set(SUPPORTED_TOOLS) 7if(CMAKE_SYSTEM_NAME MATCHES "Darwin|Linux|FreeBSD" AND NOT ANDROID) 8 list(APPEND SUPPORTED_TOOLS asan) 9endif() 10if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT ANDROID) 11 list(APPEND SUPPORTED_TOOLS tsan) 12 list(APPEND SUPPORTED_TOOLS msan) 13 list(APPEND SUPPORTED_TOOLS lsan) 14endif() 15 16# Create a separate config for each tool we support. 17foreach(tool ${SUPPORTED_TOOLS}) 18 string(TOUPPER ${tool} tool_toupper) 19 if(${tool_toupper}_SUPPORTED_ARCH AND NOT COMPILER_RT_STANDALONE_BUILD) 20 list(APPEND SANITIZER_COMMON_TEST_DEPS ${tool}) 21 endif() 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}) 28 set(SANITIZER_COMMON_LIT_TEST_MODE ${tool}) 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) 36 string(REPLACE ";" " " SANITIZER_COMMON_TEST_TARGET_CFLAGS "${SANITIZER_COMMON_TEST_TARGET_CFLAGS}") 37 endif() 38 set(CONFIG_NAME ${tool}-${arch}-${OS_NAME}) 39 configure_lit_site_cfg( 40 ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in 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() 45endforeach() 46 47# Unit tests. 48if(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) 54endif() 55 56# FIXME: Re-enable on 64-bit Windows. 57if(SANITIZER_COMMON_TESTSUITES AND 58 (NOT OS_NAME MATCHES "Windows" OR CMAKE_SIZEOF_VOID_P EQUAL 4)) 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 "Compiler-RT Misc") 64endif() 65