Skip to content

Commit 986afe8

Browse files
committed
[sanitizer] Fix test to tolerate chmod not working as intended
Attempts to fix a bot failure from 634da7a on an Android bot: https://lab.llvm.org/buildbot#builders/77/builds/14339 It appears that the chmod is not making the directory unwritable as expected on this system for some reason. Adopt an approach used in compiler-rt/test/fuzzer/fuzzer-dirs.test for systems with non-functioning chmod by including illegal characters in directory.
1 parent 06df1a2 commit 986afe8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Test __sanitizer_set_report_path and __sanitizer_get_report_path:
22
// RUN: rm -rf %t.report_path
33
// RUN: %clangxx -O2 %s -o %t
4-
// RUN: %run %t | FileCheck %s
4+
// RUN: %run %t %t | FileCheck %s
55
// Try again with a directory without write access.
6-
// RUN: rm -rf %t.report_path && mkdir -p %t.report_path
7-
// RUN: chmod u-w %t.report_path || true
8-
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=FAIL
6+
// RUN: rm -rf %t.baddir && mkdir -p %t.baddir
7+
// 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
911

1012
#include <assert.h>
1113
#include <sanitizer/common_interface_defs.h>
@@ -16,11 +18,11 @@ volatile int *null = 0;
1618

1719
int main(int argc, char **argv) {
1820
char buff[1000];
19-
sprintf(buff, "%s.report_path/report", argv[0]);
21+
sprintf(buff, "%s.report_path/report", argv[1]);
2022
__sanitizer_set_report_path(buff);
2123
assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0);
2224
printf("Path %s\n", __sanitizer_get_report_path());
2325
}
2426

2527
// CHECK: Path {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.report_path/report.
26-
// FAIL: ERROR: Can't open file: {{.*}}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

0 commit comments

Comments
 (0)