Home | History | Annotate | Download | only in lit_tests
      1 // Test the blacklist functionality of ASan
      2 
      3 // RUN: echo "fun:*brokenFunction*" > %tmp
      4 // RUN: echo "global:*badGlobal*" >> %tmp
      5 // RUN: echo "src:*blacklist-extra.cc" >> %tmp
      6 // RUN: %clangxx_asan -mllvm -asan-blacklist=%tmp -m64 -O0 %s -o %t \
      7 // RUN: %p/Helpers/blacklist-extra.cc && %t 2>&1
      8 // RUN: %clangxx_asan -mllvm -asan-blacklist=%tmp -m64 -O1 %s -o %t \
      9 // RUN: %p/Helpers/blacklist-extra.cc && %t 2>&1
     10 // RUN: %clangxx_asan -mllvm -asan-blacklist=%tmp -m64 -O2 %s -o %t \
     11 // RUN: %p/Helpers/blacklist-extra.cc && %t 2>&1
     12 // RUN: %clangxx_asan -mllvm -asan-blacklist=%tmp -m64 -O3 %s -o %t \
     13 // RUN: %p/Helpers/blacklist-extra.cc && %t 2>&1
     14 // RUN: %clangxx_asan -mllvm -asan-blacklist=%tmp -m32 -O0 %s -o %t \
     15 // RUN: %p/Helpers/blacklist-extra.cc && %t 2>&1
     16 // RUN: %clangxx_asan -mllvm -asan-blacklist=%tmp -m32 -O1 %s -o %t \
     17 // RUN: %p/Helpers/blacklist-extra.cc && %t 2>&1
     18 // RUN: %clangxx_asan -mllvm -asan-blacklist=%tmp -m32 -O2 %s -o %t \
     19 // RUN: %p/Helpers/blacklist-extra.cc && %t 2>&1
     20 // RUN: %clangxx_asan -mllvm -asan-blacklist=%tmp -m32 -O3 %s -o %t \
     21 // RUN: %p/Helpers/blacklist-extra.cc && %t 2>&1
     22 
     23 // badGlobal is accessed improperly, but we blacklisted it.
     24 int badGlobal;
     25 int readBadGlobal() {
     26   return (&badGlobal)[1];
     27 }
     28 
     29 // A function which is broken, but excluded in the blacklist.
     30 int brokenFunction(int argc) {
     31   char x[10] = {0};
     32   return x[argc * 10];  // BOOM
     33 }
     34 
     35 // This function is defined in Helpers/blacklist-extra.cc, a source file which
     36 // is blacklisted by name
     37 int externalBrokenFunction(int x);
     38 
     39 int main(int argc, char **argv) {
     40   brokenFunction(argc);
     41   int x = readBadGlobal();
     42   externalBrokenFunction(argc);
     43   return 0;
     44 }
     45