[sanitizer] Skip test on Android where chmod is not working

Third attempt to fix a bot failure from
634da7a1c6 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
634da7a1c6 and move the bad path test to
a new test file, marking it unsupported on Android.
This commit is contained in:
Teresa Johnson 2022-02-13 19:38:50 -08:00
parent 352e19c023
commit f4214e1469
2 changed files with 28 additions and 15 deletions

View file

@ -0,0 +1,27 @@
// Test __sanitizer_set_report_path and __sanitizer_get_report_path with an
// unwritable directory.
// RUN: rm -rf %t.report_path && mkdir -p %t.report_path
// RUN: chmod u-w %t.report_path || true
// RUN: %clangxx -O2 %s -o %t
// RUN: not %run %t 2>&1 | FileCheck %s --check-prefix=FAIL
// The chmod is not working on the android bot for some reason.
// UNSUPPORTED: android
#include <assert.h>
#include <sanitizer/common_interface_defs.h>
#include <stdio.h>
#include <string.h>
volatile int *null = 0;
int main(int argc, char **argv) {
char buff[1000];
sprintf(buff, "%s.report_path/report", argv[0]);
__sanitizer_set_report_path(buff);
assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0);
printf("Path %s\n", __sanitizer_get_report_path());
}
// FAIL: ERROR: Can't open file: {{.*}}Posix/Output/sanitizer_bad_report_path_test.cpp.tmp.report_path/report.
// FAIL-NOT: Path {{.*}}Posix/Output/sanitizer_bad_report_path_test.cpp.tmp.report_path/report.

View file

@ -1,9 +1,6 @@
// Test __sanitizer_set_report_path and __sanitizer_get_report_path:
// RUN: %clangxx -O2 %s -o %t
// Create a directory without write access.
// RUN: rm -rf %t.baddir && mkdir -p %t.baddir
// RUN: chmod u-w %t.baddir || true
// RUN: not %run %t 2>&1 | FileCheck %s
// RUN: %run %t | FileCheck %s
#include <assert.h>
#include <sanitizer/common_interface_defs.h>
@ -18,17 +15,6 @@ int main(int argc, char **argv) {
__sanitizer_set_report_path(buff);
assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0);
printf("Path %s\n", __sanitizer_get_report_path());
fflush(stdout);
// Try setting again with an invalid/inaccessible directory.
// Use invalid characters in directory name in case chmod doesn't work as
// intended.
sprintf(buff, "%s.baddir/?bad?/report", argv[0]);
__sanitizer_set_report_path(buff);
assert(strncmp(buff, __sanitizer_get_report_path(), strlen(buff)) == 0);
printf("Path %s\n", __sanitizer_get_report_path());
}
// CHECK: Path {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.report_path/report.
// CHECK: ERROR: Can't create directory: {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.baddir
// CHECK-NOT: Path {{.*}}Posix/Output/sanitizer_set_report_path_test.cpp.tmp.baddir