Home | History | Annotate | Download | only in tsan
      1 set(TSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
      2 if(${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "x86_64")
      3   list(APPEND TSAN_TEST_DEPS GotsanRuntimeCheck)
      4 endif()
      5 if(NOT COMPILER_RT_STANDALONE_BUILD)
      6   list(APPEND TSAN_TEST_DEPS tsan)
      7 endif()
      8 if(COMPILER_RT_HAS_LIBCXX_SOURCES AND
      9    COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang"
     10    AND NOT APPLE)
     11   list(APPEND TSAN_TEST_DEPS libcxx_tsan)
     12   set(TSAN_HAS_LIBCXX True)
     13 else()
     14   set(TSAN_HAS_LIBCXX False)
     15 endif()
     16 
     17 set(TSAN_TESTSUITES)
     18 
     19 set(TSAN_TEST_ARCH ${TSAN_SUPPORTED_ARCH})
     20 if(APPLE)
     21   darwin_filter_host_archs(TSAN_SUPPORTED_ARCH TSAN_TEST_ARCH)
     22 endif()
     23 
     24 foreach(arch ${TSAN_TEST_ARCH})
     25   set(TSAN_TEST_TARGET_ARCH ${arch})
     26   string(TOLOWER "-${arch}" TSAN_TEST_CONFIG_SUFFIX)
     27   if(ANDROID OR ${arch} MATCHES "arm|aarch64")
     28     # This is only true if we are cross-compiling.
     29     # Build all tests with host compiler and use host tools.
     30     set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
     31     set(TSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS})
     32   else()
     33     get_target_flags_for_arch(${arch} TSAN_TEST_TARGET_CFLAGS)
     34     string(REPLACE ";" " " TSAN_TEST_TARGET_CFLAGS "${TSAN_TEST_TARGET_CFLAGS}")
     35   endif()
     36 
     37   string(TOUPPER ${arch} ARCH_UPPER_CASE)
     38   set(CONFIG_NAME ${ARCH_UPPER_CASE}Config)
     39 
     40   configure_lit_site_cfg(
     41     ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
     42     ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
     43   list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
     44 endforeach()
     45 
     46 if(COMPILER_RT_INCLUDE_TESTS)
     47   configure_lit_site_cfg(
     48     ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
     49     ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
     50   list(APPEND TSAN_TEST_DEPS TsanUnitTests)
     51   list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
     52 endif()
     53 
     54 add_lit_testsuite(check-tsan "Running ThreadSanitizer tests"
     55   ${TSAN_TESTSUITES}
     56   DEPENDS ${TSAN_TEST_DEPS})
     57 set_target_properties(check-tsan PROPERTIES FOLDER "Compiler-RT Tests")
     58