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