Home | History | Annotate | Download | only in ubsan
      1 set(UBSAN_LIT_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
      2 
      3 set(UBSAN_TESTSUITES)
      4 set(UBSAN_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
      5 
      6 macro(add_ubsan_testsuite test_mode sanitizer arch)
      7   set(UBSAN_LIT_TEST_MODE "${test_mode}")
      8   set(CONFIG_NAME ${UBSAN_LIT_TEST_MODE}-${arch})
      9   configure_lit_site_cfg(
     10     ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
     11     ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}/lit.site.cfg)
     12   list(APPEND UBSAN_TESTSUITES ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME})
     13   if(NOT COMPILER_RT_STANDALONE_BUILD)
     14     list(APPEND UBSAN_TEST_DEPS ${sanitizer})
     15   endif()
     16 endmacro()
     17 
     18 set(UBSAN_TEST_ARCH ${UBSAN_SUPPORTED_ARCH})
     19 if(APPLE)
     20   darwin_filter_host_archs(UBSAN_SUPPORTED_ARCH UBSAN_TEST_ARCH)
     21 endif()
     22 
     23 foreach(arch ${UBSAN_TEST_ARCH})
     24   set(UBSAN_TEST_TARGET_ARCH ${arch})
     25   if(${arch} MATCHES "arm|aarch64")
     26     # This is only true if we're cross-compiling.
     27     set(UBSAN_TEST_TARGET_CFLAGS ${COMPILER_RT_TEST_COMPILER_CFLAGS})
     28   else()
     29     get_target_flags_for_arch(${arch} UBSAN_TEST_TARGET_CFLAGS)
     30     string(REPLACE ";" " " UBSAN_TEST_TARGET_CFLAGS "${UBSAN_TEST_TARGET_CFLAGS}")
     31   endif()
     32   add_ubsan_testsuite("Standalone" ubsan ${arch})
     33 
     34   if(COMPILER_RT_HAS_ASAN AND ";${ASAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
     35     # TODO(wwchrome): Re-enable ubsan for asan win 64-bit when ready.
     36     # Disable ubsan with AddressSanitizer tests for Windows 64-bit.
     37     if(NOT OS_NAME MATCHES "Windows" OR CMAKE_SIZEOF_VOID_P EQUAL 4)
     38       add_ubsan_testsuite("AddressSanitizer" asan ${arch})
     39     endif()
     40   endif()
     41   if(COMPILER_RT_HAS_MSAN AND ";${MSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
     42     add_ubsan_testsuite("MemorySanitizer" msan ${arch})
     43   endif()
     44   if(COMPILER_RT_HAS_TSAN AND ";${TSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
     45     add_ubsan_testsuite("ThreadSanitizer" tsan ${arch})
     46   endif()
     47 endforeach()
     48 
     49 add_lit_testsuite(check-ubsan "Running UndefinedBehaviorSanitizer tests"
     50   ${UBSAN_TESTSUITES}
     51   DEPENDS ${UBSAN_TEST_DEPS})
     52 set_target_properties(check-ubsan PROPERTIES FOLDER "Compiler-RT Misc")
     53