summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/lsan/lit_tests
diff options
context:
space:
mode:
authorSergey Matveev <earthdok@google.com>2013-12-17 18:01:45 +0000
committerSergey Matveev <earthdok@google.com>2013-12-17 18:01:45 +0000
commitb5769dbb86173c1cafb083012ed78acc5bbbd77c (patch)
tree5a7ce8a1c07680518b2182717aab5ef1ba4719e4 /compiler-rt/lib/lsan/lit_tests
parente955e3998ffccf7d4f8cca3370f04a35e5ab3d8b (diff)
downloadbcm5719-llvm-b5769dbb86173c1cafb083012ed78acc5bbbd77c.tar.gz
bcm5719-llvm-b5769dbb86173c1cafb083012ed78acc5bbbd77c.zip
[lsan] Introduce print_suppressions flag.
Introduce a flag to either always or never print matched suppressions. Previously, matched suppressions were printed unconditionally if there were unsuppressed leaks. Also, verbosity=1 no longer has the semantics of "always print suppressions and summary". llvm-svn: 197510
Diffstat (limited to 'compiler-rt/lib/lsan/lit_tests')
-rw-r--r--compiler-rt/lib/lsan/lit_tests/TestCases/leak_check_at_exit.cc12
-rw-r--r--compiler-rt/lib/lsan/lit_tests/TestCases/print_suppressions.cc33
2 files changed, 40 insertions, 5 deletions
diff --git a/compiler-rt/lib/lsan/lit_tests/TestCases/leak_check_at_exit.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/leak_check_at_exit.cc
index 38c1063b6eb..d921afc8462 100644
--- a/compiler-rt/lib/lsan/lit_tests/TestCases/leak_check_at_exit.cc
+++ b/compiler-rt/lib/lsan/lit_tests/TestCases/leak_check_at_exit.cc
@@ -1,15 +1,17 @@
// 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="verbosity=1" %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
-// RUN: LSAN_OPTIONS="verbosity=1" %t 2>&1 | FileCheck %s --check-prefix=CHECK-do
-// RUN: LSAN_OPTIONS="verbosity=1:leak_check_at_exit=0" ASAN_OPTIONS="$ASAN_OPTIONS:leak_check_at_exit=0" %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
-// RUN: LSAN_OPTIONS="verbosity=1:leak_check_at_exit=0" ASAN_OPTIONS="$ASAN_OPTIONS:leak_check_at_exit=0" %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont
+// 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[]) {
- printf("printf to break optimization\n");
+ fprintf(stderr, "Test alloc: %p.\n", malloc(1337));
if (argc > 1)
__lsan_do_leak_check();
return 0;
diff --git a/compiler-rt/lib/lsan/lit_tests/TestCases/print_suppressions.cc b/compiler-rt/lib/lsan/lit_tests/TestCases/print_suppressions.cc
new file mode 100644
index 00000000000..97e67a01631
--- /dev/null
+++ b/compiler-rt/lib/lsan/lit_tests/TestCases/print_suppressions.cc
@@ -0,0 +1,33 @@
+// 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:
OpenPOWER on IntegriCloud