summaryrefslogtreecommitdiff
path: root/lib/asan/lit_tests
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
commit1a249181dcdf217d368fbf4c1f09d8af7e617cb0 (patch)
tree0c4417b1134800cf3b2f53d3cbb5eb041c45b444 /lib/asan/lit_tests
parenta3cb27e188bd23190ba7a41a8c62fa7cc5ac5544 (diff)
downloadcompiler-rt-1a249181dcdf217d368fbf4c1f09d8af7e617cb0.tar.gz
compiler-rt-1a249181dcdf217d368fbf4c1f09d8af7e617cb0.tar.bz2
compiler-rt-1a249181dcdf217d368fbf4c1f09d8af7e617cb0.tar.xz
[ASan] turn on leak checking for ASan tests and fix a few discovered leaks
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190274 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/lit_tests')
-rw-r--r--lib/asan/lit_tests/TestCases/Linux/glob.cc1
-rw-r--r--lib/asan/lit_tests/TestCases/Linux/interception_readdir_r_test.cc2
-rw-r--r--lib/asan/lit_tests/Unit/lit.site.cfg.in3
-rw-r--r--lib/asan/lit_tests/lit.cfg4
4 files changed, 10 insertions, 0 deletions
diff --git a/lib/asan/lit_tests/TestCases/Linux/glob.cc b/lib/asan/lit_tests/TestCases/Linux/glob.cc
index a375f1b6..123768b0 100644
--- a/lib/asan/lit_tests/TestCases/Linux/glob.cc
+++ b/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/lib/asan/lit_tests/TestCases/Linux/interception_readdir_r_test.cc b/lib/asan/lit_tests/TestCases/Linux/interception_readdir_r_test.cc
index 28c7df42..198e1f38 100644
--- a/lib/asan/lit_tests/TestCases/Linux/interception_readdir_r_test.cc
+++ b/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/lib/asan/lit_tests/Unit/lit.site.cfg.in b/lib/asan/lit_tests/Unit/lit.site.cfg.in
index 0db09400..a45870c9 100644
--- a/lib/asan/lit_tests/Unit/lit.site.cfg.in
+++ b/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/lib/asan/lit_tests/lit.cfg b/lib/asan/lit_tests/lit.cfg
index 16e3565c..5c129c5c 100644
--- a/lib/asan/lit_tests/lit.cfg
+++ b/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']