[compiler-rt] f4214e1 - [sanitizer] Skip test on Android where chmod is not working

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 13 19:50:40 PST 2022


Author: Teresa Johnson
Date: 2022-02-13T19:50:25-08:00
New Revision: f4214e1469ada1b9d57473d78d06eccd6d49e9b8

URL: https://github.com/llvm/llvm-project/commit/f4214e1469ada1b9d57473d78d06eccd6d49e9b8
DIFF: https://github.com/llvm/llvm-project/commit/f4214e1469ada1b9d57473d78d06eccd6d49e9b8.diff

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

Third attempt to fix a bot failure from
634da7a1c61ee8c173e90a841eb1f4ea03caa20b 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
634da7a1c61ee8c173e90a841eb1f4ea03caa20b and move the bad path test to
a new test file, marking it unsupported on Android.

Added: 
    compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_bad_report_path_test.cpp

Modified: 
    compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_bad_report_path_test.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_bad_report_path_test.cpp
new file mode 100644
index 0000000000000..fd4abf448b09d
--- /dev/null
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_bad_report_path_test.cpp
@@ -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.

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_test.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_test.cpp
index acaa997c4d692..17cee722749d6 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_test.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/sanitizer_set_report_path_test.cpp
@@ -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


        


More information about the llvm-commits mailing list