blob: b4218ad85230201204838e9f32b2b11d0aa9c4f7 [file] [log] [blame]
Stephen Hines6a211c52014-07-21 00:49:56 -07001// FIXME: https://code.google.com/p/address-sanitizer/issues/detail?id=316
2// XFAIL: android
3//
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08004// The for loop in the backticks below requires bash.
5// REQUIRES: shell
6//
Stephen Hines2d1fdb22014-05-28 23:58:16 -07007// 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 Nainar799172d2016-03-03 15:50:30 -080015// RUN: %env_asan_opts=log_path=%t.log not %run %t 2> %t.out
Stephen Hines2d1fdb22014-05-28 23:58:16 -070016// RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.*
17
18// Invalid log_path.
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080019// RUN: %env_asan_opts=log_path=/dev/null/INVALID not %run %t 2> %t.out
Stephen Hines2d1fdb22014-05-28 23:58:16 -070020// RUN: FileCheck %s --check-prefix=CHECK-INVALID < %t.out
21
22// Too long log_path.
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080023// RUN: %env_asan_opts=log_path=`for((i=0;i<10000;i++)); do echo -n $i; done` \
Stephen Hines2d1fdb22014-05-28 23:58:16 -070024// 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 Nainar799172d2016-03-03 15:50:30 -080029// RUN: %env_asan_opts=log_path=%t.log %run %t ARG ARG ARG
Stephen Hines2d1fdb22014-05-28 23:58:16 -070030// RUN: not cat %t.log.*
31
Stephen Hines6a211c52014-07-21 00:49:56 -070032// FIXME: log_path is not supported on Windows yet.
33// XFAIL: win32
Stephen Hines2d1fdb22014-05-28 23:58:16 -070034
35#include <stdlib.h>
36#include <string.h>
37int 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 Hines86277eb2015-03-23 12:06:32 -070046// CHECK-INVALID: ERROR: Can't open file: /dev/null/INVALID
Stephen Hines2d1fdb22014-05-28 23:58:16 -070047// CHECK-LONG: ERROR: Path is too long: 01234