[docs] Fix build-docs.sh
[llvm-project.git] / compiler-rt / test / lsan / TestCases / suppressions_file.cpp
blobd74bb47e5f6bb5dd4d5ad04093186964e263c812
1 // RUN: %clangxx_lsan %s -o %t
3 // RUN: rm -f %t.supp
4 // RUN: touch %t.supp
5 // RUN: %push_to_device %t.supp %device_rundir/%t.supp
6 // RUN: %env_lsan_opts="use_registers=0:use_stacks=0:suppressions='%device_rundir/%t.supp'" not %run %t 2>&1 | FileCheck %s --check-prefix=NOSUPP
8 // RUN: echo "leak:*LSanTestLeakingFunc*" > %t.supp
9 // RUN: %push_to_device %t.supp %device_rundir/%t.supp
10 // RUN: %env_lsan_opts="use_registers=0:use_stacks=0:suppressions='%device_rundir/%t.supp'" not %run %t 2>&1 | FileCheck %s
12 // RUN: echo "leak:%t" > %t.supp
13 // RUN: %push_to_device %t.supp %device_rundir/%t.supp
14 // RUN: %env_lsan_opts="use_registers=0:use_stacks=0:suppressions='%device_rundir/%t.supp':symbolize=false" %run %t
16 #include <stdio.h>
17 #include <stdlib.h>
19 void *LSanTestLeakingFunc() {
20 void *p = malloc(666);
21 fprintf(stderr, "Test alloc: %p.\n", p);
22 return p;
25 void LSanTestUnsuppressedLeakingFunc() {
26 void **p = (void **)LSanTestLeakingFunc();
27 *p = malloc(777);
28 fprintf(stderr, "Test alloc: %p.\n", *p);
31 int main() {
32 LSanTestUnsuppressedLeakingFunc();
33 void *q = malloc(1337);
34 fprintf(stderr, "Test alloc: %p.\n", q);
35 return 0;
37 // CHECK: Suppressions used:
38 // CHECK: 1 666 *LSanTestLeakingFunc*
39 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
41 // NOSUPP: SUMMARY: {{(Leak|Address)}}Sanitizer: 2780 byte(s) leaked in 3 allocation(s).