[llvm-commits] [compiler-rt] r163209 - in /compiler-rt/trunk/lib/asan: CMakeLists.txt lit_tests/CMakeLists.txt lit_tests/lit.cfg
Alexey Samsonov
samsonov at google.com
Wed Sep 5 03:41:26 PDT 2012
Author: samsonov
Date: Wed Sep 5 05:41:25 2012
New Revision: 163209
URL: http://llvm.org/viewvc/llvm-project?rev=163209&view=rev
Log:
[ASan] Hack ASan lit config to allow running lit on tests manually
Modified:
compiler-rt/trunk/lib/asan/CMakeLists.txt
compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt
compiler-rt/trunk/lib/asan/lit_tests/lit.cfg
Modified: compiler-rt/trunk/lib/asan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/CMakeLists.txt?rev=163209&r1=163208&r2=163209&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/CMakeLists.txt Wed Sep 5 05:41:25 2012
@@ -106,7 +106,7 @@
set_target_compile_flags(clang_rt.asan_osx_dynamic ${ASAN_CFLAGS})
filter_available_targets(ASAN_TARGETS x86_64 i386)
set_target_properties(clang_rt.asan_osx_dynamic PROPERTIES
- COMPILE_DEFINITIONS ${ASAN_DYLIB_DEFINITIONS}
+ COMPILE_DEFINITIONS "${ASAN_DYLIB_DEFINITIONS}"
OSX_ARCHITECTURES "${ASAN_TARGETS}"
LINK_FLAGS "-framework Foundation")
list(APPEND ASAN_DYNAMIC_RUNTIME_LIBRARIES clang_rt.asan_osx_dynamic)
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=163209&r1=163208&r2=163209&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/CMakeLists.txt Wed Sep 5 05:41:25 2012
@@ -18,11 +18,15 @@
clang clang-headers FileCheck count not llvm-nm
${ASAN_RUNTIME_LIBRARIES}
)
+ set(ASAN_TEST_PARAMS
+ asan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+ )
if(LLVM_INCLUDE_TESTS)
list(APPEND ASAN_TEST_DEPS AsanUnitTests)
endif()
add_lit_testsuite(check-asan "Running the AddressSanitizer tests"
${CMAKE_CURRENT_BINARY_DIR}
+ PARAMS ${ASAN_TEST_PARAMS}
DEPENDS ${ASAN_TEST_DEPS}
)
set_target_properties(check-asan PROPERTIES FOLDER "ASan tests")
Modified: compiler-rt/trunk/lib/asan/lit_tests/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/lit.cfg?rev=163209&r1=163208&r2=163209&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/lit.cfg (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/lit.cfg Wed Sep 5 05:41:25 2012
@@ -2,26 +2,60 @@
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_cfg = os.path.join(llvm_src_root, "projects", "compiler-rt",
- "lib", "lit.common.cfg")
-lit.load_config(config, compiler_rt_lit_cfg)
-
# Setup config name.
config.name = 'AddressSanitizer'
# Setup source root.
config.test_source_root = os.path.dirname(__file__)
+def DisplayNoConfigMessage():
+ lit.fatal("No site specific configuration available! " +
+ "Try running your test from the build tree or running " +
+ "make check-asan")
+
+# 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.
+ asan_site_cfg = lit.params.get('asan_site_config', None)
+ if (asan_site_cfg) and (os.path.exists(asan_site_cfg)):
+ lit.load_config(config, asan_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()
+
+ # Validate that llvm-config points to the same source tree.
+ llvm_src_root = lit.util.capture(["llvm-config", "--src-root"]).strip()
+ asan_test_src_root = os.path.join(llvm_src_root, "projects", "compiler-rt",
+ "lib", "asan", "lit_tests")
+ if (os.path.realpath(asan_test_src_root) !=
+ os.path.realpath(config.test_source_root)):
+ DisplayNoConfigMessage()
+
+ # Find out the presumed location of generated site config.
+ llvm_obj_root = lit.util.capture(["llvm-config", "--obj-root"]).strip()
+ asan_site_cfg = os.path.join(llvm_obj_root, "projects", "compiler-rt",
+ "lib", "asan", "lit_tests", "lit.site.cfg")
+ if (not asan_site_cfg) or (not os.path.exists(asan_site_cfg)):
+ DisplayNoConfigMessage()
+
+ lit.load_config(config, asan_site_cfg)
+ raise SystemExit
+
+# 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 -faddress-sanitizer option.
# FIXME: Review the set of required flags and check if it can be reduced.
clang_asan_cxxflags = ("-ccc-clang-cxx "
More information about the llvm-commits
mailing list