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(s: buff, format: "%s.report_path/report" , argv[0]); |
12 | __sanitizer_set_report_path(path: buff); |
13 | // CHECK: {{.*}}.report_path/report.[[PID:[0-9]+]] |
14 | fprintf(stderr, format: "%s\n" , __sanitizer_get_report_path()); |
15 | |
16 | strcpy(dest: buff, src: "%H/foo" ); |
17 | __sanitizer_set_report_path(path: buff); |
18 | // CHECK: [[T:.*]].homedir/foo.[[PID]] |
19 | fprintf(stderr, format: "%s\n" , __sanitizer_get_report_path()); |
20 | |
21 | strcpy(dest: buff, src: "%t/foo" ); |
22 | __sanitizer_set_report_path(path: buff); |
23 | // CHECK: [[T]].tmpdir/foo.[[PID]] |
24 | fprintf(stderr, format: "%s\n" , __sanitizer_get_report_path()); |
25 | |
26 | strcpy(dest: buff, src: "%H/%p/%%foo" ); |
27 | __sanitizer_set_report_path(path: buff); |
28 | // CHECK: [[T]].homedir/[[PID]]/%foo.[[PID]] |
29 | fprintf(stderr, format: "%s\n" , __sanitizer_get_report_path()); |
30 | |
31 | strcpy(dest: buff, src: "%%foo%%bar" ); |
32 | __sanitizer_set_report_path(path: buff); |
33 | // CHECK: %foo%bar.[[PID]] |
34 | fprintf(stderr, format: "%s\n" , __sanitizer_get_report_path()); |
35 | |
36 | strcpy(dest: buff, src: "%%foo%ba%%r" ); |
37 | __sanitizer_set_report_path(path: buff); |
38 | // CHECK: Unexpected pattern: %%foo%ba%%r |
39 | // CHECK: %%foo%ba%%r.[[PID]] |
40 | fprintf(stderr, format: "%s\n" , __sanitizer_get_report_path()); |
41 | } |
42 | |