Skip to content

Commit 273600b

Browse files
committed
[sanitizer] Second test fix to tolerate chmod not working as intended
Second attempt to fix a bot failure from 634da7a on an Android bot: https://lab.llvm.org/buildbot#builders/77/builds/14339 With the fix in 986afe8 there was a different issue, because we need the fully qualified path name to the binary, which is only available in arg[0]. New failure: https://lab.llvm.org/buildbot/#/builders/77/builds/14346/steps/16/logs/stdio Restructure the test so both attempts are made from the same invocation, which sets up the bad paths directly.
1 parent 890beda commit 273600b

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
// Test __sanitizer_set_report_path and __sanitizer_get_report_path:
2-
// RUN: rm -rf %t.report_path
32
// 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.
64
// RUN: rm -rf %t.baddir && mkdir -p %t.baddir
75
// 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
117

128
#include <assert.h>
139
#include <sanitizer/common_interface_defs.h>
@@ -18,11 +14,21 @@ volatile int *null = 0;
1814

1915
int main(int argc, char **argv) {
2016
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]);
2227
__sanitizer_set_report_path(buff);
2328
assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0);
2429
printf("Path %s\n", __sanitizer_get_report_path());
2530
}
2631

2732
// 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

Comments
 (0)