1 | // RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1 |
2 | // FileCheck %s <%t.out |
3 | // RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1 |
4 | // FileCheck %s <%t.out |
5 | // RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1 |
6 | // FileCheck %s <%t.out |
7 | |
8 | // Test behavior of -fsanitize-recover=memory and MSAN_OPTIONS=keep_going. |
9 | // -fsanitize-recover=memory provides the default value of keep_going flag; value |
10 | // of 1 can be overwritten by MSAN_OPTIONS, value of 0 can not. |
11 | |
12 | // RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && not %run %t >%t.out 2>&1 |
13 | // FileCheck --check-prefix=CHECK-RECOVER %s <%t.out |
14 | // RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1 |
15 | // FileCheck %s <%t.out |
16 | // RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1 |
17 | // FileCheck --check-prefix=CHECK-RECOVER %s <%t.out |
18 | // RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=1 not %run %t >%t.out 2>&1 |
19 | // FileCheck %s <%t.out |
20 | // RUN: %clangxx_msan -fsanitize-recover=memory -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=0 not %run %t >%t.out 2>&1 |
21 | // FileCheck --check-prefix=CHECK-RECOVER %s <%t.out |
22 | |
23 | // Basic test of legacy -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going. |
24 | |
25 | // RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && not %run %t >%t.out 2>&1 |
26 | // FileCheck --check-prefix=CHECK-RECOVER %s <%t.out |
27 | // RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1 |
28 | // FileCheck %s <%t.out |
29 | |
30 | #include <stdio.h> |
31 | #include <stdlib.h> |
32 | |
33 | int main(int argc, char **argv) { |
34 | char *volatile x = (char*)malloc(size: 5 * sizeof(char)); |
35 | if (x[0]) |
36 | exit(status: 0); |
37 | fprintf(stderr, format: "Done\n" ); |
38 | // CHECK-NOT: Done |
39 | // CHECK-RECOVER: Done |
40 | return 0; |
41 | } |
42 | |