| 1 | // RUN: %clangxx -O2 %s -o %t |
| 2 | |
| 3 | // Case 1: Try setting a path that is an invalid/inaccessible directory. |
| 4 | // RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=ERROR1 |
| 5 | |
| 6 | // Case 2: Try setting a path that is too large. |
| 7 | // RUN: not %run %t A 2>&1 | FileCheck %s --check-prefix=ERROR2 |
| 8 | |
| 9 | #include <sanitizer/common_interface_defs.h> |
| 10 | #include <stdio.h> |
| 11 | |
| 12 | int main(int argc, char **argv) { |
| 13 | char buff[4096]; |
| 14 | if (argc == 1) { |
| 15 | // Case 1 |
| 16 | sprintf(s: buff, format: "%s/report" , argv[0]); |
| 17 | // ERROR1: Can't create directory: {{.*}} |
| 18 | } else { |
| 19 | // Case 2 |
| 20 | snprintf(s: buff, maxlen: sizeof(buff), format: "%04095d" , 42); |
| 21 | // ERROR2: Path is too long: 00000000... |
| 22 | } |
| 23 | __sanitizer_set_report_path(path: buff); |
| 24 | } |
| 25 | |