• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1set(TSAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
2
3set(TSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
4if(${COMPILER_RT_DEFAULT_TARGET_ARCH} MATCHES "x86_64")
5  list(APPEND TSAN_TEST_DEPS GotsanRuntimeCheck)
6endif()
7if(NOT COMPILER_RT_STANDALONE_BUILD)
8  list(APPEND TSAN_TEST_DEPS tsan)
9endif()
10if(COMPILER_RT_LIBCXX_PATH AND
11   COMPILER_RT_LIBCXXABI_PATH AND
12   COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang"
13   AND NOT APPLE AND NOT ANDROID)
14  list(APPEND TSAN_TEST_DEPS libcxx_tsan)
15  set(TSAN_HAS_LIBCXX True)
16else()
17  set(TSAN_HAS_LIBCXX False)
18endif()
19
20set(TSAN_TESTSUITES)
21
22if (NOT DEFINED TSAN_TEST_DEFLAKE_THRESHOLD)
23  set(TSAN_TEST_DEFLAKE_THRESHOLD "10")
24endif()
25
26set(TSAN_TEST_ARCH ${TSAN_SUPPORTED_ARCH})
27if(APPLE)
28  darwin_filter_host_archs(TSAN_SUPPORTED_ARCH TSAN_TEST_ARCH)
29endif()
30
31foreach(arch ${TSAN_TEST_ARCH})
32  set(TSAN_TEST_APPLE_PLATFORM "osx")
33  set(TSAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_osx_MIN_VER_FLAG}")
34
35  set(TSAN_TEST_TARGET_ARCH ${arch})
36  string(TOLOWER "-${arch}" TSAN_TEST_CONFIG_SUFFIX)
37  get_test_cc_for_arch(${arch} TSAN_TEST_TARGET_CC TSAN_TEST_TARGET_CFLAGS)
38
39  string(REPLACE ";" " " LIBDISPATCH_CFLAGS_STRING " ${COMPILER_RT_TEST_LIBDISPATCH_CFLAGS}")
40  string(APPEND TSAN_TEST_TARGET_CFLAGS ${LIBDISPATCH_CFLAGS_STRING})
41
42  string(TOUPPER ${arch} ARCH_UPPER_CASE)
43  set(CONFIG_NAME ${ARCH_UPPER_CASE}Config)
44
45  configure_lit_site_cfg(
46    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
47    ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py)
48  list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
49endforeach()
50
51# iOS and iOS simulator test suites
52# These are not added into "check-all", in order to run these tests, use
53# "check-tsan-iossim-x86_64" and similar. They also require an extra environment
54# variable to select which iOS device or simulator to use, e.g.:
55# SANITIZER_IOSSIM_TEST_DEVICE_IDENTIFIER="iPhone 6"
56if(APPLE)
57  set(TSAN_TEST_TARGET_CC ${COMPILER_RT_TEST_COMPILER})
58  set(TSAN_APPLE_PLATFORMS ${TSAN_SUPPORTED_OS})
59  foreach(platform ${TSAN_APPLE_PLATFORMS})
60    if ("${platform}" STREQUAL "osx")
61      # Skip macOS because it's handled by the code above that builds tests for the host machine.
62      continue()
63    endif()
64    list_intersect(
65      TSAN_TEST_${platform}_ARCHS
66      TSAN_SUPPORTED_ARCH
67      DARWIN_${platform}_ARCHS
68    )
69    foreach(arch ${TSAN_TEST_${platform}_ARCHS})
70      get_test_cflags_for_apple_platform(
71        "${platform}"
72        "${arch}"
73        TSAN_TEST_TARGET_CFLAGS
74        )
75      string(TOUPPER "${arch}" ARCH_UPPER_CASE)
76      get_capitalized_apple_platform("${platform}" PLATFORM_CAPITALIZED)
77      set(CONFIG_NAME "${PLATFORM_CAPITALIZED}${ARCH_UPPER_CASE}Config")
78      set(TSAN_TEST_CONFIG_SUFFIX "-${arch}-${platform}")
79      set(TSAN_TEST_APPLE_PLATFORM "${platform}")
80      set(TSAN_TEST_TARGET_ARCH "${arch}")
81      set(TSAN_TEST_MIN_DEPLOYMENT_TARGET_FLAG "${DARWIN_${platform}_MIN_VER_FLAG}")
82      configure_lit_site_cfg(
83        ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
84        ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg.py
85        )
86      add_lit_testsuite(check-tsan-${platform}-${arch} "ThreadSanitizer ${platform} ${arch} tests"
87        ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/
88        EXCLUDE_FROM_CHECK_ALL
89        DEPENDS ${TSAN_TEST_DEPS})
90    endforeach()
91  endforeach()
92endif()
93
94if(COMPILER_RT_INCLUDE_TESTS)
95  configure_lit_site_cfg(
96    ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in
97    ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py)
98  list(APPEND TSAN_TEST_DEPS TsanUnitTests)
99  list(APPEND TSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/Unit)
100endif()
101
102add_lit_testsuite(check-tsan "Running ThreadSanitizer tests"
103  ${TSAN_TESTSUITES}
104  DEPENDS ${TSAN_TEST_DEPS})
105set_target_properties(check-tsan PROPERTIES FOLDER "Compiler-RT Tests")
106