[compiler-rt] r201553 - Simplify lit test configs for LSan and UBSan by using a generic config
Alexey Samsonov
samsonov at google.com
Tue Feb 18 00:56:50 PST 2014
Author: samsonov
Date: Tue Feb 18 02:56:49 2014
New Revision: 201553
URL: http://llvm.org/viewvc/llvm-project?rev=201553&view=rev
Log:
Simplify lit test configs for LSan and UBSan by using a generic config
Added:
compiler-rt/trunk/test/lsan/lit.site.cfg.in
- copied, changed from r201542, compiler-rt/trunk/test/lsan/LsanConfig/lit.site.cfg.in
compiler-rt/trunk/test/ubsan/lit.site.cfg.in
- copied, changed from r201544, compiler-rt/trunk/test/ubsan/AsanConfig/lit.site.cfg.in
Removed:
compiler-rt/trunk/test/lsan/AsanConfig/
compiler-rt/trunk/test/lsan/LsanConfig/
compiler-rt/trunk/test/ubsan/AsanConfig/
compiler-rt/trunk/test/ubsan/UbsanConfig/
Modified:
compiler-rt/trunk/test/lsan/CMakeLists.txt
compiler-rt/trunk/test/lsan/lit.common.cfg
compiler-rt/trunk/test/ubsan/CMakeLists.txt
compiler-rt/trunk/test/ubsan/lit.common.cfg
Modified: compiler-rt/trunk/test/lsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/CMakeLists.txt?rev=201553&r1=201552&r2=201553&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/lsan/CMakeLists.txt Tue Feb 18 02:56:49 2014
@@ -1,14 +1,14 @@
set(LSAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(LSAN_LIT_TEST_MODE "Standalone")
configure_lit_site_cfg(
- ${CMAKE_CURRENT_SOURCE_DIR}/LsanConfig/lit.site.cfg.in
- ${CMAKE_CURRENT_BINARY_DIR}/LsanConfig/lit.site.cfg
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/LsanConfig/lit.site.cfg)
+set(LSAN_LIT_TEST_MODE "AddressSanitizer")
configure_lit_site_cfg(
- ${CMAKE_CURRENT_SOURCE_DIR}/AsanConfig/lit.site.cfg.in
- ${CMAKE_CURRENT_BINARY_DIR}/AsanConfig/lit.site.cfg
- )
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/AsanConfig/lit.site.cfg)
if(NOT APPLE AND NOT ANDROID)
set(LSAN_TEST_DEPS
Modified: compiler-rt/trunk/test/lsan/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/lit.common.cfg?rev=201553&r1=201552&r2=201553&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/lit.common.cfg (original)
+++ compiler-rt/trunk/test/lsan/lit.common.cfg Tue Feb 18 02:56:49 2014
@@ -14,11 +14,25 @@ def get_required_attr(config, attr_name)
return attr_value
# Setup source root.
-lsan_lit_src_root = get_required_attr(config, 'lsan_lit_src_root')
-config.test_source_root = os.path.join(lsan_lit_src_root, 'TestCases')
+config.test_source_root = os.path.dirname(__file__)
+
+# Choose between standalone and LSan+ASan modes.
+lsan_lit_test_mode = get_required_attr(config, 'lsan_lit_test_mode')
+if lsan_lit_test_mode == "Standalone":
+ config.name = "LeakSanitizer-Standalone"
+ lsan_cflags = ["-fsanitize=leak"]
+elif lsan_lit_test_mode == "AddressSanitizer":
+ config.name = "LeakSanitizer-AddressSanitizer"
+ lsan_cflags = ["-fsanitize=address"]
+ config.available_features.add('asan')
+ config.environment['ASAN_OPTIONS'] = 'detect_leaks=1'
+else:
+ lit_config.fatal("Unknown LSan test mode: %r" % lsan_lit_test_mode)
clang_cflags = ["-g", "-O0", "-m64"]
clang_cxxflags = ["--driver-mode=g++"] + clang_cflags
+clang_lsan_cflags = clang_cflags + lsan_cflags
+clang_lsan_cxxflags = clang_cxxflags + lsan_cflags
config.clang_cflags = clang_cflags
config.clang_cxxflags = clang_cxxflags
@@ -28,6 +42,8 @@ def build_invocation(compile_flags):
config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
+config.substitutions.append( ("%clang_lsan ", build_invocation(clang_lsan_cflags)) )
+config.substitutions.append( ("%clangxx_lsan ", build_invocation(clang_lsan_cxxflags)) )
# 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']:
Copied: compiler-rt/trunk/test/lsan/lit.site.cfg.in (from r201542, compiler-rt/trunk/test/lsan/LsanConfig/lit.site.cfg.in)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/lsan/lit.site.cfg.in?p2=compiler-rt/trunk/test/lsan/lit.site.cfg.in&p1=compiler-rt/trunk/test/lsan/LsanConfig/lit.site.cfg.in&r1=201542&r2=201553&rev=201553&view=diff
==============================================================================
--- compiler-rt/trunk/test/lsan/LsanConfig/lit.site.cfg.in (original)
+++ compiler-rt/trunk/test/lsan/lit.site.cfg.in Tue Feb 18 02:56:49 2014
@@ -2,7 +2,7 @@
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
# Tool-specific config options.
-config.lsan_lit_src_root = "@LSAN_LIT_SOURCE_DIR@"
+config.lsan_lit_test_mode = "@LSAN_LIT_TEST_MODE@"
# Load tool-specific config that would do the real work.
-lit_config.load_config(config, "@LSAN_LIT_SOURCE_DIR@/LsanConfig/lit.cfg")
+lit_config.load_config(config, "@LSAN_LIT_SOURCE_DIR@/lit.common.cfg")
Modified: compiler-rt/trunk/test/ubsan/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/CMakeLists.txt?rev=201553&r1=201552&r2=201553&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/CMakeLists.txt (original)
+++ compiler-rt/trunk/test/ubsan/CMakeLists.txt Tue Feb 18 02:56:49 2014
@@ -1,11 +1,13 @@
set(UBSAN_LIT_TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(UBSAN_LIT_TEST_MODE "Standalone")
configure_lit_site_cfg(
- ${CMAKE_CURRENT_SOURCE_DIR}/UbsanConfig/lit.site.cfg.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/UbsanConfig/lit.site.cfg)
+set(UBSAN_LIT_TEST_MODE "AddressSanitizer")
configure_lit_site_cfg(
- ${CMAKE_CURRENT_SOURCE_DIR}/AsanConfig/lit.site.cfg.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
${CMAKE_CURRENT_BINARY_DIR}/AsanConfig/lit.site.cfg)
set(UBSAN_TEST_DEPS
Modified: compiler-rt/trunk/test/ubsan/lit.common.cfg
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/lit.common.cfg?rev=201553&r1=201552&r2=201553&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/lit.common.cfg (original)
+++ compiler-rt/trunk/test/ubsan/lit.common.cfg Tue Feb 18 02:56:49 2014
@@ -12,8 +12,27 @@ def get_required_attr(config, attr_name)
return attr_value
# Setup source root.
-ubsan_lit_tests_dir = get_required_attr(config, 'ubsan_lit_tests_dir')
-config.test_source_root = os.path.join(ubsan_lit_tests_dir, 'TestCases')
+config.test_source_root = os.path.dirname(__file__)
+
+# Choose between standalone and UBSan+ASan modes.
+ubsan_lit_test_mode = get_required_attr(config, 'ubsan_lit_test_mode')
+if ubsan_lit_test_mode == "Standalone":
+ config.name = 'UndefinedBehaviorSanitizer-Standalone'
+ clang_ubsan_cflags = []
+elif ubsan_lit_test_mode == "AddressSanitizer":
+ config.name = 'UndefinedBehaviorSanitizer-AddressSanitizer'
+ clang_ubsan_cflags = ["-fsanitize=address"]
+else:
+ lit_config.fatal("Unknown UBSan test mode: %r" % ubsan_lit_test_mode)
+
+def build_invocation(compile_flags):
+ return " " + " ".join([config.clang] + compile_flags) + " "
+
+clang_ubsan_cxxflags = ["--driver-mode=g++"] + clang_ubsan_cflags
+
+# Define %clang and %clangxx substitutions to use in test RUN lines.
+config.substitutions.append( ("%clang ", build_invocation(clang_ubsan_cflags)) )
+config.substitutions.append( ("%clangxx ", build_invocation(clang_ubsan_cxxflags)) )
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
Copied: compiler-rt/trunk/test/ubsan/lit.site.cfg.in (from r201544, compiler-rt/trunk/test/ubsan/AsanConfig/lit.site.cfg.in)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/ubsan/lit.site.cfg.in?p2=compiler-rt/trunk/test/ubsan/lit.site.cfg.in&p1=compiler-rt/trunk/test/ubsan/AsanConfig/lit.site.cfg.in&r1=201544&r2=201553&rev=201553&view=diff
==============================================================================
--- compiler-rt/trunk/test/ubsan/AsanConfig/lit.site.cfg.in (original)
+++ compiler-rt/trunk/test/ubsan/lit.site.cfg.in Tue Feb 18 02:56:49 2014
@@ -2,7 +2,7 @@
lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
# Tool-specific config options.
-config.ubsan_lit_tests_dir = "@UBSAN_LIT_TESTS_DIR@"
+config.ubsan_lit_test_mode = "@UBSAN_LIT_TEST_MODE@"
# Load tool-specific config that would do the real work.
-lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/AsanConfig/lit.cfg")
+lit_config.load_config(config, "@UBSAN_LIT_TESTS_DIR@/lit.common.cfg")
More information about the llvm-commits
mailing list