diff options
author | Sergey Matveev <earthdok@google.com> | 2013-05-31 13:13:55 +0000 |
---|---|---|
committer | Sergey Matveev <earthdok@google.com> | 2013-05-31 13:13:55 +0000 |
commit | 5494e0bec303af3557f96fa3e6dff88428b885a8 (patch) | |
tree | b94c17606c512e7b986e6a461bb657b442424c4e | |
parent | 4717d2d4945ced853b80600e3b0c3490e966da34 (diff) | |
download | bcm5719-llvm-5494e0bec303af3557f96fa3e6dff88428b885a8.tar.gz bcm5719-llvm-5494e0bec303af3557f96fa3e6dff88428b885a8.zip |
[lsan] Run the leak detection tests under both ASan and LSan.
Change the LSan lit test logic. Now "check-lsan" tests the leak
checking functionality in both standalone LSan and ASan.
llvm-svn: 183000
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/AsanConfig/lit.cfg | 26 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/AsanConfig/lit.site.cfg.in (renamed from compiler-rt/lib/lsan/lit_tests/lit.site.cfg.in) | 3 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/CMakeLists.txt | 23 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/LsanConfig/lit.cfg | 24 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in | 21 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/SharedLibs/huge_tls_lib_so.cc (renamed from compiler-rt/lib/lsan/lit_tests/SharedLibs/huge_tls_lib_so.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/SharedLibs/lit.local.cfg (renamed from compiler-rt/lib/lsan/lit_tests/SharedLibs/lit.local.cfg) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/large_allocation_leak.cc (renamed from compiler-rt/lib/lsan/lit_tests/large_allocation_leak.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/stale_stack_leak.cc (renamed from compiler-rt/lib/lsan/lit_tests/stale_stack_leak.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/use_globals_initialized.cc (renamed from compiler-rt/lib/lsan/lit_tests/use_globals_initialized.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/use_globals_uninitialized.cc (renamed from compiler-rt/lib/lsan/lit_tests/use_globals_uninitialized.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/use_registers.cc (renamed from compiler-rt/lib/lsan/lit_tests/use_registers.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/use_stacks.cc (renamed from compiler-rt/lib/lsan/lit_tests/use_stacks.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/use_stacks_threaded.cc (renamed from compiler-rt/lib/lsan/lit_tests/use_stacks_threaded.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_dynamic.cc (renamed from compiler-rt/lib/lsan/lit_tests/use_tls_dynamic.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_dynamic.cc (renamed from compiler-rt/lib/lsan/lit_tests/use_tls_pthread_specific_dynamic.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_static.cc (renamed from compiler-rt/lib/lsan/lit_tests/use_tls_pthread_specific_static.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_static.cc (renamed from compiler-rt/lib/lsan/lit_tests/use_tls_static.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/TestCases/use_unaligned.cc (renamed from compiler-rt/lib/lsan/lit_tests/use_unaligned.cc) | 0 | ||||
-rw-r--r-- | compiler-rt/lib/lsan/lit_tests/lit.common.cfg (renamed from compiler-rt/lib/lsan/lit_tests/lit.cfg) | 27 |
20 files changed, 98 insertions, 26 deletions
diff --git a/compiler-rt/lib/lsan/lit_tests/AsanConfig/lit.cfg b/compiler-rt/lib/lsan/lit_tests/AsanConfig/lit.cfg new file mode 100644 index 00000000000..9bf3e9cc708 --- /dev/null +++ b/compiler-rt/lib/lsan/lit_tests/AsanConfig/lit.cfg @@ -0,0 +1,26 @@ +# -*- 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 + +lsan_lit_src_root = get_required_attr(config, "lsan_lit_src_root") +lsan_lit_cfg = os.path.join(lsan_lit_src_root, "lit.common.cfg") +if not os.path.exists(lsan_lit_cfg): + lit.fatal("Can't find common LSan lit config at: %r" % lsan_lit_cfg) +lit.load_config(config, lsan_lit_cfg) + +config.name = 'LeakSanitizer-AddressSanitizer' + +clang_lsan_cxxflags = config.clang_cxxflags + " -fsanitize=address " + +config.substitutions.append( ("%clangxx_lsan ", (" " + config.clang + " " + + clang_lsan_cxxflags + " ")) ) + +config.environment['ASAN_OPTIONS'] = 'detect_leaks=1' diff --git a/compiler-rt/lib/lsan/lit_tests/lit.site.cfg.in b/compiler-rt/lib/lsan/lit_tests/AsanConfig/lit.site.cfg.in index 3de98a9811f..d57c67d691e 100644 --- a/compiler-rt/lib/lsan/lit_tests/lit.site.cfg.in +++ b/compiler-rt/lib/lsan/lit_tests/AsanConfig/lit.site.cfg.in @@ -7,6 +7,7 @@ config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.clang = "@LLVM_BINARY_DIR@/bin/clang" config.compiler_rt_arch = "@COMPILER_RT_SUPPORTED_ARCH@" +config.lsan_lit_src_root = "@LSAN_LIT_SOURCE_DIR@" # LLVM tools dir can be passed in lit parameters, so try to # apply substitution. @@ -17,4 +18,4 @@ except KeyError,e: 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_LIT_SOURCE_DIR@/AsanConfig/lit.cfg") diff --git a/compiler-rt/lib/lsan/lit_tests/CMakeLists.txt b/compiler-rt/lib/lsan/lit_tests/CMakeLists.txt index e1be508202b..66ea5fcb40a 100644 --- a/compiler-rt/lib/lsan/lit_tests/CMakeLists.txt +++ b/compiler-rt/lib/lsan/lit_tests/CMakeLists.txt @@ -1,9 +1,16 @@ set(LSAN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..) set(LSAN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/..) +set(LSAN_LIT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +configure_lit_site_cfg( + ${CMAKE_CURRENT_SOURCE_DIR}/LsanConfig/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/LsanConfig/lit.site.cfg + ) + configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/AsanConfig/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/AsanConfig/lit.site.cfg ) configure_lit_site_cfg( @@ -11,18 +18,20 @@ configure_lit_site_cfg( ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg ) -if(COMPILER_RT_CAN_EXECUTE_TESTS) +if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT APPLE AND NOT ANDROID) 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) + foreach(arch ${LSAN_SUPPORTED_ARCH}) + list(APPEND LSAN_TEST_DEPS clang_rt.asan-${arch}) + endforeach() 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} + ${CMAKE_CURRENT_BINARY_DIR}/LsanConfig + ${CMAKE_CURRENT_BINARY_DIR}/AsanConfig + ${CMAKE_CURRENT_BINARY_DIR}/Unit DEPENDS ${LSAN_TEST_DEPS}) set_target_properties(check-lsan PROPERTIES FOLDER "LSan tests") endif() diff --git a/compiler-rt/lib/lsan/lit_tests/LsanConfig/lit.cfg b/compiler-rt/lib/lsan/lit_tests/LsanConfig/lit.cfg new file mode 100644 index 00000000000..2273ca26fa7 --- /dev/null +++ b/compiler-rt/lib/lsan/lit_tests/LsanConfig/lit.cfg @@ -0,0 +1,24 @@ +# -*- 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 + +lsan_lit_src_root = get_required_attr(config, "lsan_lit_src_root") +lsan_lit_cfg = os.path.join(lsan_lit_src_root, "lit.common.cfg") +if not os.path.exists(lsan_lit_cfg): + lit.fatal("Can't find common LSan lit config at: %r" % lsan_lit_cfg) +lit.load_config(config, lsan_lit_cfg) + +config.name = 'LeakSanitizer-Standalone' + +clang_lsan_cxxflags = config.clang_cxxflags + " -fsanitize=leak " + +config.substitutions.append( ("%clangxx_lsan ", (" " + config.clang + " " + + clang_lsan_cxxflags + " ")) ) diff --git a/compiler-rt/lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in b/compiler-rt/lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in new file mode 100644 index 00000000000..2aa933197e4 --- /dev/null +++ b/compiler-rt/lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in @@ -0,0 +1,21 @@ +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.compiler_rt_src_root = "@COMPILER_RT_SOURCE_DIR@" +config.llvm_obj_root = "@LLVM_BINARY_DIR@" +config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" +config.clang = "@LLVM_BINARY_DIR@/bin/clang" +config.compiler_rt_arch = "@COMPILER_RT_SUPPORTED_ARCH@" +config.lsan_lit_src_root = "@LSAN_LIT_SOURCE_DIR@" + +# LLVM tools dir can be passed in lit parameters, so try to +# apply substitution. +try: + 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)) + +# Let the main config do the real work. +lit.load_config(config, "@LSAN_LIT_SOURCE_DIR@/LsanConfig/lit.cfg") diff --git a/compiler-rt/lib/lsan/lit_tests/SharedLibs/huge_tls_lib_so.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/SharedLibs/huge_tls_lib_so.cc index 475a66ec12a..475a66ec12a 100644 --- a/compiler-rt/lib/lsan/lit_tests/SharedLibs/huge_tls_lib_so.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/SharedLibs/huge_tls_lib_so.cc diff --git a/compiler-rt/lib/lsan/lit_tests/SharedLibs/lit.local.cfg b/compiler-rt/lib/lsan/lit_tests/TestCases/SharedLibs/lit.local.cfg index b3677c17a0f..b3677c17a0f 100644 --- a/compiler-rt/lib/lsan/lit_tests/SharedLibs/lit.local.cfg +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/SharedLibs/lit.local.cfg diff --git a/compiler-rt/lib/lsan/lit_tests/large_allocation_leak.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/large_allocation_leak.cc index 6db841ee5b0..6db841ee5b0 100644 --- a/compiler-rt/lib/lsan/lit_tests/large_allocation_leak.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/large_allocation_leak.cc diff --git a/compiler-rt/lib/lsan/lit_tests/stale_stack_leak.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/stale_stack_leak.cc index 5d57082c42c..5d57082c42c 100644 --- a/compiler-rt/lib/lsan/lit_tests/stale_stack_leak.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/stale_stack_leak.cc diff --git a/compiler-rt/lib/lsan/lit_tests/use_globals_initialized.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/use_globals_initialized.cc index 48e50b5d562..48e50b5d562 100644 --- a/compiler-rt/lib/lsan/lit_tests/use_globals_initialized.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/use_globals_initialized.cc diff --git a/compiler-rt/lib/lsan/lit_tests/use_globals_uninitialized.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/use_globals_uninitialized.cc index d383128659d..d383128659d 100644 --- a/compiler-rt/lib/lsan/lit_tests/use_globals_uninitialized.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/use_globals_uninitialized.cc diff --git a/compiler-rt/lib/lsan/lit_tests/use_registers.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/use_registers.cc index 4b29a847acb..4b29a847acb 100644 --- a/compiler-rt/lib/lsan/lit_tests/use_registers.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/use_registers.cc diff --git a/compiler-rt/lib/lsan/lit_tests/use_stacks.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/use_stacks.cc index e06a7a4788c..e06a7a4788c 100644 --- a/compiler-rt/lib/lsan/lit_tests/use_stacks.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/use_stacks.cc diff --git a/compiler-rt/lib/lsan/lit_tests/use_stacks_threaded.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/use_stacks_threaded.cc index efce855bdea..efce855bdea 100644 --- a/compiler-rt/lib/lsan/lit_tests/use_stacks_threaded.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/use_stacks_threaded.cc diff --git a/compiler-rt/lib/lsan/lit_tests/use_tls_dynamic.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_dynamic.cc index c97a1ea95b3..c97a1ea95b3 100644 --- a/compiler-rt/lib/lsan/lit_tests/use_tls_dynamic.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_dynamic.cc diff --git a/compiler-rt/lib/lsan/lit_tests/use_tls_pthread_specific_dynamic.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_dynamic.cc index a8fd061dc11..a8fd061dc11 100644 --- a/compiler-rt/lib/lsan/lit_tests/use_tls_pthread_specific_dynamic.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_dynamic.cc diff --git a/compiler-rt/lib/lsan/lit_tests/use_tls_pthread_specific_static.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_static.cc index b28406c5323..b28406c5323 100644 --- a/compiler-rt/lib/lsan/lit_tests/use_tls_pthread_specific_static.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_static.cc diff --git a/compiler-rt/lib/lsan/lit_tests/use_tls_static.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_static.cc index a4d12f8a978..a4d12f8a978 100644 --- a/compiler-rt/lib/lsan/lit_tests/use_tls_static.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/use_tls_static.cc diff --git a/compiler-rt/lib/lsan/lit_tests/use_unaligned.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/use_unaligned.cc index 75b90d60bd7..75b90d60bd7 100644 --- a/compiler-rt/lib/lsan/lit_tests/use_unaligned.cc +++ b/compiler-rt/lib/lsan/lit_tests/TestCases/use_unaligned.cc diff --git a/compiler-rt/lib/lsan/lit_tests/lit.cfg b/compiler-rt/lib/lsan/lit_tests/lit.common.cfg index 48e1453334d..b3edc9bb219 100644 --- a/compiler-rt/lib/lsan/lit_tests/lit.cfg +++ b/compiler-rt/lib/lsan/lit_tests/lit.common.cfg @@ -1,5 +1,7 @@ # -*- Python -*- +# Common configuration for running leak detection tests under LSan/ASan. + import os def get_required_attr(config, attr_name): @@ -10,21 +12,13 @@ def get_required_attr(config, attr_name): "to lit.site.cfg " % attr_name) return attr_value -# Setup attributes common for all compiler-rt projects. -compiler_rt_src_root = get_required_attr(config, 'compiler_rt_src_root') -compiler_rt_lit_unit_cfg = os.path.join(compiler_rt_src_root, "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__) +lsan_lit_src_root = get_required_attr(config, 'lsan_lit_src_root') +config.test_source_root = os.path.join(lsan_lit_src_root, 'TestCases') # Setup attributes common for all compiler-rt projects. -compiler_rt_lit_cfg = os.path.join(compiler_rt_src_root, "lib", - "lit.common.cfg") +compiler_rt_src_root = get_required_attr(config, 'compiler_rt_src_root') +compiler_rt_lit_cfg = os.path.join(compiler_rt_src_root, "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) @@ -35,16 +29,13 @@ clang_cxxflags = ("-ccc-cxx " + "-O0 " + "-m64 ") -clang_lsan_cxxflags = clang_cxxflags + "-fsanitize=leak " +config.clang_cxxflags = clang_cxxflags config.substitutions.append( ("%clangxx ", (" " + config.clang + " " + clang_cxxflags + " ")) ) -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 + +config.suffixes = ['.c', '.cc', '.cpp'] |