[llvm-commits] [compiler-rt] r171160 - in /compiler-rt/trunk: CMakeLists.txt lib/asan/CMakeLists.txt lib/asan/lit_tests/CMakeLists.txt lib/asan/tests/CMakeLists.txt lib/msan/tests/CMakeLists.txt lib/sanitizer_common/tests/CMakeLists.txt lib/tsan/lit_tests/CMakeLists.txt lib/ubsan/lit_tests/CMakeLists.txt

Alexey Samsonov samsonov at google.com
Thu Dec 27 05:19:23 PST 2012


Author: samsonov
Date: Thu Dec 27 07:19:23 2012
New Revision: 171160

URL: http://llvm.org/viewvc/llvm-project?rev=171160&view=rev
Log:
Define COMPILER_RT_CAN_EXECUTE_TESTS variable on platforms where we can produce working binaries and use it in build rules for sanitizers tests

Modified:
    compiler-rt/trunk/CMakeLists.txt
    compiler-rt/trunk/lib/asan/CMakeLists.txt
    compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt
    compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
    compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
    compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
    compiler-rt/trunk/lib/tsan/lit_tests/CMakeLists.txt
    compiler-rt/trunk/lib/ubsan/lit_tests/CMakeLists.txt

Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=171160&r1=171159&r2=171160&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Thu Dec 27 07:19:23 2012
@@ -66,6 +66,15 @@
             COMPILE_DEFINITIONS "${TARGET_I386_CFLAGS}"
             CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${TARGET_I386_CFLAGS}")
 
+# We only support running instrumented tests when we're not cross compiling
+# and target a unix-like system. On Android we define the rules for building
+# unit tests, but don't execute them.
+if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID)
+  set(COMPILER_RT_CAN_EXECUTE_TESTS TRUE)
+else()
+  set(COMPILER_RT_CAN_EXECUTE_TESTS FALSE)
+endif()
+    
 function(filter_available_targets out_var)
   set(archs)
   foreach(arch ${ARGN})

Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=171160&r1=171159&r2=171160&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Thu Dec 27 07:19:23 2012
@@ -129,7 +129,4 @@
   add_subdirectory(tests)
 endif()
 
-# ASan output tests.
-# FIXME: move all output tests from output_tests/ to lit_tests/ and get rid
-# of the first directory.
 add_subdirectory(lit_tests)

Modified: compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt?rev=171160&r1=171159&r2=171160&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt Thu Dec 27 07:19:23 2012
@@ -11,9 +11,8 @@
   ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
   )
 
-if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}")
-  # Run ASan output tests only if we're not cross-compiling,
-  # and can be sure that clang would produce working binaries.
+if(COMPILER_RT_CAN_EXECUTE_TESTS)
+  # Run ASan tests only if we're sure we may produce working binaries.
   set(ASAN_TEST_DEPS
     clang clang-headers FileCheck count not llvm-nm llvm-symbolizer
     ${ASAN_RUNTIME_LIBRARIES}
@@ -30,11 +29,4 @@
     DEPENDS ${ASAN_TEST_DEPS}
     )
   set_target_properties(check-asan PROPERTIES FOLDER "ASan tests")
-elseif(LLVM_INCLUDE_TESTS)
-  # Otherwise run only ASan unit tests.
-  add_lit_testsuite(check-asan "Running the AddressSanitizer unit tests"
-    ${CMAKE_CURRENT_BINARY_DIR}/Unit
-    DEPENDS AsanUnitTests
-    )
-  set_target_properties(check-asan PROPERTIES FOLDER "ASan unit tests")
 endif()

Modified: compiler-rt/trunk/lib/asan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/CMakeLists.txt?rev=171160&r1=171159&r2=171160&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/tests/CMakeLists.txt Thu Dec 27 07:19:23 2012
@@ -153,11 +153,7 @@
                 ${ASAN_BENCHMARKS_OBJECTS} ${ASAN_INST_GTEST})
 endmacro()
 
-# We only support building instrumented tests when we're not cross compiling
-# and targeting a unix-like system where we can predict viable compilation and
-# linking strategies.
-# We use a different approach to build these tests for Android. See below.
-if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID)
+if(COMPILER_RT_CAN_EXECUTE_TESTS)
   if(CAN_TARGET_X86_64)
     add_asan_tests_for_arch(x86_64)
   endif()

Modified: compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/CMakeLists.txt?rev=171160&r1=171159&r2=171160&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/msan/tests/CMakeLists.txt Thu Dec 27 07:19:23 2012
@@ -147,21 +147,20 @@
                 ${MSAN_INST_LIBCXX} ${MSANDR_TEST_SO})
 endmacro()
 
-if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID
-   AND EXISTS ${MSAN_LIBCXX_PATH}/)
+if(COMPILER_RT_CAN_EXECUTE_TESTS AND EXISTS ${MSAN_LIBCXX_PATH}/)
   if(CAN_TARGET_X86_64)
     add_msan_tests_for_arch(x86_64)
   endif()
-endif()
 
-# Run unittests as a part of lit testsuite.
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-  )
+  # Run unittests as a part of lit testsuite.
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+    )
 
-add_lit_testsuite(check-msan "Running MemorySanitizer unittests"
-  ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS MsanUnitTests
-  )
-set_target_properties(check-msan PROPERTIES FOLDER "MemorySanitizer unittests")
+  add_lit_testsuite(check-msan "Running MemorySanitizer unittests"
+    ${CMAKE_CURRENT_BINARY_DIR}
+    DEPENDS MsanUnitTests
+    )
+  set_target_properties(check-msan PROPERTIES FOLDER "MemorySanitizer unittests")
+endif()

Modified: compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt?rev=171160&r1=171159&r2=171160&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/sanitizer_common/tests/CMakeLists.txt Thu Dec 27 07:19:23 2012
@@ -75,7 +75,9 @@
                        LINK_FLAGS ${SANITIZER_TEST_LINK_FLAGS})
 endmacro()
 
-if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}" AND UNIX AND NOT ANDROID)
+if(COMPILER_RT_CAN_EXECUTE_TESTS)
+  # We use just-built clang to build sanitizer_common unittests, so we must
+  # be sure that produced binaries would work.
   if(APPLE)
     add_sanitizer_common_lib("RTSanitizerCommon.test.osx"
                              $<TARGET_OBJECTS:RTSanitizerCommon.osx>)
@@ -95,16 +97,16 @@
   if(CAN_TARGET_I386)
     add_sanitizer_tests_for_arch(i386)
   endif()
-endif()
 
-# Run unittests as a part of lit testsuite.
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
-  )
+  # Run unittests as a part of lit testsuite.
+  configure_lit_site_cfg(
+    ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+    ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+    )
 
-add_lit_testsuite(check-sanitizer "Running sanitizer library unittests"
-  ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS SanitizerUnitTests
-  )
-set_target_properties(check-sanitizer PROPERTIES FOLDER "Sanitizer unittests")
+  add_lit_testsuite(check-sanitizer "Running sanitizer library unittests"
+    ${CMAKE_CURRENT_BINARY_DIR}
+    DEPENDS SanitizerUnitTests
+    )
+  set_target_properties(check-sanitizer PROPERTIES FOLDER "Sanitizer unittests")
+endif()

Modified: compiler-rt/trunk/lib/tsan/lit_tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/lit_tests/CMakeLists.txt?rev=171160&r1=171159&r2=171160&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/lit_tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/tsan/lit_tests/CMakeLists.txt Thu Dec 27 07:19:23 2012
@@ -8,9 +8,8 @@
   ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
   )
 
-if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}")
-  # Run TSan output tests only if we're not cross-compiling,
-  # and can be sure that clang would produce working binaries.
+if(COMPILER_RT_CAN_EXECUTE_TESTS)
+  # Run TSan output tests only if we're sure we can produce working binaries.
   set(TSAN_TEST_DEPS
     clang clang-headers FileCheck count not llvm-symbolizer
     ${TSAN_RUNTIME_LIBRARIES}
@@ -28,7 +27,8 @@
     )
   set_target_properties(check-tsan PROPERTIES FOLDER "TSan unittests")
 elseif(LLVM_INCLUDE_TESTS)
-  # Otherwise run only TSan unit tests.
+  # Otherwise run only TSan unit tests (they are linked using the
+  # host compiler).
   add_lit_testsuite(check-tsan "Running ThreadSanitizer tests"
     ${CMAKE_CURRENT_BINARY_DIR}/Unit
     DEPENDS TsanUnitTests llvm-symbolizer)

Modified: compiler-rt/trunk/lib/ubsan/lit_tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/CMakeLists.txt?rev=171160&r1=171159&r2=171160&view=diff
==============================================================================
--- compiler-rt/trunk/lib/ubsan/lit_tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/ubsan/lit_tests/CMakeLists.txt Thu Dec 27 07:19:23 2012
@@ -3,9 +3,9 @@
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
   )
 
-if("${CMAKE_HOST_SYSTEM}" STREQUAL "${CMAKE_SYSTEM}")
-  # Run UBSan output tests only if we're not cross-compiling,
-  # and can be sure that clang would produce working binaries.
+if(COMPILER_RT_CAN_EXECUTE_TESTS)
+  # Run UBSan output tests only if we're sure that clang would produce
+  # working binaries.
   set(UBSAN_TEST_DEPS
     clang clang-headers FileCheck count not
     ${UBSAN_RUNTIME_LIBRARIES}





More information about the llvm-commits mailing list