blob: 805091cba4c4f3bc213349503a04398d29c2aeb8 [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001// RUN: LSAN_BASE="use_registers=0:use_stacks=0"
2// RUN: %clangxx_lsan %s -o %t
3
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08004// RUN: rm -f %t.supp
5// RUN: touch %t.supp
6// RUN: LSAN_OPTIONS="$LSAN_BASE:suppressions='%t.supp'" not %run %t 2>&1 | FileCheck %s --check-prefix=NOSUPP
7
Stephen Hines86277eb2015-03-23 12:06:32 -07008// RUN: echo "leak:*LSanTestLeakingFunc*" > %t.supp
9// RUN: LSAN_OPTIONS="$LSAN_BASE:suppressions='%t.supp'" not %run %t 2>&1 | FileCheck %s
Stephen Hines2d1fdb22014-05-28 23:58:16 -070010
Stephen Hines86277eb2015-03-23 12:06:32 -070011// RUN: echo "leak:%t" > %t.supp
12// RUN: LSAN_OPTIONS="$LSAN_BASE:suppressions='%t.supp':symbolize=false" %run %t
Stephen Hines2d1fdb22014-05-28 23:58:16 -070013
14#include <stdio.h>
15#include <stdlib.h>
16
17void LSanTestLeakingFunc() {
18 void *p = malloc(666);
19 fprintf(stderr, "Test alloc: %p.\n", p);
20}
21
22int main() {
23 LSanTestLeakingFunc();
24 void *q = malloc(1337);
25 fprintf(stderr, "Test alloc: %p.\n", q);
26 return 0;
27}
28// CHECK: Suppressions used:
29// CHECK: 1 666 *LSanTestLeakingFunc*
30// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080031
32// NOSUPP: SUMMARY: {{(Leak|Address)}}Sanitizer: 2003 byte(s) leaked in 2 allocation(s).