1 | // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -g %s -o %t |
2 | // RUN: %run %t 2>&1 | \ |
3 | // RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS %s |
4 | // RUN: MSAN_OPTIONS=print_stats=1 %run %t 2>&1 | \ |
5 | // RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS %s |
6 | // RUN: MSAN_OPTIONS=print_stats=1,atexit=1 %run %t 2>&1 | \ |
7 | // RUN: FileCheck --check-prefixes=CHECK,CHECK-STATS %s |
8 | |
9 | // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -g -DPOSITIVE=1 %s -o %t |
10 | // RUN: not %run %t 2>&1 | \ |
11 | // RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS %s |
12 | // RUN: MSAN_OPTIONS=print_stats=1 not %run %t 2>&1 | \ |
13 | // RUN: FileCheck --check-prefixes=CHECK,CHECK-STATS %s |
14 | |
15 | // RUN: %clangxx_msan -fsanitize-memory-track-origins=2 -fsanitize-recover=memory -g -DPOSITIVE=1 %s -o %t |
16 | // RUN: not %run %t 2>&1 | \ |
17 | // RUN: FileCheck --check-prefixes=CHECK,CHECK-NOSTATS,CHECK-RECOVER %s |
18 | // RUN: MSAN_OPTIONS=print_stats=1 not %run %t 2>&1 | \ |
19 | // RUN: FileCheck --check-prefixes=CHECK,CHECK-STATS,CHECK-RECOVER %s |
20 | |
21 | #include <stdio.h> |
22 | int main(int argc, char **argv) { |
23 | int x; |
24 | int *volatile p = &x; |
25 | fprintf(stderr, format: "TEST\n" ); |
26 | #ifdef POSITIVE |
27 | return *p; |
28 | #else |
29 | return 0; |
30 | #endif |
31 | } |
32 | |
33 | // CHECK: TEST |
34 | |
35 | // CHECK-STATS: Unique heap origins: |
36 | // CHECK-STATS: Stack depot allocated bytes: |
37 | // CHECK-STATS: Unique origin histories: |
38 | // CHECK-STATS: History depot allocated bytes: |
39 | |
40 | // CHECK-NOSTATS-NOT: Unique heap origins: |
41 | // CHECK-NOSTATS-NOT: Stack depot allocated bytes: |
42 | // CHECK-NOSTATS-NOT: Unique origin histories: |
43 | // CHECK-NOSTATS-NOT: History depot allocated bytes: |
44 | |
45 | // CHECK-RECOVER: MemorySanitizer: 1 warnings reported. |
46 | |