[compiler-rt] r201412 - Move MSan lit-tests under test/msan

Alexey Samsonov samsonov at google.com
Fri Feb 14 05:02:58 PST 2014


Author: samsonov
Date: Fri Feb 14 07:02:58 2014
New Revision: 201412

URL: http://llvm.org/viewvc/llvm-project?rev=201412&view=rev
Log:
Move MSan lit-tests under test/msan

Added:
    compiler-rt/trunk/test/msan/
      - copied from r201409, compiler-rt/trunk/lib/msan/lit_tests/
Removed:
    compiler-rt/trunk/lib/msan/lit_tests/
Modified:
    compiler-rt/trunk/CMakeLists.txt
    compiler-rt/trunk/lib/msan/CMakeLists.txt
    compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
    compiler-rt/trunk/test/CMakeLists.txt
    compiler-rt/trunk/test/lsan/CMakeLists.txt
    compiler-rt/trunk/test/msan/CMakeLists.txt
    compiler-rt/trunk/test/msan/Unit/lit.site.cfg.in
    compiler-rt/trunk/test/msan/lit.cfg
    compiler-rt/trunk/test/msan/lit.site.cfg.in

Modified: compiler-rt/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/CMakeLists.txt?rev=201412&r1=201411&r2=201412&view=diff
==============================================================================
--- compiler-rt/trunk/CMakeLists.txt (original)
+++ compiler-rt/trunk/CMakeLists.txt Fri Feb 14 07:02:58 2014
@@ -233,6 +233,7 @@ filter_available_targets(SANITIZER_COMMO
   x86_64 i386 powerpc64 arm)
 filter_available_targets(DFSAN_SUPPORTED_ARCH x86_64)
 filter_available_targets(LSAN_SUPPORTED_ARCH x86_64)
+filter_available_targets(MSAN_SUPPORTED_ARCH x86_64)
 filter_available_targets(UBSAN_SUPPORTED_ARCH x86_64 i386)
 
 add_subdirectory(include)
@@ -248,6 +249,13 @@ if (NOT ANDROID)
   endif()
 endif()
 
+set(COMPILER_RT_LIBCXX_PATH ${LLVM_MAIN_SRC_DIR}/projects/libcxx)
+if(EXISTS ${COMPILER_RT_LIBCXX_PATH}/)
+  set(COMPILER_RT_HAS_LIBCXX_SOURCES TRUE)
+else()
+  set(COMPILER_RT_HAS_LIBCXX_SOURCES FALSE)
+endif()
+
 add_subdirectory(lib)
 
 if(LLVM_INCLUDE_TESTS)

Modified: compiler-rt/trunk/lib/msan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/CMakeLists.txt?rev=201412&r1=201411&r2=201412&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/msan/CMakeLists.txt Fri Feb 14 07:02:58 2014
@@ -17,7 +17,7 @@ set(MSAN_RTL_CFLAGS
   -ffreestanding)
 
 # Static runtime library.
-set(MSAN_RUNTIME_LIBRARIES)
+add_custom_target(msan)
 set(arch "x86_64")
 if(CAN_TARGET_${arch})
   add_compiler_rt_static_runtime(clang_rt.msan-${arch} ${arch}
@@ -26,25 +26,16 @@ if(CAN_TARGET_${arch})
             $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
             $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
     CFLAGS ${MSAN_RTL_CFLAGS})
-  list(APPEND MSAN_RUNTIME_LIBRARIES clang_rt.msan-${arch})
+  add_dependencies(msan clang_rt.msan-${arch})
   if(UNIX)
     add_sanitizer_rt_symbols(clang_rt.msan-${arch} msan.syms.extra)
-    list(APPEND MSAN_RUNTIME_LIBRARIES clang_rt.msan-${arch}-symbols)
+    add_dependencies(msan clang_rt.msan-${arch}-symbols)
   endif()
 endif()
 
 add_compiler_rt_resource_file(msan_blacklist msan_blacklist.txt)
-
-# We should only build MSan unit tests if we can build instrumented libcxx.
-set(MSAN_LIBCXX_PATH ${LLVM_MAIN_SRC_DIR}/projects/libcxx)
-if(EXISTS ${MSAN_LIBCXX_PATH}/)
-  set(MSAN_CAN_INSTRUMENT_LIBCXX TRUE)
-else()
-  set(MSAN_CAN_INSTRUMENT_LIBCXX FALSE)
-endif()
+add_dependencies(msan msan_blacklist)
 
 if(LLVM_INCLUDE_TESTS)
   add_subdirectory(tests)
 endif()
-
-add_subdirectory(lit_tests)

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=201412&r1=201411&r2=201412&view=diff
==============================================================================
--- compiler-rt/trunk/lib/msan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/msan/tests/CMakeLists.txt Fri Feb 14 07:02:58 2014
@@ -6,9 +6,9 @@ include_directories(..)
 include_directories(../..)
 
 # Instrumented libcxx sources and build flags.
-file(GLOB MSAN_LIBCXX_SOURCES ${MSAN_LIBCXX_PATH}/src/*.cpp)
+file(GLOB MSAN_LIBCXX_SOURCES ${COMPILER_RT_LIBCXX_PATH}/src/*.cpp)
 set(MSAN_LIBCXX_CFLAGS
-  -I${MSAN_LIBCXX_PATH}/include
+  -I${COMPILER_RT_LIBCXX_PATH}/include
   -fsanitize=memory
   -fsanitize-memory-track-origins
   -fPIC
@@ -39,7 +39,7 @@ set(MSAN_UNITTEST_HEADERS
 )
 set(MSANDR_UNITTEST_SOURCE msandr_test_so.cc)
 set(MSAN_UNITTEST_COMMON_CFLAGS
-  -I${MSAN_LIBCXX_PATH}/include
+  -I${COMPILER_RT_LIBCXX_PATH}/include
   ${COMPILER_RT_GTEST_INCLUDE_CFLAGS}
   -I${COMPILER_RT_SOURCE_DIR}/include
   -I${COMPILER_RT_SOURCE_DIR}/lib
@@ -78,7 +78,7 @@ macro(msan_compile obj_list source arch)
   get_target_flags_for_arch(${arch} TARGET_CFLAGS)
   clang_compile(${output_obj} ${source}
                 CFLAGS ${ARGN} ${TARGET_CFLAGS}
-                DEPS gtest ${MSAN_RUNTIME_LIBRARIES} ${MSAN_UNITTEST_HEADERS})
+                DEPS gtest msan ${MSAN_UNITTEST_HEADERS})
   list(APPEND ${obj_list} ${output_obj})
 endmacro()
 
@@ -99,7 +99,7 @@ macro(add_msan_test test_suite test_name
   get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
   add_compiler_rt_test(${test_suite} ${test_name}
                        OBJECTS ${ARGN}
-                       DEPS ${MSAN_RUNTIME_LIBRARIES} ${ARGN}
+                       DEPS msan ${ARGN}
                             ${MSAN_LOADABLE_SO}
                        LINK_FLAGS ${MSAN_UNITTEST_LINK_FLAGS}
                                   ${TARGET_LINK_FLAGS}
@@ -128,7 +128,7 @@ macro(add_msan_tests_for_arch arch)
   msan_link_shared(MSAN_INST_LIBCXX "libcxx" ${arch}
                    OBJECTS ${MSAN_INST_LIBCXX_OBJECTS}
                    LINKFLAGS ${MSAN_LIBCXX_LINK_FLAGS}
-                   DEPS ${MSAN_INST_LIBCXX_OBJECTS} ${MSAN_RUNTIME_LIBRARIES})
+                   DEPS ${MSAN_INST_LIBCXX_OBJECTS} msan)
 
   # Instrumented tests.
   set(MSAN_INST_TEST_OBJECTS)
@@ -151,13 +151,13 @@ macro(add_msan_tests_for_arch arch)
   set(MSAN_LOADABLE_SO)
   msan_link_shared(MSAN_LOADABLE_SO "libmsan_loadable" ${arch}
                    OBJECTS ${MSAN_INST_LOADABLE_OBJECTS}
-                   DEPS ${MSAN_INST_LOADABLE_OBJECTS} ${MSAN_RUNTIME_LIBRARIES})
+                   DEPS ${MSAN_INST_LOADABLE_OBJECTS} msan)
 
   # Uninstrumented shared library tests.
   set(MSANDR_TEST_SO)
   msan_link_shared(MSANDR_TEST_SO "libmsandr_test" ${arch}
                    OBJECTS ${MSANDR_TEST_OBJECTS}
-                   DEPS ${MSANDR_TEST_OBJECTS} ${MSAN_RUNTIME_LIBRARIES})
+                   DEPS ${MSANDR_TEST_OBJECTS} msan)
 
   # Link everything together.
   add_msan_test(MsanUnitTests "Msan-${arch}-Test" ${arch}
@@ -165,7 +165,8 @@ macro(add_msan_tests_for_arch arch)
                 ${MSAN_INST_LIBCXX} ${MSANDR_TEST_SO})
 endmacro()
 
-if(COMPILER_RT_CAN_EXECUTE_TESTS AND MSAN_CAN_INSTRUMENT_LIBCXX)
+# We should only build MSan unit tests if we can build instrumented libcxx.
+if(COMPILER_RT_CAN_EXECUTE_TESTS AND COMPILER_RT_HAS_LIBCXX_SOURCES)
   if(CAN_TARGET_x86_64)
     add_msan_tests_for_arch(x86_64)
   endif()

Modified: compiler-rt/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/CMakeLists.txt?rev=201412&r1=201411&r2=201412&view=diff
==============================================================================
--- compiler-rt/trunk/test/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/CMakeLists.txt Fri Feb 14 07:02:58 2014
@@ -15,6 +15,9 @@ if(COMPILER_RT_CAN_EXECUTE_TESTS)
   if(LSAN_SUPPORTED_ARCH)
     add_subdirectory(lsan)
   endif()
+  if(MSAN_SUPPORTED_ARCH)
+    add_subdirectory(msan)
+  endif()
   if(UBSAN_SUPPORTED_ARCH)
     add_subdirectory(ubsan)
   endif()

Modified: compiler-rt/trunk/test/lsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/CMakeLists.txt?rev=201412&r1=201411&r2=201412&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/lsan/CMakeLists.txt Fri Feb 14 07:02:58 2014
@@ -10,7 +10,7 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/AsanConfig/lit.site.cfg
   )
 
-if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT APPLE AND NOT ANDROID)
+if(NOT APPLE AND NOT ANDROID)
   set(LSAN_TEST_DEPS
     ${SANITIZER_COMMON_LIT_TEST_DEPS}
     lsan

Modified: compiler-rt/trunk/test/msan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/CMakeLists.txt?rev=201412&r1=201409&r2=201412&view=diff
==============================================================================
--- compiler-rt/trunk/test/msan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/msan/CMakeLists.txt Fri Feb 14 07:02:58 2014
@@ -1,31 +1,22 @@
-set(MSAN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
-set(MSAN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/..)
+set(MSAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
 configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
 
-if(MSAN_CAN_INSTRUMENT_LIBCXX)
+set(MSAN_TEST_DEPS
+  ${SANITIZER_COMMON_LIT_TEST_DEPS}
+  msan)
+
+if(LLVM_INCLUDE_TESTS AND COMPILER_RT_HAS_LIBCXX_SOURCES)
   configure_lit_site_cfg(
     ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
     ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
+  list(APPEND MSAN_TEST_DEPS MsanUnitTests)
 endif()
 
-if(COMPILER_RT_CAN_EXECUTE_TESTS AND CAN_TARGET_x86_64)
-  # Run MSan tests only if we're sure we may produce working binaries.
-  set(MSAN_TEST_DEPS
-    ${SANITIZER_COMMON_LIT_TEST_DEPS}
-    ${MSAN_RUNTIME_LIBRARIES}
-    msan_blacklist)
-  set(MSAN_TEST_PARAMS
-    msan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
-  if(LLVM_INCLUDE_TESTS AND MSAN_CAN_INSTRUMENT_LIBCXX)
-    list(APPEND MSAN_TEST_DEPS MsanUnitTests)
-  endif()
-  add_lit_testsuite(check-msan "Running the MemorySanitizer tests"
-    ${CMAKE_CURRENT_BINARY_DIR}
-    PARAMS ${MSAN_TEST_PARAMS}
-    DEPENDS ${MSAN_TEST_DEPS}
-    )
-  set_target_properties(check-msan PROPERTIES FOLDER "MSan tests")
-endif()
+add_lit_testsuite(check-msan "Running the MemorySanitizer tests"
+  ${CMAKE_CURRENT_BINARY_DIR}
+  DEPENDS ${MSAN_TEST_DEPS}
+  )
+set_target_properties(check-msan PROPERTIES FOLDER "MSan tests")

Modified: compiler-rt/trunk/test/msan/Unit/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/Unit/lit.site.cfg.in?rev=201412&r1=201409&r2=201412&view=diff
==============================================================================
--- compiler-rt/trunk/test/msan/Unit/lit.site.cfg.in (original)
+++ compiler-rt/trunk/test/msan/Unit/lit.site.cfg.in Fri Feb 14 07:02:58 2014
@@ -9,5 +9,6 @@ config.name = 'MemorySanitizer-Unit'
 
 # Setup test source and exec root. For unit tests, we define
 # it as build directory with MSan unit tests.
-config.test_exec_root = "@MSAN_BINARY_DIR@/tests"
+# FIXME: Don't use hardcoded path to MSan unit tests.
+config.test_exec_root = "@COMPILER_RT_BINARY_DIR@/lib/msan/tests"
 config.test_source_root = config.test_exec_root

Modified: compiler-rt/trunk/test/msan/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/lit.cfg?rev=201412&r1=201409&r2=201412&view=diff
==============================================================================
--- compiler-rt/trunk/test/msan/lit.cfg (original)
+++ compiler-rt/trunk/test/msan/lit.cfg Fri Feb 14 07:02:58 2014
@@ -2,55 +2,12 @@
 
 import os
 
-import lit.util
-
-def get_required_attr(config, attr_name):
-  attr_value = getattr(config, attr_name, None)
-  if not attr_value:
-    lit_config.fatal(
-      "No attribute %r in test configuration! You may need to run "
-      "tests from your build directory or add this attribute "
-      "to lit.site.cfg " % attr_name)
-  return attr_value
-
 # Setup config name.
 config.name = 'MemorySanitizer'
 
 # Setup source root.
 config.test_source_root = os.path.dirname(__file__)
 
-def DisplayNoConfigMessage():
-  lit_config.fatal("No site specific configuration available! " +
-                   "Try running your test from the build tree or running " +
-                   "make check-msan")
-
-# Figure out LLVM source root.
-llvm_src_root = getattr(config, 'llvm_src_root', None)
-if llvm_src_root is None:
-  # We probably haven't loaded the site-specific configuration: the user
-  # is likely trying to run a test file directly, and the site configuration
-  # wasn't created by the build system.
-  msan_site_cfg = lit_config.params.get('msan_site_config', None)
-  if (msan_site_cfg) and (os.path.exists(msan_site_cfg)):
-    lit_config.load_config(config, msan_site_cfg)
-    raise SystemExit
-
-  # Try to guess the location of site-specific configuration using llvm-config
-  # util that can point where the build tree is.
-  llvm_config = lit.util.which("llvm-config", config.environment["PATH"])
-  if not llvm_config:
-    DisplayNoConfigMessage()
-
-  # Find out the presumed location of generated site config.
-  llvm_obj_root = lit.util.capture(["llvm-config", "--obj-root"]).strip()
-  msan_site_cfg = os.path.join(llvm_obj_root, "projects", "compiler-rt",
-                               "lib", "msan", "lit_tests", "lit.site.cfg")
-  if (not msan_site_cfg) or (not os.path.exists(msan_site_cfg)):
-    DisplayNoConfigMessage()
-
-  lit_config.load_config(config, msan_site_cfg)
-  raise SystemExit
-
 # Setup default compiler flags used with -fsanitize=memory option.
 clang_msan_cflags = ["-fsanitize=memory",
                      "-mno-omit-leaf-frame-pointer",

Modified: compiler-rt/trunk/test/msan/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/msan/lit.site.cfg.in?rev=201412&r1=201409&r2=201412&view=diff
==============================================================================
--- compiler-rt/trunk/test/msan/lit.site.cfg.in (original)
+++ compiler-rt/trunk/test/msan/lit.site.cfg.in Fri Feb 14 07:02:58 2014
@@ -2,4 +2,4 @@
 lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
 
 # Load tool-specific config that would do the real work.
-lit_config.load_config(config, "@MSAN_SOURCE_DIR@/lit_tests/lit.cfg")
+lit_config.load_config(config, "@MSAN_LIT_SOURCE_DIR@/lit.cfg")





More information about the llvm-commits mailing list