Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26: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 globs below do not work in the lit shell. |
| 5 | // REQUIRES: shell |
| 6 | |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 7 | // RUN: %clangxx -fsanitize=undefined %s -O1 -o %t |
| 8 | |
| 9 | // Regular run. |
| 10 | // RUN: %run %t -4 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_ubsan_opts=log_path='"%t.log"' %run %t -4 2> %t.out |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 16 | // RUN: FileCheck %s --check-prefix=CHECK-ERROR < %t.log.* |
| 17 | |
| 18 | // Run w/o errors should not produce any log. |
| 19 | // RUN: rm -f %t.log.* |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 20 | // RUN: %env_ubsan_opts=log_path='"%t.log"' %run %t 4 |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 21 | // RUN: not cat %t.log.* |
| 22 | |
| 23 | // FIXME: log_path is not supported on Windows yet. |
| 24 | // XFAIL: win32 |
| 25 | |
| 26 | #include <stdio.h> |
| 27 | #include <stdlib.h> |
| 28 | int main(int argc, char *argv[]) { |
| 29 | double a = atof(argv[1]); |
| 30 | unsigned int ai = (unsigned int) a; |
| 31 | printf("%f %u\n", a, ai); |
| 32 | return 0; |
| 33 | } |
| 34 | |
| 35 | // CHECK-ERROR: runtime error: value -4 is outside the range of representable values of type 'unsigned int' |
| 36 | |