1 // Print matched suppressions only if print_suppressions=1 AND at least one is
2 // matched. Default is print_suppressions=true.
3 // RUN: %clangxx_lsan %s -o %t
4 // RUN: %env_lsan_opts=use_registers=0:use_stacks=0:print_suppressions=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print
5 // RUN: %env_lsan_opts=use_registers=0:use_stacks=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print
6 // RUN: %env_lsan_opts=use_registers=0:use_stacks=0:print_suppressions=0 %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-dont-print
7 // RUN: %env_lsan_opts=use_registers=0:use_stacks=0 %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-print
8
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 #include "sanitizer/lsan_interface.h"
13
14 extern "C"
__lsan_default_suppressions()15 const char *__lsan_default_suppressions() {
16 return "leak:*LSanTestLeakingFunc*";
17 }
18
LSanTestLeakingFunc()19 void LSanTestLeakingFunc() {
20 void *p = malloc(666);
21 fprintf(stderr, "Test alloc: %p.\n", p);
22 }
23
main(int argc,char ** argv)24 int main(int argc, char **argv) {
25 printf("print for nonempty output\n");
26 if (argc > 1)
27 LSanTestLeakingFunc();
28 return 0;
29 }
30 // CHECK-print: Suppressions used:
31 // CHECK-print: 1 666 *LSanTestLeakingFunc*
32 // CHECK-dont-print-NOT: Suppressions used:
33