[docs] Fix build-docs.sh
[llvm-project.git] / compiler-rt / test / lsan / TestCases / print_suppressions.cpp
blob872ce7a95582e2fa440b7bc4e5d9498ef0c7865f
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
9 #include <stdio.h>
10 #include <stdlib.h>
12 #include "sanitizer/lsan_interface.h"
14 extern "C"
15 const char *__lsan_default_suppressions() {
16 return "leak:*LSanTestLeakingFunc*";
19 void LSanTestLeakingFunc() {
20 void *p = malloc(666);
21 fprintf(stderr, "Test alloc: %p.\n", p);
24 int main(int argc, char **argv) {
25 printf("print for nonempty output\n");
26 if (argc > 1)
27 LSanTestLeakingFunc();
28 return 0;
30 // CHECK-print: Suppressions used:
31 // CHECK-print: 1 666 *LSanTestLeakingFunc*
32 // CHECK-dont-print-NOT: Suppressions used: