1
1
// Test __sanitizer_set_report_path and __sanitizer_get_report_path:
2
- // RUN: rm -rf %t.report_path
3
2
// RUN: %clangxx -O2 %s -o %t
4
- // RUN: %run %t %t | FileCheck %s
5
- // Try again with a directory without write access.
3
+ // Create a directory without write access.
6
4
// RUN: rm -rf %t.baddir && mkdir -p %t.baddir
7
5
// RUN: chmod u-w %t.baddir || true
8
- // Use invalid characters in directory name in case chmod doesn't work as
9
- // intended.
10
- // RUN: not %run %t %t.baddir/?bad? 2>&1 | FileCheck %s --check-prefix=FAIL
6
+ // RUN: not %run %t 2>&1 | FileCheck %s
11
7
12
8
#include < assert.h>
13
9
#include < sanitizer/common_interface_defs.h>
@@ -18,11 +14,21 @@ volatile int *null = 0;
18
14
19
15
int main (int argc, char **argv) {
20
16
char buff[1000 ];
21
- sprintf (buff, " %s.report_path/report" , argv[1 ]);
17
+ sprintf (buff, " %s.report_path/report" , argv[0 ]);
18
+ __sanitizer_set_report_path (buff);
19
+ assert (strncmp (buff, __sanitizer_get_report_path (), strlen (buff)) == 0 );
20
+ printf (" Path %s\n " , __sanitizer_get_report_path ());
21
+ fflush (stdout);
22
+
23
+ // Try setting again with an invalid/inaccessible directory.
24
+ // Use invalid characters in directory name in case chmod doesn't work as
25
+ // intended.
26
+ sprintf (buff, " %s.baddir/?bad?/report" , argv[0 ]);
22
27
__sanitizer_set_report_path (buff);
23
28
assert (strncmp (buff, __sanitizer_get_report_path (), strlen (buff)) == 0 );
24
29
printf (" Path %s\n " , __sanitizer_get_report_path ());
25
30
}
26
31
27
32
// CHECK: Path {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.report_path/report.
28
- // FAIL: ERROR: Can't create directory: {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.baddir
33
+ // CHECK: ERROR: Can't create directory: {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.baddir
34
+ // CHECK-NOT: Path {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.baddir
0 commit comments