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