]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/lsan/TestCases/suppressions_file.cc
Vendor import of compiler-rt trunk r256633:
[FreeBSD/FreeBSD.git] / test / lsan / TestCases / suppressions_file.cc
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: LSAN_OPTIONS="$LSAN_BASE:suppressions='%t.supp'" not %run %t 2>&1 | FileCheck %s --check-prefix=NOSUPP
7
8 // RUN: echo "leak:*LSanTestLeakingFunc*" > %t.supp
9 // RUN: LSAN_OPTIONS="$LSAN_BASE:suppressions='%t.supp'" not %run %t 2>&1 | FileCheck %s
10
11 // RUN: echo "leak:%t" > %t.supp
12 // RUN: LSAN_OPTIONS="$LSAN_BASE:suppressions='%t.supp':symbolize=false" %run %t
13
14 #include <stdio.h>
15 #include <stdlib.h>
16
17 void LSanTestLeakingFunc() {
18   void *p = malloc(666);
19   fprintf(stderr, "Test alloc: %p.\n", p);
20 }
21
22 int 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)
31
32 // NOSUPP: SUMMARY: {{(Leak|Address)}}Sanitizer: 2003 byte(s) leaked in 2 allocation(s).