summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-02-14 12:26:05 +0000
committerAlexey Samsonov <samsonov@google.com>2014-02-14 12:26:05 +0000
commitf4b1a71ace678a375340ad3514779e935214d4d1 (patch)
treed3122058736c4169eec747c5e35f14391c02ffd2 /lib
parentf425ebe34e9d9ab27512685b9b059ac210ca9ec9 (diff)
Move LSan test suite under test/
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201408 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/lsan/CMakeLists.txt10
-rw-r--r--lib/lsan/lit_tests/AsanConfig/lit.cfg34
-rw-r--r--lib/lsan/lit_tests/AsanConfig/lit.site.cfg.in8
-rw-r--r--lib/lsan/lit_tests/CMakeLists.txt28
-rw-r--r--lib/lsan/lit_tests/LsanConfig/lit.cfg30
-rw-r--r--lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in8
-rw-r--r--lib/lsan/lit_tests/TestCases/cleanup_in_tsd_destructor.cc45
-rw-r--r--lib/lsan/lit_tests/TestCases/disabler.cc23
-rw-r--r--lib/lsan/lit_tests/TestCases/disabler_in_tsd_destructor.cc38
-rw-r--r--lib/lsan/lit_tests/TestCases/do_leak_check_override.cc36
-rw-r--r--lib/lsan/lit_tests/TestCases/fork.cc24
-rw-r--r--lib/lsan/lit_tests/TestCases/fork_threaded.cc43
-rw-r--r--lib/lsan/lit_tests/TestCases/high_allocator_contention.cc48
-rw-r--r--lib/lsan/lit_tests/TestCases/ignore_object.cc24
-rw-r--r--lib/lsan/lit_tests/TestCases/ignore_object_errors.cc22
-rw-r--r--lib/lsan/lit_tests/TestCases/large_allocation_leak.cc18
-rw-r--r--lib/lsan/lit_tests/TestCases/leak_check_at_exit.cc21
-rw-r--r--lib/lsan/lit_tests/TestCases/link_turned_off.cc24
-rw-r--r--lib/lsan/lit_tests/TestCases/new_array_with_dtor_0.cc19
-rw-r--r--lib/lsan/lit_tests/TestCases/pointer_to_self.cc18
-rw-r--r--lib/lsan/lit_tests/TestCases/print_suppressions.cc33
-rw-r--r--lib/lsan/lit_tests/TestCases/register_root_region.cc32
-rw-r--r--lib/lsan/lit_tests/TestCases/sanity_check_pure_c.c10
-rw-r--r--lib/lsan/lit_tests/TestCases/stale_stack_leak.cc42
-rw-r--r--lib/lsan/lit_tests/TestCases/suppressions_default.cc28
-rw-r--r--lib/lsan/lit_tests/TestCases/suppressions_file.cc26
-rw-r--r--lib/lsan/lit_tests/TestCases/swapcontext.cc42
-rw-r--r--lib/lsan/lit_tests/TestCases/use_after_return.cc23
-rw-r--r--lib/lsan/lit_tests/TestCases/use_globals_initialized.cc21
-rw-r--r--lib/lsan/lit_tests/TestCases/use_globals_uninitialized.cc21
-rw-r--r--lib/lsan/lit_tests/TestCases/use_poisoned_asan.cc25
-rw-r--r--lib/lsan/lit_tests/TestCases/use_registers.cc51
-rw-r--r--lib/lsan/lit_tests/TestCases/use_stacks.cc20
-rw-r--r--lib/lsan/lit_tests/TestCases/use_stacks_threaded.cc36
-rw-r--r--lib/lsan/lit_tests/TestCases/use_tls_dynamic.cc50
-rw-r--r--lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_dynamic.cc37
-rw-r--r--lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_static.cc31
-rw-r--r--lib/lsan/lit_tests/TestCases/use_tls_static.cc21
-rw-r--r--lib/lsan/lit_tests/TestCases/use_unaligned.cc23
-rw-r--r--lib/lsan/lit_tests/lit.common.cfg43
40 files changed, 2 insertions, 1134 deletions
diff --git a/lib/lsan/CMakeLists.txt b/lib/lsan/CMakeLists.txt
index c9c0e22f3..5d46fd045 100644
--- a/lib/lsan/CMakeLists.txt
+++ b/lib/lsan/CMakeLists.txt
@@ -22,11 +22,7 @@ set(LSAN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
filter_available_targets(LSAN_COMMON_SUPPORTED_ARCH
x86_64 i386 powerpc64 arm)
-# Architectures supported by the standalone LSan.
-filter_available_targets(LSAN_SUPPORTED_ARCH
- x86_64)
-
-set(LSAN_RUNTIME_LIBRARIES)
+add_custom_target(lsan)
if(APPLE)
foreach(os ${SANITIZER_COMMON_SUPPORTED_DARWIN_OS})
@@ -50,8 +46,6 @@ elseif(NOT ANDROID)
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
$<TARGET_OBJECTS:RTLSanCommon.${arch}>
CFLAGS ${LSAN_CFLAGS})
- list(APPEND LSAN_RUNTIME_LIBRARIES clang_rt.lsan-${arch})
+ add_dependencies(lsan clang_rt.lsan-${arch})
endforeach()
endif()
-
-add_subdirectory(lit_tests)
diff --git a/lib/lsan/lit_tests/AsanConfig/lit.cfg b/lib/lsan/lit_tests/AsanConfig/lit.cfg
deleted file mode 100644
index edb5adfd3..000000000
--- a/lib/lsan/lit_tests/AsanConfig/lit.cfg
+++ /dev/null
@@ -1,34 +0,0 @@
-# -*- Python -*-
-
-import os
-
-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
-
-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_config.fatal("Can't find common LSan lit config at: %r" % lsan_lit_cfg)
-lit_config.load_config(config, lsan_lit_cfg)
-
-config.available_features.add('asan')
-
-config.name = 'LeakSanitizer-AddressSanitizer'
-
-clang_lsan_cxxflags = config.clang_cxxflags + " -fsanitize=address "
-
-config.substitutions.append( ("%clangxx_lsan ", (" " + config.clang + " " +
- clang_lsan_cxxflags + " ")) )
-
-clang_lsan_cflags = config.clang_cflags + " -fsanitize=address "
-
-config.substitutions.append( ("%clang_lsan ", (" " + config.clang + " " +
- clang_lsan_cflags + " ")) )
-
-config.environment['ASAN_OPTIONS'] = 'detect_leaks=1'
diff --git a/lib/lsan/lit_tests/AsanConfig/lit.site.cfg.in b/lib/lsan/lit_tests/AsanConfig/lit.site.cfg.in
deleted file mode 100644
index 95f006954..000000000
--- a/lib/lsan/lit_tests/AsanConfig/lit.site.cfg.in
+++ /dev/null
@@ -1,8 +0,0 @@
-# Load common config for all compiler-rt lit tests.
-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@"
-
-# Load tool-specific config that would do the real work.
-lit_config.load_config(config, "@LSAN_LIT_SOURCE_DIR@/AsanConfig/lit.cfg")
diff --git a/lib/lsan/lit_tests/CMakeLists.txt b/lib/lsan/lit_tests/CMakeLists.txt
deleted file mode 100644
index 9b26357fb..000000000
--- a/lib/lsan/lit_tests/CMakeLists.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-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}/AsanConfig/lit.site.cfg.in
- ${CMAKE_CURRENT_BINARY_DIR}/AsanConfig/lit.site.cfg
- )
-
-if(COMPILER_RT_CAN_EXECUTE_TESTS AND NOT APPLE AND NOT ANDROID)
- set(LSAN_TEST_DEPS
- ${SANITIZER_COMMON_LIT_TEST_DEPS}
- ${LSAN_RUNTIME_LIBRARIES})
- foreach(arch ${LSAN_SUPPORTED_ARCH})
- list(APPEND LSAN_TEST_DEPS clang_rt.asan-${arch})
- endforeach()
- add_lit_testsuite(check-lsan "Running the LeakSanitizer tests"
- ${CMAKE_CURRENT_BINARY_DIR}/LsanConfig
- ${CMAKE_CURRENT_BINARY_DIR}/AsanConfig
- DEPENDS ${LSAN_TEST_DEPS})
- set_target_properties(check-lsan PROPERTIES FOLDER "LSan tests")
-endif()
diff --git a/lib/lsan/lit_tests/LsanConfig/lit.cfg b/lib/lsan/lit_tests/LsanConfig/lit.cfg
deleted file mode 100644
index 84faf9167..000000000
--- a/lib/lsan/lit_tests/LsanConfig/lit.cfg
+++ /dev/null
@@ -1,30 +0,0 @@
-# -*- Python -*-
-
-import os
-
-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
-
-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_config.fatal("Can't find common LSan lit config at: %r" % lsan_lit_cfg)
-lit_config.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 + " ")) )
-
-clang_lsan_cflags = config.clang_cflags + " -fsanitize=leak "
-
-config.substitutions.append( ("%clang_lsan ", (" " + config.clang + " " +
- clang_lsan_cflags + " ")) )
diff --git a/lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in b/lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in
deleted file mode 100644
index 8e9076e94..000000000
--- a/lib/lsan/lit_tests/LsanConfig/lit.site.cfg.in
+++ /dev/null
@@ -1,8 +0,0 @@
-# Load common config for all compiler-rt lit tests.
-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@"
-
-# Load tool-specific config that would do the real work.
-lit_config.load_config(config, "@LSAN_LIT_SOURCE_DIR@/LsanConfig/lit.cfg")
diff --git a/lib/lsan/lit_tests/TestCases/cleanup_in_tsd_destructor.cc b/lib/lsan/lit_tests/TestCases/cleanup_in_tsd_destructor.cc
deleted file mode 100644
index 1cae226d4..000000000
--- a/lib/lsan/lit_tests/TestCases/cleanup_in_tsd_destructor.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// Regression test for thread lifetime tracking. Thread data should be
-// considered live during the thread's termination, at least until the
-// user-installed TSD destructors have finished running (since they may contain
-// additional cleanup tasks). LSan doesn't actually meet that goal 100%, but it
-// makes its best effort.
-// RUN: LSAN_BASE="report_objects=1:use_registers=0:use_stacks=0:use_globals=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:use_tls=1 %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:use_tls=0 not %t 2>&1 | FileCheck %s
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "sanitizer/lsan_interface.h"
-
-pthread_key_t key;
-__thread void *p;
-
-void key_destructor(void *arg) {
- // Generally this may happen on a different thread.
- __lsan_do_leak_check();
-}
-
-void *thread_func(void *arg) {
- p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
- int res = pthread_setspecific(key, (void*)1);
- assert(res == 0);
- return 0;
-}
-
-int main() {
- int res = pthread_key_create(&key, &key_destructor);
- assert(res == 0);
- pthread_t thread_id;
- res = pthread_create(&thread_id, 0, thread_func, 0);
- assert(res == 0);
- res = pthread_join(thread_id, 0);
- assert(res == 0);
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: [[ADDR]] (1337 bytes)
diff --git a/lib/lsan/lit_tests/TestCases/disabler.cc b/lib/lsan/lit_tests/TestCases/disabler.cc
deleted file mode 100644
index db0cd8fab..000000000
--- a/lib/lsan/lit_tests/TestCases/disabler.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Test for ScopedDisabler.
-// RUN: LSAN_BASE="report_objects=1:use_registers=0:use_stacks=0:use_globals=0:use_tls=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE not %t 2>&1 | FileCheck %s
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "sanitizer/lsan_interface.h"
-
-int main() {
- void **p;
- {
- __lsan::ScopedDisabler d;
- p = new void *;
- }
- *reinterpret_cast<void **>(p) = malloc(666);
- void *q = malloc(1337);
- // Break optimization.
- fprintf(stderr, "Test alloc: %p.\n", q);
- return 0;
-}
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
diff --git a/lib/lsan/lit_tests/TestCases/disabler_in_tsd_destructor.cc b/lib/lsan/lit_tests/TestCases/disabler_in_tsd_destructor.cc
deleted file mode 100644
index 94e4fc390..000000000
--- a/lib/lsan/lit_tests/TestCases/disabler_in_tsd_destructor.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// Regression test. Disabler should not depend on TSD validity.
-// RUN: LSAN_BASE="report_objects=1:use_registers=0:use_stacks=0:use_globals=0:use_tls=1"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE %t
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "sanitizer/lsan_interface.h"
-
-pthread_key_t key;
-
-void key_destructor(void *arg) {
- __lsan::ScopedDisabler d;
- void *p = malloc(1337);
- // Break optimization.
- fprintf(stderr, "Test alloc: %p.\n", p);
- pthread_setspecific(key, 0);
-}
-
-void *thread_func(void *arg) {
- int res = pthread_setspecific(key, (void*)1);
- assert(res == 0);
- return 0;
-}
-
-int main() {
- int res = pthread_key_create(&key, &key_destructor);
- assert(res == 0);
- pthread_t thread_id;
- res = pthread_create(&thread_id, 0, thread_func, 0);
- assert(res == 0);
- res = pthread_join(thread_id, 0);
- assert(res == 0);
- return 0;
-}
diff --git a/lib/lsan/lit_tests/TestCases/do_leak_check_override.cc b/lib/lsan/lit_tests/TestCases/do_leak_check_override.cc
deleted file mode 100644
index be0ed0a6d..000000000
--- a/lib/lsan/lit_tests/TestCases/do_leak_check_override.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Test for __lsan_do_leak_check(). We test it by making the leak check run
-// before global destructors, which also tests compatibility with HeapChecker's
-// "normal" mode (LSan runs in "strict" mode by default).
-// RUN: LSAN_BASE="use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE not %t 2>&1 | FileCheck --check-prefix=CHECK-strict %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE not %t foo 2>&1 | FileCheck --check-prefix=CHECK-normal %s
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sanitizer/lsan_interface.h>
-
-struct LeakyGlobal {
- LeakyGlobal() {
- p = malloc(1337);
- }
- ~LeakyGlobal() {
- p = 0;
- }
- void *p;
-};
-
-LeakyGlobal leaky_global;
-
-int main(int argc, char *argv[]) {
- // Register leak check to run before global destructors.
- if (argc > 1)
- atexit(&__lsan_do_leak_check);
- void *p = malloc(666);
- printf("Test alloc: %p\n", p);
- printf("Test alloc in leaky global: %p\n", leaky_global.p);
- return 0;
-}
-
-// CHECK-strict: SUMMARY: {{(Leak|Address)}}Sanitizer: 2003 byte(s) leaked in 2 allocation(s)
-// CHECK-normal: SUMMARY: {{(Leak|Address)}}Sanitizer: 666 byte(s) leaked in 1 allocation(s)
diff --git a/lib/lsan/lit_tests/TestCases/fork.cc b/lib/lsan/lit_tests/TestCases/fork.cc
deleted file mode 100644
index 69258d9a0..000000000
--- a/lib/lsan/lit_tests/TestCases/fork.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// Test that thread local data is handled correctly after forking without exec().
-// RUN: %clangxx_lsan %s -o %t
-// RUN: %t 2>&1
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-__thread void *thread_local_var;
-
-int main() {
- int status = 0;
- thread_local_var = malloc(1337);
- pid_t pid = fork();
- assert(pid >= 0);
- if (pid > 0) {
- waitpid(pid, &status, 0);
- assert(WIFEXITED(status));
- return WEXITSTATUS(status);
- }
- return 0;
-}
diff --git a/lib/lsan/lit_tests/TestCases/fork_threaded.cc b/lib/lsan/lit_tests/TestCases/fork_threaded.cc
deleted file mode 100644
index 24a586109..000000000
--- a/lib/lsan/lit_tests/TestCases/fork_threaded.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// Test that thread local data is handled correctly after forking without
-// exec(). In this test leak checking is initiated from a non-main thread.
-// RUN: %clangxx_lsan %s -o %t
-// RUN: %t 2>&1
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-__thread void *thread_local_var;
-
-void *exit_thread_func(void *arg) {
- exit(0);
-}
-
-void ExitFromThread() {
- pthread_t tid;
- int res;
- res = pthread_create(&tid, 0, exit_thread_func, 0);
- assert(res == 0);
- pthread_join(tid, 0);
-}
-
-int main() {
- int status = 0;
- thread_local_var = malloc(1337);
- pid_t pid = fork();
- assert(pid >= 0);
- if (pid > 0) {
- waitpid(pid, &status, 0);
- assert(WIFEXITED(status));
- return WEXITSTATUS(status);
- } else {
- // Spawn a thread and call exit() from there, to check that we track main
- // thread's pid correctly even if leak checking is initiated from another
- // thread.
- ExitFromThread();
- }
- return 0;
-}
diff --git a/lib/lsan/lit_tests/TestCases/high_allocator_contention.cc b/lib/lsan/lit_tests/TestCases/high_allocator_contention.cc
deleted file mode 100644
index 1cecb2a55..000000000
--- a/lib/lsan/lit_tests/TestCases/high_allocator_contention.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// A benchmark that executes malloc/free pairs in parallel.
-// Usage: ./a.out number_of_threads total_number_of_allocations
-// RUN: %clangxx_lsan %s -o %t
-// RUN: %t 5 1000000 2>&1
-#include <assert.h>
-#include <pthread.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-int num_threads;
-int total_num_alloc;
-const int kMaxNumThreads = 5000;
-pthread_t tid[kMaxNumThreads];
-
-pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
-pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-bool go = false;
-
-void *thread_fun(void *arg) {
- pthread_mutex_lock(&mutex);
- while (!go) pthread_cond_wait(&cond, &mutex);
- pthread_mutex_unlock(&mutex);
- for (int i = 0; i < total_num_alloc / num_threads; i++) {
- void *p = malloc(10);
- __asm__ __volatile__("" : : "r"(p) : "memory");
- free((void *)p);
- }
- return 0;
-}
-
-int main(int argc, char** argv) {
- assert(argc == 3);
- num_threads = atoi(argv[1]);
- assert(num_threads > 0);
- assert(num_threads <= kMaxNumThreads);
- total_num_alloc = atoi(argv[2]);
- assert(total_num_alloc > 0);
- printf("%d threads, %d allocations in each\n", num_threads,
- total_num_alloc / num_threads);
- for (int i = 0; i < num_threads; i++)
- pthread_create(&tid[i], 0, thread_fun, 0);
- pthread_mutex_lock(&mutex);
- go = true;
- pthread_cond_broadcast(&cond);
- pthread_mutex_unlock(&mutex);
- for (int i = 0; i < num_threads; i++) pthread_join(tid[i], 0);
- return 0;
-}
diff --git a/lib/lsan/lit_tests/TestCases/ignore_object.cc b/lib/lsan/lit_tests/TestCases/ignore_object.cc
deleted file mode 100644
index 4cf303b00..000000000
--- a/lib/lsan/lit_tests/TestCases/ignore_object.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// Test for __lsan_ignore_object().
-// RUN: LSAN_BASE="report_objects=1:use_registers=0:use_stacks=0:use_globals=0:use_tls=0:verbosity=2"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE ASAN_OPTIONS=$ASAN_OPTIONS:"verbosity=2" not %t 2>&1 | FileCheck %s
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "sanitizer/lsan_interface.h"
-
-int main() {
- // Explicitly ignored object.
- void **p = new void *;
- // Transitively ignored object.
- *p = malloc(666);
- // Non-ignored object.
- volatile void *q = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
- __lsan_ignore_object(p);
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: ignoring heap object at [[ADDR]]
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
diff --git a/lib/lsan/lit_tests/TestCases/ignore_object_errors.cc b/lib/lsan/lit_tests/TestCases/ignore_object_errors.cc
deleted file mode 100644
index c49d2c7ea..000000000
--- a/lib/lsan/lit_tests/TestCases/ignore_object_errors.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-// Test for incorrect use of __lsan_ignore_object().
-// RUN: LSAN_BASE="verbosity=2"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE ASAN_OPTIONS=$ASAN_OPTIONS:verbosity=2 %t 2>&1 | FileCheck %s
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "sanitizer/lsan_interface.h"
-
-int main() {
- void *p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
- __lsan_ignore_object(p);
- __lsan_ignore_object(p);
- free(p);
- __lsan_ignore_object(p);
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: heap object at [[ADDR]] is already being ignored
-// CHECK: no heap object found at [[ADDR]]
diff --git a/lib/lsan/lit_tests/TestCases/large_allocation_leak.cc b/lib/lsan/lit_tests/TestCases/large_allocation_leak.cc
deleted file mode 100644
index 38219341d..000000000
--- a/lib/lsan/lit_tests/TestCases/large_allocation_leak.cc
+++ /dev/null
@@ -1,18 +0,0 @@
-// Test that LargeMmapAllocator's chunks aren't reachable via some internal data structure.
-// RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE not %t 2>&1 | FileCheck %s
-
-#include <stdio.h>
-#include <stdlib.h>
-
-int main() {
- // maxsize in primary allocator is always less than this (1 << 25).
- void *large_alloc = malloc(33554432);
- fprintf(stderr, "Test alloc: %p.\n", large_alloc);
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (33554432 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/leak_check_at_exit.cc b/lib/lsan/lit_tests/TestCases/leak_check_at_exit.cc
deleted file mode 100644
index d921afc84..000000000
--- a/lib/lsan/lit_tests/TestCases/leak_check_at_exit.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-// Test for the leak_check_at_exit flag.
-// RUN: LSAN_BASE="use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE not %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
-// RUN: LSAN_OPTIONS=$LSAN_BASE not %t 2>&1 | FileCheck %s --check-prefix=CHECK-do
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"leak_check_at_exit=0" ASAN_OPTIONS="$ASAN_OPTIONS:leak_check_at_exit=0" not %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
-// RUN: LSAN_OPTIONS=%LSAN_BASE:"leak_check_at_exit=0" ASAN_OPTIONS="$ASAN_OPTIONS:leak_check_at_exit=0" %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sanitizer/lsan_interface.h>
-
-int main(int argc, char *argv[]) {
- fprintf(stderr, "Test alloc: %p.\n", malloc(1337));
- if (argc > 1)
- __lsan_do_leak_check();
- return 0;
-}
-
-// CHECK-do: SUMMARY: {{(Leak|Address)}}Sanitizer:
-// CHECK-dont-NOT: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/link_turned_off.cc b/lib/lsan/lit_tests/TestCases/link_turned_off.cc
deleted file mode 100644
index 93628a1d1..000000000
--- a/lib/lsan/lit_tests/TestCases/link_turned_off.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// Test for disabling LSan at link-time.
-// RUN: LSAN_BASE="use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE not %t foo 2>&1 | FileCheck %s
-
-#include <sanitizer/lsan_interface.h>
-
-int argc_copy;
-
-extern "C" {
-int __lsan_is_turned_off() {
- return (argc_copy == 1);
-}
-}
-
-int main(int argc, char *argv[]) {
- volatile int *x = new int;
- *x = 42;
- argc_copy = argc;
- return 0;
-}
-
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 4 byte(s) leaked in 1 allocation(s)
diff --git a/lib/lsan/lit_tests/TestCases/new_array_with_dtor_0.cc b/lib/lsan/lit_tests/TestCases/new_array_with_dtor_0.cc
deleted file mode 100644
index 3784d81a5..000000000
--- a/lib/lsan/lit_tests/TestCases/new_array_with_dtor_0.cc
+++ /dev/null
@@ -1,19 +0,0 @@
-// Regression test:
-// https://code.google.com/p/address-sanitizer/issues/detail?id=257
-// RUN: %clangxx_lsan %s -o %t && %t 2>&1 | FileCheck %s
-
-#include <stdio.h>
-
-struct T {
- ~T() { printf("~T\n"); }
-};
-
-T *t;
-
-int main(int argc, char **argv) {
- t = new T[argc - 1];
- printf("OK\n");
-}
-
-// CHECK: OK
-
diff --git a/lib/lsan/lit_tests/TestCases/pointer_to_self.cc b/lib/lsan/lit_tests/TestCases/pointer_to_self.cc
deleted file mode 100644
index c638c2b7e..000000000
--- a/lib/lsan/lit_tests/TestCases/pointer_to_self.cc
+++ /dev/null
@@ -1,18 +0,0 @@
-// Regression test: pointers to self should not confuse LSan into thinking the
-// object is indirectly leaked. Only external pointers count.
-// RUN: LSAN_BASE="report_objects=1:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_stacks=0" not %t 2>&1 | FileCheck %s
-
-#include <stdio.h>
-#include <stdlib.h>
-
-int main() {
- void *p = malloc(1337);
- *reinterpret_cast<void **>(p) = p;
- fprintf(stderr, "Test alloc: %p.\n", p);
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/print_suppressions.cc b/lib/lsan/lit_tests/TestCases/print_suppressions.cc
deleted file mode 100644
index 97e67a016..000000000
--- a/lib/lsan/lit_tests/TestCases/print_suppressions.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// Print matched suppressions only if print_suppressions=1 AND at least one is
-// matched. Default is print_suppressions=true.
-// RUN: LSAN_BASE="use_registers=0:use_stacks=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print
-// RUN: LSAN_OPTIONS=$LSAN_BASE %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print
-// RUN: LSAN_OPTIONS=$LSAN_BASE:print_suppressions=0 %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print
-// RUN: LSAN_OPTIONS=$LSAN_BASE %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-print
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "sanitizer/lsan_interface.h"
-
-extern "C"
-const char *__lsan_default_suppressions() {
- return "leak:*LSanTestLeakingFunc*";
-}
-
-void LSanTestLeakingFunc() {
- void *p = malloc(666);
- fprintf(stderr, "Test alloc: %p.\n", p);
-}
-
-int main(int argc, char **argv) {
- printf("print for nonempty output\n");
- if (argc > 1)
- LSanTestLeakingFunc();
- return 0;
-}
-// CHECK-print: Suppressions used:
-// CHECK-print: 1 666 *LSanTestLeakingFunc*
-// CHECK-dont-print-NOT: Suppressions used:
diff --git a/lib/lsan/lit_tests/TestCases/register_root_region.cc b/lib/lsan/lit_tests/TestCases/register_root_region.cc
deleted file mode 100644
index 27349aaef..000000000
--- a/lib/lsan/lit_tests/TestCases/register_root_region.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Test for __lsan_(un)register_root_region().
-// RUN: LSAN_BASE="use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE not %t foo 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:use_root_regions=0 not %t 2>&1 | FileCheck %s
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-#include <sanitizer/lsan_interface.h>
-
-int main(int argc, char *argv[]) {
- size_t size = getpagesize() * 2;
- void *p =
- mmap(0, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- assert(p);
- // Make half of the memory inaccessible. LSan must not crash trying to read it.
- assert(0 == mprotect((char *)p + size / 2, size / 2, PROT_NONE));
-
- __lsan_register_root_region(p, size);
- *((void **)p) = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
- if (argc > 1)
- __lsan_unregister_root_region(p, size);
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
diff --git a/lib/lsan/lit_tests/TestCases/sanity_check_pure_c.c b/lib/lsan/lit_tests/TestCases/sanity_check_pure_c.c
deleted file mode 100644
index 085412b47..000000000
--- a/lib/lsan/lit_tests/TestCases/sanity_check_pure_c.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Check that we can build C code.
-// RUN: %clang_lsan %s -o %t
-#ifdef __cplusplus
-#error "This test must be built in C mode"
-#endif
-
-int main() {
- // FIXME: ideally this should somehow check that we don't have libstdc++
- return 0;
-}
diff --git a/lib/lsan/lit_tests/TestCases/stale_stack_leak.cc b/lib/lsan/lit_tests/TestCases/stale_stack_leak.cc
deleted file mode 100644
index 4a53910ab..000000000
--- a/lib/lsan/lit_tests/TestCases/stale_stack_leak.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// Test that out-of-scope local variables are ignored by LSan.
-// RUN: LSAN_BASE="report_objects=1:use_registers=0:use_stacks=1"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE":exitcode=0" %t 2>&1 | FileCheck --check-prefix=CHECK-sanity %s
-
-#include <stdio.h>
-#include <stdlib.h>
-
-void **pp;
-
-// Put pointer far enough on the stack that LSan has space to run in without
-// overwriting it.
-// Hopefully the argument p will be passed on a register, saving us from false
-// negatives.
-__attribute__((noinline))
-void *PutPointerOnStaleStack(void *p) {
- void *locals[2048];
- locals[0] = p;
- pp = &locals[0];
- fprintf(stderr, "Test alloc: %p.\n", locals[0]);
- return 0;
-}
-
-int main() {
- PutPointerOnStaleStack(malloc(1337));
- return 0;
-}
-
-// This must run after LSan, to ensure LSan didn't overwrite the pointer before
-// it had a chance to see it. If LSan is invoked with atexit(), this works.
-// Otherwise, we need a different method.
-__attribute__((destructor))
-void ConfirmPointerHasSurvived() {
- fprintf(stderr, "Value after LSan: %p.\n", *pp);
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK-sanity: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
-// CHECK-sanity: Value after LSan: [[ADDR]].
diff --git a/lib/lsan/lit_tests/TestCases/suppressions_default.cc b/lib/lsan/lit_tests/TestCases/suppressions_default.cc
deleted file mode 100644
index 968074662..000000000
--- a/lib/lsan/lit_tests/TestCases/suppressions_default.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// RUN: LSAN_BASE="use_registers=0:use_stacks=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE not %t 2>&1 | FileCheck %s
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "sanitizer/lsan_interface.h"
-
-extern "C"
-const char *__lsan_default_suppressions() {
- return "leak:*LSanTestLeakingFunc*";
-}
-
-void LSanTestLeakingFunc() {
- void *p = malloc(666);
- fprintf(stderr, "Test alloc: %p.\n", p);
-}
-
-int main() {
- LSanTestLeakingFunc();
- void *q = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", q);
- return 0;
-}
-// CHECK: Suppressions used:
-// CHECK: 1 666 *LSanTestLeakingFunc*
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
diff --git a/lib/lsan/lit_tests/TestCases/suppressions_file.cc b/lib/lsan/lit_tests/TestCases/suppressions_file.cc
deleted file mode 100644
index bc8913a6c..000000000
--- a/lib/lsan/lit_tests/TestCases/suppressions_file.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// RUN: LSAN_BASE="use_registers=0:use_stacks=0"
-// RUN: %clangxx_lsan %s -o %t
-
-// RUN: echo "leak:*LSanTestLeakingFunc*" > %t.supp1
-// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions=%t.supp1 not %t 2>&1 | FileCheck %s
-
-// RUN: echo "leak:%t" > %t.supp2
-// RUN: LSAN_OPTIONS=$LSAN_BASE:suppressions="%t.supp2":symbolize=false %t
-
-#include <stdio.h>
-#include <stdlib.h>
-
-void LSanTestLeakingFunc() {
- void *p = malloc(666);
- fprintf(stderr, "Test alloc: %p.\n", p);
-}
-
-int main() {
- LSanTestLeakingFunc();
- void *q = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", q);
- return 0;
-}
-// CHECK: Suppressions used:
-// CHECK: 1 666 *LSanTestLeakingFunc*
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
diff --git a/lib/lsan/lit_tests/TestCases/swapcontext.cc b/lib/lsan/lit_tests/TestCases/swapcontext.cc
deleted file mode 100644
index a06685ca2..000000000
--- a/lib/lsan/lit_tests/TestCases/swapcontext.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// We can't unwind stack if we're running coroutines on heap-allocated
-// memory. Make sure we don't report these leaks.
-
-// RUN: %clangxx_lsan %s -o %t
-// RUN: %t 2>&1
-// RUN: not %t foo 2>&1 | FileCheck %s
-
-#include <stdio.h>
-#include <ucontext.h>
-#include <unistd.h>
-
-const int kStackSize = 1 << 20;
-
-void Child() {
- int child_stack;
- printf("Child: %p\n", &child_stack);
- int *leaked = new int[666];
-}
-
-int main(int argc, char *argv[]) {
- char stack_memory[kStackSize + 1];
- char *heap_memory = new char[kStackSize + 1];
- char *child_stack = (argc > 1) ? stack_memory : heap_memory;
-
- printf("Child stack: %p\n", child_stack);
- ucontext_t orig_context;
- ucontext_t child_context;
- getcontext(&child_context);
- child_context.uc_stack.ss_sp = child_stack;
- child_context.uc_stack.ss_size = kStackSize / 2;
- child_context.uc_link = &orig_context;
- makecontext(&child_context, Child, 0);
- if (swapcontext(&orig_context, &child_context) < 0) {
- perror("swapcontext");
- return 1;
- }
-
- delete[] heap_memory;
- return 0;
-}
-
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 2664 byte(s) leaked in 1 allocation(s)
diff --git a/lib/lsan/lit_tests/TestCases/use_after_return.cc b/lib/lsan/lit_tests/TestCases/use_after_return.cc
deleted file mode 100644
index ffa20f399..000000000
--- a/lib/lsan/lit_tests/TestCases/use_after_return.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Test that fake stack (introduced by ASan's use-after-return mode) is included
-// in the root set.
-// RUN: LSAN_BASE="report_objects=1:use_registers=0"
-// RUN: %clangxx_lsan %s -O2 -o %t
-// RUN: ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=1 LSAN_OPTIONS=$LSAN_BASE:"use_stacks=0" not %t 2>&1 | FileCheck %s
-// RUN: ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=1 LSAN_OPTIONS=$LSAN_BASE:"use_stacks=1" %t 2>&1
-// RUN: ASAN_OPTIONS=$ASAN_OPTIONS:detect_stack_use_after_return=1 LSAN_OPTIONS="" %t 2>&1
-
-#include <stdio.h>
-#include <stdlib.h>
-
-int main() {
- void *stack_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", stack_var);
- // Take pointer to variable, to ensure it's not optimized into a register.
- fprintf(stderr, "Stack var at: %p.\n", &stack_var);
- // Do not return from main to prevent the pointer from going out of scope.
- exit(0);
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/use_globals_initialized.cc b/lib/lsan/lit_tests/TestCases/use_globals_initialized.cc
deleted file mode 100644
index 2a5331cfd..000000000
--- a/lib/lsan/lit_tests/TestCases/use_globals_initialized.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-// Test that initialized globals are included in the root set.
-// RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_globals=0" not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_globals=1" %t 2>&1
-// RUN: LSAN_OPTIONS="" %t 2>&1
-
-#include <stdio.h>
-#include <stdlib.h>
-
-void *data_var = (void *)1;
-
-int main() {
- data_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", data_var);
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/use_globals_uninitialized.cc b/lib/lsan/lit_tests/TestCases/use_globals_uninitialized.cc
deleted file mode 100644
index 9fdb1fdd5..000000000
--- a/lib/lsan/lit_tests/TestCases/use_globals_uninitialized.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-// Test that uninitialized globals are included in the root set.
-// RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_globals=0" not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_globals=1" %t 2>&1
-// RUN: LSAN_OPTIONS="" %t 2>&1
-
-#include <stdio.h>
-#include <stdlib.h>
-
-void *bss_var;
-
-int main() {
- bss_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", bss_var);
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/use_poisoned_asan.cc b/lib/lsan/lit_tests/TestCases/use_poisoned_asan.cc
deleted file mode 100644
index 1a72ac223..000000000
--- a/lib/lsan/lit_tests/TestCases/use_poisoned_asan.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// ASan-poisoned memory should be ignored if use_poisoned is false.
-// REQUIRES: asan
-// RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_poisoned=0" not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_poisoned=1" %t 2>&1
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sanitizer/asan_interface.h>
-#include <assert.h>
-
-void **p;
-
-int main() {
- p = new void *;
- *p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", *p);
- __asan_poison_memory_region(p, sizeof(*p));
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: AddressSanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/use_registers.cc b/lib/lsan/lit_tests/TestCases/use_registers.cc
deleted file mode 100644
index 1a90994e3..000000000
--- a/lib/lsan/lit_tests/TestCases/use_registers.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Test that registers of running threads are included in the root set.
-// RUN: LSAN_BASE="report_objects=1:use_stacks=0"
-// RUN: %clangxx_lsan -pthread %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_registers=0" not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_registers=1" %t 2>&1
-// RUN: LSAN_OPTIONS="" %t 2>&1
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-extern "C"
-void *registers_thread_func(void *arg) {
- int *sync = reinterpret_cast<int *>(arg);
- void *p = malloc(1337);
- // To store the pointer, choose a register which is unlikely to be reused by
- // a function call.
-#if defined(__i386__)
- asm ( "mov %0, %%esi"
- :
- : "r" (p)
- );
-#elif defined(__x86_64__)
- asm ( "mov %0, %%r15"
- :
- : "r" (p)
- );
-#else
-#error "Test is not supported on this architecture."
-#endif
- fprintf(stderr, "Test alloc: %p.\n", p);
- fflush(stderr);
- __sync_fetch_and_xor(sync, 1);
- while (true)
- pthread_yield();
-}
-
-int main() {
- int sync = 0;
- pthread_t thread_id;
- int res = pthread_create(&thread_id, 0, registers_thread_func, &sync);
- assert(res == 0);
- while (!__sync_fetch_and_xor(&sync, 0))
- pthread_yield();
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/use_stacks.cc b/lib/lsan/lit_tests/TestCases/use_stacks.cc
deleted file mode 100644
index aea90bba1..000000000
--- a/lib/lsan/lit_tests/TestCases/use_stacks.cc
+++ /dev/null
@@ -1,20 +0,0 @@
-// Test that stack of main thread is included in the root set.
-// RUN: LSAN_BASE="report_objects=1:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_stacks=0" not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_stacks=1" %t 2>&1
-// RUN: LSAN_OPTIONS="" %t 2>&1
-
-#include <stdio.h>
-#include <stdlib.h>
-
-int main() {
- void *stack_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", stack_var);
- // Do not return from main to prevent the pointer from going out of scope.
- exit(0);
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/use_stacks_threaded.cc b/lib/lsan/lit_tests/TestCases/use_stacks_threaded.cc
deleted file mode 100644
index bcb4b1e2d..000000000
--- a/lib/lsan/lit_tests/TestCases/use_stacks_threaded.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// Test that stacks of non-main threads are included in the root set.
-// RUN: LSAN_BASE="report_objects=1:use_registers=0"
-// RUN: %clangxx_lsan -pthread %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_stacks=0" not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_stacks=1" %t 2>&1
-// RUN: LSAN_OPTIONS="" %t 2>&1
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-extern "C"
-void *stacks_thread_func(void *arg) {
- int *sync = reinterpret_cast<int *>(arg);
- void *p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
- fflush(stderr);
- __sync_fetch_and_xor(sync, 1);
- while (true)
- pthread_yield();
-}
-
-int main() {
- int sync = 0;
- pthread_t thread_id;
- int res = pthread_create(&thread_id, 0, stacks_thread_func, &sync);
- assert(res == 0);
- while (!__sync_fetch_and_xor(&sync, 0))
- pthread_yield();
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/use_tls_dynamic.cc b/lib/lsan/lit_tests/TestCases/use_tls_dynamic.cc
deleted file mode 100644
index 552206a14..000000000
--- a/lib/lsan/lit_tests/TestCases/use_tls_dynamic.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// Test that dynamically allocated TLS space is included in the root set.
-// RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
-// RUN: %clangxx %s -DBUILD_DSO -fPIC -shared -o %t-so.so
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_tls=0" not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_tls=1" %t 2>&1
-// RUN: LSAN_OPTIONS="" %t 2>&1
-
-#ifndef BUILD_DSO
-#include <assert.h>
-#include <dlfcn.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string>
-
-int main(int argc, char *argv[]) {
- std::string path = std::string(argv[0]) + "-so.so";
-
- void *handle = dlopen(path.c_str(), RTLD_LAZY);
- assert(handle != 0);
- typedef void **(* store_t)(void *p);
- store_t StoreToTLS = (store_t)dlsym(handle, "StoreToTLS");
- assert(dlerror() == 0);
-
- void *p = malloc(1337);
- // If we don't know about dynamic TLS, we will return a false leak above.
- void **p_in_tls = StoreToTLS(p);
- assert(*p_in_tls == p);
- fprintf(stderr, "Test alloc: %p.\n", p);
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
-
-#else // BUILD_DSO
-// A loadable module with a large thread local section, which would require
-// allocation of a new TLS storage chunk when loaded with dlopen(). We use it
-// to test the reachability of such chunks in LSan tests.
-
-// This must be large enough that it doesn't fit into preallocated static TLS
-// space (see STATIC_TLS_SURPLUS in glibc).
-__thread void *huge_thread_local_array[(1 << 20) / sizeof(void *)]; // NOLINT
-
-extern "C" void **StoreToTLS(void *p) {
- huge_thread_local_array[0] = p;
- return &huge_thread_local_array[0];
-}
-#endif // BUILD_DSO
diff --git a/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_dynamic.cc b/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_dynamic.cc
deleted file mode 100644
index cfb6b2dd9..000000000
--- a/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_dynamic.cc
+++ /dev/null
@@ -1,37 +0,0 @@
-// Test that dynamically allocated thread-specific storage is included in the root set.
-// RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_tls=0" not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_tls=1" %t 2>&1
-// RUN: LSAN_OPTIONS="" %t 2>&1
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-// From glibc: this many keys are stored in the thread descriptor directly.
-const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32;
-
-int main() {
- static const unsigned kDummyKeysCount = PTHREAD_KEY_2NDLEVEL_SIZE;
- int res;
- pthread_key_t dummy_keys[kDummyKeysCount];
- for (unsigned i = 0; i < kDummyKeysCount; i++) {
- res = pthread_key_create(&dummy_keys[i], NULL);
- assert(res == 0);
- }
- pthread_key_t key;
- res = pthread_key_create(&key, NULL);
- assert(key >= PTHREAD_KEY_2NDLEVEL_SIZE);
- assert(res == 0);
- void *p = malloc(1337);
- res = pthread_setspecific(key, p);
- assert(res == 0);
- fprintf(stderr, "Test alloc: %p.\n", p);
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_static.cc b/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_static.cc
deleted file mode 100644
index 4def4c021..000000000
--- a/lib/lsan/lit_tests/TestCases/use_tls_pthread_specific_static.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// Test that statically allocated thread-specific storage is included in the root set.
-// RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_tls=0" not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_tls=1" %t 2>&1
-// RUN: LSAN_OPTIONS="" %t 2>&1
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-// From glibc: this many keys are stored in the thread descriptor directly.
-const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32;
-
-int main() {
- pthread_key_t key;
- int res;
- res = pthread_key_create(&key, NULL);
- assert(res == 0);
- assert(key < PTHREAD_KEY_2NDLEVEL_SIZE);
- void *p = malloc(1337);
- res = pthread_setspecific(key, p);
- assert(res == 0);
- fprintf(stderr, "Test alloc: %p.\n", p);
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/use_tls_static.cc b/lib/lsan/lit_tests/TestCases/use_tls_static.cc
deleted file mode 100644
index 1c5512568..000000000
--- a/lib/lsan/lit_tests/TestCases/use_tls_static.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-// Test that statically allocated TLS space is included in the root set.
-// RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_tls=0" not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_tls=1" %t 2>&1
-// RUN: LSAN_OPTIONS="" %t 2>&1
-
-#include <stdio.h>
-#include <stdlib.h>
-
-__thread void *tls_var;
-
-int main() {
- tls_var = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", tls_var);
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/TestCases/use_unaligned.cc b/lib/lsan/lit_tests/TestCases/use_unaligned.cc
deleted file mode 100644
index 50eb74952..000000000
--- a/lib/lsan/lit_tests/TestCases/use_unaligned.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Test that unaligned pointers are detected correctly.
-// RUN: LSAN_BASE="report_objects=1:use_stacks=0:use_registers=0"
-// RUN: %clangxx_lsan %s -o %t
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_unaligned=0" not %t 2>&1 | FileCheck %s
-// RUN: LSAN_OPTIONS=$LSAN_BASE:"use_unaligned=1" %t 2>&1
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-void *arr[2];
-
-int main() {
- void *p = malloc(1337);
- fprintf(stderr, "Test alloc: %p.\n", p);
- char *char_arr = (char *)arr;
- memcpy(char_arr + 1, &p, sizeof(p));
- return 0;
-}
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK: LeakSanitizer: detected memory leaks
-// CHECK: [[ADDR]] (1337 bytes)
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/lib/lsan/lit_tests/lit.common.cfg b/lib/lsan/lit_tests/lit.common.cfg
deleted file mode 100644
index 96dc1b1f5..000000000
--- a/lib/lsan/lit_tests/lit.common.cfg
+++ /dev/null
@@ -1,43 +0,0 @@
-# -*- Python -*-
-
-# Common configuration for running leak detection tests under LSan/ASan.
-
-import os
-
-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 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')
-
-clang_cxxflags = ("--driver-mode=g++ "
- + "-g "
- + "-O0 "
- + "-m64 ")
-
-clang_cflags = ("-g "
- + "-O0 "
- + "-m64 ")
-
-config.clang_cxxflags = clang_cxxflags
-
-config.substitutions.append( ("%clangxx ", (" " + config.clang + " " +
- clang_cxxflags + " ")) )
-
-config.clang_cflags = clang_cflags
-
-config.substitutions.append( ("%clang ", (" " + config.clang + " " +
- clang_cflags + " ")) )
-
-# 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']