Home | History | Annotate | Download | only in sanitizer_common
      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)
     13   list(APPEND SUPPORTED_TOOLS lsan)
     14 endif()
     15 
     16 # Create a separate config for each tool we support.
     17 foreach(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()
     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 
     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))
     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()
     65