1 // RUN: LSAN_BASE="use_registers=0:use_stacks=0"
2 // RUN: %clangxx_lsan %s -o %t
3
4 // RUN: rm -f %t.supp
5 // RUN: touch %t.supp
6 // RUN: %push_to_device %t.supp %device_rundir/%t.supp
7 // RUN: %env_lsan_opts="$LSAN_BASE:suppressions='%device_rundir/%t.supp'" not %run %t 2>&1 | FileCheck %s --check-prefix=NOSUPP
8
9 // RUN: echo "leak:*LSanTestLeakingFunc*" > %t.supp
10 // RUN: %push_to_device %t.supp %device_rundir/%t.supp
11 // RUN: %env_lsan_opts="$LSAN_BASE:suppressions='%device_rundir/%t.supp'" not %run %t 2>&1 | FileCheck %s
12 //
13 // RUN: echo "leak:%t" > %t.supp
14 // RUN: %push_to_device %t.supp %device_rundir/%t.supp
15 // RUN: %env_lsan_opts="$LSAN_BASE:suppressions='%device_rundir/%t.supp':symbolize=false" %run %t
16
17 #include <stdio.h>
18 #include <stdlib.h>
19
LSanTestLeakingFunc()20 void LSanTestLeakingFunc() {
21 void *p = malloc(666);
22 fprintf(stderr, "Test alloc: %p.\n", p);
23 }
24
main()25 int main() {
26 LSanTestLeakingFunc();
27 void *q = malloc(1337);
28 fprintf(stderr, "Test alloc: %p.\n", q);
29 return 0;
30 }
31 // CHECK: Suppressions used:
32 // CHECK: 1 666 *LSanTestLeakingFunc*
33 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
34
35 // NOSUPP: SUMMARY: {{(Leak|Address)}}Sanitizer: 2003 byte(s) leaked in 2 allocation(s).
36