Home | History | Annotate | Download | only in TestCases
      1 // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
      2 // XFAIL: android
      3 //
      4 // RUN: %clangxx_asan  %s -o %t
      5 
      6 // Regular run.
      7 // RUN: not %run %t 2> %t.out
      8 // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.out
      9 
     10 // Good log_path.
     11 // RUN: rm -f %t.log.*
     12 // RUN: env ASAN_OPTIONS=log_path=%t.log not %run %t 2> %t.out
     13 // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.*
     14 
     15 // Invalid log_path.
     16 // RUN: env ASAN_OPTIONS=log_path=/INVALID not %run %t 2> %t.out
     17 // RUN: FileCheck %s --check-prefix=CHECK-INVALID < %t.out
     18 
     19 // Too long log_path.
     20 // RUN: env ASAN_OPTIONS=log_path=`for((i=0;i<10000;i++)); do echo -n $i; done` \
     21 // RUN:   not %run %t 2> %t.out
     22 // RUN: FileCheck %s --check-prefix=CHECK-LONG < %t.out
     23 
     24 // Run w/o errors should not produce any log.
     25 // RUN: rm -f %t.log.*
     26 // RUN: env ASAN_OPTIONS=log_path=%t.log  %run %t ARG ARG ARG
     27 // RUN: not cat %t.log.*
     28 
     29 // FIXME: log_path is not supported on Windows yet.
     30 // XFAIL: win32
     31 
     32 #include <stdlib.h>
     33 #include <string.h>
     34 int main(int argc, char **argv) {
     35   if (argc > 2) return 0;
     36   char *x = (char*)malloc(10);
     37   memset(x, 0, 10);
     38   int res = x[argc * 10];  // BOOOM
     39   free(x);
     40   return res;
     41 }
     42 // CHECK-ERROR: ERROR: AddressSanitizer
     43 // CHECK-INVALID: ERROR: Can't open file: /INVALID
     44 // CHECK-LONG: ERROR: Path is too long: 01234
     45