Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 1 | // FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316 |
| 2 | // XFAIL: android |
| 3 | // |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 4 | // The for loop in the backticks below requires bash. |
| 5 | // REQUIRES: shell |
| 6 | // |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 7 | // RUN: %clangxx_asan %s -o %t |
| 8 | |
| 9 | // Regular run. |
| 10 | // RUN: not %run %t 2> %t.out |
| 11 | // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.out |
| 12 | |
| 13 | // Good log_path. |
| 14 | // RUN: rm -f %t.log.* |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 15 | // RUN: %env_asan_opts=log_path=%t.log not %run %t 2> %t.out |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 16 | // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.* |
| 17 | |
| 18 | // Invalid log_path. |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 19 | // RUN: %env_asan_opts=log_path=/dev/null/INVALID not %run %t 2> %t.out |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 20 | // RUN: FileCheck %s --check-prefix=CHECK-INVALID < %t.out |
| 21 | |
| 22 | // Too long log_path. |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 23 | // RUN: %env_asan_opts=log_path=`for((i=0;i<10000;i++)); do echo -n $i; done` \ |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 24 | // RUN: not %run %t 2> %t.out |
| 25 | // RUN: FileCheck %s --check-prefix=CHECK-LONG < %t.out |
| 26 | |
| 27 | // Run w/o errors should not produce any log. |
| 28 | // RUN: rm -f %t.log.* |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 29 | // RUN: %env_asan_opts=log_path=%t.log %run %t ARG ARG ARG |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 30 | // RUN: not cat %t.log.* |
| 31 | |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 32 | // FIXME: log_path is not supported on Windows yet. |
| 33 | // XFAIL: win32 |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 34 | |
| 35 | #include <stdlib.h> |
| 36 | #include <string.h> |
| 37 | int main(int argc, char **argv) { |
| 38 | if (argc > 2) return 0; |
| 39 | char *x = (char*)malloc(10); |
| 40 | memset(x, 0, 10); |
| 41 | int res = x[argc * 10]; // BOOOM |
| 42 | free(x); |
| 43 | return res; |
| 44 | } |
| 45 | // CHECK-ERROR: ERROR: AddressSanitizer |
Stephen Hines | 86277eb | 2015-03-23 12:06:32 -0700 | [diff] [blame] | 46 | // CHECK-INVALID: ERROR: Can't open file: /dev/null/INVALID |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 47 | // CHECK-LONG: ERROR: Path is too long: 01234 |