| 1 |
// Test __sanitizer_set_report_path and __sanitizer_get_report_path: |
| 2 |
// RUN: %clangxx -O2 %s -o %t |
| 3 |
// RUN: %env HOME=%device_rundir/%t.homedir TMPDIR=%device_rundir/%t.tmpdir %run %t 2>&1 | FileCheck %s |
| 4 |
|
| 5 |
#include <sanitizer/common_interface_defs.h> |
| 6 |
#include <stdio.h> |
| 7 |
#include <string.h> |
| 8 |
|
| 9 |
int main(int argc, char **argv) { |
| 10 |
char buff[4096]; |
| 11 |
sprintf(buff, "%s.report_path/report", argv[0]); |
| 12 |
__sanitizer_set_report_path(buff); |
| 13 |
// CHECK: {{.*}}.report_path/report.[[PID:[0-9]+]] |
| 14 |
fprintf(stderr, "%s\n", __sanitizer_get_report_path()); |
| 15 |
|
| 16 |
strcpy(buff, "%H/foo"); |
| 17 |
__sanitizer_set_report_path(buff); |
| 18 |
// CHECK: [[T:.*]].homedir/foo.[[PID]] |
| 19 |
fprintf(stderr, "%s\n", __sanitizer_get_report_path()); |
| 20 |
|
| 21 |
strcpy(buff, "%t/foo"); |
| 22 |
__sanitizer_set_report_path(buff); |
| 23 |
// CHECK: [[T]].tmpdir/foo.[[PID]] |
| 24 |
fprintf(stderr, "%s\n", __sanitizer_get_report_path()); |
| 25 |
|
| 26 |
strcpy(buff, "%H/%p/%%foo"); |
| 27 |
__sanitizer_set_report_path(buff); |
| 28 |
// CHECK: [[T]].homedir/[[PID]]/%foo.[[PID]] |
| 29 |
fprintf(stderr, "%s\n", __sanitizer_get_report_path()); |
| 30 |
|
| 31 |
strcpy(buff, "%%foo%%bar"); |
| 32 |
__sanitizer_set_report_path(buff); |
| 33 |
// CHECK: %foo%bar.[[PID]] |
| 34 |
fprintf(stderr, "%s\n", __sanitizer_get_report_path()); |
| 35 |
|
| 36 |
strcpy(buff, "%%foo%ba%%r"); |
| 37 |
__sanitizer_set_report_path(buff); |
| 38 |
// CHECK: Unexpected pattern: %%foo%ba%%r |
| 39 |
// CHECK: %%foo%ba%%r.[[PID]] |
| 40 |
fprintf(stderr, "%s\n", __sanitizer_get_report_path()); |
| 41 |
} |