Skip to content

Commit f4214e1

Browse files
committed
[sanitizer] Skip test on Android where chmod is not working
Third attempt to fix a bot failure from 634da7a on an Android bot: https://lab.llvm.org/buildbot#builders/77/builds/14339 My last attempt used an approach from another test where chmod was not working of using a bad character in the path name. But it looks like this trick only works on Windows. Instead, restore the original version of this test before my change at 634da7a and move the bad path test to a new test file, marking it unsupported on Android.
1 parent 352e19c commit f4214e1

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Test __sanitizer_set_report_path and __sanitizer_get_report_path with an
2+
// unwritable directory.
3+
// RUN: rm -rf %t.report_path && mkdir -p %t.report_path
4+
// RUN: chmod u-w %t.report_path || true
5+
// RUN: %clangxx -O2 %s -o %t
6+
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=FAIL
7+
8+
// The chmod is not working on the android bot for some reason.
9+
// UNSUPPORTED: android
10+
11+
#include <assert.h>
12+
#include <sanitizer/common_interface_defs.h>
13+
#include <stdio.h>
14+
#include <string.h>
15+
16+
volatile int *null = 0;
17+
18+
int main(int argc, char **argv) {
19+
char buff[1000];
20+
sprintf(buff, "%s.report_path/report", argv[0]);
21+
__sanitizer_set_report_path(buff);
22+
assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0);
23+
printf("Path %s\n", __sanitizer_get_report_path());
24+
}
25+
26+
// FAIL: ERROR: Can't open file: {{.*}}Posix/Output/sanitizer_bad_report_path_test.cpp.tmp.report_path/report.
27+
// FAIL-NOT: Path {{.*}}Posix/Output/sanitizer_bad_report_path_test.cpp.tmp.report_path/report.
Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
// Test __sanitizer_set_report_path and __sanitizer_get_report_path:
22
// RUN: %clangxx -O2 %s -o %t
3-
// Create a directory without write access.
4-
// RUN: rm -rf %t.baddir && mkdir -p %t.baddir
5-
// RUN: chmod u-w %t.baddir || true
6-
// RUN: not %run %t 2>&1 | FileCheck %s
3+
// RUN: %run %t | FileCheck %s
74

85
#include <assert.h>
96
#include <sanitizer/common_interface_defs.h>
@@ -18,17 +15,6 @@ int main(int argc, char **argv) {
1815
__sanitizer_set_report_path(buff);
1916
assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0);
2017
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]);
27-
__sanitizer_set_report_path(buff);
28-
assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0);
29-
printf("Path %s\n", __sanitizer_get_report_path());
3018
}
3119

3220
// CHECK: Path {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.report_path/report.
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)