summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2013-09-08 13:23:29 +0000
committerAlexey Samsonov <samsonov@google.com>2013-09-08 13:23:29 +0000
commit071cc9e89d6a129a28a6ef206e06f4c3e48ef187 (patch)
tree8758db6f067e1879f749986a2797f7dc47f30df7 /compiler-rt
parent65ebb58524d91ab48b18c7720de93cdc6dc974ed (diff)
downloadbcm5719-llvm-071cc9e89d6a129a28a6ef206e06f4c3e48ef187.tar.gz
bcm5719-llvm-071cc9e89d6a129a28a6ef206e06f4c3e48ef187.zip
[ASan] turn on leak checking for ASan tests and fix a few discovered leaks
llvm-svn: 190274
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/lib/asan/lit_tests/TestCases/Linux/glob.cc1
-rw-r--r--compiler-rt/lib/asan/lit_tests/TestCases/Linux/interception_readdir_r_test.cc2
-rw-r--r--compiler-rt/lib/asan/lit_tests/Unit/lit.site.cfg.in3
-rw-r--r--compiler-rt/lib/asan/lit_tests/lit.cfg4
-rw-r--r--compiler-rt/lib/asan/tests/asan_noinst_test.cc1
-rw-r--r--compiler-rt/lib/asan/tests/asan_str_test.cc1
-rw-r--r--compiler-rt/lib/lit.common.unit.cfg7
-rw-r--r--compiler-rt/lib/lit.common.unit.configured.in1
8 files changed, 20 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/lit_tests/TestCases/Linux/glob.cc b/compiler-rt/lib/asan/lit_tests/TestCases/Linux/glob.cc
index a375f1b67c8..123768b099e 100644
--- a/compiler-rt/lib/asan/lit_tests/TestCases/Linux/glob.cc
+++ b/compiler-rt/lib/asan/lit_tests/TestCases/Linux/glob.cc
@@ -22,6 +22,7 @@ int main(int argc, char *argv[]) {
assert(globbuf.gl_pathc == 2);
printf("%zu\n", strlen(globbuf.gl_pathv[0]));
printf("%zu\n", strlen(globbuf.gl_pathv[1]));
+ globfree(&globbuf);
printf("PASS\n");
// CHECK: PASS
return 0;
diff --git a/compiler-rt/lib/asan/lit_tests/TestCases/Linux/interception_readdir_r_test.cc b/compiler-rt/lib/asan/lit_tests/TestCases/Linux/interception_readdir_r_test.cc
index 28c7df42447..198e1f3884d 100644
--- a/compiler-rt/lib/asan/lit_tests/TestCases/Linux/interception_readdir_r_test.cc
+++ b/compiler-rt/lib/asan/lit_tests/TestCases/Linux/interception_readdir_r_test.cc
@@ -33,6 +33,7 @@ int main() {
++count;
} while (result != NULL);
fprintf(stderr, "read %d entries\n", count);
+ closedir(d);
// CHECK: test1: reading the {{.*}} directory...
// CHECK-NOT: stack-buffer-overflow
// CHECK: read {{.*}} entries
@@ -51,6 +52,7 @@ int main() {
++count;
} while (result64 != NULL);
fprintf(stderr, "read %d entries\n", count);
+ closedir(d);
// CHECK: test2: reading the {{.*}} directory...
// CHECK-NOT: stack-buffer-overflow
// CHECK: read {{.*}} entries
diff --git a/compiler-rt/lib/asan/lit_tests/Unit/lit.site.cfg.in b/compiler-rt/lib/asan/lit_tests/Unit/lit.site.cfg.in
index 0db09400368..a45870c9b0e 100644
--- a/compiler-rt/lib/asan/lit_tests/Unit/lit.site.cfg.in
+++ b/compiler-rt/lib/asan/lit_tests/Unit/lit.site.cfg.in
@@ -11,3 +11,6 @@ config.name = 'AddressSanitizer-Unit'
# it as build directory with ASan unit tests.
config.test_exec_root = "@ASAN_BINARY_DIR@/tests"
config.test_source_root = config.test_exec_root
+
+if config.host_os == 'Linux':
+ config.environment['ASAN_OPTIONS'] = 'detect_leaks=1'
diff --git a/compiler-rt/lib/asan/lit_tests/lit.cfg b/compiler-rt/lib/asan/lit_tests/lit.cfg
index 16e3565c09f..5c129c5c648 100644
--- a/compiler-rt/lib/asan/lit_tests/lit.cfg
+++ b/compiler-rt/lib/asan/lit_tests/lit.cfg
@@ -82,6 +82,10 @@ config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os)))
config.available_features.add("asan-" + config.bits + "-bits")
+# Turn on leak detection on 64-bit Linux.
+if config.host_os == 'Linux' and config.bits == '64':
+ config.environment['ASAN_OPTIONS'] = 'detect_leaks=1'
+
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
diff --git a/compiler-rt/lib/asan/tests/asan_noinst_test.cc b/compiler-rt/lib/asan/tests/asan_noinst_test.cc
index 9d8a09c2a2e..0ec5b55ec48 100644
--- a/compiler-rt/lib/asan/tests/asan_noinst_test.cc
+++ b/compiler-rt/lib/asan/tests/asan_noinst_test.cc
@@ -654,6 +654,7 @@ TEST(AddressSanitizerInterface, PoisoningStressTest) {
}
}
}
+ free(arr);
}
TEST(AddressSanitizerInterface, PoisonedRegion) {
diff --git a/compiler-rt/lib/asan/tests/asan_str_test.cc b/compiler-rt/lib/asan/tests/asan_str_test.cc
index 17bef55d3d0..78101129db3 100644
--- a/compiler-rt/lib/asan/tests/asan_str_test.cc
+++ b/compiler-rt/lib/asan/tests/asan_str_test.cc
@@ -70,6 +70,7 @@ TEST(AddressSanitizer, WcsLenTest) {
memcpy(heap_string, L"Hello, World!", hello_size);
EXPECT_EQ(hello_len, Ident(wcslen(heap_string)));
EXPECT_DEATH(Ident(wcslen(heap_string + 14)), RightOOBReadMessage(0));
+ free(heap_string);
}
#ifndef __APPLE__
diff --git a/compiler-rt/lib/lit.common.unit.cfg b/compiler-rt/lib/lit.common.unit.cfg
index ccc3ffa0fe1..2bd8f376f00 100644
--- a/compiler-rt/lib/lit.common.unit.cfg
+++ b/compiler-rt/lib/lit.common.unit.cfg
@@ -15,6 +15,13 @@ config.test_format = lit.formats.GoogleTest(llvm_build_mode, "Test")
# Setup test suffixes.
config.suffixes = []
+# Tweak PATH to include llvm tools dir.
+llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
+if (not llvm_tools_dir) or (not os.path.exists(llvm_tools_dir)):
+ lit_config.fatal("Invalid llvm_tools_dir config attribute: %r" % llvm_tools_dir)
+path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
+config.environment['PATH'] = path
+
# Propagate the temp directory. Windows requires this because it uses \Windows\
# if none of these are present.
if 'TMP' in os.environ:
diff --git a/compiler-rt/lib/lit.common.unit.configured.in b/compiler-rt/lib/lit.common.unit.configured.in
index 88eeed1ae92..430816b2428 100644
--- a/compiler-rt/lib/lit.common.unit.configured.in
+++ b/compiler-rt/lib/lit.common.unit.configured.in
@@ -8,6 +8,7 @@ config.llvm_obj_root = "@LLVM_BINARY_DIR@"
config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
config.compiler_rt_src_root = "@COMPILER_RT_SOURCE_DIR@"
config.llvm_build_mode = "@LLVM_BUILD_MODE@"
+config.host_os = "@HOST_OS@"
# LLVM tools dir and build mode can be passed in lit parameters,
# so try to apply substitution.
OpenPOWER on IntegriCloud