summaryrefslogtreecommitdiff
path: root/test/lsan
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-12-30 11:52:19 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-12-30 11:52:19 +0000
commit5c909fa013fc285f010a95e8d387e0ef3412da9c (patch)
tree1059d068ad281f4776ff44cd414574f99a460023 /test/lsan
parentf31bcc68c72371a2bf63aead9f3373a1ff2053b6 (diff)
downloadsrc-test2-5c909fa013fc285f010a95e8d387e0ef3412da9c.tar.gz
src-test2-5c909fa013fc285f010a95e8d387e0ef3412da9c.zip
Notes
Diffstat (limited to 'test/lsan')
-rw-r--r--test/lsan/TestCases/cleanup_in_tsd_destructor.c (renamed from test/lsan/TestCases/cleanup_in_tsd_destructor.cc)2
-rw-r--r--test/lsan/TestCases/disabler.c24
-rw-r--r--test/lsan/TestCases/disabler.cc10
-rw-r--r--test/lsan/TestCases/disabler_in_tsd_destructor.c (renamed from test/lsan/TestCases/disabler_in_tsd_destructor.cc)5
-rw-r--r--test/lsan/TestCases/ignore_object.c (renamed from test/lsan/TestCases/ignore_object.cc)4
-rw-r--r--test/lsan/TestCases/suppressions_file.cc6
6 files changed, 42 insertions, 9 deletions
diff --git a/test/lsan/TestCases/cleanup_in_tsd_destructor.cc b/test/lsan/TestCases/cleanup_in_tsd_destructor.c
index 5335454ffbeb..debf05c20473 100644
--- a/test/lsan/TestCases/cleanup_in_tsd_destructor.cc
+++ b/test/lsan/TestCases/cleanup_in_tsd_destructor.c
@@ -4,7 +4,7 @@
// 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: %clang_lsan %s -o %t
// RUN: LSAN_OPTIONS=$LSAN_BASE:use_tls=1 %run %t
// RUN: LSAN_OPTIONS=$LSAN_BASE:use_tls=0 not %run %t 2>&1 | FileCheck %s
diff --git a/test/lsan/TestCases/disabler.c b/test/lsan/TestCases/disabler.c
new file mode 100644
index 000000000000..1c4529df4f84
--- /dev/null
+++ b/test/lsan/TestCases/disabler.c
@@ -0,0 +1,24 @@
+// Test for __lsan_disable() / __lsan_enable().
+// RUN: LSAN_BASE="report_objects=1:use_registers=0:use_stacks=0:use_globals=0:use_tls=0"
+// RUN: %clang_lsan %s -o %t
+// RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t 2>&1 | FileCheck %s
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "sanitizer/lsan_interface.h"
+
+int main() {
+ void **p;
+ {
+ __lsan_disable();
+ p = malloc(sizeof(void *));
+ __lsan_enable();
+ }
+ *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/test/lsan/TestCases/disabler.cc b/test/lsan/TestCases/disabler.cc
index f83106501fa3..12e5ffe4d44a 100644
--- a/test/lsan/TestCases/disabler.cc
+++ b/test/lsan/TestCases/disabler.cc
@@ -13,11 +13,13 @@ int main() {
{
__lsan::ScopedDisabler d;
p = new void *;
+ fprintf(stderr, "Test alloc p: %p.\n", p);
}
- *reinterpret_cast<void **>(p) = malloc(666);
+ *p = malloc(666);
void *q = malloc(1337);
- // Break optimization.
- fprintf(stderr, "Test alloc: %p.\n", q);
+ fprintf(stderr, "Test alloc q: %p.\n", q);
return 0;
}
-// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
+
+// CHECK: Test alloc p: [[ADDR:.*]].
+// CHECK-NOT: [[ADDR]]
diff --git a/test/lsan/TestCases/disabler_in_tsd_destructor.cc b/test/lsan/TestCases/disabler_in_tsd_destructor.c
index a0012c74dd96..982fb899ec5b 100644
--- a/test/lsan/TestCases/disabler_in_tsd_destructor.cc
+++ b/test/lsan/TestCases/disabler_in_tsd_destructor.c
@@ -1,6 +1,6 @@
// 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: %clang_lsan %s -o %t
// RUN: LSAN_OPTIONS=$LSAN_BASE %run %t
#include <assert.h>
@@ -13,11 +13,12 @@
pthread_key_t key;
void key_destructor(void *arg) {
- __lsan::ScopedDisabler d;
+ __lsan_disable();
void *p = malloc(1337);
// Break optimization.
fprintf(stderr, "Test alloc: %p.\n", p);
pthread_setspecific(key, 0);
+ __lsan_enable();
}
void *thread_func(void *arg) {
diff --git a/test/lsan/TestCases/ignore_object.cc b/test/lsan/TestCases/ignore_object.c
index ac69e12a4ba6..2aa4f14e2916 100644
--- a/test/lsan/TestCases/ignore_object.cc
+++ b/test/lsan/TestCases/ignore_object.c
@@ -1,6 +1,6 @@
// Test for __lsan_ignore_object().
// 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: %clang_lsan %s -o %t
// RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t 2>&1 | FileCheck %s
#include <stdio.h>
@@ -10,7 +10,7 @@
int main() {
// Explicitly ignored object.
- void **p = new void *;
+ void **p = malloc(sizeof(void *));
// Transitively ignored object.
*p = malloc(666);
// Non-ignored object.
diff --git a/test/lsan/TestCases/suppressions_file.cc b/test/lsan/TestCases/suppressions_file.cc
index d030896d519f..805091cba4c4 100644
--- a/test/lsan/TestCases/suppressions_file.cc
+++ b/test/lsan/TestCases/suppressions_file.cc
@@ -1,6 +1,10 @@
// RUN: LSAN_BASE="use_registers=0:use_stacks=0"
// RUN: %clangxx_lsan %s -o %t
+// RUN: rm -f %t.supp
+// RUN: touch %t.supp
+// RUN: LSAN_OPTIONS="$LSAN_BASE:suppressions='%t.supp'" not %run %t 2>&1 | FileCheck %s --check-prefix=NOSUPP
+
// RUN: echo "leak:*LSanTestLeakingFunc*" > %t.supp
// RUN: LSAN_OPTIONS="$LSAN_BASE:suppressions='%t.supp'" not %run %t 2>&1 | FileCheck %s
@@ -24,3 +28,5 @@ int main() {
// CHECK: Suppressions used:
// CHECK: 1 666 *LSanTestLeakingFunc*
// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
+
+// NOSUPP: SUMMARY: {{(Leak|Address)}}Sanitizer: 2003 byte(s) leaked in 2 allocation(s).