[compiler-rt] r182583 - [lsan] Add lit test support.

Sergey Matveev earthdok at google.com
Thu May 23 05:58:57 PDT 2013


Author: smatveev
Date: Thu May 23 07:58:56 2013
New Revision: 182583

URL: http://llvm.org/viewvc/llvm-project?rev=182583&view=rev
Log:
[lsan] Add lit test support.

"check-lsan" now runs both the tests from lib/lsan/tests and any lit
tests found under lib/lsan/lit_tests.

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

Modified: compiler-rt/trunk/lib/lsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/CMakeLists.txt?rev=182583&r1=182582&r2=182583&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/lsan/CMakeLists.txt Thu May 23 07:58:56 2013
@@ -45,4 +45,7 @@ if (NOT APPLE AND NOT ANDROID)
   endforeach()
 endif()
 
-add_subdirectory(tests)
+if (LLVM_INCLUDE_TESTS)
+  add_subdirectory(tests)
+endif()
+add_subdirectory(lit_tests)

Added: compiler-rt/trunk/lib/lsan/lit_tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lit_tests/CMakeLists.txt?rev=182583&view=auto
==============================================================================
--- compiler-rt/trunk/lib/lsan/lit_tests/CMakeLists.txt (added)
+++ compiler-rt/trunk/lib/lsan/lit_tests/CMakeLists.txt Thu May 23 07:58:56 2013
@@ -0,0 +1,28 @@
+set(LSAN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
+set(LSAN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/..)
+
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+  )
+
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
+  )
+
+if(COMPILER_RT_CAN_EXECUTE_TESTS)
+  set(LSAN_TEST_DEPS
+    ${SANITIZER_COMMON_LIT_TEST_DEPS}
+    ${LSAN_RUNTIME_LIBRARIES})
+  set(LSAN_TEST_PARAMS
+    lsan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+  if(LLVM_INCLUDE_TESTS)
+    list(APPEND LSAN_TEST_DEPS LsanTests)
+  endif()
+  add_lit_testsuite(check-lsan "Running the LeakSanitizer tests"
+    ${CMAKE_CURRENT_BINARY_DIR}
+    PARAMS ${LSAN_TEST_PARAMS}
+    DEPENDS ${LSAN_TEST_DEPS})
+  set_target_properties(check-lsan PROPERTIES FOLDER "LSan tests")
+endif()

Copied: compiler-rt/trunk/lib/lsan/lit_tests/Unit/lit.cfg (from r182582, compiler-rt/trunk/lib/lsan/tests/lit.cfg)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lit_tests/Unit/lit.cfg?p2=compiler-rt/trunk/lib/lsan/lit_tests/Unit/lit.cfg&p1=compiler-rt/trunk/lib/lsan/tests/lit.cfg&r1=182582&r2=182583&rev=182583&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/tests/lit.cfg (original)
+++ compiler-rt/trunk/lib/lsan/lit_tests/Unit/lit.cfg Thu May 23 07:58:56 2013
@@ -18,12 +18,10 @@ compiler_rt_lit_unit_cfg = os.path.join(
 lit.load_config(config, compiler_rt_lit_unit_cfg)
 
 # Setup config name.
-config.name = 'LeakSanitizer'
+config.name = 'LeakSanitizer-Unit'
 
 # Setup test source and exec root. For unit tests, we define
-# it as build directory with lsan unit tests.
-llvm_obj_root = get_required_attr(config, "llvm_obj_root")
-config.test_exec_root = os.path.join(llvm_obj_root, "projects",
-                                     "compiler-rt", "lib",
-                                     "lsan", "tests")
+# it as build directory with LSan unit tests.
+lsan_binary_dir = get_required_attr(config, "lsan_binary_dir")
+config.test_exec_root = os.path.join(lsan_binary_dir, "tests")
 config.test_source_root = config.test_exec_root

Copied: compiler-rt/trunk/lib/lsan/lit_tests/Unit/lit.site.cfg.in (from r182582, compiler-rt/trunk/lib/lsan/tests/lit.site.cfg.in)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lit_tests/Unit/lit.site.cfg.in?p2=compiler-rt/trunk/lib/lsan/lit_tests/Unit/lit.site.cfg.in&p1=compiler-rt/trunk/lib/lsan/tests/lit.site.cfg.in&r1=182582&r2=182583&rev=182583&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/tests/lit.site.cfg.in (original)
+++ compiler-rt/trunk/lib/lsan/lit_tests/Unit/lit.site.cfg.in Thu May 23 07:58:56 2013
@@ -1,14 +1,16 @@
+## Autogenerated by LLVM/Clang configuration.
+# Do not edit!
+
+config.target_triple = "@TARGET_TRIPLE@"
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
-config.llvm_obj_root = "@LLVM_BINARY_DIR@"
 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
+config.lsan_binary_dir = "@LSAN_BINARY_DIR@"
 
-# LLVM tools dir can be passed in lit parameters, so try to
-# apply substitution.
 try:
   config.llvm_build_mode = config.llvm_build_mode % lit.params
-except KeyError, e:
+except KeyError,e:
   key, = e.args
   lit.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
 
 # Let the main config do the real work.
-lit.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")
+lit.load_config(config, "@LSAN_SOURCE_DIR@/lit_tests/Unit/lit.cfg")

Added: compiler-rt/trunk/lib/lsan/lit_tests/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lit_tests/lit.cfg?rev=182583&view=auto
==============================================================================
--- compiler-rt/trunk/lib/lsan/lit_tests/lit.cfg (added)
+++ compiler-rt/trunk/lib/lsan/lit_tests/lit.cfg Thu May 23 07:58:56 2013
@@ -0,0 +1,46 @@
+# -*- Python -*-
+
+import os
+
+def get_required_attr(config, attr_name):
+  attr_value = getattr(config, attr_name, None)
+  if not attr_value:
+    lit.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 attributes common for all compiler-rt projects.
+llvm_src_root = get_required_attr(config, 'llvm_src_root')
+compiler_rt_lit_unit_cfg = os.path.join(llvm_src_root, "projects",
+                                        "compiler-rt", "lib",
+                                        "lit.common.unit.cfg")
+lit.load_config(config, compiler_rt_lit_unit_cfg)
+
+# Setup config name.
+config.name = 'LeakSanitizer'
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+
+# Setup attributes common for all compiler-rt projects.
+compiler_rt_lit_cfg = os.path.join(llvm_src_root, "projects", "compiler-rt",
+                                   "lib", "lit.common.cfg")
+if (not compiler_rt_lit_cfg) or (not os.path.exists(compiler_rt_lit_cfg)):
+  lit.fatal("Can't find common compiler-rt lit config at: %r"
+            % compiler_rt_lit_cfg)
+lit.load_config(config, compiler_rt_lit_cfg)
+
+# Setup default compiler flags used with -fsanitize=leak option.
+clang_lsan_cxxflags = ("-ccc-cxx "
+                      + "-fsanitize=leak "
+                      + "-g")
+config.substitutions.append( ("%clangxx_lsan ", (" " + config.clang + " " +
+                                                clang_lsan_cxxflags + " ")) )
+
+# Default test suffixes.
+config.suffixes = ['.c', '.cc', '.cpp']
+
+# LeakSanitizer tests are currently supported on x86-64 Linux only.
+if config.host_os not in ['Linux'] or config.host_arch not in ['x86_64']:
+  config.unsupported = True

Copied: compiler-rt/trunk/lib/lsan/lit_tests/lit.site.cfg.in (from r182582, compiler-rt/trunk/lib/lsan/tests/lit.site.cfg.in)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/lit_tests/lit.site.cfg.in?p2=compiler-rt/trunk/lib/lsan/lit_tests/lit.site.cfg.in&p1=compiler-rt/trunk/lib/lsan/tests/lit.site.cfg.in&r1=182582&r2=182583&rev=182583&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/tests/lit.site.cfg.in (original)
+++ compiler-rt/trunk/lib/lsan/lit_tests/lit.site.cfg.in Thu May 23 07:58:56 2013
@@ -1,12 +1,17 @@
+config.host_os = "@HOST_OS@"
+config.host_arch = "@HOST_ARCH@"
+config.llvm_build_mode = "@LLVM_BUILD_MODE@"
 config.llvm_src_root = "@LLVM_SOURCE_DIR@"
 config.llvm_obj_root = "@LLVM_BINARY_DIR@"
-config.llvm_build_mode = "@LLVM_BUILD_MODE@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.clang = "@LLVM_BINARY_DIR@/bin/clang"
+config.compiler_rt_arch = "@COMPILER_RT_SUPPORTED_ARCH@"
 
 # LLVM tools dir can be passed in lit parameters, so try to
 # apply substitution.
 try:
-  config.llvm_build_mode = config.llvm_build_mode % lit.params
-except KeyError, e:
+  config.llvm_tools_dir = config.llvm_tools_dir % lit.params
+except KeyError,e:
   key, = e.args
   lit.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
 

Modified: compiler-rt/trunk/lib/lsan/tests/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/tests/CMakeLists.txt?rev=182583&r1=182582&r2=182583&view=diff
==============================================================================
--- compiler-rt/trunk/lib/lsan/tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/lsan/tests/CMakeLists.txt Thu May 23 07:58:56 2013
@@ -56,22 +56,3 @@ if(UNIX AND NOT APPLE AND CAN_TARGET_x86
   add_lsan_tests_for_arch(x86_64)
 endif()
 
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
-
-if(COMPILER_RT_CAN_EXECUTE_TESTS)
-  set(LSAN_TEST_DEPS
-    clang clang-headers
-    ${LSAN_RUNTIME_LIBRARIES})
-  set(LSAN_TEST_PARAMS
-    lsan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
-  if(LLVM_INCLUDE_TESTS)
-    list(APPEND LSAN_TEST_DEPS LsanTests)
-  endif()
-  add_lit_testsuite(check-lsan "Running the LeakSanitizer tests"
-    ${CMAKE_CURRENT_BINARY_DIR}
-    PARAMS ${LSAN_TEST_PARAMS}
-    DEPENDS ${LSAN_TEST_DEPS})
-  set_target_properties(check-lsan PROPERTIES FOLDER "LSan tests")
-endif()

Removed: compiler-rt/trunk/lib/lsan/tests/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/tests/lit.cfg?rev=182582&view=auto
==============================================================================
--- compiler-rt/trunk/lib/lsan/tests/lit.cfg (original)
+++ compiler-rt/trunk/lib/lsan/tests/lit.cfg (removed)
@@ -1,29 +0,0 @@
-# -*- Python -*-
-
-import os
-
-def get_required_attr(config, attr_name):
-  attr_value = getattr(config, attr_name, None)
-  if not attr_value:
-    lit.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 attributes common for all compiler-rt projects.
-llvm_src_root = get_required_attr(config, 'llvm_src_root')
-compiler_rt_lit_unit_cfg = os.path.join(llvm_src_root, "projects",
-                                        "compiler-rt", "lib",
-                                        "lit.common.unit.cfg")
-lit.load_config(config, compiler_rt_lit_unit_cfg)
-
-# Setup config name.
-config.name = 'LeakSanitizer'
-
-# Setup test source and exec root. For unit tests, we define
-# it as build directory with lsan unit tests.
-llvm_obj_root = get_required_attr(config, "llvm_obj_root")
-config.test_exec_root = os.path.join(llvm_obj_root, "projects",
-                                     "compiler-rt", "lib",
-                                     "lsan", "tests")
-config.test_source_root = config.test_exec_root

Removed: compiler-rt/trunk/lib/lsan/tests/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/lsan/tests/lit.site.cfg.in?rev=182582&view=auto
==============================================================================
--- compiler-rt/trunk/lib/lsan/tests/lit.site.cfg.in (original)
+++ compiler-rt/trunk/lib/lsan/tests/lit.site.cfg.in (removed)
@@ -1,14 +0,0 @@
-config.llvm_src_root = "@LLVM_SOURCE_DIR@"
-config.llvm_obj_root = "@LLVM_BINARY_DIR@"
-config.llvm_build_mode = "@LLVM_BUILD_MODE@"
-
-# LLVM tools dir can be passed in lit parameters, so try to
-# apply substitution.
-try:
-  config.llvm_build_mode = config.llvm_build_mode % lit.params
-except KeyError, e:
-  key, = e.args
-  lit.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key, key))
-
-# Let the main config do the real work.
-lit.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")





More information about the llvm-commits mailing list