xref: /aosp_15_r20/external/compiler-rt/test/msan/keep-going-dso.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -O0 %s -o %t && not %run %t >%t.out 2>&1
2*7c3d14c8STreehugger Robot // FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
3*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
4*7c3d14c8STreehugger Robot // FileCheck %s <%t.out
5*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
6*7c3d14c8STreehugger Robot // FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
7*7c3d14c8STreehugger Robot 
8*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && not %run %t >%t.out 2>&1
9*7c3d14c8STreehugger Robot // FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
10*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %run %t >%t.out 2>&1
11*7c3d14c8STreehugger Robot // FileCheck %s <%t.out
12*7c3d14c8STreehugger Robot // RUN: %clangxx_msan -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %run %t >%t.out 2>&1
13*7c3d14c8STreehugger Robot // FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
14*7c3d14c8STreehugger Robot 
15*7c3d14c8STreehugger Robot // Test how -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going affect reports
16*7c3d14c8STreehugger Robot // from interceptors.
17*7c3d14c8STreehugger Robot // -mllvm -msan-keep-going provides the default value of keep_going flag, but is
18*7c3d14c8STreehugger Robot // always overwritten by MSAN_OPTIONS
19*7c3d14c8STreehugger Robot 
20*7c3d14c8STreehugger Robot #include <stdio.h>
21*7c3d14c8STreehugger Robot #include <stdlib.h>
22*7c3d14c8STreehugger Robot #include <string.h>
23*7c3d14c8STreehugger Robot 
main(int argc,char ** argv)24*7c3d14c8STreehugger Robot int main(int argc, char **argv) {
25*7c3d14c8STreehugger Robot   char *volatile x = (char*)malloc(5 * sizeof(char));
26*7c3d14c8STreehugger Robot   x[4] = 0;
27*7c3d14c8STreehugger Robot   if (strlen(x) < 3)
28*7c3d14c8STreehugger Robot     exit(0);
29*7c3d14c8STreehugger Robot   fprintf(stderr, "Done\n");
30*7c3d14c8STreehugger Robot   // CHECK-NOT: Done
31*7c3d14c8STreehugger Robot   // CHECK-KEEP-GOING: Done
32*7c3d14c8STreehugger Robot   return 0;
33*7c3d14c8STreehugger Robot }
34