1set(TSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS}) 2if(${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "x86_64") 3 list(APPEND TSAN_TEST_DEPS GotsanRuntimeCheck) 4endif() 5if(NOT COMPILER_RT_STANDALONE_BUILD) 6 list(APPEND TSAN_TEST_DEPS tsan) 7endif() 8if(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) 13else() 14 set(TSAN_HAS_LIBCXX False) 15endif() 16 17set(TSAN_TESTSUITES) 18 19set(TSAN_TEST_ARCH ${TSAN_SUPPORTED_ARCH}) 20if(APPLE) 21 darwin_filter_host_archs(TSAN_SUPPORTED_ARCH TSAN_TEST_ARCH) 22endif() 23 24foreach(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}) 44endforeach() 45 46if(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) 52endif() 53 54add_lit_testsuite(check-tsan "Running ThreadSanitizer tests" 55 ${TSAN_TESTSUITES} 56 DEPENDS ${TSAN_TEST_DEPS}) 57set_target_properties(check-tsan PROPERTIES FOLDER "Compiler-RT Tests") 58